Merge branch 'development' of https://github.com/tzapu/WiFiManager into development

This commit is contained in:
tablatronix
2019-01-26 18:07:24 -06:00
4 changed files with 63 additions and 4 deletions
@@ -7,6 +7,54 @@
#define TRIGGER_PIN 0
const char* modes[] = { "NULL", "STA", "AP", "STA+AP" };
// // #define MYOLED
// #include <Wire.h>
// #include <Adafruit_GFX.h>
// #include <Adafruit_SSD1306.h>
// #ifdef MYOLED
// #define SCREEN_WIDTH 128 // OLED display width, in pixels
// #define SCREEN_HEIGHT 32 // OLED display height, in pixels
// // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
// Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// void init_oled(){
// Wire.begin(SCL,SDA); // begin(sda, scl) SWAP!
// // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
// if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
// Serial.println(F("SSD1306 allocation failed"));
// }
// display.clearDisplay();
// display.setTextSize(1); // Normal 1:1 pixepl scale
// display.setTextColor(WHITE); // Draw white text
// display.setCursor(0,0); // Start at top-left corner
// display.display();
// }
// void print_oled(String str,uint8_t size){
// display.clearDisplay();
// display.setTextSize(size);
// display.setTextColor(WHITE);
// display.setCursor(0,0);
// display.println(str);
// display.display();
// }
// #else
// void print_oled(String str,uint8_t size){
// (void)str;
// (void)size;
// }
// #endif
void print_oled(String str,uint8_t size){
(void)str;
(void)size;
}
WiFiManager wm;
bool TEST_CP = false; // always start the configportal
bool TEST_NET = true; // do a network test, get ntp time
@@ -20,6 +68,7 @@ void saveWifiCallback(){
//gets called when WiFiManager enters configuration mode
void configModeCallback (WiFiManager *myWiFiManager) {
Serial.println("[CALLBACK] configModeCallback fired");
print_oled("WiFiManager Waiting\nIP: " + WiFi.softAPIP().toString() + "\nSSID: " + WiFi.softAPSSID(),1);
// myWiFiManager->setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
// Serial.println(WiFi.softAPIP());
//if you used auto generated SSID, print it
@@ -44,11 +93,15 @@ void handleRoute(){
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.setDebugOutput(true);
// Serial.setDebugOutput(true);
// delay(3000);
Serial.println("\n Starting");
// WiFi.setSleepMode(WIFI_NONE_SLEEP); // disable sleep, can improve ap stability
#ifdef OLED
init_oled();
#endif
print_oled(F("Starting..."),2);
wm.debugPlatformInfo();
//Local intialization. Once its business is done, there is no need to keep it around
@@ -121,8 +174,10 @@ void setup() {
//here "AutoConnectAP"
//and goes into a blocking loop awaiting configuration
print_oled(F("Connecting..."),2);
if(!wm.autoConnect("AutoConnectAP")) {
Serial.println("failed to connect and hit timeout");
print_oled("Not Connected",2);
}
else if(TEST_CP) {
// start configportal always
@@ -132,6 +187,7 @@ void setup() {
else {
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
print_oled("Connected\nIP: " + WiFi.localIP().toString() + "\nSSID: " + WiFi.SSID(),1);
}
pinMode(TRIGGER_PIN, INPUT);
}
@@ -151,6 +207,7 @@ void loop() {
} else {
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
print_oled("Connected\nIP: " + WiFi.localIP().toString() + "\nSSID: " + WiFi.SSID(),1);
getTime();
}
}
@@ -175,7 +232,7 @@ void getTime() {
if((millis() - start) > timeout){
Serial.println("[ERROR] Failed to get NTP time.");
return;
}
}
}
Serial.println("");
struct tm timeinfo;