reset wifi-settings on press of button, fixes #4

This commit is contained in:
Ronald Schaten 2016-02-24 10:28:49 +01:00
parent 12c641a43d
commit 84dfe25160

View File

@ -19,6 +19,8 @@ extern "C" {
//#define DHTTYPE DHT21 // DHT21 (AM2301)
#define DHTTYPE DHT22 // DHT22 (AM2302)
#define CONFIGPIN D3 // config-button is connected to this pin
// define default values here, overwritten by values from config.json
char mqtt_server[40];
char mqtt_port[6] = "1883";
@ -183,10 +185,11 @@ void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// set led pin as output
pinMode(BUILTIN_LED, OUTPUT);
pinMode(BUILTIN_LED, OUTPUT); // set led pin as output
ticker.attach(0.5, toggle_led); // toggle led slowly during initialization
pinMode(CONFIGPIN, INPUT); // flash-button on nodemcu
// clean FS, for testing
//SPIFFS.format();
@ -230,8 +233,12 @@ void setup() {
// local intialization
WiFiManager wifiManager;
// reset settings - for testing
//wifiManager.resetSettings();
// reset settings if config-button is pressed
if (!digitalRead(CONFIGPIN)) {
Serial.println("config-button pressed, resetting wifi settings");
wifiManager.resetSettings();
}
// set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode
wifiManager.setAPCallback(configModeCallback);