updated Example 13
Moved "new SpanEvent" into DEV_Sensors.h and verified it works fine.
This commit is contained in:
parent
698592b7a3
commit
56225b1018
|
|
@ -47,7 +47,6 @@ void setup() {
|
||||||
new SpanAccessory();
|
new SpanAccessory();
|
||||||
new DEV_Identify("Temp Sensor","HomeSpan","123-ABC","Celsius","0.9",0);
|
new DEV_Identify("Temp Sensor","HomeSpan","123-ABC","Celsius","0.9",0);
|
||||||
new DEV_TempSensor(); // Create a Temperature Sensor
|
new DEV_TempSensor(); // Create a Temperature Sensor
|
||||||
new SpanEvent(5000);
|
|
||||||
|
|
||||||
new SpanAccessory();
|
new SpanAccessory();
|
||||||
new DEV_Identify("Air Quality","HomeSpan","123-ABC","Sensor","0.9",0);
|
new DEV_Identify("Air Quality","HomeSpan","123-ABC","Sensor","0.9",0);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ struct DEV_TempSensor : Service::TemperatureSensor { // A standalone Tempera
|
||||||
|
|
||||||
DEV_TempSensor(ServiceType sType=ServiceType::Regular) : Service::TemperatureSensor(sType){ // constructor() method
|
DEV_TempSensor(ServiceType sType=ServiceType::Regular) : Service::TemperatureSensor(sType){ // constructor() method
|
||||||
|
|
||||||
|
new SpanEvent(5000);
|
||||||
temp=new Characteristic::CurrentTemperature();
|
temp=new Characteristic::CurrentTemperature();
|
||||||
|
|
||||||
Serial.print("Configuring Temperature Sensor"); // initialization message
|
Serial.print("Configuring Temperature Sensor"); // initialization message
|
||||||
|
|
@ -18,7 +19,10 @@ struct DEV_TempSensor : Service::TemperatureSensor { // A standalone Tempera
|
||||||
|
|
||||||
void event(){
|
void event(){
|
||||||
|
|
||||||
temp->setVal((double)random(15,25));
|
float temperature=temp->getVal<float>()+1.0;
|
||||||
|
if(temperature>35)
|
||||||
|
temperature=10;
|
||||||
|
temp->setVal(temperature);
|
||||||
|
|
||||||
} // event
|
} // event
|
||||||
};
|
};
|
||||||
|
|
@ -48,7 +52,7 @@ struct DEV_AirQualitySensor : Service::AirQualitySensor { // A standalone Ai
|
||||||
|
|
||||||
void event(){
|
void event(){
|
||||||
|
|
||||||
airQuality->setVal((int)random(1,6));
|
airQuality->setVal((airQuality->getVal()+1)%6);
|
||||||
o3Density->setVal((double)random(200,500));
|
o3Density->setVal((double)random(200,500));
|
||||||
if(!random(2)){
|
if(!random(2)){
|
||||||
no2Density->setVal((double)random(600,800));
|
no2Density->setVal((double)random(600,800));
|
||||||
|
|
|
||||||
|
|
@ -218,8 +218,8 @@ struct SpanRange{
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
struct SpanBuf{ // temporary storage buffer for use with putCharacteristicsURL() and checkTimedResets()
|
struct SpanBuf{ // temporary storage buffer for use with putCharacteristicsURL() and checkTimedResets()
|
||||||
int aid; // updated aid
|
int aid=0; // updated aid
|
||||||
int iid; // updated iid
|
int iid=0; // updated iid
|
||||||
char *val=NULL; // updated value (optional, though either at least 'val' or 'ev' must be specified)
|
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)
|
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)
|
StatusCode status; // return status (HAP Table 6-11)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue