mirror of
https://github.com/lumapu/ahoy.git
synced 2025-08-06 09:58:23 +02:00
0.8.144
fix ESP8266 compile
This commit is contained in:
parent
9bc8385af1
commit
97d978632a
1 changed files with 11 additions and 3 deletions
|
@ -26,7 +26,7 @@ class AhoyNetwork {
|
||||||
mOnNetworkCB = onNetworkCB;
|
mOnNetworkCB = onNetworkCB;
|
||||||
mOnTimeCB = onTimeCB;
|
mOnTimeCB = onTimeCB;
|
||||||
|
|
||||||
mNtpIp = IPAddress(0, 0, 0, 0);
|
mNtpIp = IPADDR_NONE;
|
||||||
|
|
||||||
if('\0' == mConfig->sys.deviceName[0])
|
if('\0' == mConfig->sys.deviceName[0])
|
||||||
snprintf(mConfig->sys.deviceName, DEVNAME_LEN, "%s", DEF_DEVICE_NAME);
|
snprintf(mConfig->sys.deviceName, DEVNAME_LEN, "%s", DEF_DEVICE_NAME);
|
||||||
|
@ -60,12 +60,16 @@ class AhoyNetwork {
|
||||||
static void dnsCallback(const char *name, const ip_addr_t *ipaddr, void *pClass) {
|
static void dnsCallback(const char *name, const ip_addr_t *ipaddr, void *pClass) {
|
||||||
AhoyNetwork *obj = static_cast<AhoyNetwork*>(pClass);
|
AhoyNetwork *obj = static_cast<AhoyNetwork*>(pClass);
|
||||||
if (ipaddr) {
|
if (ipaddr) {
|
||||||
|
#if defined(ESP32)
|
||||||
obj->mNtpIp = ipaddr->u_addr.ip4.addr;
|
obj->mNtpIp = ipaddr->u_addr.ip4.addr;
|
||||||
|
#else
|
||||||
|
obj->mNtpIp = ipaddr->addr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateNtpTime() {
|
void updateNtpTime() {
|
||||||
if(mNtpIp != 0) {
|
if(mNtpIp != IPADDR_NONE) {
|
||||||
startNtpUpdate();
|
startNtpUpdate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +81,11 @@ class AhoyNetwork {
|
||||||
err_t err = dns_gethostbyname(mConfig->ntp.addr, &ipaddr, dnsCallback, this);
|
err_t err = dns_gethostbyname(mConfig->ntp.addr, &ipaddr, dnsCallback, this);
|
||||||
|
|
||||||
if (err == ERR_OK) {
|
if (err == ERR_OK) {
|
||||||
|
#if defined(ESP32)
|
||||||
mNtpIp = ipaddr.u_addr.ip4.addr;
|
mNtpIp = ipaddr.u_addr.ip4.addr;
|
||||||
|
#else
|
||||||
|
mNtpIp = ipaddr.addr;
|
||||||
|
#endif
|
||||||
startNtpUpdate();
|
startNtpUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +104,7 @@ class AhoyNetwork {
|
||||||
sendNTPpacket();
|
sendNTPpacket();
|
||||||
|
|
||||||
// reset to start with DNS lookup next time again
|
// reset to start with DNS lookup next time again
|
||||||
mNtpIp = IPAddress(0, 0, 0, 0);
|
mNtpIp = IPADDR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue