diff --git a/code/src/websockets.ino b/code/src/websockets.ino index 54667256..f2bfa48b 100644 --- a/code/src/websockets.ino +++ b/code/src/websockets.ino @@ -30,13 +30,8 @@ bool webSocketSend(uint8_t num, char * payload) { void webSocketParse(uint8_t num, uint8_t * payload, size_t length) { // Parse JSON input - - char buffer[length+1]; - memcpy(buffer, payload, length); - buffer[length] = 0; - DynamicJsonBuffer jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(buffer); + JsonObject& root = jsonBuffer.parseObject((char *) payload); if (!root.success()) { DEBUG_MSG("[WEBSOCKET] Error parsing data\n"); return; @@ -67,6 +62,8 @@ void webSocketParse(uint8_t num, uint8_t * payload, size_t length) { for (unsigned int i=0; i