diff --git a/src/HAP.cpp b/src/HAP.cpp index 4b163af..b747ac5 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -640,6 +640,9 @@ int HAPClient::postPairSetupURL(){ homeSpan.statusLED->on(); + if(homeSpan.statusCallback) + homeSpan.statusCallback(HS_PAIRED); + if(homeSpan.pairCallback) // if set, invoke user-defined Pairing Callback to indicate device has been paired homeSpan.pairCallback(true); @@ -1638,6 +1641,8 @@ void HAPClient::removeController(uint8_t *id){ LOG1("That was last Admin Controller! Removing any remaining Regular Controllers and unpairing Accessory\n"); mdns_service_txt_item_set("_hap","_tcp","sf","1"); // set Status Flag = 1 (Table 6-8) homeSpan.statusLED->start(LED_PAIRING_NEEDED); + if(homeSpan.statusCallback) + homeSpan.statusCallback(HS_PAIRING_NEEDED); if(homeSpan.pairCallback) // if set, invoke user-defined Pairing Callback to indicate device has been paired homeSpan.pairCallback(false); } diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 5b1e4fb..baffbe4 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -878,7 +878,9 @@ void Span::processSerialCommand(const char *c){ nvs_commit(charNVS); nvs_erase_all(otaNVS); nvs_commit(otaNVS); - WiFi.begin("none"); + WiFi.begin("none"); + if(statusCallback) + statusCallback(HS_FACTORY_RESET); Serial.print("\n*** FACTORY RESET! Restarting...\n\n"); delay(1000); ESP.restart(); @@ -2139,6 +2141,8 @@ void SpanOTA::start(){ esp_ota_get_running_partition()->label,esp_ota_get_next_update_partition(NULL)->label); otaPercent=0; homeSpan.statusLED->start(LED_OTA_STARTED); + if(homeSpan.statusCallback) + homeSpan.statusCallback(HS_OTA_STARTED); } /////////////////////////////// @@ -2148,7 +2152,7 @@ void SpanOTA::end(){ nvs_commit(homeSpan.otaNVS); Serial.printf(" DONE! Rebooting...\n"); homeSpan.statusLED->off(); - delay(100); // make sure commit it finished before reboot + delay(100); // make sure commit is finished before reboot } /////////////////////////////// diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 69e7c8b..c3eb23a 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -78,8 +78,11 @@ enum HS_STATUS { HS_CONFIG_MODE_UNPAIR, HS_CONFIG_MODE_ERASE_WIFI, HS_REBOOTING, + HS_FACTORY_RESET, HS_WIFI_ERASED, - HS_AP_STARTED + HS_AP_STARTED, + HS_AP_CONNECTED, + HS_OTA_STARTED }; /////////////////////////////// diff --git a/src/Network.cpp b/src/Network.cpp index 6467089..24f2843 100644 --- a/src/Network.cpp +++ b/src/Network.cpp @@ -276,7 +276,9 @@ void Network::processRequest(char *body, char *formData){ getFormValue(formData,"pwd",wifiData.pwd,MAX_PWD); homeSpan.statusLED->start(LED_WIFI_CONNECTING); - + if(homeSpan.statusCallback) + homeSpan.statusCallback(HS_WIFI_CONNECTING); + responseBody+="" "
Initiating WiFi connection to:
" + String(wifiData.ssid) + "
"; @@ -323,7 +325,9 @@ void Network::processRequest(char *body, char *formData){ } else { homeSpan.statusLED->start(LED_AP_CONNECTED); // slow double-blink - + if(homeSpan.statusCallback) + homeSpan.statusCallback(HS_AP_CONNECTED); + responseBody+="SUCCESS! Connected to:
" + String(wifiData.ssid) + "
"; responseBody+="You may enter new 8-digit Setup Code below, or leave blank to retain existing code.
"; @@ -343,6 +347,9 @@ void Network::processRequest(char *body, char *formData){ LOG1("In Landing Page...\n"); homeSpan.statusLED->start(LED_AP_CONNECTED); + if(homeSpan.statusCallback) + homeSpan.statusCallback(HS_AP_CONNECTED); + waitTime=2; responseBody+="Welcome to HomeSpan! This page allows you to configure the above HomeSpan device to connect to your WiFi network.
"