Added more events to statusCallback()

This commit is contained in:
Gregg 2022-10-29 07:37:34 -05:00
parent bb1b599797
commit d55dad1529
4 changed files with 24 additions and 5 deletions

View File

@ -640,6 +640,9 @@ int HAPClient::postPairSetupURL(){
homeSpan.statusLED->on(); 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 if(homeSpan.pairCallback) // if set, invoke user-defined Pairing Callback to indicate device has been paired
homeSpan.pairCallback(true); 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"); 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) mdns_service_txt_item_set("_hap","_tcp","sf","1"); // set Status Flag = 1 (Table 6-8)
homeSpan.statusLED->start(LED_PAIRING_NEEDED); 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 if(homeSpan.pairCallback) // if set, invoke user-defined Pairing Callback to indicate device has been paired
homeSpan.pairCallback(false); homeSpan.pairCallback(false);
} }

View File

@ -878,7 +878,9 @@ void Span::processSerialCommand(const char *c){
nvs_commit(charNVS); nvs_commit(charNVS);
nvs_erase_all(otaNVS); nvs_erase_all(otaNVS);
nvs_commit(otaNVS); nvs_commit(otaNVS);
WiFi.begin("none"); WiFi.begin("none");
if(statusCallback)
statusCallback(HS_FACTORY_RESET);
Serial.print("\n*** FACTORY RESET! Restarting...\n\n"); Serial.print("\n*** FACTORY RESET! Restarting...\n\n");
delay(1000); delay(1000);
ESP.restart(); ESP.restart();
@ -2139,6 +2141,8 @@ void SpanOTA::start(){
esp_ota_get_running_partition()->label,esp_ota_get_next_update_partition(NULL)->label); esp_ota_get_running_partition()->label,esp_ota_get_next_update_partition(NULL)->label);
otaPercent=0; otaPercent=0;
homeSpan.statusLED->start(LED_OTA_STARTED); 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); nvs_commit(homeSpan.otaNVS);
Serial.printf(" DONE! Rebooting...\n"); Serial.printf(" DONE! Rebooting...\n");
homeSpan.statusLED->off(); homeSpan.statusLED->off();
delay(100); // make sure commit it finished before reboot delay(100); // make sure commit is finished before reboot
} }
/////////////////////////////// ///////////////////////////////

View File

@ -78,8 +78,11 @@ enum HS_STATUS {
HS_CONFIG_MODE_UNPAIR, HS_CONFIG_MODE_UNPAIR,
HS_CONFIG_MODE_ERASE_WIFI, HS_CONFIG_MODE_ERASE_WIFI,
HS_REBOOTING, HS_REBOOTING,
HS_FACTORY_RESET,
HS_WIFI_ERASED, HS_WIFI_ERASED,
HS_AP_STARTED HS_AP_STARTED,
HS_AP_CONNECTED,
HS_OTA_STARTED
}; };
/////////////////////////////// ///////////////////////////////

View File

@ -276,7 +276,9 @@ void Network::processRequest(char *body, char *formData){
getFormValue(formData,"pwd",wifiData.pwd,MAX_PWD); getFormValue(formData,"pwd",wifiData.pwd,MAX_PWD);
homeSpan.statusLED->start(LED_WIFI_CONNECTING); homeSpan.statusLED->start(LED_WIFI_CONNECTING);
if(homeSpan.statusCallback)
homeSpan.statusCallback(HS_WIFI_CONNECTING);
responseBody+="<meta http-equiv = \"refresh\" content = \"" + String(waitTime) + "; url = /wifi-status\" />" responseBody+="<meta http-equiv = \"refresh\" content = \"" + String(waitTime) + "; url = /wifi-status\" />"
"<p>Initiating WiFi connection to:</p><p><b>" + String(wifiData.ssid) + "</p>"; "<p>Initiating WiFi connection to:</p><p><b>" + String(wifiData.ssid) + "</p>";
@ -323,7 +325,9 @@ void Network::processRequest(char *body, char *formData){
} else { } else {
homeSpan.statusLED->start(LED_AP_CONNECTED); // slow double-blink homeSpan.statusLED->start(LED_AP_CONNECTED); // slow double-blink
if(homeSpan.statusCallback)
homeSpan.statusCallback(HS_AP_CONNECTED);
responseBody+="<p>SUCCESS! Connected to:</p><p><b>" + String(wifiData.ssid) + "</b></p>"; responseBody+="<p>SUCCESS! Connected to:</p><p><b>" + String(wifiData.ssid) + "</b></p>";
responseBody+="<p>You may enter new 8-digit Setup Code below, or leave blank to retain existing code.</p>"; responseBody+="<p>You may enter new 8-digit Setup Code below, or leave blank to retain existing code.</p>";
@ -343,6 +347,9 @@ void Network::processRequest(char *body, char *formData){
LOG1("In Landing Page...\n"); LOG1("In Landing Page...\n");
homeSpan.statusLED->start(LED_AP_CONNECTED); homeSpan.statusLED->start(LED_AP_CONNECTED);
if(homeSpan.statusCallback)
homeSpan.statusCallback(HS_AP_CONNECTED);
waitTime=2; waitTime=2;
responseBody+="<p>Welcome to HomeSpan! This page allows you to configure the above HomeSpan device to connect to your WiFi network.</p>" responseBody+="<p>Welcome to HomeSpan! This page allows you to configure the above HomeSpan device to connect to your WiFi network.</p>"