Skip to content

Commit

Permalink
0.8.144
Browse files Browse the repository at this point in the history
fix ESP8266 compile
  • Loading branch information
lumapu committed Sep 14, 2024
1 parent 9bc8385 commit 97d9786
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/network/AhoyNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AhoyNetwork {
mOnNetworkCB = onNetworkCB;
mOnTimeCB = onTimeCB;

mNtpIp = IPAddress(0, 0, 0, 0);
mNtpIp = IPADDR_NONE;

if('\0' == mConfig->sys.deviceName[0])
snprintf(mConfig->sys.deviceName, DEVNAME_LEN, "%s", DEF_DEVICE_NAME);
Expand Down Expand Up @@ -60,12 +60,16 @@ class AhoyNetwork {
static void dnsCallback(const char *name, const ip_addr_t *ipaddr, void *pClass) {
AhoyNetwork *obj = static_cast<AhoyNetwork*>(pClass);
if (ipaddr) {
#if defined(ESP32)
obj->mNtpIp = ipaddr->u_addr.ip4.addr;
#else
obj->mNtpIp = ipaddr->addr;
#endif
}
}

void updateNtpTime() {
if(mNtpIp != 0) {
if(mNtpIp != IPADDR_NONE) {
startNtpUpdate();
return;
}
Expand All @@ -77,7 +81,11 @@ class AhoyNetwork {
err_t err = dns_gethostbyname(mConfig->ntp.addr, &ipaddr, dnsCallback, this);

if (err == ERR_OK) {
#if defined(ESP32)
mNtpIp = ipaddr.u_addr.ip4.addr;
#else
mNtpIp = ipaddr.addr;
#endif
startNtpUpdate();
}
}
Expand All @@ -96,7 +104,7 @@ class AhoyNetwork {
sendNTPpacket();

// reset to start with DNS lookup next time again
mNtpIp = IPAddress(0, 0, 0, 0);
mNtpIp = IPADDR_NONE;
}

public:
Expand Down

0 comments on commit 97d9786

Please sign in to comment.