fix TCP client request buffer parsing

pull/39/head
Thorsten von Eicken 9 years ago
parent 71bc355038
commit 29100391b1
  1. 7
      serial/tcpclient.c
  2. 3
      user/status.c

@ -261,10 +261,15 @@ tcpClientCommand(uint8_t chan, char cmd, char *cmdBuf) {
char *hostname; char *hostname;
char *port; char *port;
// copy the command so we can modify it
char buf[128];
os_strncpy(buf, cmdBuf, 128);
buf[127] = 0;
switch (cmd) { switch (cmd) {
//== TCP Connect command //== TCP Connect command
case 'T': case 'T':
hostname = cmdBuf; hostname = buf;
port = hostname; port = hostname;
while (*port != 0 && *port != ':') port++; while (*port != 0 && *port != ':') port++;
if (*port != ':') break; if (*port != ':') break;

@ -81,6 +81,7 @@ static void ICACHE_FLASH_ATTR rssiTimerCb(void *v) {
return; return;
sint8 rssi = wifi_station_get_rssi(); sint8 rssi = wifi_station_get_rssi();
os_printf("timer rssi=%d\n", rssi);
if (rssi >= 0) return; // not connected or other error if (rssi >= 0) return; // not connected or other error
// compose TCP command // compose TCP command
@ -100,7 +101,7 @@ static void ICACHE_FLASH_ATTR rssiTimerCb(void *v) {
"[{\"compId\":\"%s\", \"streamId\":\"%s\", \"data\":%d}]\r", "[{\"compId\":\"%s\", \"streamId\":\"%s\", \"data\":%d}]\r",
flashConfig.hostname, GS_STREAM, rssi); flashConfig.hostname, GS_STREAM, rssi);
buf[hdrLen+dataLen++] = 0; buf[hdrLen+dataLen++] = 0;
buf[hdrLen+dataLen++] = '\r'; buf[hdrLen+dataLen++] = '\n';
// hackish way to fill in the content-length // hackish way to fill in the content-length
os_sprintf(buf+hdrLen-9, "%5d", dataLen); os_sprintf(buf+hdrLen-9, "%5d", dataLen);

Loading…
Cancel
Save