From d285387f389889b2f07b2ec8105a830311b6f486 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 --- .../lib/WebsocketCommunicator/WebsocketCommunicator.cpp | 3 ++- modules/control/Firmware/src/main.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/control/Firmware/lib/WebsocketCommunicator/WebsocketCommunicator.cpp b/modules/control/Firmware/lib/WebsocketCommunicator/WebsocketCommunicator.cpp index e29690e..00fa93b 100644 --- a/modules/control/Firmware/lib/WebsocketCommunicator/WebsocketCommunicator.cpp +++ b/modules/control/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/modules/control/Firmware/src/main.cpp b/modules/control/Firmware/src/main.cpp index cf2307b..d07cc11 100644 --- a/modules/control/Firmware/src/main.cpp +++ b/modules/control/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); }