From 0ade00eb9aeffa3a042846b8d371e389f65f31b4 Mon Sep 17 00:00:00 2001 From: Gregg Date: Fri, 14 Aug 2020 17:46:35 -0500 Subject: [PATCH] Implemented checkTimedWrites() This check all timed write PID/TTL entries and clears all those that are expired. This completes the implementation of Timed Write functionality as required for PUT /prepare requests. --- src/HAP.cpp | 18 ++++++++++++++++++ src/HAP.h | 1 + src/HomeSpan.cpp | 2 +- src/Settings.h | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/HAP.cpp b/src/HAP.cpp index 08ecea1..c5a88da 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -1234,6 +1234,24 @@ void HAPClient::checkTimedResets(){ ////////////////////////////////////// +void HAPClient::checkTimedWrites(){ + + unsigned long cTime=millis(); // get current time + + char c[64]; + + for(auto tw=homeSpan.TimedWrites.begin(); tw!=homeSpan.TimedWrites.end(); tw++){ // loop over all Timed Writes using an iterator + if(cTime>tw->second){ // timer has expired + sprintf(c,"Removing PID=%llu ALARM=%lu\n",tw->first,tw->second); + LOG1(c); + homeSpan.TimedWrites.erase(tw); + } + } +} + +////////////////////////////////////// + + void HAPClient::eventNotify(SpanBuf *pObj, int nObj, int ignoreClient){ for(int cNum=0;cNum