mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-24 06:16:11 +02:00
improved scheduler #483
refactored NTP generate bin.gz only for ESP8285 fix calcSunrise calculation
This commit is contained in:
parent
a9e4429f9f
commit
183b9b35f6
6 changed files with 43 additions and 38 deletions
|
@ -115,9 +115,11 @@ void ahoywifi::setupStation(void) {
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void ahoywifi::getNtpTime(void) {
|
||||
bool ahoywifi::getNtpTime(void) {
|
||||
//DPRINTLN(DBG_VERBOSE, F("wifi::getNtpTime"));
|
||||
time_t date = 0;
|
||||
if(!mConnected)
|
||||
return false;
|
||||
|
||||
IPAddress timeServer;
|
||||
uint8_t buf[NTP_PACKET_SIZE];
|
||||
uint8_t retry = 0;
|
||||
|
@ -138,16 +140,16 @@ void ahoywifi::getNtpTime(void) {
|
|||
secsSince1900 |= (buf[42] << 8);
|
||||
secsSince1900 |= (buf[43] );
|
||||
|
||||
date = secsSince1900 - 2208988800UL; // UTC time
|
||||
break;
|
||||
*mUtcTimestamp = secsSince1900 - 2208988800UL; // UTC time
|
||||
DPRINTLN(DBG_INFO, F("[NTP]: ") + ah::getDateTimeStr(*mUtcTimestamp) + F(" UTC"));
|
||||
return true;
|
||||
} else
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
*mUtcTimestamp = date;
|
||||
|
||||
DPRINTLN(DBG_INFO, "[NTP]: " + ah::getDateTimeStr(*mUtcTimestamp) + " UTC");
|
||||
DPRINTLN(DBG_INFO, F("[NTP]: getNtpTime failed"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue