diff --git a/examples/07-IdentifyRoutines/DEV_Identify.h b/examples/07-IdentifyRoutines/DEV_Identify.h index 4e2c5fc..01e591b 100644 --- a/examples/07-IdentifyRoutines/DEV_Identify.h +++ b/examples/07-IdentifyRoutines/DEV_Identify.h @@ -23,9 +23,9 @@ struct DEV_Identify : Service::AccessoryInformation { 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 + this->nBlinks=nBlinks; // store the number of times to blink the LED - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output + pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output } // How HomeKit Identifies Devices: @@ -39,20 +39,22 @@ struct DEV_Identify : Service::AccessoryInformation { // There are many ways to implement some form of identification. For an LED, you could blink it one or more times. // For a LightBulb, you can flash it on and off. For window shade, you could raise and lower it. // Most commerical devices don't do anything. Because HomeSpan can be used to control many different types of - // device, below we implement a very generic routine that simply blinks the internal LED of the ESP32 the - // number of times specified above. In principle, this code could call a user-defined routine that is different - // for each physcially-attached device (light, shade, fan, etc), but in practice this is overkill. + // device, below we implement a very generic routine that simply blinks the Status LED the number of times specified above. + // In principle, this code could call a user-defined routine that is different for each physcially-attached device (light, shade, fan, etc), + // but in practice this is overkill. - // Note that the blink routine below starts by turning off the built-in LED and then leaves it on once it has blinked + // Note that the blink routine below starts by turning off the Status LED and then leaves it on once it has blinked // the specified number of times. This is because when HomeSpan starts up if confirms to user that it has connected - // to the WiFi network by turning on the built-in LED. Thus we want to leave it on when blinking is completed. + // to the WiFi network by turning on the Status LED. Thus we want to leave it on when blinking is completed. + + // Also note we use the homeSpan.getStatusPin() method to find the pin number associated with the Status LED boolean update(){ for(int i=0;inBlinks=nBlinks; // store the number of times to blink the built-in LED + this->nBlinks=nBlinks; // store the number of times to blink the LED - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output + pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output } boolean update(){ for(int i=0;inBlinks=nBlinks; // store the number of times to blink the built-in LED + this->nBlinks=nBlinks; // store the number of times to blink the LED - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output + pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output } boolean update(){ for(int i=0;inBlinks=nBlinks; // store the number of times to blink the built-in LED + this->nBlinks=nBlinks; // store the number of times to blink the LED - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output + pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output } boolean update(){ for(int i=0;inBlinks=nBlinks; // store the number of times to blink the built-in LED + this->nBlinks=nBlinks; // store the number of times to blink the LED - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output + pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output } boolean update(){ for(int i=0;inBlinks=nBlinks; // store the number of times to blink the built-in LED + this->nBlinks=nBlinks; // store the number of times to blink the LED - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output + pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output } boolean update(){ for(int i=0;inBlinks=nBlinks; // store the number of times to blink the built-in LED + this->nBlinks=nBlinks; // store the number of times to blink the LED - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output + pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output } boolean update(){ for(int i=0;inBlinks=nBlinks; // store the number of times to blink the built-in LED + this->nBlinks=nBlinks; // store the number of times to blink the LED - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output + pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output } boolean update(){ for(int i=0;inBlinks=nBlinks; // store the number of times to blink the built-in LED + this->nBlinks=nBlinks; // store the number of times to blink the LED - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output + pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output } boolean update(){ for(int i=0;inBlinks=nBlinks; // store the number of times to blink the built-in LED + this->nBlinks=nBlinks; // store the number of times to blink the LED - pinMode(LED_BUILTIN,OUTPUT); // make sure built-in LED is set for output + pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output } boolean update(){ for(int i=0;i\n\n"); Serial.print("Message Logs: Level "); - Serial.print(homeSpan.logLevel); + Serial.print(logLevel); Serial.print("\nStatus LED: Pin "); Serial.print(statusPin); Serial.print("\nDevice Control: Pin "); @@ -82,7 +82,7 @@ void Span::begin(Category catID, const char *displayName, const char *hostNameBa Serial.print(__TIME__); Serial.print("\n\nDevice Name: "); - Serial.print(homeSpan.displayName); + Serial.print(displayName); Serial.print("\n\n"); } // begin diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 6662345..ebbf623 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -134,6 +134,7 @@ struct Span{ void setControlPin(uint8_t pin){controlPin=pin;} // sets Control Pin void setStatusPin(uint8_t pin){statusPin=pin;} // sets Status Pin + int getStatusPin(){return(statusPin);} // gets Status Pin void setApSSID(char *ssid){network.apSSID=ssid;} // sets Access Point SSID void setApPassword(char *pwd){network.apPassword=pwd;} // sets Access Point Password void setApTimeout(uint16_t nSec){network.lifetime=nSec*1000;} // sets Access Point Timeout (seconds) diff --git a/src/Settings.h b/src/Settings.h index 1419bc9..5e5638d 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -62,7 +62,7 @@ #define DEFAULT_SETUP_CODE "46637726" // changed during network setup or with 'S' command #define DEFAULT_CONTROL_PIN 21 // change with homeSpan.setControlPin(pin) -#define DEFAULT_STATUS_PIN LED_BUILTIN // change with homeSpan.setStatusPin(pin) +#define DEFAULT_STATUS_PIN 13 // change with homeSpan.setStatusPin(pin) #define DEFAULT_AP_SSID "HomeSpan-Setup" // change with homeSpan.setApSSID(pwd) #define DEFAULT_AP_PASSWORD "homespan" // change with homeSpan.setApPassword(pwd)