diff --git a/main/protocols/websocket_protocol.cc b/main/protocols/websocket_protocol.cc index f0cc034..4b74a5e 100644 --- a/main/protocols/websocket_protocol.cc +++ b/main/protocols/websocket_protocol.cc @@ -147,7 +147,7 @@ bool WebsocketProtocol::OpenAudioChannel() { } } else { // Parse JSON data - auto root = cJSON_Parse(data); + auto root = cJSON_ParseWithLength(data, len); auto type = cJSON_GetObjectItem(root, "type"); if (cJSON_IsString(type)) { if (strcmp(type->valuestring, "hello") == 0) { @@ -158,7 +158,7 @@ bool WebsocketProtocol::OpenAudioChannel() { } } } else { - ESP_LOGE(TAG, "Missing message type, data: %s", data); + ESP_LOGE(TAG, "Missing message type, data: %s", std::string(data, len).c_str()); } cJSON_Delete(root); }