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.
This commit is contained in:
parent
ffb7b7ed87
commit
0ade00eb9a
18
src/HAP.cpp
18
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<MAX_CONNECTIONS;cNum++){ // loop over all connection slots
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ struct HAPClient {
|
|||
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 checkEvents(); // 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)
|
||||
static void eventNotify(SpanBuf *pObj, int nObj, int ignoreClient=-1); // transmits EVENT Notifications for nObj SpanBuf objects, pObj, with optional flag to ignore a specific client
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ void Span::poll() {
|
|||
|
||||
HAPClient::checkTimedResets();
|
||||
HAPClient::checkEvents();
|
||||
HAPClient::checkTimedWrites();
|
||||
|
||||
} // poll
|
||||
|
||||
|
|
@ -400,7 +401,6 @@ void Span::processSerialCommand(char *c){
|
|||
Serial.print("** Unknown command: '");
|
||||
Serial.print(c);
|
||||
Serial.print("' - type '?' for list of commands.\n");
|
||||
|
||||
break;
|
||||
|
||||
} // switch
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const int MAX_CONNECTIONS=8;
|
|||
// Verbosity -- controls message output //
|
||||
// 0=Minimal, 1=Informative, 2=All //
|
||||
|
||||
#define VERBOSITY 2
|
||||
#define VERBOSITY 1
|
||||
|
||||
//-------------------------------------------------//
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue