diff --git a/src/HAP.cpp b/src/HAP.cpp index afce14d..1cb1572 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -966,7 +966,7 @@ int HAPClient::postPairingsURL(){ for(int i=0;iallocated)){ // accessory unpaired, OR client connection is verified but points to an unallocated controller + if(!nAdminControllers() || (hap[i].cPair && !hap[i].cPair->allocated)){ // accessory unpaired, OR client connection is verified but points to a newly *unallocated* controller LOG1("*** Terminating Client #"); LOG1(i); LOG1("\n"); diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 4433c8b..7d072d0 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -33,19 +33,15 @@ void Span::begin(Category catID, char *displayName, char *hostNameBase, char *mo "Welcome to HomeSpan!\n" "Apple HomeKit for the Espressif ESP-32 WROOM and Arduino IDE\n" "************************************************************\n\n" - "** Please ensure serial monitor is set to transmit \n"); + "** Please ensure serial monitor is set to transmit \n\n"); - Serial.print("** Ground pin "); - Serial.print(resetPin); - Serial.print(" to delete all stored WiFi Network and HomeKit Pairing data (factory reset)\n\n"); - - Serial.print("HomeSpan Version: "); + Serial.print("Device Control: Pin "); + Serial.print(resetPin); + Serial.print("\nHomeSpan Version: "); Serial.print(HOMESPAN_VERSION); - Serial.print("\n"); - Serial.print("ESP-IDF Version: "); + Serial.print("\nESP-IDF Version: "); Serial.print(esp_get_idf_version()); - Serial.print("\n"); - Serial.print("Sketch Compiled: "); + Serial.print("\nSketch Compiled: "); Serial.print(__DATE__); Serial.print(" "); Serial.print(__TIME__); @@ -177,11 +173,13 @@ void Span::poll() { case 2: if(digitalRead(resetPin)){ statusLED.off(); - processSerialCommand("H"); + resetPressed=0; + processSerialCommand("U"); // UPAIR Device } else if(millis()>resetTime){ - statusLED.off(); - processSerialCommand("F"); + statusLED.on(); + delay(1000); + processSerialCommand("W"); // Delete WiFi Data and Restart } break; } // switch @@ -472,12 +470,34 @@ void Span::processSerialCommand(char *c){ } break; + case 'U': { + + HAPClient::removeControllers(); // clear all Controller data + nvs_set_blob(HAPClient::hapNVS,"CONTROLLERS",HAPClient::controllers,sizeof(HAPClient::controllers)); // update data + nvs_commit(HAPClient::hapNVS); // commit to NVS + Serial.print("\n** HomeSpan Pairing Data DELETED **\n\n"); + + for(int i=0;i