Merge pull request #670 from frankonski/verbose_reconnect
Verbose WiFi Reconnect
This commit is contained in:
commit
a93aef1604
|
|
@ -30,7 +30,7 @@ The following **optional** `homeSpan` methods override various HomeSpan initiali
|
||||||
Methods with a return type of `Span&` return a reference to `homeSpan` itself and can thus be chained together (e.g. `homeSpan.setControlPin(21).setStatusPin(13);`). If a method is *not* called, HomeSpan uses the default parameter indicated below:
|
Methods with a return type of `Span&` return a reference to `homeSpan` itself and can thus be chained together (e.g. `homeSpan.setControlPin(21).setStatusPin(13);`). If a method is *not* called, HomeSpan uses the default parameter indicated below:
|
||||||
|
|
||||||
* `Span& setControlPin(uint8_t pin)`
|
* `Span& setControlPin(uint8_t pin)`
|
||||||
* sets the ESP32 pin to use for the HomeSpan Control Button. If not specified, HomeSpan will assume there is no Control Button
|
* sets the ESP32 pin to use for the HomeSpan Control Button (which must connect the specified pin to **ground** when pushed). If not specified, HomeSpan will assume there is no Control Button
|
||||||
|
|
||||||
* `int getControlPin()`
|
* `int getControlPin()`
|
||||||
* returns the pin number of the HomeSpan Control Button as set by `setControlPin(pin)`, or -1 if no pin has been set
|
* returns the pin number of the HomeSpan Control Button as set by `setControlPin(pin)`, or -1 if no pin has been set
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ void loop(){
|
||||||
// For example, if you were using an MCP I/O Port Expander with the Adafruit mcp library, you could create a triggerType function for a pin
|
// For example, if you were using an MCP I/O Port Expander with the Adafruit mcp library, you could create a triggerType function for a pin
|
||||||
// on the MCP device that is connected to ground through a pushbutton as such:
|
// on the MCP device that is connected to ground through a pushbutton as such:
|
||||||
//
|
//
|
||||||
// boolean MCP_READ(int mcpPin) { return ( !mcp.digitalRead(mcpPin); ) }
|
// boolean MCP_READ(int mcpPin) { return ( !mcp.digitalRead(mcpPin) ); }
|
||||||
//
|
//
|
||||||
// And then simply pass MCP_READ to SpanButton as the triggerType parameter using any of the SpanButton constuctors:
|
// And then simply pass MCP_READ to SpanButton as the triggerType parameter using any of the SpanButton constuctors:
|
||||||
//
|
//
|
||||||
|
|
@ -258,7 +258,7 @@ void loop(){
|
||||||
//
|
//
|
||||||
// Alternatively, you can use a lambda function as the triggerType parameter, thus creating your function on the fly when instantiating a SpanButton:
|
// Alternatively, you can use a lambda function as the triggerType parameter, thus creating your function on the fly when instantiating a SpanButton:
|
||||||
//
|
//
|
||||||
// new SpanButton(23,[](int mcpPin)->boolean{ return ( !mcp.digitalRead(mcpPin); ) }
|
// new SpanButton(23,[](int mcpPin)->boolean{ return ( !mcp.digitalRead(mcpPin) ); });
|
||||||
//
|
//
|
||||||
// Note: If you create your own triggerType function, don't forget to perform any initialization of the "pin", or setup/configuration of a
|
// Note: If you create your own triggerType function, don't forget to perform any initialization of the "pin", or setup/configuration of a
|
||||||
// pin extender, etc., prior to instantiating a SpanButton that uses your custom function. HomeSpan cannot do this for you.
|
// pin extender, etc., prior to instantiating a SpanButton that uses your custom function. HomeSpan cannot do this for you.
|
||||||
|
|
|
||||||
|
|
@ -408,7 +408,7 @@ void Span::checkConnect(){
|
||||||
LOG0("\n*** Can't connect to %s. You may type 'W <return>' to re-configure WiFi, or 'X <return>' to erase WiFi credentials. Will try connecting again in 60 seconds.\n\n",network.wifiData.ssid);
|
LOG0("\n*** Can't connect to %s. You may type 'W <return>' to re-configure WiFi, or 'X <return>' to erase WiFi credentials. Will try connecting again in 60 seconds.\n\n",network.wifiData.ssid);
|
||||||
waitTime=60000;
|
waitTime=60000;
|
||||||
} else {
|
} else {
|
||||||
addWebLog(true,"Trying to connect to %s. Waiting %d sec...",network.wifiData.ssid,waitTime/1000);
|
if (verboseWiFiReconnect) addWebLog(true,"Trying to connect to %s. Waiting %d sec...",network.wifiData.ssid,waitTime/1000);
|
||||||
WiFi.begin(network.wifiData.ssid,network.wifiData.pwd);
|
WiFi.begin(network.wifiData.ssid,network.wifiData.pwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,7 @@ class Span{
|
||||||
Network network; // configures WiFi and Setup Code via either serial monitor or temporary Access Point
|
Network network; // configures WiFi and Setup Code via either serial monitor or temporary Access Point
|
||||||
SpanWebLog webLog; // optional web status/log
|
SpanWebLog webLog; // optional web status/log
|
||||||
TaskHandle_t pollTaskHandle = NULL; // optional task handle to use for poll() function
|
TaskHandle_t pollTaskHandle = NULL; // optional task handle to use for poll() function
|
||||||
|
boolean verboseWiFiReconnect = true; // Set to false to not print WiFi reconnect attempts messages
|
||||||
|
|
||||||
SpanOTA spanOTA; // manages OTA process
|
SpanOTA spanOTA; // manages OTA process
|
||||||
SpanConfig hapConfig; // track configuration changes to the HAP Accessory database; used to increment the configuration number (c#) when changes found
|
SpanConfig hapConfig; // track configuration changes to the HAP Accessory database; used to increment the configuration number (c#) when changes found
|
||||||
|
|
@ -352,6 +353,8 @@ class Span{
|
||||||
Span& setWebLogCSS(const char *css){webLog.css="\n" + String(css) + "\n";return(*this);}
|
Span& setWebLogCSS(const char *css){webLog.css="\n" + String(css) + "\n";return(*this);}
|
||||||
Span& setWebLogCallback(void (*f)(String &)){weblogCallback=f;return(*this);}
|
Span& setWebLogCallback(void (*f)(String &)){weblogCallback=f;return(*this);}
|
||||||
|
|
||||||
|
void setVerboseWiFiReconnect(bool verbose) { verboseWiFiReconnect = verbose;}
|
||||||
|
|
||||||
void autoPoll(uint32_t stackSize=8192, uint32_t priority=1, uint32_t cpu=0){ // start pollTask()
|
void autoPoll(uint32_t stackSize=8192, uint32_t priority=1, uint32_t cpu=0){ // start pollTask()
|
||||||
xTaskCreateUniversal([](void *parms){for(;;)homeSpan.pollTask();}, "pollTask", stackSize, NULL, priority, &pollTaskHandle, cpu);
|
xTaskCreateUniversal([](void *parms){for(;;)homeSpan.pollTask();}, "pollTask", stackSize, NULL, priority, &pollTaskHandle, cpu);
|
||||||
LOG0("\n*** AutoPolling Task started with priority=%d\n\n",uxTaskPriorityGet(pollTaskHandle));
|
LOG0("\n*** AutoPolling Task started with priority=%d\n\n",uxTaskPriorityGet(pollTaskHandle));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue