STM32F407 to use prominene.
Also, switch the :'s to \t's everywhere I could find for the protocol to the ESP8266.
This commit is contained in:
parent
ee756a820d
commit
30648367b7
|
@ -85,13 +85,19 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
|
|||
case 'f': case 'F': //Flashing commands (F_)
|
||||
{
|
||||
flashchip->chip_size = 0x01000000;
|
||||
const char * colon = (const char *) ets_strstr( (char*)&pusrdata[2], ":" );
|
||||
const char * colon = (const char *) ets_strstr( (char*)&pusrdata[2], "\t" );
|
||||
int nr = my_atoi( &pusrdata[2] );
|
||||
|
||||
switch (pusrdata[1])
|
||||
{
|
||||
case 'e': case 'E': //(FE#\n) <- # = sector.
|
||||
{
|
||||
if( nr < 128 )
|
||||
{
|
||||
buffend += ets_sprintf(buffend, "!FE%d\r\n", nr );
|
||||
break;
|
||||
}
|
||||
|
||||
EnterCritical();
|
||||
spi_flash_erase_sector( nr ); //SPI_FLASH_SEC_SIZE 4096
|
||||
ExitCritical();
|
||||
|
@ -100,8 +106,14 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
|
|||
break;
|
||||
}
|
||||
|
||||
case 'b': case 'B': //(FE#\n) <- # = sector.
|
||||
case 'b': case 'B': //(FB#\n) <- # = block.
|
||||
{
|
||||
if( nr < 8 )
|
||||
{
|
||||
buffend += ets_sprintf(buffend, "!FB%d\r\n", nr );
|
||||
break;
|
||||
}
|
||||
|
||||
EnterCritical();
|
||||
SPIEraseBlock( nr );
|
||||
ExitCritical();
|
||||
|
@ -120,8 +132,8 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
|
|||
if( colon )
|
||||
{
|
||||
colon++;
|
||||
const char * colon2 = (const char *) ets_strstr( (char*)colon, ":" );
|
||||
if( colon2 )
|
||||
const char * colon2 = (const char *) ets_strstr( (char*)colon, "\t" );
|
||||
if( colon2 && nr >= 524288)
|
||||
{
|
||||
colon2++;
|
||||
int datlen = (int)len - (colon2 - pusrdata);
|
||||
|
@ -145,7 +157,7 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
|
|||
datlen = (datlen/4)*4; //Must be multiple of 4 bytes
|
||||
if( datlen <= 1280 )
|
||||
{
|
||||
buffend += ets_sprintf(buffend, "FR%08d:%04d:", nr, datlen ); //Caution: This string must be a multiple of 4 bytes.
|
||||
buffend += ets_sprintf(buffend, "FR%08d\t%04d\t", nr, datlen ); //Caution: This string must be a multiple of 4 bytes.
|
||||
spi_flash_read( nr, (uint32*)buffend, datlen );
|
||||
break;
|
||||
}
|
||||
|
@ -424,11 +436,11 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
|
|||
on = !on;
|
||||
GPIO_OUTPUT_SET(GPIO_ID_PIN(nr), on );
|
||||
g_gpiooutputmask |= (1<<nr);
|
||||
buffend += ets_sprintf( buffend, "GF%d:%d\n", nr, on );
|
||||
buffend += ets_sprintf( buffend, "GF%d\t%d\n", nr, on );
|
||||
break;
|
||||
}
|
||||
case 'g': case 'G':
|
||||
buffend += ets_sprintf( buffend, "GG%d:%d\n", nr, GPIO_INPUT_GET( GPIO_ID_PIN(nr) ) );
|
||||
buffend += ets_sprintf( buffend, "GG%d\t%d\n", nr, GPIO_INPUT_GET( GPIO_ID_PIN(nr) ) );
|
||||
break;
|
||||
case 's': case 'S':
|
||||
{
|
||||
|
@ -438,7 +450,7 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
|
|||
{
|
||||
rmask |= GPIO_INPUT_GET( GPIO_ID_PIN(i) )?(1<<i):0;
|
||||
}
|
||||
buffend += ets_sprintf( buffend, "GS:%d:%d\n", g_gpiooutputmask, rmask );
|
||||
buffend += ets_sprintf( buffend, "GS\t%d\t%d\n", g_gpiooutputmask, rmask );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,22 +12,6 @@
|
|||
static const char * key = "";
|
||||
static int keylen = 0;
|
||||
|
||||
void SafeMD5Update( MD5_CTX * md5ctx, uint8_t*from, uint32_t size1 )
|
||||
{
|
||||
char __attribute__ ((aligned (32))) buffer[32];
|
||||
|
||||
|
||||
while( size1 > 32 )
|
||||
{
|
||||
ets_memcpy( buffer, from, 32 );
|
||||
MD5Update( md5ctx, buffer, 32 );
|
||||
size1-=32;
|
||||
from+=32;
|
||||
}
|
||||
ets_memcpy( buffer, from, 32 );
|
||||
MD5Update( md5ctx, buffer, size1 );
|
||||
}
|
||||
|
||||
|
||||
static int MyRewriteFlash( char * command, int commandlen )
|
||||
{
|
||||
|
@ -36,7 +20,7 @@ static int MyRewriteFlash( char * command, int commandlen )
|
|||
char * colons[8];
|
||||
int i, ipl = 0;
|
||||
int p;
|
||||
//[from_address]:[to_address]:[size]:[MD5(key+data)]:[from_address]:[to_address]:[size]:[MD5(key+data)]
|
||||
//[from_address]\t[to_address]\t[size]\t[MD5(key+data)]\t[from_address]\t[to_address]\t[size]\t[MD5(key+data)]
|
||||
command[commandlen] = 0;
|
||||
|
||||
flashchip->chip_size = 0x01000000;
|
||||
|
@ -47,7 +31,7 @@ static int MyRewriteFlash( char * command, int commandlen )
|
|||
for( i = 0; i < commandlen; i++ )
|
||||
{
|
||||
if( command[i] == 0 ) break;
|
||||
if( command[i] == ':' )
|
||||
if( command[i] == '\t' )
|
||||
{
|
||||
if( ipl >= 8 ) break;
|
||||
command[i] = 0;
|
||||
|
|
|
@ -268,7 +268,7 @@ void ICACHE_FLASH_ATTR HTTPHandleInternalCallback( )
|
|||
curhttp->isdone = 1;
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR InternalStartHTTP( )
|
||||
void InternalStartHTTP( )
|
||||
{
|
||||
int32_t clusterno;
|
||||
int8_t i;
|
||||
|
@ -327,7 +327,8 @@ http_disconnetcb(void *arg) {
|
|||
((struct HTTPConnection * )pespconn->reverse)->state = 0;
|
||||
}
|
||||
|
||||
LOCAL void http_recvcb(void *arg, char *pusrdata, unsigned short length)
|
||||
LOCAL void ICACHE_FLASH_ATTR
|
||||
http_recvcb(void *arg, char *pusrdata, unsigned short length)
|
||||
{
|
||||
struct espconn *pespconn = (struct espconn *) arg;
|
||||
|
||||
|
|
|
@ -174,3 +174,21 @@ void ICACHE_FLASH_ATTR my_base64_encode(const unsigned char *data, size_t input_
|
|||
encoded_data[j] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ICACHE_FLASH_ATTR SafeMD5Update( MD5_CTX * md5ctx, uint8_t*from, uint32_t size1 )
|
||||
{
|
||||
char __attribute__ ((aligned (32))) buffer[32];
|
||||
|
||||
|
||||
while( size1 > 32 )
|
||||
{
|
||||
ets_memcpy( buffer, from, 32 );
|
||||
MD5Update( md5ctx, buffer, 32 );
|
||||
size1-=32;
|
||||
from+=32;
|
||||
}
|
||||
ets_memcpy( buffer, from, 32 );
|
||||
MD5Update( md5ctx, buffer, size1 );
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <user_interface.h>
|
||||
#include <ets_sys.h>
|
||||
#include <espconn.h>
|
||||
#include <esp8266_rom.h>
|
||||
|
||||
extern char generic_print_buffer[384];
|
||||
|
||||
|
@ -42,4 +43,8 @@ int ICACHE_FLASH_ATTR ColonsToInts( const char * str, int32_t * vals, int max_q
|
|||
//as it does stuff with dynamic memory.
|
||||
void ICACHE_FLASH_ATTR my_base64_encode(const unsigned char *data, size_t input_length, uint8_t * encoded_data );
|
||||
|
||||
|
||||
void ICACHE_FLASH_ATTR SafeMD5Update( MD5_CTX * md5ctx, uint8_t*from, uint32_t size1 );
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Binary file not shown.
|
@ -107,7 +107,7 @@ uint32_t Push( uint32_t offset, const char * file )
|
|||
}
|
||||
|
||||
|
||||
int r = sprintf( bufferout, "FW%d:%d:", sendplace, sendsize );
|
||||
int r = sprintf( bufferout, "FW%d\t%d\t", sendplace, sendsize );
|
||||
memcpy( bufferout + r, buffer, sendsize );
|
||||
|
||||
printf( "bufferout: %d %d\n", sendplace, sendsize );
|
||||
|
@ -224,11 +224,11 @@ int main(int argc, char**argv)
|
|||
|
||||
printf( "%s %s\n", md5_f1, md5_f2 );
|
||||
|
||||
//FM[from_address]:[to_address]:[size]:[MD5(key+data)]:[from_address]:[to_address]:[size]:[MD5(key+data)]
|
||||
//FM[from_address]\t[to_address]\t[size]\t[MD5(key+data)]\t[from_address]\t[to_address]\t[size]\t[MD5(key+data)]
|
||||
|
||||
char cmd[1024];
|
||||
|
||||
sprintf( cmd, "FM%d:%d:%d:%s:%d:%d:%d:%s\n",
|
||||
sprintf( cmd, "FM%d\t%d\t%d\t%s\t%d\t%d\t%d\t%s\n",
|
||||
0x080000,
|
||||
0x000000,
|
||||
fs1, //roundup( fs1 ),
|
||||
|
|
|
@ -153,7 +153,7 @@ int main(int argc, char**argv)
|
|||
#endif
|
||||
resend_times = 0;
|
||||
resend:
|
||||
r = sprintf( bufferout, "FW%d:%d:", sendplace, sendsize );
|
||||
r = sprintf( bufferout, "FW%d\t%d\t", sendplace, sendsize );
|
||||
printf( "bufferout: %d %d %s\n", sendplace, sendsize, bufferout );
|
||||
memcpy( bufferout + r, buffer, sendsize );
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ void NewFrame()
|
|||
int i;
|
||||
HandleFrameInfo();
|
||||
|
||||
UpdateLinearLEDs();
|
||||
// UpdateAllSameLEDs();
|
||||
// UpdateLinearLEDs();
|
||||
UpdateAllSameLEDs();
|
||||
|
||||
SendSPI2812( ledOut, NUM_LIN_LEDS );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue