Provision status BLE proper definition

This commit is contained in:
samuelbles07
2025-10-31 02:08:02 +07:00
parent 2f13c8fa66
commit 3a56ee448d
3 changed files with 21 additions and 9 deletions

View File

@@ -691,7 +691,7 @@ static void sendDataToAg() {
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnecting);
}
stateMachine.handleLeds(AgStateMachineWiFiOkServerConnecting);
wifiConnector.bleNotifyStatus(1);
wifiConnector.bleNotifyStatus(PROV_CONNECTING_TO_SERVER);
/** Task handle led connecting animation */
xTaskCreate(
@@ -720,13 +720,13 @@ static void sendDataToAg() {
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnected);
}
stateMachine.handleLeds(AgStateMachineWiFiOkServerConnected);
wifiConnector.bleNotifyStatus(2);
wifiConnector.bleNotifyStatus(PROV_SERVER_REACHABLE);
} else {
if (ag->isOne()) {
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnectFailed);
}
stateMachine.handleLeds(AgStateMachineWiFiOkServerConnectFailed);
wifiConnector.bleNotifyStatus(11);
wifiConnector.bleNotifyStatus(PROV_ERR_SERVER_UNREACHABLE);
}
stateMachine.handleLeds(AgStateMachineNormal);
@@ -1048,17 +1048,17 @@ void initializeNetwork() {
if (agClient->isRegisteredOnAgServer() == false) {
stateMachine.displaySetAddToDashBoard();
stateMachine.displayHandle(AgStateMachineWiFiOkServerOkSensorConfigFailed);
wifiConnector.bleNotifyStatus(13);
wifiConnector.bleNotifyStatus(PROV_ERR_MONITOR_NOT_REGISTERED);
} else {
stateMachine.displayClearAddToDashBoard();
wifiConnector.bleNotifyStatus(12);
wifiConnector.bleNotifyStatus(PROV_ERR_GET_MONITOR_CONFIG_FAILED);
}
}
stateMachine.handleLeds(AgStateMachineWiFiOkServerOkSensorConfigFailed);
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
} else {
ledBarEnabledUpdate();
wifiConnector.bleNotifyStatus(3);
wifiConnector.bleNotifyStatus(PROV_MONITOR_CONFIGURED);
}
}

View File

@@ -242,7 +242,7 @@ bool WifiConnector::connect(void) {
// If not connect send status through BLE while also turn led and display indicator
WiFi.disconnect();
wifiConnecting = false;
bleNotifyStatus(10);
bleNotifyStatus(PROV_ERR_WIFI_CONNECT_FAILED);
// Show failed inficator then revert back to provision mode
sm.ledAnimationInit();
@@ -295,7 +295,7 @@ bool WifiConnector::connect(void) {
config.setDisableCloudConnection(result == "T");
}
hasPortalConfig = false;
bleNotifyStatus(0);
bleNotifyStatus(PROV_WIFI_CONNECT);
}
return true;
@@ -715,7 +715,7 @@ void WifiConnector::stopBLE() {
if (bleServerRunning) {
Serial.println("Stopping BLE");
NimBLEDevice::deinit();
}
}
bleServerRunning = false;
}

View File

@@ -14,6 +14,18 @@
#include <Arduino.h>
#include <NimBLEDevice.h>
// Provisioning Status Codes
#define PROV_WIFI_CONNECT 0 // WiFi Connect
#define PROV_CONNECTING_TO_SERVER 1 // Connecting to server
#define PROV_SERVER_REACHABLE 2 // Server reachable
#define PROV_MONITOR_CONFIGURED 3 // Monitor configured properly on dashboard
// Provisioning Error Codes
#define PROV_ERR_WIFI_CONNECT_FAILED 10 // Failed to connect to WiFi
#define PROV_ERR_SERVER_UNREACHABLE 11 // Server unreachable
#define PROV_ERR_GET_MONITOR_CONFIG_FAILED 12 // Failed to get monitor configuration from dashboard
#define PROV_ERR_MONITOR_NOT_REGISTERED 13 // Monitor is not registered on dashboard
class WifiConnector : public PrintLog {
public:
enum class ProvisionMethod {