mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-13 06:41:20 +10:00
Merge branch 'development' of https://github.com/tzapu/WiFiManager into development
This commit is contained in:
+10
-8
@@ -180,8 +180,6 @@ boolean WiFiManager::autoConnect() {
|
||||
boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
DEBUG_WM(F("AutoConnect"));
|
||||
|
||||
Serial.println(getMenuOut());
|
||||
|
||||
// attempt to connect using saved settings, on fail fallback to AP config portal
|
||||
WiFi.enableSTA(true);
|
||||
_usermode = WIFI_STA;
|
||||
@@ -738,9 +736,8 @@ String WiFiManager::getMenuOut(){
|
||||
String page;
|
||||
int i;
|
||||
for(i=0;i<sizeof(_menuIds);i++){
|
||||
if(i == MENU_PARAM){
|
||||
if(_paramsCount == 0) continue;
|
||||
}
|
||||
if(_menuIds[i] == 255) continue;
|
||||
if((i == MENU_PARAM) && (_paramsCount == 0)) continue; // no params set, omit params
|
||||
page += HTTP_PORTAL_MENU[_menuIds[i]];
|
||||
}
|
||||
return page;
|
||||
@@ -1701,7 +1698,12 @@ bool WiFiManager::setHostname(const char * hostname){
|
||||
}
|
||||
|
||||
void WiFiManager::setMenu(uint8_t menu[]){
|
||||
// _menuIds = menu;
|
||||
int i;
|
||||
int n = sizeof(menu);
|
||||
for(i=0;i<sizeof(_menuIds);i++){
|
||||
if(_menuIds[i] == MENU_PARAM) _paramsInWifi = false; // param auto flag
|
||||
_menuIds[i] = i<n ? menu[i] : 255;
|
||||
}
|
||||
}
|
||||
|
||||
// GETTERS
|
||||
@@ -1995,8 +1997,8 @@ String WiFiManager::WiFi_SSID(){
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ESP32
|
||||
void WiFiManager::WiFiEvent(WiFiEvent_t event,system_event_info_t info){
|
||||
#ifdef ESP32
|
||||
// WiFiManager _WiFiManager;
|
||||
// Serial.print("WM: EVENT: ");Serial.println(event);
|
||||
if(event == SYSTEM_EVENT_STA_DISCONNECTED){
|
||||
@@ -2011,8 +2013,8 @@ void WiFiManager::WiFiEvent(WiFiEvent_t event,system_event_info_t info){
|
||||
Serial.println("*WM: Event: SYSTEM_EVENT_STA_DISCONNECTED, reconnecting");
|
||||
WiFi.reconnect();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void WiFiManager::WiFi_autoReconnect(){
|
||||
#ifdef ESP8266
|
||||
|
||||
+3
-2
@@ -301,9 +301,10 @@ class WiFiManager
|
||||
void WiFi_autoReconnect();
|
||||
String WiFi_SSID();
|
||||
|
||||
#ifdef ESP32
|
||||
static void WiFiEvent(WiFiEvent_t event, system_event_info_t info);
|
||||
#endif
|
||||
|
||||
|
||||
// output helpers
|
||||
String getParamOut();
|
||||
String getIpForm(String id, String title, String value);
|
||||
@@ -338,7 +339,7 @@ class WiFiManager
|
||||
|
||||
// debugging
|
||||
boolean _debug = true;
|
||||
uint8_t _debugLevel = 1;
|
||||
uint8_t _debugLevel = 2;
|
||||
Stream& _debugPort; // debug output stream ref
|
||||
template <typename Generic>
|
||||
void DEBUG_WM(Generic text);
|
||||
|
||||
@@ -6,10 +6,13 @@
|
||||
#define TRIGGER_PIN 0
|
||||
const char* modes[] = { "NULL", "STA", "AP", "STA+AP" };
|
||||
|
||||
WiFiManager wifiManager;
|
||||
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
delay(3000);
|
||||
Serial.println("\n Starting");
|
||||
|
||||
Serial.setDebugOutput(true);
|
||||
@@ -17,7 +20,6 @@ void setup() {
|
||||
WiFi.printDiag(Serial);
|
||||
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
@@ -25,14 +27,16 @@ void setup() {
|
||||
//useful to make it all retry or go to sleep
|
||||
//in seconds
|
||||
wifiManager.setConfigPortalTimeout(180);
|
||||
|
||||
// uint8_t menu[] = {wifiManager.MENU_WIFI,wifiManager.MENU_INFO,wifiManager.MENU_PARAM,wifiManager.MENU_CLOSE};
|
||||
// wifiManager.setMenu(menu);
|
||||
|
||||
//fetches ssid and pass and tries to connect
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
//here "AutoConnectAP"
|
||||
//and goes into a blocking loop awaiting configuration
|
||||
if(!wifiManager.autoConnect("AutoConnectAP","12345678")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
}
|
||||
}
|
||||
|
||||
pinMode(TRIGGER_PIN, INPUT);
|
||||
}
|
||||
@@ -43,7 +47,6 @@ void loop() {
|
||||
if ( digitalRead(TRIGGER_PIN) == LOW ) {
|
||||
//WiFiManager
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
Reference in New Issue
Block a user