From 5c41e066e01b8b26962469a8770956ffee58a362 Mon Sep 17 00:00:00 2001 From: GHOSCHT <31184695+GHOSCHT@users.noreply.github.com> Date: Wed, 13 Apr 2022 18:42:39 +0200 Subject: [PATCH] Implement websocket receive --- Firmware/lib/WebsocketCommunicator/WebsocketCommunicator.cpp | 3 ++- Firmware/src/main.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Firmware/lib/WebsocketCommunicator/WebsocketCommunicator.cpp b/Firmware/lib/WebsocketCommunicator/WebsocketCommunicator.cpp index e29690e..00fa93b 100644 --- a/Firmware/lib/WebsocketCommunicator/WebsocketCommunicator.cpp +++ b/Firmware/lib/WebsocketCommunicator/WebsocketCommunicator.cpp @@ -46,5 +46,6 @@ char *WebsocketCommunicator::receiveMessage() void WebsocketCommunicator::handleMessage(void *arg, uint8_t *data, size_t len) { - Serial.println("data"); + int effectiveLen = len < bufferSize ? len : bufferSize; + strncpy(messageBuffer, (char *)data, effectiveLen); } \ No newline at end of file diff --git a/Firmware/src/main.cpp b/Firmware/src/main.cpp index cf2307b..d07cc11 100644 --- a/Firmware/src/main.cpp +++ b/Firmware/src/main.cpp @@ -28,9 +28,10 @@ void websocketTask(void *parameter) while (true) { websocket->sendMessage(light->getBjtState(), light->getBjtCount()); + light->updateState(websocket->receiveMessage(), STEPS); websocket->clearBuffer(); - vTaskDelay(90 / portTICK_PERIOD_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); } vTaskDelete(NULL); }