diff --git a/esp32/include/communication/native_server.h b/esp32/include/communication/native_server.h index 4b61f5e..4f55122 100644 --- a/esp32/include/communication/native_server.h +++ b/esp32/include/communication/native_server.h @@ -26,7 +26,7 @@ class NativeServer { NativeServer(); ~NativeServer(); - void config(size_t maxUriHandlers, size_t stackSize, size_t maxUploadSize); + void config(size_t maxUriHandlers, size_t stackSize); esp_err_t listen(uint16_t port); void stop(); @@ -42,7 +42,7 @@ class NativeServer { esp_err_t wsSendAll(const uint8_t* data, size_t len); void addWsClient(int sockfd); void removeWsClient(int sockfd); - std::vector& getWsClients(); + std::vector getWsClients(); void addDefaultHeader(const char* key, const char* value); diff --git a/esp32/src/communication/native_server.cpp b/esp32/src/communication/native_server.cpp index 14806d5..32700ce 100644 --- a/esp32/src/communication/native_server.cpp +++ b/esp32/src/communication/native_server.cpp @@ -17,7 +17,7 @@ NativeServer::~NativeServer() { vSemaphoreDelete(wsMutex_); } -void NativeServer::config(size_t maxUriHandlers, size_t stackSize, size_t maxUploadSize) { +void NativeServer::config(size_t maxUriHandlers, size_t stackSize) { config_.max_uri_handlers = maxUriHandlers; config_.stack_size = stackSize; config_.max_resp_headers = 16; @@ -252,7 +252,12 @@ void NativeServer::removeWsClient(int sockfd) { xSemaphoreGive(wsMutex_); } -std::vector& NativeServer::getWsClients() { return wsClients_; } +std::vector NativeServer::getWsClients() { + xSemaphoreTake(wsMutex_, portMAX_DELAY); + std::vector clients = wsClients_; + xSemaphoreGive(wsMutex_); + return clients; +} esp_err_t NativeServer::wsSend(int sockfd, const uint8_t* data, size_t len) { httpd_ws_frame_t frame = {.final = true, diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index b8f6f71..5712715 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -40,7 +40,7 @@ WiFiService wifiService; APService apService; void setupServer() { - nativeServer.config(50 + WWW_ASSETS_COUNT, 32768, 1000000); + nativeServer.config(50 + WWW_ASSETS_COUNT, 32768); nativeServer.listen(80); nativeServer.on("/api/system/reset", HTTP_POST,