Added WiFi callback functionality
HomeSpan will call a user-defined function upon establishing WiFi connectivity. Set function with homeSpan.setWifiCallback(f), where f must be of form void f().
This commit is contained in:
parent
3a519bdc54
commit
7e03998865
|
|
@ -495,6 +495,9 @@ void Span::checkConnect(){
|
||||||
} else {
|
} else {
|
||||||
statusLED.on();
|
statusLED.on();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(wifiCallback)
|
||||||
|
wifiCallback();
|
||||||
|
|
||||||
} // initWiFi
|
} // initWiFi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ struct Span{
|
||||||
char qrID[5]=""; // Setup ID used for pairing with QR Code
|
char qrID[5]=""; // Setup ID used for pairing with QR Code
|
||||||
boolean otaEnabled=false; // enables Over-the-Air ("OTA") updates
|
boolean otaEnabled=false; // enables Over-the-Air ("OTA") updates
|
||||||
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
|
||||||
|
void (*wifiCallback)()=NULL; // optional callback function to invoke once WiFi connectivity is established
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -156,6 +157,7 @@ struct Span{
|
||||||
void enableOTA(){otaEnabled=true;} // enables Over-the-Air updates
|
void enableOTA(){otaEnabled=true;} // enables Over-the-Air updates
|
||||||
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
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
|
||||||
11
src/src.ino
11
src/src.ino
|
|
@ -14,8 +14,9 @@ void setup() {
|
||||||
homeSpan.setPortNum(1200);
|
homeSpan.setPortNum(1200);
|
||||||
homeSpan.setMaxConnections(16);
|
homeSpan.setMaxConnections(16);
|
||||||
// homeSpan.setQRID("One1");
|
// homeSpan.setQRID("One1");
|
||||||
// homeSpan.enableOTA();
|
homeSpan.enableOTA();
|
||||||
homeSpan.setSketchVersion("Test 1.2.3");
|
homeSpan.setSketchVersion("Test 1.2.4");
|
||||||
|
homeSpan.setWifiCallback(wifiEstablished);
|
||||||
|
|
||||||
homeSpan.begin(Category::Lighting,"HomeSpanTest");
|
homeSpan.begin(Category::Lighting,"HomeSpanTest");
|
||||||
|
|
||||||
|
|
@ -44,3 +45,9 @@ void loop(){
|
||||||
homeSpan.poll();
|
homeSpan.poll();
|
||||||
|
|
||||||
} // end of loop()
|
} // end of loop()
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
void wifiEstablished(){
|
||||||
|
Serial.println("\n\nIN CALLBACK FUNCTION\n\n");
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue