revert to non-task-driven, no tangible difference in performance. May change back later.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
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
|
||||
@@ -65,7 +66,7 @@ static void socketio_event_handler(void *handler_args, esp_event_base_t base,
|
||||
|
||||
// Mark connection as failed
|
||||
connected = false;
|
||||
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_DISCONNECTED);
|
||||
statusResolved = true;
|
||||
}
|
||||
// Handle device_init event
|
||||
else if (strcmp(eventName->valuestring, "device_init") == 0) {
|
||||
@@ -92,7 +93,7 @@ static void socketio_event_handler(void *handler_args, esp_event_base_t base,
|
||||
if (port != 1) printf("ERROR: NON-1 PORT RECEIVED\n");
|
||||
// Report back actual calibration status from device
|
||||
else {
|
||||
bool deviceCalibrated = Calibration::getCalibrated();
|
||||
bool deviceCalibrated = calib.getCalibrated();
|
||||
emitCalibStatus(deviceCalibrated);
|
||||
printf(" Reported calibrated=%d for port %d\n", deviceCalibrated, port);
|
||||
runToAppPos(lastPos);
|
||||
@@ -102,13 +103,13 @@ static void socketio_event_handler(void *handler_args, esp_event_base_t base,
|
||||
|
||||
// Now mark as connected
|
||||
connected = true;
|
||||
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_CONNECTED);
|
||||
statusResolved = true;
|
||||
} else {
|
||||
printf("Device authentication failed\n");
|
||||
Calibration::clearCalibrated();
|
||||
calib.clearCalibrated();
|
||||
deleteWiFiAndTokenDetails();
|
||||
connected = false;
|
||||
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_DISCONNECTED);
|
||||
statusResolved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,10 +123,10 @@ static void socketio_event_handler(void *handler_args, esp_event_base_t base,
|
||||
printf("Server message: %s\n", message->valuestring);
|
||||
}
|
||||
}
|
||||
Calibration::clearCalibrated();
|
||||
calib.clearCalibrated();
|
||||
deleteWiFiAndTokenDetails();
|
||||
connected = false;
|
||||
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_DISCONNECTED);
|
||||
statusResolved = true;
|
||||
}
|
||||
|
||||
// Handle calib_start event
|
||||
@@ -292,9 +293,8 @@ static void socketio_event_handler(void *handler_args, esp_event_base_t base,
|
||||
}
|
||||
}
|
||||
|
||||
// Signal disconnection via event group
|
||||
connected = false;
|
||||
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_DISCONNECTED);
|
||||
statusResolved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -303,7 +303,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;
|
||||
xEventGroupSetBits(g_system_events, EVENT_SOCKETIO_DISCONNECTED);
|
||||
statusResolved = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,6 +312,7 @@ 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 = {};
|
||||
@@ -338,6 +339,7 @@ void stopSocketIO() {
|
||||
io_client = NULL;
|
||||
tx_packet = NULL;
|
||||
connected = false;
|
||||
statusResolved = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user