Browse Source

fix wifimanager

move wifimanager out of ticker call, set flag in ticker for non-blocking
operation
Etienne Landon 9 years ago
parent
commit
d9dc7169c8
6 changed files with 373 additions and 378 deletions
  1. 9 6
      ESP_UKI.ino
  2. 140 140
      eeprom.h
  3. 210 210
      helpers.h
  4. 6 6
      includes.h
  5. 4 16
      leds.h
  6. 4 0
      ota.h

+ 9 - 6
ESP_UKI.ino

@@ -27,22 +27,24 @@
 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;
+//int GSR_sensor;
 
 
 void setup ( void ) {
   
-  EEPROM.begin(512);
+  //EEPROM.begin(512);
   Serial.begin(115200);
   Serial.println("Starting ESP8266");
-  setupLeds();
   setupWifi();
-  setupOTA();
+  
+  //setupLeds();
+  
+  //setupOTA();
   
   delay(200);
   Serial.println("Ready");
   Serial.print("IP address: ");
-  Serial.println(WiFi.localIP());
+  //Serial.println(WiFi.localIP());
 
   //UKI sensor setup
   UKI_UDP.begin(UKI_UDP_In_Port); 
@@ -52,13 +54,14 @@ void setup ( void ) {
 //  delay(1000);
 //  ledBlink(Red_Led, 3, 100); //3 quick blink on red led as we start 
 //  delay (1000);
-  blueLedState(-1, 500);
+  //blueLedState(-1, 500);
   
   
 }
 
 
 void loop ( void ) {
+  StartConfigAP();
   
 
   /*  UKI part	*/

+ 140 - 140
eeprom.h

@@ -1,141 +1,141 @@
-
-struct strConfig {
-  String ssid;
-  String password;
-  byte  IP[4];
-  byte  Netmask[4];
-  byte  Gateway[4];
-  boolean dhcp;
-  String ntpServerName;
-  long Update_Time_Via_NTP_Every;
-  long timezone;
-  boolean daylight;
-  String DeviceName;
-  boolean AutoTurnOff;
-  boolean AutoTurnOn;
-  byte TurnOffHour;
-  byte TurnOffMinute;
-  byte TurnOnHour;
-  byte TurnOnMinute;
-  byte LED_R;
-  byte LED_G;
-  byte LED_B;
-}   config;
-
-
-/*
-**
-** CONFIGURATION HANDLING
-**
-*/
-
-
-
-
-
-
-void WriteConfig()
-{
-
-  Serial.println("Writing Config");
-  EEPROM.write(0,'C');
-  EEPROM.write(1,'F');
-  EEPROM.write(2,'G');
-
-  EEPROM.write(16,config.dhcp);
-  EEPROM.write(17,config.daylight);
-  
-  EEPROMWritelong(18,config.Update_Time_Via_NTP_Every); // 4 Byte
-
-  EEPROMWritelong(22,config.timezone);  // 4 Byte
-
-
-  EEPROM.write(26,config.LED_R);
-  EEPROM.write(27,config.LED_G);
-  EEPROM.write(28,config.LED_B);
-
-  EEPROM.write(32,config.IP[0]);
-  EEPROM.write(33,config.IP[1]);
-  EEPROM.write(34,config.IP[2]);
-  EEPROM.write(35,config.IP[3]);
-
-  EEPROM.write(36,config.Netmask[0]);
-  EEPROM.write(37,config.Netmask[1]);
-  EEPROM.write(38,config.Netmask[2]);
-  EEPROM.write(39,config.Netmask[3]);
-
-  EEPROM.write(40,config.Gateway[0]);
-  EEPROM.write(41,config.Gateway[1]);
-  EEPROM.write(42,config.Gateway[2]);
-  EEPROM.write(43,config.Gateway[3]);
-
-
-  WriteStringToEEPROM(64,config.ssid);
-  WriteStringToEEPROM(96,config.password);
-  WriteStringToEEPROM(128,config.ntpServerName);
-
-  EEPROM.write(300,config.AutoTurnOn);
-  EEPROM.write(301,config.AutoTurnOff);
-  EEPROM.write(302,config.TurnOnHour);
-  EEPROM.write(303,config.TurnOnMinute);
-  EEPROM.write(304,config.TurnOffHour);
-  EEPROM.write(305,config.TurnOffMinute);
-  WriteStringToEEPROM(306,config.DeviceName);
-  
-
-
-  EEPROM.commit();
-}
-boolean ReadConfig()
-{
-
-  Serial.println("Reading Configuration");
-  if (EEPROM.read(0) == 'C' && EEPROM.read(1) == 'F'  && EEPROM.read(2) == 'G' )
-  {
-    Serial.println("Configurarion Found!");
-    config.dhcp =   EEPROM.read(16);
-
-    config.daylight = EEPROM.read(17);
-
-    config.Update_Time_Via_NTP_Every = EEPROMReadlong(18); // 4 Byte
-
-    config.timezone = EEPROMReadlong(22); // 4 Byte
-
-    config.LED_R = EEPROM.read(26);
-    config.LED_G = EEPROM.read(27);
-    config.LED_B = EEPROM.read(28);
-
-    config.IP[0] = EEPROM.read(32);
-    config.IP[1] = EEPROM.read(33);
-    config.IP[2] = EEPROM.read(34);
-    config.IP[3] = EEPROM.read(35);
-    config.Netmask[0] = EEPROM.read(36);
-    config.Netmask[1] = EEPROM.read(37);
-    config.Netmask[2] = EEPROM.read(38);
-    config.Netmask[3] = EEPROM.read(39);
-    config.Gateway[0] = EEPROM.read(40);
-    config.Gateway[1] = EEPROM.read(41);
-    config.Gateway[2] = EEPROM.read(42);
-    config.Gateway[3] = EEPROM.read(43);
-    config.ssid = ReadStringFromEEPROM(64);
-    config.password = ReadStringFromEEPROM(96);
-    config.ntpServerName = ReadStringFromEEPROM(128);
-    
-    
-    config.AutoTurnOn = EEPROM.read(300);
-    config.AutoTurnOff = EEPROM.read(301);
-    config.TurnOnHour = EEPROM.read(302);
-    config.TurnOnMinute = EEPROM.read(303);
-    config.TurnOffHour = EEPROM.read(304);
-    config.TurnOffMinute = EEPROM.read(305);
-    config.DeviceName= ReadStringFromEEPROM(306);
-    return true;
-    
-  }
-  else
-  {
-    Serial.println("Configurarion NOT FOUND!!!!");
-    return false;
-  }
-}
+//
+//struct strConfig {
+//  String ssid;
+//  String password;
+//  byte  IP[4];
+//  byte  Netmask[4];
+//  byte  Gateway[4];
+//  boolean dhcp;
+//  String ntpServerName;
+//  long Update_Time_Via_NTP_Every;
+//  long timezone;
+//  boolean daylight;
+//  String DeviceName;
+//  boolean AutoTurnOff;
+//  boolean AutoTurnOn;
+//  byte TurnOffHour;
+//  byte TurnOffMinute;
+//  byte TurnOnHour;
+//  byte TurnOnMinute;
+//  byte LED_R;
+//  byte LED_G;
+//  byte LED_B;
+//}   config;
+//
+//
+///*
+//**
+//** CONFIGURATION HANDLING
+//**
+//*/
+//
+//
+//
+//
+//
+//
+//void WriteConfig()
+//{
+//
+//  Serial.println("Writing Config");
+//  EEPROM.write(0,'C');
+//  EEPROM.write(1,'F');
+//  EEPROM.write(2,'G');
+//
+//  EEPROM.write(16,config.dhcp);
+//  EEPROM.write(17,config.daylight);
+//  
+//  EEPROMWritelong(18,config.Update_Time_Via_NTP_Every); // 4 Byte
+//
+//  EEPROMWritelong(22,config.timezone);  // 4 Byte
+//
+//
+//  EEPROM.write(26,config.LED_R);
+//  EEPROM.write(27,config.LED_G);
+//  EEPROM.write(28,config.LED_B);
+//
+//  EEPROM.write(32,config.IP[0]);
+//  EEPROM.write(33,config.IP[1]);
+//  EEPROM.write(34,config.IP[2]);
+//  EEPROM.write(35,config.IP[3]);
+//
+//  EEPROM.write(36,config.Netmask[0]);
+//  EEPROM.write(37,config.Netmask[1]);
+//  EEPROM.write(38,config.Netmask[2]);
+//  EEPROM.write(39,config.Netmask[3]);
+//
+//  EEPROM.write(40,config.Gateway[0]);
+//  EEPROM.write(41,config.Gateway[1]);
+//  EEPROM.write(42,config.Gateway[2]);
+//  EEPROM.write(43,config.Gateway[3]);
+//
+//
+//  WriteStringToEEPROM(64,config.ssid);
+//  WriteStringToEEPROM(96,config.password);
+//  WriteStringToEEPROM(128,config.ntpServerName);
+//
+//  EEPROM.write(300,config.AutoTurnOn);
+//  EEPROM.write(301,config.AutoTurnOff);
+//  EEPROM.write(302,config.TurnOnHour);
+//  EEPROM.write(303,config.TurnOnMinute);
+//  EEPROM.write(304,config.TurnOffHour);
+//  EEPROM.write(305,config.TurnOffMinute);
+//  WriteStringToEEPROM(306,config.DeviceName);
+//  
+//
+//
+//  EEPROM.commit();
+//}
+//boolean ReadConfig()
+//{
+//
+//  Serial.println("Reading Configuration");
+//  if (EEPROM.read(0) == 'C' && EEPROM.read(1) == 'F'  && EEPROM.read(2) == 'G' )
+//  {
+//    Serial.println("Configurarion Found!");
+//    config.dhcp =   EEPROM.read(16);
+//
+//    config.daylight = EEPROM.read(17);
+//
+//    config.Update_Time_Via_NTP_Every = EEPROMReadlong(18); // 4 Byte
+//
+//    config.timezone = EEPROMReadlong(22); // 4 Byte
+//
+//    config.LED_R = EEPROM.read(26);
+//    config.LED_G = EEPROM.read(27);
+//    config.LED_B = EEPROM.read(28);
+//
+//    config.IP[0] = EEPROM.read(32);
+//    config.IP[1] = EEPROM.read(33);
+//    config.IP[2] = EEPROM.read(34);
+//    config.IP[3] = EEPROM.read(35);
+//    config.Netmask[0] = EEPROM.read(36);
+//    config.Netmask[1] = EEPROM.read(37);
+//    config.Netmask[2] = EEPROM.read(38);
+//    config.Netmask[3] = EEPROM.read(39);
+//    config.Gateway[0] = EEPROM.read(40);
+//    config.Gateway[1] = EEPROM.read(41);
+//    config.Gateway[2] = EEPROM.read(42);
+//    config.Gateway[3] = EEPROM.read(43);
+//    config.ssid = ReadStringFromEEPROM(64);
+//    config.password = ReadStringFromEEPROM(96);
+//    config.ntpServerName = ReadStringFromEEPROM(128);
+//    
+//    
+//    config.AutoTurnOn = EEPROM.read(300);
+//    config.AutoTurnOff = EEPROM.read(301);
+//    config.TurnOnHour = EEPROM.read(302);
+//    config.TurnOnMinute = EEPROM.read(303);
+//    config.TurnOffHour = EEPROM.read(304);
+//    config.TurnOffMinute = EEPROM.read(305);
+//    config.DeviceName= ReadStringFromEEPROM(306);
+//    return true;
+//    
+//  }
+//  else
+//  {
+//    Serial.println("Configurarion NOT FOUND!!!!");
+//    return false;
+//  }
+//}
 

+ 210 - 210
helpers.h

@@ -1,210 +1,210 @@
-#ifndef HELPERS_H
-#define HELPERS_H
-
-
-
-static const uint8_t monthDays[]={31,28,31,30,31,30,31,31,30,31,30,31}; 
-#define LEAP_YEAR(Y) ( ((1970+Y)>0) && !((1970+Y)%4) && ( ((1970+Y)%100) || !((1970+Y)%400) ) )
-
-
-struct  strDateTime
-{
-	byte hour;
-	byte minute;
-	byte second;
-	int year;
-	byte month;
-	byte day;
-	byte wday;
-
-} ;
-
-
-
-//
-// Summertime calculates the daylight saving for a given date.
-//
-boolean summertime(int year, byte month, byte day, byte hour, byte tzHours)
-// input parameters: "normal time" for year, month, day, hour and tzHours (0=UTC, 1=MEZ)
-{
- if (month<3 || month>10) return false; // keine Sommerzeit in Jan, Feb, Nov, Dez
- if (month>3 && month<10) return true; // Sommerzeit in Apr, Mai, Jun, Jul, Aug, Sep
- if (month==3 && (hour + 24 * day)>=(1 + tzHours + 24*(31 - (5 * year /4 + 4) % 7)) || month==10 && (hour + 24 * day)<(1 + tzHours + 24*(31 - (5 * year /4 + 1) % 7)))
-   return true;
- else
-   return false;
-}
-
-//
-// Check the Values is between 0-255
-//
-boolean checkRange(String Value)
-{
-	 if (Value.toInt() < 0 || Value.toInt() > 255)
-	 {
-		 return false;
-	 }
-	 else
-	 {
-		 return true;
-	 }
-}
-
-
-void WriteStringToEEPROM(int beginaddress, String string)
-{
-	char  charBuf[string.length()+1];
-	string.toCharArray(charBuf, string.length()+1);
-	for (int t=  0; t<sizeof(charBuf);t++)
-	{
-			EEPROM.write(beginaddress + t,charBuf[t]);
-	}
-}
-String  ReadStringFromEEPROM(int beginaddress)
-{
-	byte counter=0;
-	char rChar;
-	String retString = "";
-	while (1)
-	{
-		rChar = EEPROM.read(beginaddress + counter);
-		if (rChar == 0) break;
-		if (counter > 31) break;
-		counter++;
-		retString.concat(rChar);
-
-	}
-	return retString;
-}
-void EEPROMWritelong(int address, long value)
-      {
-      byte four = (value & 0xFF);
-      byte three = ((value >> 8) & 0xFF);
-      byte two = ((value >> 16) & 0xFF);
-      byte one = ((value >> 24) & 0xFF);
-
-      //Write the 4 bytes into the eeprom memory.
-      EEPROM.write(address, four);
-      EEPROM.write(address + 1, three);
-      EEPROM.write(address + 2, two);
-      EEPROM.write(address + 3, one);
-      }
-long EEPROMReadlong(long address)
-      {
-      //Read the 4 bytes from the eeprom memory.
-      long four = EEPROM.read(address);
-      long three = EEPROM.read(address + 1);
-      long two = EEPROM.read(address + 2);
-      long one = EEPROM.read(address + 3);
-
-      //Return the recomposed long by using bitshift.
-      return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
-}
-
-void ConvertUnixTimeStamp( unsigned long TimeStamp, struct strDateTime* DateTime)
-{
-		uint8_t year;
-	uint8_t month, monthLength;
-	uint32_t time;
-	unsigned long days;
-	  time = (uint32_t)TimeStamp;
-	  DateTime->second = time % 60;
-	  time /= 60; // now it is minutes
-	  DateTime->minute = time % 60;
-	  time /= 60; // now it is hours
-	  DateTime->hour = time % 24;
-	  time /= 24; // now it is days
-	  DateTime->wday = ((time + 4) % 7) + 1;  // Sunday is day 1 
-  
-	  year = 0;  
-	days = 0;
-	while((unsigned)(days += (LEAP_YEAR(year) ? 366 : 365)) <= time) {
-		year++;
-	}
-	DateTime->year = year; // year is offset from 1970 
-  
-	  days -= LEAP_YEAR(year) ? 366 : 365;
-	  time  -= days; // now it is days in this year, starting at 0
-  
-	  days=0;
-	  month=0;
-	  monthLength=0;
-	  for (month=0; month<12; month++) {
-		if (month==1) { // february
-		  if (LEAP_YEAR(year)) {
-			monthLength=29;
-		  } else {
-			monthLength=28;
-		  }
-		} else {
-		  monthLength = monthDays[month];
-		}
-    
-		if (time >= monthLength) {
-		  time -= monthLength;
-		} else {
-			break;
-		}
-	  }
-	  DateTime->month = month + 1;  // jan is month 1  
-	  DateTime->day = time + 1;     // day of month
-	  DateTime->year += 1970;
-
-	 
-}
-
-
-	
-String GetMacAddress()
-{
-	uint8_t mac[6];
-    char macStr[18] = {0};
-	WiFi.macAddress(mac);
-    sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0],  mac[1], mac[2], mac[3], mac[4], mac[5]);
-    return  String(macStr);
-}
-
-// convert a single hex digit character to its integer value (from https://code.google.com/p/avr-netino/)
-unsigned char h2int(char c)
-{
-    if (c >= '0' && c <='9'){
-        return((unsigned char)c - '0');
-    }
-    if (c >= 'a' && c <='f'){
-        return((unsigned char)c - 'a' + 10);
-    }
-    if (c >= 'A' && c <='F'){
-        return((unsigned char)c - 'A' + 10);
-    }
-    return(0);
-}
-
-String urldecode(String input) // (based on https://code.google.com/p/avr-netino/)
-{
-	 char c;
-	 String ret = "";
-	 
-	 for(byte t=0;t<input.length();t++)
-	 {
-		 c = input[t];
-		 if (c == '+') c = ' ';
-         if (c == '%') {
-
-
-         t++;
-         c = input[t];
-         t++;
-         c = (h2int(c) << 4) | h2int(input[t]);
-		 }
-		
-		 ret.concat(c);
-	 }
-	 return ret;
-  
-}
-
-
-
-
- 
-#endif
+//#ifndef HELPERS_H
+//#define HELPERS_H
+//
+//
+//
+//static const uint8_t monthDays[]={31,28,31,30,31,30,31,31,30,31,30,31}; 
+//#define LEAP_YEAR(Y) ( ((1970+Y)>0) && !((1970+Y)%4) && ( ((1970+Y)%100) || !((1970+Y)%400) ) )
+//
+//
+//struct  strDateTime
+//{
+//	byte hour;
+//	byte minute;
+//	byte second;
+//	int year;
+//	byte month;
+//	byte day;
+//	byte wday;
+//
+//} ;
+//
+//
+//
+////
+//// Summertime calculates the daylight saving for a given date.
+////
+//boolean summertime(int year, byte month, byte day, byte hour, byte tzHours)
+//// input parameters: "normal time" for year, month, day, hour and tzHours (0=UTC, 1=MEZ)
+//{
+// if (month<3 || month>10) return false; // keine Sommerzeit in Jan, Feb, Nov, Dez
+// if (month>3 && month<10) return true; // Sommerzeit in Apr, Mai, Jun, Jul, Aug, Sep
+// if (month==3 && (hour + 24 * day)>=(1 + tzHours + 24*(31 - (5 * year /4 + 4) % 7)) || month==10 && (hour + 24 * day)<(1 + tzHours + 24*(31 - (5 * year /4 + 1) % 7)))
+//   return true;
+// else
+//   return false;
+//}
+//
+////
+//// Check the Values is between 0-255
+////
+//boolean checkRange(String Value)
+//{
+//	 if (Value.toInt() < 0 || Value.toInt() > 255)
+//	 {
+//		 return false;
+//	 }
+//	 else
+//	 {
+//		 return true;
+//	 }
+//}
+//
+//
+//void WriteStringToEEPROM(int beginaddress, String string)
+//{
+//	char  charBuf[string.length()+1];
+//	string.toCharArray(charBuf, string.length()+1);
+//	for (int t=  0; t<sizeof(charBuf);t++)
+//	{
+//			EEPROM.write(beginaddress + t,charBuf[t]);
+//	}
+//}
+//String  ReadStringFromEEPROM(int beginaddress)
+//{
+//	byte counter=0;
+//	char rChar;
+//	String retString = "";
+//	while (1)
+//	{
+//		rChar = EEPROM.read(beginaddress + counter);
+//		if (rChar == 0) break;
+//		if (counter > 31) break;
+//		counter++;
+//		retString.concat(rChar);
+//
+//	}
+//	return retString;
+//}
+//void EEPROMWritelong(int address, long value)
+//      {
+//      byte four = (value & 0xFF);
+//      byte three = ((value >> 8) & 0xFF);
+//      byte two = ((value >> 16) & 0xFF);
+//      byte one = ((value >> 24) & 0xFF);
+//
+//      //Write the 4 bytes into the eeprom memory.
+//      EEPROM.write(address, four);
+//      EEPROM.write(address + 1, three);
+//      EEPROM.write(address + 2, two);
+//      EEPROM.write(address + 3, one);
+//      }
+//long EEPROMReadlong(long address)
+//      {
+//      //Read the 4 bytes from the eeprom memory.
+//      long four = EEPROM.read(address);
+//      long three = EEPROM.read(address + 1);
+//      long two = EEPROM.read(address + 2);
+//      long one = EEPROM.read(address + 3);
+//
+//      //Return the recomposed long by using bitshift.
+//      return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
+//}
+//
+//void ConvertUnixTimeStamp( unsigned long TimeStamp, struct strDateTime* DateTime)
+//{
+//		uint8_t year;
+//	uint8_t month, monthLength;
+//	uint32_t time;
+//	unsigned long days;
+//	  time = (uint32_t)TimeStamp;
+//	  DateTime->second = time % 60;
+//	  time /= 60; // now it is minutes
+//	  DateTime->minute = time % 60;
+//	  time /= 60; // now it is hours
+//	  DateTime->hour = time % 24;
+//	  time /= 24; // now it is days
+//	  DateTime->wday = ((time + 4) % 7) + 1;  // Sunday is day 1 
+//  
+//	  year = 0;  
+//	days = 0;
+//	while((unsigned)(days += (LEAP_YEAR(year) ? 366 : 365)) <= time) {
+//		year++;
+//	}
+//	DateTime->year = year; // year is offset from 1970 
+//  
+//	  days -= LEAP_YEAR(year) ? 366 : 365;
+//	  time  -= days; // now it is days in this year, starting at 0
+//  
+//	  days=0;
+//	  month=0;
+//	  monthLength=0;
+//	  for (month=0; month<12; month++) {
+//		if (month==1) { // february
+//		  if (LEAP_YEAR(year)) {
+//			monthLength=29;
+//		  } else {
+//			monthLength=28;
+//		  }
+//		} else {
+//		  monthLength = monthDays[month];
+//		}
+//    
+//		if (time >= monthLength) {
+//		  time -= monthLength;
+//		} else {
+//			break;
+//		}
+//	  }
+//	  DateTime->month = month + 1;  // jan is month 1  
+//	  DateTime->day = time + 1;     // day of month
+//	  DateTime->year += 1970;
+//
+//	 
+//}
+//
+//
+//	
+//String GetMacAddress()
+//{
+//	uint8_t mac[6];
+//    char macStr[18] = {0};
+//	WiFi.macAddress(mac);
+//    sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0],  mac[1], mac[2], mac[3], mac[4], mac[5]);
+//    return  String(macStr);
+//}
+//
+//// convert a single hex digit character to its integer value (from https://code.google.com/p/avr-netino/)
+//unsigned char h2int(char c)
+//{
+//    if (c >= '0' && c <='9'){
+//        return((unsigned char)c - '0');
+//    }
+//    if (c >= 'a' && c <='f'){
+//        return((unsigned char)c - 'a' + 10);
+//    }
+//    if (c >= 'A' && c <='F'){
+//        return((unsigned char)c - 'A' + 10);
+//    }
+//    return(0);
+//}
+//
+//String urldecode(String input) // (based on https://code.google.com/p/avr-netino/)
+//{
+//	 char c;
+//	 String ret = "";
+//	 
+//	 for(byte t=0;t<input.length();t++)
+//	 {
+//		 c = input[t];
+//		 if (c == '+') c = ' ';
+//         if (c == '%') {
+//
+//
+//         t++;
+//         c = input[t];
+//         t++;
+//         c = (h2int(c) << 4) | h2int(input[t]);
+//		 }
+//		
+//		 ret.concat(c);
+//	 }
+//	 return ret;
+//  
+//}
+//
+//
+//
+//
+// 
+//#endif

+ 6 - 6
includes.h

@@ -19,21 +19,21 @@
 #include <ArduinoOTA.h>
 
 
-ESP8266WebServer server(80); 
+//ESP8266WebServer server(80); 
 
 WiFiUDP UKI_UDP;
 
 
 
-#include "leds.h"     //config and functions relative to leds
+//#include "leds.h"     //config and functions relative to leds
 
-#include "helpers.h"  //some helpers functions
+//#include "helpers.h"  //some helpers functions
 
-#include "eeprom.h"   //config and functions relative to config permanent storage
-#include "wifimgr.h"   //config and functions relative to wifi and access point configuration
-#include "ota.h"      //config and functions relative to ota firmware updates
+//#include "eeprom.h"   //config and functions relative to config permanent storage
 
+//#include "ota.h"      //config and functions relative to ota firmware updates
 
+#include "wifimgr.h"   //config and functions relative to wifi and access point configuration
 
 
 

+ 4 - 16
leds.h

@@ -1,12 +1,10 @@
-const int Blue_Led = 2;
+const byte Blue_Led = 2;
 bool Blue_Led_State = 1 ;
 Ticker tkBlue_Led ;
-int tkBlue_Led_Counter;
 
-const int Red_Led = 0;
+const byte Red_Led = 0;
 bool Red_Led_State = 0;
 Ticker tkRed_Led ;
-int tkRed_Led_Counter;
 
 /*Faire des fonctions simples à appeler depuis autres functions callbacks, les fonctions locales attachent et detachent les tkLeds
 
@@ -14,16 +12,6 @@ fonctions extérieures appellent blueLedState (0 off, 1 on, -1 blink; time_ms)
 blueStateLed attache/détache les tickers sur fonction invert
 */
 
-//void LedState ( int Led, int state) { // -1 inverts, 0 off, 1 on
-//  if (Led==Red_Led) {
-//    if (state == -1) { Red_Led_State = !Red_Led_State;}
-//    else {Red_Led_State = state ;}
-//  }
-//  if (Blue_Led)
-//  digitalWrite(Led, !Red_Led_State) ; // inverted, 1 is off and 0 is on
-//  Serial.println("Red Led "+(String)Red_Led_State);
-//}
-
 void blinkLed(int Led) {
   if (Led==0) {Red_Led_State = !Red_Led_State; digitalWrite(Red_Led, !Red_Led_State) ;}
   if (Led==1) {Blue_Led_State = !Blue_Led_State; digitalWrite(Blue_Led, !Blue_Led_State);}
@@ -39,7 +27,7 @@ void redLedState ( int state, int time_ms) { // -1 inverts, 0 off, 1 on
     digitalWrite(Red_Led, !Red_Led_State) ; // inverted, 1 is off and 0 is on
     }
   
-  Serial.println("Red Led "+(String)Red_Led_State);
+  //Serial.println("Red Led "+(String)Red_Led_State);
 }
 
 void blueLedState ( int state, int time_ms) { // -1 inverts, 0 off, 1 on
@@ -52,7 +40,7 @@ void blueLedState ( int state, int time_ms) { // -1 inverts, 0 off, 1 on
     digitalWrite(Blue_Led, !Blue_Led_State) ;
     }
    // inverted, 1 is off and 0 is on
-  Serial.println("Blue Led "+(String)Blue_Led_State);
+  //Serial.println("Blue Led "+(String)Blue_Led_State);
 }
 
 

+ 4 - 0
ota.h

@@ -7,6 +7,10 @@ void loopOTA(){
     //Serial.println("OTA check");
 }
 
+void detachOTA(){
+  tkOTA.detach();
+}
+
 
 
 void setupOTA(){