diff --git a/src/HAP.cpp b/src/HAP.cpp index 2120511..31f4435 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -661,6 +661,9 @@ int HAPClient::postPairSetupURL(){ LOG1("\n*** ACCESSORY PAIRED! ***\n"); homeSpan.statusLED.on(); + if(homeSpan.pairCallback) // if set, invoke user-defined Pairing Callback to indicate device has been paired + homeSpan.pairCallback(true); + return(1); break; @@ -1592,6 +1595,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.pairCallback) // if set, invoke user-defined Pairing Callback to indicate device has been paired + homeSpan.pairCallback(false); } LOG2("\n"); diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 8822342..3f1f215 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -131,6 +131,7 @@ struct Span{ char otaPwd[33]; // MD5 Hash of OTA password, represented as a string of hexidecimal characters boolean otaAuth; // OTA requires password when set to true void (*wifiCallback)()=NULL; // optional callback function to invoke once WiFi connectivity is established + void (*pairCallback)(boolean isPaired)=NULL; // optional callback function to invoke when pairing is established (true) or lost (false) boolean autoStartAPEnabled=false; // enables auto start-up of Access Point when WiFi Credentials not found void (*apFunction)()=NULL; // optional function to invoke when starting Access Point @@ -191,6 +192,7 @@ struct Span{ void setSketchVersion(const char *sVer){sketchVersion=sVer;} // set optional sketch version number const char *getSketchVersion(){return sketchVersion;} // get sketch version number void setWifiCallback(void (*f)()){wifiCallback=f;} // sets an optional user-defined function to call once WiFi connectivity is established + void setPairCallback(void (*f)(boolean isPaired)){pairCallback=f;} // sets an optional user-defined function to call when Pairing is established (true) or lost (false) void setApFunction(void (*f)()){apFunction=f;} // sets an optional user-defined function to call when activating the WiFi Access Point void protectPinISR(uint8_t pin){ProtectedGPIOs[pin]=0;} // protects ISR on pin from NVS operations diff --git a/src/src.ino b/src/src.ino index 1aa3888..bb37e6d 100644 --- a/src/src.ino +++ b/src/src.ino @@ -50,7 +50,6 @@ void setup() { new Characteristic::On(0); new Characteristic::LightMode("HELLO"); new Characteristic::DarkMode(); - new Characteristic::DarkMode("OVERRIDE"); new Characteristic::Brightness(50); new Characteristic::Name("Light 1"); new Characteristic::ColorTemperature();