Browse Source

wifimanager first implementation

on demand portal starts and crashes immediately
detach all tickers before going to config mode
Etienne Landon 9 years ago
parent
commit
093b4bfc6b
3 changed files with 7 additions and 68 deletions
  1. 6 5
      ESP_UKI.ino
  2. 0 61
      global.h
  3. 1 2
      includes.h

+ 6 - 5
ESP_UKI.ino

@@ -22,8 +22,12 @@
 
 
 
-Ticker tkUKI;  // periodic send ADC to UDP
 
+/* UDP CONFIGURATION */
+int UKI_UDP_In_Port = 9000;  //udp port input for ESP
+IPAddress UKI_UDP_Master_IP(192, 168, 0, 41);  //default udp address to send to. Will automatically change to the ip sending something to udp in
+Ticker tkUKI;  // periodic send ADC to UDP
+int GSR_sensor;
 
 
 void setup ( void ) {
@@ -32,7 +36,7 @@ void setup ( void ) {
   Serial.begin(115200);
   Serial.println("Starting ESP8266");
   setupLeds();
-  //setupWifi();
+  setupWifi();
   setupOTA();
   
   delay(200);
@@ -55,10 +59,7 @@ void setup ( void ) {
 
 
 void loop ( void ) {
-  loop_counter += 1;
-  //loopWebserver();
   
-  //loopOTA();
 
   /*  UKI part	*/
 //  GSR_sensor = analogRead(A0);

+ 0 - 61
global.h

@@ -1,61 +0,0 @@
-#ifndef GLOBAL_H
-#define GLOBAL_H
-
-
-
-/* DEFAULT ACCESS POINT CONFIGURATION */
-#define ACCESS_POINT_NAME  "ESP"
-#define ACCESS_POINT_PASSWORD  "12345678"
-boolean AdminEnabled = false; // Enable Admin Mode for a given Time
-int AdminTimeOutCounter = 0;  // Counter for Disabling the AdminMode
-#define AdminTimeOut 60  // Defines the Time in Seconds, when the Admin-Mode will be disabled
-
-
-
-/* UDP CONFIGURATION */
-int UKI_UDP_In_Port = 9000;  //udp port input for ESP
-IPAddress UKI_UDP_Master_IP(192, 168, 0, 41);  //default udp address to send to. Will automatically change to the ip sending something to udp in
- 
-
-
-int GSR_sensor;
-int loop_counter;
-int counter;
-
-
-void setupWifi() {
-  
-  //if no config in eeprom, start as default access point
-  if (!ReadConfig())  {
-    WiFi.mode(WIFI_AP);
-    WiFi.softAP( ACCESS_POINT_NAME , ACCESS_POINT_PASSWORD);
-    Serial.println("Starting default access point (SSID:ESP, pwd:12345678)");
-    Serial.println(WiFi.softAPIP());
-    }
-  //if config in eeprom, try and connect to wifi, if fail after timeout start access point with config.name SSID
-  else {  
-    WiFi.mode(WIFI_STA);
-   // ConfigureWifi();
-    Serial.println("Connecting to configured wifi network");
-    while (WiFi.status() != 3) {
-      counter++;
-      Serial.print(".");
-      Serial.println(WiFi.status());
-
-      if (counter > 50) {
-        Serial.println("failed");
-        Serial.println("Starting as access point, SSID:"+ (String)config.DeviceName.c_str()+" pwd:" + (String)ACCESS_POINT_PASSWORD);
-        WiFi.mode(WIFI_AP);
-        //WiFi.softAP( ACCESS_POINT_NAME , ACCESS_POINT_PASSWORD);
-        WiFi.softAP( config.DeviceName.c_str() , ACCESS_POINT_PASSWORD);
-        Serial.println(WiFi.softAPIP());
-        break;
-        }
-      }
-    } 
- 
-}
-
-
-
-#endif

+ 1 - 2
includes.h

@@ -30,8 +30,7 @@ WiFiUDP UKI_UDP;
 #include "helpers.h"  //some helpers functions
 
 #include "eeprom.h"   //config and functions relative to config permanent storage
-#include "global.h"   //config and functions relative to wifi and access point configuration
-//#include "web.h"      //config and functions relative to configuration web server
+#include "wifimgr.h"   //config and functions relative to wifi and access point configuration
 #include "ota.h"      //config and functions relative to ota firmware updates