Eliminated TimedResets from Library

This is no longer needed since PushButtons can be easily emulated from within a Service loop() as per Example 14.  Library is now fully up-to-date: TimedResets and SpanEvents have been fully removed.
This commit is contained in:
Gregg 2020-08-17 21:54:43 -05:00
parent 258882fe6d
commit 6c5a5835e6
4 changed files with 0 additions and 76 deletions

View File

@ -1185,44 +1185,6 @@ void HAPClient::checkNotifications(){
//////////////////////////////////////
void HAPClient::checkTimedResets(){
unsigned long cTime=millis(); // current time
vector<SpanBuf> spanBuf; // vector to SpanBuf objects
for(int i=0;i<homeSpan.TimedResets.size();i++){ // loop through all defined Timed Resets
if(!homeSpan.TimedResets[i]->characteristic->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

View File

@ -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)

View File

@ -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 //
///////////////////////////////

View File

@ -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<SpanAccessory *> Accessories; // vector of pointers to all Accessories
vector<SpanTimedReset *> TimedResets; // vector of pointers to all TimedResets
vector<SpanService *> Loops; // vector of pointer to all Services that have over-ridden loop() methods
vector<SpanBuf> Notifications; // vector of SpanBuf objects that store info for Characteristics that are updated with setVal() and require a Notification Event
unordered_map<uint64_t, uint32_t> 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