diff --git a/src/HAP.cpp b/src/HAP.cpp index ffb0944..c154981 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -1185,44 +1185,6 @@ void HAPClient::checkNotifications(){ ////////////////////////////////////// -void HAPClient::checkTimedResets(){ - - unsigned long cTime=millis(); // current time - vector spanBuf; // vector to SpanBuf objects - - for(int i=0;icharacteristic->value.BOOL){ // characteristic is off - homeSpan.TimedResets[i]->start=false; // ensure timer is not started - } - else if(!homeSpan.TimedResets[i]->start){ // else characteristic is on but timer is not started - homeSpan.TimedResets[i]->start=true; // start timer - homeSpan.TimedResets[i]->alarmTime=cTime+homeSpan.TimedResets[i]->waitTime; // set alarm time - } - else if(cTime>homeSpan.TimedResets[i]->alarmTime){ // else characteristic is on, timer is started, and timer is expired - - LOG1("Resetting aid="); - LOG1(homeSpan.TimedResets[i]->characteristic->aid); - LOG1(" iid="); - LOG1(homeSpan.TimedResets[i]->characteristic->iid); - LOG1("\n"); - - memset(&(homeSpan.TimedResets[i]->characteristic->value),0,sizeof(SpanCharacteristic::UVal)); - - SpanBuf sb; // create SpanBuf object - sb.characteristic=homeSpan.TimedResets[i]->characteristic; // set characteristic - sb.status=StatusCode::OK; // set status - sb.val=""; // set dummy "val" so that sprintfNotify knows to consider this "update" - spanBuf.push_back(sb); - } - } - - if(spanBuf.size()>0) // if updated items are found - eventNotify(&spanBuf[0],spanBuf.size()); // transmit EVENT Notifications - -} - -////////////////////////////////////// - void HAPClient::checkTimedWrites(){ unsigned long cTime=millis(); // get current time diff --git a/src/HAP.h b/src/HAP.h index 57ca5c2..87e793c 100644 --- a/src/HAP.h +++ b/src/HAP.h @@ -112,7 +112,6 @@ struct HAPClient { static void removeControllers(); // removes all Controllers (sets allocated flags to false for all slots) static void removeController(uint8_t *id); // removes specific Controller. If no remaining admin Controllers, remove all others (if any) as per HAP requirements. static void printControllers(); // prints IDs of all allocated (paired) Controller - static void checkTimedResets(); // checks for Timed Resets and reports to controllers as needed (HAP Section 6.8) static void callServiceLoops(); // call the loop() method for any Service with that over-rode the default method static void checkNotifications(); // checks for Event Notifications and reports to controllers as needed (HAP Section 6.8) static void checkTimedWrites(); // checks for expired Timed Write PIDs, and clears any found (HAP Section 6.7.2.4) diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 9e3651f..77f6e52 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -147,7 +147,6 @@ void Span::poll() { } // process HAP Client } // for-loop over connection slots - HAPClient::checkTimedResets(); HAPClient::callServiceLoops(); HAPClient::checkNotifications(); HAPClient::checkTimedWrites(); @@ -1136,28 +1135,6 @@ int SpanCharacteristic::timeVal(){ return(homeSpan.snapTime-updateTime); } -/////////////////////////////// -// SpanTimedReset // -/////////////////////////////// - -SpanTimedReset::SpanTimedReset(int waitTime){ - - if(homeSpan.Accessories.empty() || homeSpan.Accessories.back()->Services.empty() || homeSpan.Accessories.back()->Services.back()->Characteristics.empty() ){ - Serial.print("*** FATAL ERROR: Can't create new Timed Reset without a defined Characteristic. Program halted!\n\n"); - while(1); - } - - if(!(homeSpan.Accessories.back()->Services.back()->Characteristics.back()->perms&SpanCharacteristic::PW)){ - Serial.print("*** FATAL ERROR: Can't create new Timed Reset for Read-Only Characteristic. Program halted!\n\n"); - while(1); - } - - this->characteristic=homeSpan.Accessories.back()->Services.back()->Characteristics.back(); - this->waitTime=waitTime; - homeSpan.TimedResets.push_back(this); - -} - /////////////////////////////// // SpanRange // /////////////////////////////// diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 499027a..4118ac5 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -25,7 +25,6 @@ struct SpanService; struct SpanCharacteristic; struct SpanRange; struct SpanBuf; -struct SpanTimedReset; /////////////////////////////// @@ -48,7 +47,6 @@ struct Span{ SpanConfig hapConfig; // track configuration changes to the HAP Accessory database; used to increment the configuration number (c#) when changes found vector Accessories; // vector of pointers to all Accessories - vector TimedResets; // vector of pointers to all TimedResets vector Loops; // vector of pointer to all Services that have over-ridden loop() methods vector Notifications; // vector of SpanBuf objects that store info for Characteristics that are updated with setVal() and require a Notification Event unordered_map TimedWrites; // map of timed-write PIDs and Alarm Times (based on TTLs) @@ -233,18 +231,6 @@ struct SpanBuf{ // temporary storage buffer for us SpanCharacteristic *characteristic=NULL; // Characteristic to update (NULL if not found) }; -/////////////////////////////// - -struct SpanTimedReset{ - SpanCharacteristic *characteristic; // characteristic to auto-reset whenever activated - int waitTime; // time to wait until auto-reset (in milliseconds) - unsigned long alarmTime; // alarm time for trigger to auto-reset - boolean start=false; // alarm timer started - boolean trigger=false; // alarm timer triggered - - SpanTimedReset(int waitTime); -}; - ///////////////////////////////////////////////// // Extern Variables