Added AirQualitySensor
to use for development of multi-characteristic checkEvents()
This commit is contained in:
parent
8d6db796cb
commit
6ad063a2b2
|
|
@ -12,7 +12,7 @@
|
|||
#include "HomeSpan.h"
|
||||
#include "DEV_LED.h"
|
||||
#include "DEV_Identify.h"
|
||||
#include "DEV_Temperature.h"
|
||||
#include "DEV_Sensors.h"
|
||||
|
||||
void setup() {
|
||||
|
||||
|
|
@ -49,6 +49,11 @@ void setup() {
|
|||
new DEV_TempSensor(); // Create a Temperature Sensor
|
||||
new SpanEvent(5000);
|
||||
|
||||
new SpanAccessory();
|
||||
new DEV_Identify("Air Quality","HomeSpan","123-ABC","Sensor","0.9",0);
|
||||
new DEV_AirQualitySensor(); // Create an Air Quality Sensor
|
||||
new SpanEvent(10000);
|
||||
|
||||
} // end of setup()
|
||||
|
||||
//////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
|
||||
////////////////////////////////////
|
||||
// DEVICE-SPECIFIC LED SERVICES //
|
||||
////////////////////////////////////
|
||||
|
||||
struct DEV_TempSensor : Service::TemperatureSensor { // A standalone Temperature sensor
|
||||
|
||||
SpanCharacteristic *temp; // reference to the Current Temperature Characteristic
|
||||
|
||||
DEV_TempSensor(ServiceType sType=ServiceType::Regular) : Service::TemperatureSensor(sType){ // constructor() method
|
||||
|
||||
temp=new Characteristic::CurrentTemperature();
|
||||
|
||||
Serial.print("Configuring Temperature Sensor"); // initialization message
|
||||
Serial.print("\n");
|
||||
|
||||
} // end constructor
|
||||
|
||||
void event(){
|
||||
|
||||
temp->setVal(22.0);
|
||||
|
||||
} // event
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
struct DEV_AirQualitySensor : Service::AirQualitySensor { // A standalone Air Quality sensor
|
||||
|
||||
SpanCharacteristic *airQuality;
|
||||
SpanCharacteristic *o3Density;
|
||||
SpanCharacteristic *no2Density;
|
||||
SpanCharacteristic *so2Density;
|
||||
SpanCharacteristic *pm25Density;
|
||||
SpanCharacteristic *pm10Density;
|
||||
SpanCharacteristic *vocDensity;
|
||||
|
||||
DEV_AirQualitySensor(ServiceType sType=ServiceType::Regular) : Service::AirQualitySensor(sType){ // constructor() method
|
||||
|
||||
airQuality=new Characteristic::AirQuality(1);
|
||||
o3Density=new Characteristic::OzoneDensity(40.7);
|
||||
no2Density=new Characteristic::NitrogenDioxideDensity(13.2);
|
||||
|
||||
Serial.print("Configuring Air Quality Sensor"); // initialization message
|
||||
Serial.print("\n");
|
||||
|
||||
} // end constructor
|
||||
|
||||
void event(){
|
||||
|
||||
airQuality->setVal(1);
|
||||
o3Density->setVal(10.8);
|
||||
if(!random(2)){
|
||||
Serial.println("HERE\n");
|
||||
no2Density->setVal(50.3);
|
||||
}
|
||||
|
||||
} // event
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
|
||||
////////////////////////////////////
|
||||
// DEVICE-SPECIFIC LED SERVICES //
|
||||
////////////////////////////////////
|
||||
|
||||
struct DEV_TempSensor : Service::TemperatureSensor { // A standalone temperature sensor
|
||||
|
||||
SpanCharacteristic *temp; // reference to the Current Temperature Characteristic
|
||||
|
||||
DEV_TempSensor(ServiceType sType=ServiceType::Regular) : Service::TemperatureSensor(sType){ // constructor() method
|
||||
|
||||
temp=new Characteristic::CurrentTemperature();
|
||||
|
||||
Serial.print("Configuring Temperature Sensor"); // initialization message
|
||||
Serial.print("\n");
|
||||
|
||||
} // end constructor
|
||||
|
||||
void event(){
|
||||
|
||||
temp->setVal(22.0);
|
||||
|
||||
} // event
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
|
|
@ -83,6 +83,8 @@ namespace Characteristic {
|
|||
|
||||
struct Active : SpanCharacteristic { Active(uint8_t value=0) : SpanCharacteristic{"B0",PR+PW+EV,(uint8_t)value}{} };
|
||||
|
||||
struct AirQuality : SpanCharacteristic { AirQuality(uint8_t value=0) : SpanCharacteristic{"95",PR+EV,(uint8_t)value}{} };
|
||||
|
||||
struct Brightness : SpanCharacteristic { Brightness(int value=0) : SpanCharacteristic{"8",PR+PW+EV,(int)value}{} };
|
||||
|
||||
struct ColorTemperature : SpanCharacteristic { ColorTemperature(uint32_t value=50) : SpanCharacteristic{"CE",PR+PW+EV,(uint32_t)value}{} };
|
||||
|
|
@ -99,10 +101,18 @@ namespace Characteristic {
|
|||
|
||||
struct Name : SpanCharacteristic { Name(char *value) : SpanCharacteristic{"23",PR,(char *)value}{} };
|
||||
|
||||
struct NitrogenDioxideDensity : SpanCharacteristic { NitrogenDioxideDensity(double value=0) : SpanCharacteristic{"C4",PR+EV,(double)value}{} };
|
||||
|
||||
struct On : SpanCharacteristic { On(boolean value=false) : SpanCharacteristic{"25",PR+PW+EV,(boolean)value}{} };
|
||||
|
||||
struct OutletInUse : SpanCharacteristic { OutletInUse(boolean value=false) : SpanCharacteristic{"26",PR+EV,(boolean)value}{} };
|
||||
|
||||
struct OzoneDensity : SpanCharacteristic { OzoneDensity(double value=0) : SpanCharacteristic{"C3",PR+EV,(double)value}{} };
|
||||
|
||||
struct PM10Density : SpanCharacteristic { PM10Density(double value=0) : SpanCharacteristic{"C7",PR+EV,(double)value}{} };
|
||||
|
||||
struct PM25Density : SpanCharacteristic { PM25Density(double value=0) : SpanCharacteristic{"C6",PR+EV,(double)value}{} };
|
||||
|
||||
struct RotationDirection : SpanCharacteristic { RotationDirection(int value=0) : SpanCharacteristic{"28",PR+PW+EV,(int)value}{} };
|
||||
|
||||
struct RotationSpeed : SpanCharacteristic { RotationSpeed(double value=0) : SpanCharacteristic{"29",PR+PW+EV,(double)value}{} };
|
||||
|
|
@ -111,10 +121,28 @@ namespace Characteristic {
|
|||
|
||||
struct SerialNumber : SpanCharacteristic { SerialNumber(char *value) : SpanCharacteristic{"30",PR,(char *)value}{} };
|
||||
|
||||
struct SlatType : SpanCharacteristic { SlatType(uint8_t value=0) : SpanCharacteristic{"C0",PR,(uint8_t)value}{} };
|
||||
|
||||
struct SmokeDetected : SpanCharacteristic { SmokeDetected(uint8_t value=0) : SpanCharacteristic{"76",PR+EV,(uint8_t)value}{} };
|
||||
|
||||
struct StatusActive : SpanCharacteristic { StatusActive(boolean value=true) : SpanCharacteristic{"75",PR+EV,(boolean)value}{} };
|
||||
|
||||
struct StatusFault : SpanCharacteristic { StatusFault(uint8_t value=0) : SpanCharacteristic{"77",PR+EV,(uint8_t)value}{} };
|
||||
|
||||
struct StatusJammed : SpanCharacteristic { StatusJammed(uint8_t value=0) : SpanCharacteristic{"78",PR+EV,(uint8_t)value}{} };
|
||||
|
||||
struct StatusLowBattery : SpanCharacteristic { StatusLowBattery(uint8_t value=0) : SpanCharacteristic{"79",PR+EV,(uint8_t)value}{} };
|
||||
|
||||
struct StatusTampered : SpanCharacteristic { StatusTampered(uint8_t value=0) : SpanCharacteristic{"7A",PR+EV,(uint8_t)value}{} };
|
||||
|
||||
struct SulphurDioxideDensity : SpanCharacteristic { SulphurDioxideDensity(double value=0) : SpanCharacteristic{"C5",PR+EV,(double)value}{} };
|
||||
|
||||
struct SwingMode : SpanCharacteristic { SwingMode(uint8_t value=0) : SpanCharacteristic{"B6",PR+PW+EV,(uint8_t)value}{} };
|
||||
|
||||
struct CurrentTemperature : SpanCharacteristic { CurrentTemperature(double value=0) : SpanCharacteristic{"11",PR+EV,(double)value}{} };
|
||||
|
||||
struct Version : SpanCharacteristic { Version(char *value) : SpanCharacteristic{"37",PR,(char *)value}{} };
|
||||
|
||||
struct VOCDensity : SpanCharacteristic { VOCDensity(double value=0) : SpanCharacteristic{"C8",PR+EV,(double)value}{} };
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
#error THIS IS NOT COMPILABLE CODE
|
||||
|
||||
This is a dummy .ino file that allows you to easily edit the contents of this library using the Arduino IDE.
|
||||
The code is NOT designed to be compiled from this point. Compile and test the library using one of the examples.
|
||||
// This is a dummy .ino file that allows you to easily edit the contents of this library using the Arduino IDE.
|
||||
// The code is NOT designed to be compiled from this point. Compile and test the library using one of the examples.
|
||||
|
|
|
|||
Loading…
Reference in New Issue