41 lines
1.4 KiB
C
41 lines
1.4 KiB
C
|
|
//////////////////////////////////
|
|
// DEVICE-SPECIFIC SERVICES //
|
|
//////////////////////////////////
|
|
|
|
struct DEV_Identify : Service::AccessoryInformation {
|
|
|
|
int nBlinks; // number of times to blink built-in LED in identify routine
|
|
SpanCharacteristic *identify; // reference to the Identify Characteristic
|
|
|
|
// NEW! modified constructor() method to include optional ServiceType argument
|
|
|
|
DEV_Identify(char *name, char *manu, char *sn, char *model, char *version, int nBlinks, ServiceType sType=ServiceType::Regular) : Service::AccessoryInformation(sType){
|
|
|
|
new Characteristic::Name(name); // create all the required Characteristics with values set based on above arguments
|
|
new Characteristic::Manufacturer(manu);
|
|
new Characteristic::SerialNumber(sn);
|
|
new Characteristic::Model(model);
|
|
new Characteristic::FirmwareRevision(version);
|
|
identify=new Characteristic::Identify(); // store a reference to the Identify Characteristic for use below
|
|
|
|
this->nBlinks=nBlinks; // store the number of times to blink the built-in LED
|
|
|
|
pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output
|
|
}
|
|
|
|
StatusCode update(){
|
|
|
|
for(int i=0;i<nBlinks;i++){
|
|
digitalWrite(LED_BUILTIN,LOW);
|
|
delay(250);
|
|
digitalWrite(LED_BUILTIN,HIGH);
|
|
delay(250);
|
|
}
|
|
|
|
return(StatusCode::OK);
|
|
|
|
} // update
|
|
|
|
};
|