mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-14 15:11:32 +10:00
fixes #573
This commit is contained in:
+1
-1
@@ -100,7 +100,7 @@ bool WiFiManager::addParameter(WiFiManagerParameter *p) {
|
||||
// check param id is valid, unless null
|
||||
if(p->getID()){
|
||||
for (size_t i = 0; i < strlen(p->getID()); i++){
|
||||
if(!isAlphaNumeric(p->getID()[i])){
|
||||
if(!isAlphaNumeric(p->getID()[i]) && !p->getID()[i]=='_'){
|
||||
DEBUG_WM(DEBUG_ERROR,"[ERROR] parameter IDs can only contain alpha numeric chars");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@ void setup() {
|
||||
Serial.println(modes[WiFi.getMode()]);
|
||||
WiFi.printDiag(Serial);
|
||||
|
||||
//WiFiManager
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
@@ -26,10 +30,50 @@ void setup() {
|
||||
//sets timeout until configuration portal gets turned off
|
||||
//useful to make it all retry or go to sleep
|
||||
//in seconds
|
||||
wifiManager.setConfigPortalTimeout(180);
|
||||
wifiManager.setConfigPortalTimeout(20);
|
||||
wifiManager.setConnectTimeout(10);
|
||||
// wifiManager.setShowStaticFields(true);
|
||||
|
||||
// uint8_t menu[] = {wifiManager.MENU_WIFI,wifiManager.MENU_INFO,wifiManager.MENU_PARAM,wifiManager.MENU_CLOSE};
|
||||
// wifiManager.setMenu(menu);
|
||||
|
||||
// std::vector<WiFiManager::menu_page_t> menu = {wifiManager.MENU_WIFI,wifiManager.MENU_INFO,wifiManager.MENU_PARAM,wifiManager.MENU_CLOSE,wifiManager.MENU_SEP,wifiManager.MENU_ERASE,wifiManager.MENU_EXIT};
|
||||
// wifiManager.setMenu(menu);
|
||||
|
||||
// std::vector<WiFiManager::menu_page_t> menu = {wifiManager.MENU_WIFI,wifiManager.MENU_INFO,wifiManager.MENU_PARAM,wifiManager.MENU_CLOSE,wifiManager.MENU_SEP,wifiManager.MENU_ERASE,wifiManager.MENU_EXIT};
|
||||
// wifiManager.setMenu(menu);
|
||||
|
||||
|
||||
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "", 40);
|
||||
WiFiManagerParameter custom_mqtt_port("port", "mqtt port", "", 6);
|
||||
WiFiManagerParameter custom_blynk_token("api_token", "api token", "", 0);
|
||||
|
||||
//add all your parameters here
|
||||
wifiManager.addParameter(&custom_mqtt_server);
|
||||
wifiManager.addParameter(&custom_mqtt_port);
|
||||
wifiManager.addParameter(&custom_blynk_token);
|
||||
|
||||
// MENU_WIFI = 0,
|
||||
// MENU_WIFINOSCAN = 1,
|
||||
// MENU_INFO = 2,
|
||||
// MENU_PARAM = 3,
|
||||
// MENU_CLOSE = 4,
|
||||
// MENU_RESTART = 5,
|
||||
// MENU_EXIT = 6,
|
||||
// MENU_ERASE = 7,
|
||||
// MENU_SEP = 8
|
||||
|
||||
// const char* menu[] = {"wifi","wifinoscan","info","param","close","sep","erase","restart","exit"};
|
||||
// wifiManager.setMenu(menu,9);
|
||||
|
||||
std::vector<const char *> menu = {"wifi","wifinoscan","info","param","close","sep","erase","restart","exit"};
|
||||
wifiManager.setMenu(menu);
|
||||
|
||||
//set static ip
|
||||
wifiManager.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
// wifiManager.setShowStaticFields(false);
|
||||
// wifiManager.setShowDnsFields(false);
|
||||
|
||||
//fetches ssid and pass and tries to connect
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
//here "AutoConnectAP"
|
||||
|
||||
Reference in New Issue
Block a user