Add homeSpan.enableAutoStartAP()
Enables auto-start of AccessPoint if WiFi Credentials not found.
This commit is contained in:
parent
d46fd3949d
commit
1dfd66bf25
|
|
@ -142,8 +142,14 @@ void Span::poll() {
|
||||||
HAPClient::init(); // read NVS and load HAP settings
|
HAPClient::init(); // read NVS and load HAP settings
|
||||||
|
|
||||||
if(!strlen(network.wifiData.ssid)){
|
if(!strlen(network.wifiData.ssid)){
|
||||||
Serial.print("*** WIFI CREDENTIALS DATA NOT FOUND. YOU MAY CONFIGURE BY TYPING 'W <RETURN>'.\n\n");
|
Serial.print("*** WIFI CREDENTIALS DATA NOT FOUND. ");
|
||||||
statusLED.start(LED_WIFI_NEEDED);
|
if(autoStartAPEnabled){
|
||||||
|
Serial.print("AUTO-START OF ACCESS POINT ENABLED...\n\n");
|
||||||
|
processSerialCommand("A");
|
||||||
|
} else {
|
||||||
|
Serial.print("YOU MAY CONFIGURE BY TYPING 'W <RETURN>'.\n\n");
|
||||||
|
statusLED.start(LED_WIFI_NEEDED);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
homeSpan.statusLED.start(LED_WIFI_CONNECTING);
|
homeSpan.statusLED.start(LED_WIFI_CONNECTING);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,7 @@ struct Span{
|
||||||
char otaPwd[33]; // MD5 Hash of OTA password, represented as a string of hexidecimal characters
|
char otaPwd[33]; // MD5 Hash of OTA password, represented as a string of hexidecimal characters
|
||||||
boolean otaAuth; // OTA requires password when set to true
|
boolean otaAuth; // OTA requires password when set to true
|
||||||
void (*wifiCallback)()=NULL; // optional callback function to invoke once WiFi connectivity is established
|
void (*wifiCallback)()=NULL; // optional callback function to invoke once WiFi connectivity is established
|
||||||
|
boolean autoStartAPEnabled=false; // enables auto start-up of Access Point when WiFi Credentials not found
|
||||||
|
|
||||||
WiFiServer *hapServer; // pointer to the HAP Server connection
|
WiFiServer *hapServer; // pointer to the HAP Server connection
|
||||||
Blinker statusLED; // indicates HomeSpan status
|
Blinker statusLED; // indicates HomeSpan status
|
||||||
|
|
@ -177,6 +178,7 @@ struct Span{
|
||||||
void setSketchVersion(const char *sVer){sketchVersion=sVer;} // set optional sketch version number
|
void setSketchVersion(const char *sVer){sketchVersion=sVer;} // set optional sketch version number
|
||||||
const char *getSketchVersion(){return sketchVersion;} // get sketch version number
|
const char *getSketchVersion(){return sketchVersion;} // get sketch version number
|
||||||
void setWifiCallback(void (*f)()){wifiCallback=f;} // sets an optional user-defined function to call once WiFi connectivity is established
|
void setWifiCallback(void (*f)()){wifiCallback=f;} // sets an optional user-defined function to call once WiFi connectivity is established
|
||||||
|
void enableAutoStartAP(){autoStartAPEnabled=true;} // enables auto start-up of Access Point when WiFi Credentials not found
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ void setup() {
|
||||||
new SpanUserCommand('d',"My Description",userCom1);
|
new SpanUserCommand('d',"My Description",userCom1);
|
||||||
new SpanUserCommand('d',"My second Description",userCom2);
|
new SpanUserCommand('d',"My second Description",userCom2);
|
||||||
|
|
||||||
|
// homeSpan.enableAutoStartAP();
|
||||||
|
|
||||||
homeSpan.begin(Category::Lighting,"HomeSpan Lamp Server","homespan");
|
homeSpan.begin(Category::Lighting,"HomeSpan Lamp Server","homespan");
|
||||||
|
|
||||||
new SpanAccessory(); // Begin by creating a new Accessory using SpanAccessory(), which takes no arguments
|
new SpanAccessory(); // Begin by creating a new Accessory using SpanAccessory(), which takes no arguments
|
||||||
|
|
@ -40,6 +42,7 @@ void setup() {
|
||||||
new Characteristic::On();
|
new Characteristic::On();
|
||||||
new Characteristic::Brightness();
|
new Characteristic::Brightness();
|
||||||
new Characteristic::Name("Light 1");
|
new Characteristic::Name("Light 1");
|
||||||
|
new Characteristic::ColorTemperature(0);
|
||||||
new Service::LightBulb();
|
new Service::LightBulb();
|
||||||
new Characteristic::On(2);
|
new Characteristic::On(2);
|
||||||
(new Characteristic::Brightness(50))->setRange(10,100,5);
|
(new Characteristic::Brightness(50))->setRange(10,100,5);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue