updated enableAutoStartAP to accept user-define function as argument
This commit is contained in:
parent
b53081dfc7
commit
e3d081bb35
|
|
@ -147,8 +147,12 @@ void Span::poll() {
|
||||||
if(!strlen(network.wifiData.ssid)){
|
if(!strlen(network.wifiData.ssid)){
|
||||||
Serial.print("*** WIFI CREDENTIALS DATA NOT FOUND. ");
|
Serial.print("*** WIFI CREDENTIALS DATA NOT FOUND. ");
|
||||||
if(autoStartAPEnabled){
|
if(autoStartAPEnabled){
|
||||||
Serial.print("AUTO-START OF ACCESS POINT ENABLED...\n\n");
|
if(apFunction){
|
||||||
processSerialCommand("A");
|
apFunction();
|
||||||
|
} else {
|
||||||
|
Serial.print("AUTO-START OF ACCESS POINT ENABLED...\n\n");
|
||||||
|
processSerialCommand("A");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Serial.print("YOU MAY CONFIGURE BY TYPING 'W <RETURN>'.\n\n");
|
Serial.print("YOU MAY CONFIGURE BY TYPING 'W <RETURN>'.\n\n");
|
||||||
statusLED.start(LED_WIFI_NEEDED);
|
statusLED.start(LED_WIFI_NEEDED);
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ struct Span{
|
||||||
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
|
boolean autoStartAPEnabled=false; // enables auto start-up of Access Point when WiFi Credentials not found
|
||||||
|
void (*apFunction)()=NULL; // optional function to invoke when using enableAutoStartAP()
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -180,7 +181,8 @@ 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
|
|
||||||
|
void enableAutoStartAP(void (*f)()=NULL){autoStartAPEnabled=true;apFunction=f;} // enables auto start-up of Access Point when WiFi Credentials not found (will call optional f, if specified)
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ 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.enableAutoStartAP(myWiFiAP);
|
||||||
|
|
||||||
homeSpan.begin(Category::Lighting,"HomeSpan Lamp Server","homespan");
|
homeSpan.begin(Category::Lighting,"HomeSpan Lamp Server","homespan");
|
||||||
|
|
||||||
|
|
@ -60,6 +60,12 @@ void loop(){
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
void myWiFiAP(){
|
||||||
|
Serial.print("Calling My WIFI AP\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
void wifiEstablished(){
|
void wifiEstablished(){
|
||||||
Serial.print("IN CALLBACK FUNCTION\n\n");
|
Serial.print("IN CALLBACK FUNCTION\n\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue