From 29100391b1c84d970b2ee4d9709fd56c87d97248 Mon Sep 17 00:00:00 2001 From: Thorsten von Eicken Date: Mon, 3 Aug 2015 22:20:36 -0700 Subject: [PATCH] fix TCP client request buffer parsing --- serial/tcpclient.c | 7 ++++++- user/status.c | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/serial/tcpclient.c b/serial/tcpclient.c index 3515459..166f533 100644 --- a/serial/tcpclient.c +++ b/serial/tcpclient.c @@ -261,10 +261,15 @@ tcpClientCommand(uint8_t chan, char cmd, char *cmdBuf) { char *hostname; char *port; + // copy the command so we can modify it + char buf[128]; + os_strncpy(buf, cmdBuf, 128); + buf[127] = 0; + switch (cmd) { //== TCP Connect command case 'T': - hostname = cmdBuf; + hostname = buf; port = hostname; while (*port != 0 && *port != ':') port++; if (*port != ':') break; diff --git a/user/status.c b/user/status.c index 6d7747e..50afb85 100644 --- a/user/status.c +++ b/user/status.c @@ -81,6 +81,7 @@ static void ICACHE_FLASH_ATTR rssiTimerCb(void *v) { return; sint8 rssi = wifi_station_get_rssi(); + os_printf("timer rssi=%d\n", rssi); if (rssi >= 0) return; // not connected or other error // compose TCP command @@ -100,7 +101,7 @@ static void ICACHE_FLASH_ATTR rssiTimerCb(void *v) { "[{\"compId\":\"%s\", \"streamId\":\"%s\", \"data\":%d}]\r", flashConfig.hostname, GS_STREAM, rssi); buf[hdrLen+dataLen++] = 0; - buf[hdrLen+dataLen++] = '\r'; + buf[hdrLen+dataLen++] = '\n'; // hackish way to fill in the content-length os_sprintf(buf+hdrLen-9, "%5d", dataLen);