Created
February 23, 2016 05:10
-
-
Save tzapu/5b13866aaa584b32074a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
//this sketch duplicated the flow that WiFIManager or any other connection manager would take | |
//first try to connect, if it fails spin up an AP, get some credentials from user, connect again | |
//then spin everything down | |
void setup() { | |
Serial.begin(115200); | |
Serial.println(); | |
Serial.println(); | |
Serial.println("Start"); | |
WiFi.mode(WIFI_STA); | |
WiFi.begin("wrongssid","wrongpass"); | |
Serial.println(WiFi.waitForConnectResult()); | |
WiFi.mode(WIFI_AP); | |
WiFi.softAP("APName"); | |
delay(2000); | |
//change details below to your router | |
WiFi.begin("correctssid","correctpass"); | |
Serial.println(WiFi.waitForConnectResult()); | |
WiFi.mode(WIFI_STA); | |
if(WiFi.status() == WL_CONNECTED) { | |
Serial.println("Connected"); | |
} else { | |
Serial.println("Not Connected"); | |
} | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment