From aa6f2464907c2230c98fa8fabc21b1d4dd2f532169097a6ff187d7a177a64da1 Mon Sep 17 00:00:00 2001 From: Sebastian Mariano Flores Date: Fri, 22 May 2026 16:54:55 -0600 Subject: [PATCH] Feature:Intregados --- include/WebSocketHandler.h | 1 - include/WiFiConf.h | 3 +++ src/WebSocketHandler.cpp | 5 ----- src/WiFiConf.cpp | 4 ++++ src/main.cpp | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/WebSocketHandler.h b/include/WebSocketHandler.h index 94f91ee..0a6d6ff 100644 --- a/include/WebSocketHandler.h +++ b/include/WebSocketHandler.h @@ -3,5 +3,4 @@ #include "Arduino.h" #include -extern volatile bool websocket_connected; void webSocketEvent( uint8_t num, WStype_t type, uint8_t * payload, size_t length ); diff --git a/include/WiFiConf.h b/include/WiFiConf.h index 9d2f0f2..e5284cb 100644 --- a/include/WiFiConf.h +++ b/include/WiFiConf.h @@ -4,6 +4,9 @@ #include "Network.h" #include + +extern volatile bool websocket_connected; + class wifi_conf { private: const char* _ssid; diff --git a/src/WebSocketHandler.cpp b/src/WebSocketHandler.cpp index f8daf2b..3da5639 100644 --- a/src/WebSocketHandler.cpp +++ b/src/WebSocketHandler.cpp @@ -1,17 +1,12 @@ #include "WebSocketHandler.h" -extern volatile bool websocket_connected; - void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { switch(type) { - case WStype_CONNECTED: - websocket_connected = true; Serial.printf("[%u] Cliente conectado\n", num); break; case WStype_DISCONNECTED: - websocket_connected = false; Serial.printf("[%u] Cliente desconectado\n", num); break; diff --git a/src/WiFiConf.cpp b/src/WiFiConf.cpp index 3f06ecb..f4f4e1d 100644 --- a/src/WiFiConf.cpp +++ b/src/WiFiConf.cpp @@ -1,10 +1,13 @@ #include "WiFiConf.h" +extern volatile bool websocket_connected; + void wifi_conf::handler_WiFi(arduino_event_id_t event, arduino_event_info_t info) { switch(event){ case ARDUINO_EVENT_WIFI_STA_CONNECTED: + websocket_connected = true; Serial.printf("Wi-Fi conectado\n"); break; @@ -13,6 +16,7 @@ void wifi_conf::handler_WiFi(arduino_event_id_t event, arduino_event_info_t info break; case ARDUINO_EVENT_WIFI_STA_DISCONNECTED: + websocket_connected = false; Serial.printf("WiFi: Desconectado\n"); Serial.printf("DEBUG: Reconectando...\n"); diff --git a/src/main.cpp b/src/main.cpp index 279d258..1995e47 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,6 +71,7 @@ void ADCTask(void *parameter){ vTaskDelay(pdMS_TO_TICKS(100)); continue; } + const uint32_t count = adc1_3.read(samples_buffer); if (count > 0) { if (xRingbufferSend(bufferHandle, samples_buffer, count * sizeof(uint16_t), pdMS_TO_TICKS(1000)) != pdTRUE) {