|  | @ -3,7 +3,11 @@ | 
			
		
	
		
		
			
				
					|  |  | // Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
 |  |  | // Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
 | 
			
		
	
		
		
			
				
					|  |  | //-----------------------------------------------------------------------------
 |  |  | //-----------------------------------------------------------------------------
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  | #include "wifi.h" |  |  | #if defined(ESP32) && defined(F) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |   #undef F | 
			
		
	
		
		
			
				
					|  |  |  |  |  |   #define F(sl) (sl) | 
			
		
	
		
		
			
				
					|  |  |  |  |  | #endif | 
			
		
	
		
		
			
				
					|  |  |  |  |  | #include "ahoywifi.h" | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | // NTP CONFIG
 |  |  | // NTP CONFIG
 | 
			
		
	
	
		
		
			
				
					|  | @ -12,7 +16,7 @@ | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | //-----------------------------------------------------------------------------
 |  |  | //-----------------------------------------------------------------------------
 | 
			
		
	
		
		
			
				
					
					|  |  | wifi::wifi(app *main, sysConfig_t *sysCfg, config_t *config) { |  |  | ahoywifi::ahoywifi(app *main, sysConfig_t *sysCfg, config_t *config) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     mMain    = main; |  |  |     mMain    = main; | 
			
		
	
		
		
			
				
					|  |  |     mSysCfg  = sysCfg; |  |  |     mSysCfg  = sysCfg; | 
			
		
	
		
		
			
				
					|  |  |     mConfig  = config; |  |  |     mConfig  = config; | 
			
		
	
	
		
		
			
				
					|  | @ -29,7 +33,7 @@ wifi::wifi(app *main, sysConfig_t *sysCfg, config_t *config) { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | //-----------------------------------------------------------------------------
 |  |  | //-----------------------------------------------------------------------------
 | 
			
		
	
		
		
			
				
					
					|  |  | void wifi::setup(uint32_t timeout, bool settingValid) { |  |  | void ahoywifi::setup(uint32_t timeout, bool settingValid) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     mWifiStationTimeout = timeout; |  |  |     mWifiStationTimeout = timeout; | 
			
		
	
		
		
			
				
					|  |  |     #ifndef AP_ONLY |  |  |     #ifndef AP_ONLY | 
			
		
	
		
		
			
				
					|  |  |         if(false == mApActive) |  |  |         if(false == mApActive) | 
			
		
	
	
		
		
			
				
					|  | @ -58,7 +62,7 @@ void wifi::setup(uint32_t timeout, bool settingValid) { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | //-----------------------------------------------------------------------------
 |  |  | //-----------------------------------------------------------------------------
 | 
			
		
	
		
		
			
				
					
					|  |  | bool wifi::loop(void) { |  |  | bool ahoywifi::loop(void) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     if(mApActive) { |  |  |     if(mApActive) { | 
			
		
	
		
		
			
				
					|  |  |         mDns->processNextRequest(); |  |  |         mDns->processNextRequest(); | 
			
		
	
		
		
			
				
					|  |  | #ifndef AP_ONLY |  |  | #ifndef AP_ONLY | 
			
		
	
	
		
		
			
				
					|  | @ -98,7 +102,7 @@ bool wifi::loop(void) { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | //-----------------------------------------------------------------------------
 |  |  | //-----------------------------------------------------------------------------
 | 
			
		
	
		
		
			
				
					
					|  |  | void wifi::setupAp(const char *ssid, const char *pwd) { |  |  | void ahoywifi::setupAp(const char *ssid, const char *pwd) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     DPRINTLN(DBG_VERBOSE, F("app::setupAp")); |  |  |     DPRINTLN(DBG_VERBOSE, F("app::setupAp")); | 
			
		
	
		
		
			
				
					|  |  |     IPAddress apIp(192, 168, 1, 1); |  |  |     IPAddress apIp(192, 168, 1, 1); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -118,7 +122,7 @@ void wifi::setupAp(const char *ssid, const char *pwd) { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | //-----------------------------------------------------------------------------
 |  |  | //-----------------------------------------------------------------------------
 | 
			
		
	
		
		
			
				
					
					|  |  | bool wifi::setupStation(uint32_t timeout) { |  |  | bool ahoywifi::setupStation(uint32_t timeout) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     DPRINTLN(DBG_VERBOSE, F("app::setupStation")); |  |  |     DPRINTLN(DBG_VERBOSE, F("app::setupStation")); | 
			
		
	
		
		
			
				
					|  |  |     int32_t cnt; |  |  |     int32_t cnt; | 
			
		
	
		
		
			
				
					|  |  |     bool startAp = false; |  |  |     bool startAp = false; | 
			
		
	
	
		
		
			
				
					|  | @ -166,12 +170,12 @@ bool wifi::setupStation(uint32_t timeout) { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | //-----------------------------------------------------------------------------
 |  |  | //-----------------------------------------------------------------------------
 | 
			
		
	
		
		
			
				
					
					|  |  | bool wifi::getApActive(void) { |  |  | bool ahoywifi::getApActive(void) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     return mApActive; |  |  |     return mApActive; | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | //-----------------------------------------------------------------------------
 |  |  | //-----------------------------------------------------------------------------
 | 
			
		
	
		
		
			
				
					
					|  |  | time_t wifi::getNtpTime(void) { |  |  | time_t ahoywifi::getNtpTime(void) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     //DPRINTLN(DBG_VERBOSE, F("wifi::getNtpTime"));
 |  |  |     //DPRINTLN(DBG_VERBOSE, F("wifi::getNtpTime"));
 | 
			
		
	
		
		
			
				
					|  |  |     time_t date = 0; |  |  |     time_t date = 0; | 
			
		
	
		
		
			
				
					|  |  |     IPAddress timeServer; |  |  |     IPAddress timeServer; | 
			
		
	
	
		
		
			
				
					|  | @ -209,7 +213,7 @@ time_t wifi::getNtpTime(void) { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | //-----------------------------------------------------------------------------
 |  |  | //-----------------------------------------------------------------------------
 | 
			
		
	
		
		
			
				
					
					|  |  | void wifi::sendNTPpacket(IPAddress& address) { |  |  | void ahoywifi::sendNTPpacket(IPAddress& address) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     //DPRINTLN(DBG_VERBOSE, F("wifi::sendNTPpacket"));
 |  |  |     //DPRINTLN(DBG_VERBOSE, F("wifi::sendNTPpacket"));
 | 
			
		
	
		
		
			
				
					|  |  |     uint8_t buf[NTP_PACKET_SIZE] = {0}; |  |  |     uint8_t buf[NTP_PACKET_SIZE] = {0}; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -232,7 +236,7 @@ void wifi::sendNTPpacket(IPAddress& address) { | 
			
		
	
		
		
			
				
					|  |  | //-----------------------------------------------------------------------------
 |  |  | //-----------------------------------------------------------------------------
 | 
			
		
	
		
		
			
				
					|  |  | // calculates the daylight saving time for middle Europe. Input: Unixtime in UTC
 |  |  | // calculates the daylight saving time for middle Europe. Input: Unixtime in UTC
 | 
			
		
	
		
		
			
				
					|  |  | // from: https://forum.arduino.cc/index.php?topic=172044.msg1278536#msg1278536
 |  |  | // from: https://forum.arduino.cc/index.php?topic=172044.msg1278536#msg1278536
 | 
			
		
	
		
		
			
				
					
					|  |  | time_t wifi::offsetDayLightSaving (uint32_t local_t) { |  |  | time_t ahoywifi::offsetDayLightSaving (uint32_t local_t) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     //DPRINTLN(DBG_VERBOSE, F("wifi::offsetDayLightSaving"));
 |  |  |     //DPRINTLN(DBG_VERBOSE, F("wifi::offsetDayLightSaving"));
 | 
			
		
	
		
		
			
				
					|  |  |     int m = month (local_t); |  |  |     int m = month (local_t); | 
			
		
	
		
		
			
				
					|  |  |     if(m < 3 || m > 10) return 0; // no DSL in Jan, Feb, Nov, Dez
 |  |  |     if(m < 3 || m > 10) return 0; // no DSL in Jan, Feb, Nov, Dez
 |