Merge branch 'development' into ota

This commit is contained in:
tablatronix
2020-05-10 14:00:22 -05:00
6 changed files with 153 additions and 92 deletions
@@ -170,7 +170,7 @@ void setup() {
std::vector<const char *> menu = {"wifi","wifinoscan","info","param","close","sep","erase","restart","exit"};
// wm.setMenu(menu); // custom menu, pass vector
wm.setParamsPage(true); // move params to seperate page, not wifi, do not combine with setmenu!
// wm.setParamsPage(true); // move params to seperate page, not wifi, do not combine with setmenu!
// set static sta ip
// wm.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
@@ -204,7 +204,7 @@ void setup() {
// wm.setCleanConnect(true); // disconenct before connect, clean connect
// wm.setBreakAfterConfig(true);
wm.setBreakAfterConfig(true);
//fetches ssid and pass and tries to connect
//if it does not connect it starts an access point with the specified name
@@ -212,7 +212,7 @@ void setup() {
//and goes into a blocking loop awaiting configuration
wifiInfo();
print_oled(F("Connecting..."),2);
if(!AUTOSTARTCP || !wm.autoConnect("WM_AutoConnectAP")) {
if(!wm.autoConnect("WM_AutoConnectAP","12345678")) {
Serial.println("failed to connect and hit timeout");
print_oled("Not Connected",2);
}
@@ -6,6 +6,13 @@
*/
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
// include MDNS
#ifdef ESP8266
#include <ESP8266mDNS.h>
#elif defined(ESP32)
#include <ESPmDNS.h>
#endif
// select which pin will trigger the configuration portal when set to LOW
#define TRIGGER_PIN 0
@@ -20,11 +27,21 @@ void setup() {
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
// put your setup code here, to run once
Serial.begin(115200);
Serial.setDebugOutput(true);
delay(1000);
Serial.println("\n Starting");
pinMode(TRIGGER_PIN, INPUT_PULLUP);
// wm.resetSettings();
wm.setHostname("MDNSEXAMPLE");
// wm.setEnableConfigPortal(false);
// wm.setConfigPortalBlocking(false);
wm.autoConnect();
}
void loop() {
MDNS.update();
doWiFiManager();
// put your main code here, to run repeatedly:
}
+24
View File
@@ -0,0 +1,24 @@
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
bool _enteredConfigMode = false;
void setup(){
Serial.begin(115200);
WiFiManager wifiManager;
// wifiManager.setAPCallback([this](WiFiManager* wifiManager) {
wifiManager.setAPCallback([&](WiFiManager* wifiManager) {
Serial.printf("Entered config mode:ip=%s, ssid='%s'\n",
WiFi.softAPIP().toString().c_str(),
wifiManager->getConfigPortalSSID().c_str());
_enteredConfigMode = true;
});
wifiManager.resetSettings();
if (!wifiManager.autoConnect()) {
Serial.printf("*** Failed to connect and hit timeout\n");
ESP.reset();
delay(1000);
}
}
void loop(){}