taskDriven by claude - must be checked

This commit is contained in:
2026-01-03 22:59:36 -06:00
parent 4e4add5287
commit daced162ba
11 changed files with 378 additions and 198 deletions

View File

@@ -6,11 +6,11 @@
#include "cJSON.h"
#include "calibration.hpp"
#include "servo.hpp"
#include "defines.h"
static esp_socketio_client_handle_t io_client;
static esp_socketio_packet_handle_t tx_packet = NULL;
std::atomic<bool> statusResolved{true};
std::atomic<bool> connected{false};
// Event handler for Socket.IO events
@@ -64,7 +64,7 @@ static void socketio_event_handler(void *handler_args, esp_event_base_t base,
// Mark connection as failed
connected = false;
statusResolved = true;
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_DISCONNECTED);
}
// Handle device_init event
else if (strcmp(eventName->valuestring, "device_init") == 0) {
@@ -101,13 +101,13 @@ static void socketio_event_handler(void *handler_args, esp_event_base_t base,
// Now mark as connected
connected = true;
statusResolved = true;
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_CONNECTED);
} else {
printf("Device authentication failed\n");
calib.clearCalibrated();
deleteWiFiAndTokenDetails();
connected = false;
statusResolved = true;
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_DISCONNECTED);
}
}
}
@@ -124,7 +124,7 @@ static void socketio_event_handler(void *handler_args, esp_event_base_t base,
calib.clearCalibrated();
deleteWiFiAndTokenDetails();
connected = false;
statusResolved = true;
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_DISCONNECTED);
}
// Handle calib_start event
@@ -236,9 +236,9 @@ static void socketio_event_handler(void *handler_args, esp_event_base_t base,
}
}
// Set flags to indicate connection failure
// Signal disconnection via event group
connected = false;
statusResolved = true;
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_DISCONNECTED);
break;
}
}
@@ -247,7 +247,7 @@ static void socketio_event_handler(void *handler_args, esp_event_base_t base,
if (data->websocket_event_id == WEBSOCKET_EVENT_DISCONNECTED) {
printf("WebSocket disconnected\n");
connected = false;
statusResolved = true;
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_DISCONNECTED);
}
}
@@ -255,7 +255,6 @@ void initSocketIO() {
// Prepare the Authorization Header (Bearer format)
std::string authHeader = "Authorization: Bearer " + webToken + "\r\n";
statusResolved = false;
connected = false;
esp_socketio_client_config_t config = {};
@@ -277,7 +276,6 @@ void stopSocketIO() {
io_client = NULL;
tx_packet = NULL;
connected = false;
statusResolved = false;
}
}