From 56225b101848ff0de8d5e21b3926a1f3a2067831 Mon Sep 17 00:00:00 2001 From: Gregg Date: Tue, 11 Aug 2020 21:55:49 -0500 Subject: [PATCH] updated Example 13 Moved "new SpanEvent" into DEV_Sensors.h and verified it works fine. --- .../13-EventNotifications/13-EventNotifications.ino | 1 - examples/Expert/13-EventNotifications/DEV_Sensors.h | 8 ++++++-- src/HomeSpan.h | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/Expert/13-EventNotifications/13-EventNotifications.ino b/examples/Expert/13-EventNotifications/13-EventNotifications.ino index 089b949..3ca8be2 100644 --- a/examples/Expert/13-EventNotifications/13-EventNotifications.ino +++ b/examples/Expert/13-EventNotifications/13-EventNotifications.ino @@ -47,7 +47,6 @@ void setup() { new SpanAccessory(); new DEV_Identify("Temp Sensor","HomeSpan","123-ABC","Celsius","0.9",0); new DEV_TempSensor(); // Create a Temperature Sensor - new SpanEvent(5000); new SpanAccessory(); new DEV_Identify("Air Quality","HomeSpan","123-ABC","Sensor","0.9",0); diff --git a/examples/Expert/13-EventNotifications/DEV_Sensors.h b/examples/Expert/13-EventNotifications/DEV_Sensors.h index a914fae..6e83e86 100644 --- a/examples/Expert/13-EventNotifications/DEV_Sensors.h +++ b/examples/Expert/13-EventNotifications/DEV_Sensors.h @@ -9,6 +9,7 @@ struct DEV_TempSensor : Service::TemperatureSensor { // A standalone Tempera DEV_TempSensor(ServiceType sType=ServiceType::Regular) : Service::TemperatureSensor(sType){ // constructor() method + new SpanEvent(5000); temp=new Characteristic::CurrentTemperature(); Serial.print("Configuring Temperature Sensor"); // initialization message @@ -18,7 +19,10 @@ struct DEV_TempSensor : Service::TemperatureSensor { // A standalone Tempera void event(){ - temp->setVal((double)random(15,25)); + float temperature=temp->getVal()+1.0; + if(temperature>35) + temperature=10; + temp->setVal(temperature); } // event }; @@ -48,7 +52,7 @@ struct DEV_AirQualitySensor : Service::AirQualitySensor { // A standalone Ai void event(){ - airQuality->setVal((int)random(1,6)); + airQuality->setVal((airQuality->getVal()+1)%6); o3Density->setVal((double)random(200,500)); if(!random(2)){ no2Density->setVal((double)random(600,800)); diff --git a/src/HomeSpan.h b/src/HomeSpan.h index a1c66ee..3b1e5f6 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -218,8 +218,8 @@ struct SpanRange{ /////////////////////////////// struct SpanBuf{ // temporary storage buffer for use with putCharacteristicsURL() and checkTimedResets() - int aid; // updated aid - int iid; // updated iid + int aid=0; // updated aid + int iid=0; // updated iid char *val=NULL; // updated value (optional, though either at least 'val' or 'ev' must be specified) char *ev=NULL; // updated event notification flag (optional, though either at least 'val' or 'ev' must be specified) StatusCode status; // return status (HAP Table 6-11)