updated Example 13

Moved "new SpanEvent" into DEV_Sensors.h and verified it works fine.
This commit is contained in:
Gregg 2020-08-11 21:55:49 -05:00
parent 698592b7a3
commit 56225b1018
3 changed files with 8 additions and 5 deletions

View File

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

View File

@ -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<float>()+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));

View File

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