Updated rest of code to reflect latest version of statusLED
Removed all checks to see if statusLED is defined, since it will now ALWAYS be defined, even if the statusDevice is set to NULL.
This commit is contained in:
parent
f2e1f5bc70
commit
355a2dfd4d
|
|
@ -638,7 +638,6 @@ int HAPClient::postPairSetupURL(){
|
|||
|
||||
LOG1("\n*** ACCESSORY PAIRED! ***\n");
|
||||
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->on();
|
||||
|
||||
if(homeSpan.pairCallback) // if set, invoke user-defined Pairing Callback to indicate device has been paired
|
||||
|
|
@ -1638,7 +1637,6 @@ void HAPClient::removeController(uint8_t *id){
|
|||
removeControllers();
|
||||
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)
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->start(LED_PAIRING_NEEDED);
|
||||
if(homeSpan.pairCallback) // if set, invoke user-defined Pairing Callback to indicate device has been paired
|
||||
homeSpan.pairCallback(false);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ void Span::begin(Category catID, const char *displayName, const char *hostNameBa
|
|||
this->modelName=modelName;
|
||||
sprintf(this->category,"%d",(int)catID);
|
||||
|
||||
statusLED=new Blinker(statusDevice,autoOffLED);
|
||||
statusLED=new Blinker(statusDevice,autoOffLED); // create Status LED, even is statusDevice is NULL
|
||||
|
||||
esp_task_wdt_delete(xTaskGetIdleTaskHandleForCPU(0)); // required to avoid watchdog timeout messages from ESP32-C3
|
||||
|
||||
|
|
@ -189,10 +189,9 @@ void Span::pollTask() {
|
|||
processSerialCommand("A");
|
||||
} else {
|
||||
Serial.print("YOU MAY CONFIGURE BY TYPING 'W <RETURN>'.\n\n");
|
||||
if(statusLED)
|
||||
statusLED->start(LED_WIFI_NEEDED);
|
||||
}
|
||||
} else if(statusLED) {
|
||||
} else {
|
||||
statusLED->start(LED_WIFI_CONNECTING);
|
||||
}
|
||||
|
||||
|
|
@ -291,11 +290,10 @@ void Span::pollTask() {
|
|||
if(spanOTA.enabled)
|
||||
ArduinoOTA.handle();
|
||||
|
||||
if(controlButton && controlButton->primed() && statusLED)
|
||||
if(controlButton && controlButton->primed())
|
||||
statusLED->start(LED_ALERT);
|
||||
|
||||
if(controlButton && controlButton->triggered(3000,10000)){
|
||||
if(statusLED)
|
||||
statusLED->off();
|
||||
if(controlButton->type()==PushButton::LONG){
|
||||
controlButton->wait();
|
||||
|
|
@ -305,7 +303,6 @@ void Span::pollTask() {
|
|||
}
|
||||
}
|
||||
|
||||
if(statusLED)
|
||||
statusLED->check();
|
||||
|
||||
} // poll
|
||||
|
|
@ -326,7 +323,7 @@ int Span::getFreeSlot(){
|
|||
|
||||
void Span::commandMode(){
|
||||
|
||||
if(!statusLED){
|
||||
if(!statusDevice){
|
||||
Serial.print("*** ERROR: CAN'T ENTER COMMAND MODE WITHOUT A DEFINED STATUS LED***\n\n");
|
||||
return;
|
||||
}
|
||||
|
|
@ -409,7 +406,6 @@ void Span::checkConnect(){
|
|||
connected++;
|
||||
waitTime=60000;
|
||||
alarmConnect=0;
|
||||
if(statusLED)
|
||||
statusLED->start(LED_WIFI_CONNECTING);
|
||||
}
|
||||
|
||||
|
|
@ -437,12 +433,10 @@ void Span::checkConnect(){
|
|||
return;
|
||||
}
|
||||
|
||||
if(statusLED){
|
||||
if(!HAPClient::nAdminControllers())
|
||||
statusLED->start(LED_PAIRING_NEEDED);
|
||||
else
|
||||
statusLED->on();
|
||||
}
|
||||
|
||||
connected++;
|
||||
|
||||
|
|
@ -767,13 +761,11 @@ void Span::processSerialCommand(const char *c){
|
|||
Serial.print("\nDEVICE NOT YET PAIRED -- PLEASE PAIR WITH HOMEKIT APP\n\n");
|
||||
mdns_service_txt_item_set("_hap","_tcp","sf","1"); // set Status Flag = 1 (Table 6-8)
|
||||
|
||||
if(statusLED){
|
||||
if(strlen(network.wifiData.ssid)==0)
|
||||
statusLED->start(LED_WIFI_NEEDED);
|
||||
else
|
||||
statusLED->start(LED_PAIRING_NEEDED);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'W': {
|
||||
|
|
@ -789,7 +781,6 @@ void Span::processSerialCommand(const char *c){
|
|||
nvs_set_blob(wifiNVS,"WIFIDATA",&network.wifiData,sizeof(network.wifiData)); // update data
|
||||
nvs_commit(wifiNVS); // commit to NVS
|
||||
Serial.print("\n*** WiFi Credentials SAVED! Re-starting ***\n\n");
|
||||
if(statusLED)
|
||||
statusLED->off();
|
||||
delay(1000);
|
||||
ESP.restart();
|
||||
|
|
@ -823,7 +814,6 @@ void Span::processSerialCommand(const char *c){
|
|||
}
|
||||
|
||||
Serial.print("\n*** Re-starting ***\n\n");
|
||||
if(statusLED)
|
||||
statusLED->off();
|
||||
delay(1000);
|
||||
ESP.restart(); // re-start device
|
||||
|
|
@ -832,7 +822,6 @@ void Span::processSerialCommand(const char *c){
|
|||
|
||||
case 'X': {
|
||||
|
||||
if(statusLED)
|
||||
statusLED->off();
|
||||
nvs_erase_all(wifiNVS);
|
||||
nvs_commit(wifiNVS);
|
||||
|
|
@ -852,7 +841,6 @@ void Span::processSerialCommand(const char *c){
|
|||
|
||||
case 'H': {
|
||||
|
||||
if(statusLED)
|
||||
statusLED->off();
|
||||
nvs_erase_all(HAPClient::hapNVS);
|
||||
nvs_commit(HAPClient::hapNVS);
|
||||
|
|
@ -864,7 +852,6 @@ void Span::processSerialCommand(const char *c){
|
|||
|
||||
case 'R': {
|
||||
|
||||
if(statusLED)
|
||||
statusLED->off();
|
||||
Serial.print("\n*** Restarting...\n\n");
|
||||
delay(1000);
|
||||
|
|
@ -874,7 +861,6 @@ void Span::processSerialCommand(const char *c){
|
|||
|
||||
case 'F': {
|
||||
|
||||
if(statusLED)
|
||||
statusLED->off();
|
||||
nvs_erase_all(HAPClient::hapNVS);
|
||||
nvs_commit(HAPClient::hapNVS);
|
||||
|
|
@ -892,7 +878,6 @@ void Span::processSerialCommand(const char *c){
|
|||
|
||||
case 'E': {
|
||||
|
||||
if(statusLED)
|
||||
statusLED->off();
|
||||
nvs_flash_erase();
|
||||
Serial.print("\n*** ALL DATA ERASED! Restarting...\n\n");
|
||||
|
|
@ -2117,7 +2102,6 @@ void SpanOTA::start(){
|
|||
Serial.printf("\n*** Current Partition: %s\n*** New Partition: %s\n*** OTA Starting..",
|
||||
esp_ota_get_running_partition()->label,esp_ota_get_next_update_partition(NULL)->label);
|
||||
otaPercent=0;
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->start(LED_OTA_STARTED);
|
||||
}
|
||||
|
||||
|
|
@ -2127,7 +2111,6 @@ void SpanOTA::end(){
|
|||
nvs_set_u8(homeSpan.otaNVS,"OTA_REQUIRED",safeLoad);
|
||||
nvs_commit(homeSpan.otaNVS);
|
||||
Serial.printf(" DONE! Rebooting...\n");
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->off();
|
||||
delay(100); // make sure commit it finished before reboot
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ class Span{
|
|||
void setStatusPin(uint8_t pin){statusDevice=new LED(pin);} // sets Status Device to a simple LED on specified pin
|
||||
void setStatusDevice(Blinkable *dev){statusDevice=dev;} // sets Status Device to generic Blinkable object
|
||||
void setStatusAutoOff(uint16_t duration){autoOffLED=duration;} // sets Status LED auto off (seconds)
|
||||
int getStatusPin(){return(statusLED?statusLED->getPin():-1);} // get Status Pin (returns -1 if undefined)
|
||||
int getStatusPin(){return(statusLED->getPin());} // get Status Pin (getPin will return -1 if underlying statusDevice is undefined)
|
||||
int getControlPin(){return(controlButton?controlButton->getPin():-1);} // get Control Pin (returns -1 if undefined)
|
||||
void setApSSID(const char *ssid){network.apSSID=ssid;} // sets Access Point SSID
|
||||
void setApPassword(const char *pwd){network.apPassword=pwd;} // sets Access Point Password
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ void Network::apConfigure(){
|
|||
Serial.print(apPassword);
|
||||
Serial.print("\n");
|
||||
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->start(LED_AP_STARTED);
|
||||
|
||||
Serial.print("\nScanning for Networks...\n\n");
|
||||
|
|
@ -155,11 +154,9 @@ void Network::apConfigure(){
|
|||
|
||||
if(homeSpan.controlButton && homeSpan.controlButton->triggered(9999,3000)){
|
||||
Serial.print("\n*** Access Point Terminated.");
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->start(LED_ALERT);
|
||||
homeSpan.controlButton->wait();
|
||||
Serial.print(" Restarting... \n\n");
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->off();
|
||||
ESP.restart();
|
||||
}
|
||||
|
|
@ -179,10 +176,8 @@ void Network::apConfigure(){
|
|||
Serial.print("\n*** Access Point: Configuration Canceled.");
|
||||
}
|
||||
Serial.print(" Restarting...\n\n");
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->start(LED_ALERT);
|
||||
delay(1000);
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->off();
|
||||
ESP.restart();
|
||||
}
|
||||
|
|
@ -278,7 +273,6 @@ void Network::processRequest(char *body, char *formData){
|
|||
getFormValue(formData,"network",wifiData.ssid,MAX_SSID);
|
||||
getFormValue(formData,"pwd",wifiData.pwd,MAX_PWD);
|
||||
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->start(LED_WIFI_CONNECTING);
|
||||
|
||||
responseBody+="<meta http-equiv = \"refresh\" content = \"" + String(waitTime) + "; url = /wifi-status\" />"
|
||||
|
|
@ -326,7 +320,6 @@ void Network::processRequest(char *body, char *formData){
|
|||
|
||||
} else {
|
||||
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->start(LED_AP_CONNECTED); // slow double-blink
|
||||
|
||||
responseBody+="<p>SUCCESS! Connected to:</p><p><b>" + String(wifiData.ssid) + "</b></p>";
|
||||
|
|
@ -347,7 +340,6 @@ void Network::processRequest(char *body, char *formData){
|
|||
|
||||
LOG1("In Landing Page...\n");
|
||||
|
||||
if(homeSpan.statusLED)
|
||||
homeSpan.statusLED->start(LED_AP_CONNECTED);
|
||||
waitTime=2;
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ void Blinker::start(int period, float dutyCycle, int nBlinks, int delayTime){
|
|||
this->nBlinks=nBlinks;
|
||||
|
||||
stop();
|
||||
Serial.printf("Starting Blink Task\n");
|
||||
xTaskCreate( blinkTask, "BlinkTask", 1024, (void *)this, 2, &blinkHandle );
|
||||
|
||||
pauseTime=millis();
|
||||
|
|
@ -89,7 +88,6 @@ void Blinker::stop(){
|
|||
return;
|
||||
|
||||
if(blinkHandle!=NULL){
|
||||
Serial.printf("Deleting Blink Task\n");
|
||||
vTaskDelete(blinkHandle);
|
||||
blinkHandle=NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue