mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-02 18:51:38 +02:00
Merge branch 'development03' of https://github.com/geronet1/ahoy into geronet1-development03
This commit is contained in:
commit
54f53aa725
2 changed files with 19 additions and 11 deletions
29
src/app.cpp
29
src/app.cpp
|
@ -170,7 +170,6 @@ void app::onNetwork(bool gotIp) {
|
||||||
mMqttReconnect = true;
|
mMqttReconnect = true;
|
||||||
mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers!
|
mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers!
|
||||||
once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2");
|
once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2");
|
||||||
//tickNtpUpdate();
|
|
||||||
#if !defined(ETHERNET)
|
#if !defined(ETHERNET)
|
||||||
if (WIFI_AP == WiFi.getMode()) {
|
if (WIFI_AP == WiFi.getMode()) {
|
||||||
mMqttEnabled = false;
|
mMqttEnabled = false;
|
||||||
|
@ -204,12 +203,7 @@ void app::regularTickers(void) {
|
||||||
|
|
||||||
#if defined(ETHERNET)
|
#if defined(ETHERNET)
|
||||||
void app::onNtpUpdate(bool gotTime) {
|
void app::onNtpUpdate(bool gotTime) {
|
||||||
uint32_t nxtTrig = 5; // default: check again in 5 sec
|
mNtpReceived = true;
|
||||||
if (gotTime || mTimestamp != 0) {
|
|
||||||
this->updateNtp();
|
|
||||||
nxtTrig = gotTime ? 43200 : 60; // depending on NTP update success check again in 12 h or in 1 min
|
|
||||||
}
|
|
||||||
once(std::bind(&app::tickNtpUpdate, this), nxtTrig, "ntp");
|
|
||||||
}
|
}
|
||||||
#endif /* defined(ETHERNET) */
|
#endif /* defined(ETHERNET) */
|
||||||
|
|
||||||
|
@ -253,13 +247,22 @@ void app::updateNtp(void) {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::tickNtpUpdate(void) {
|
void app::tickNtpUpdate(void) {
|
||||||
uint32_t nxtTrig = 5; // default: check again in 5 sec
|
uint32_t nxtTrig = 5; // default: check again in 5 sec
|
||||||
|
bool isOK = false;
|
||||||
|
|
||||||
#if defined(ETHERNET)
|
#if defined(ETHERNET)
|
||||||
bool isOK = (mTimestamp != 0);
|
if (!mNtpReceived)
|
||||||
mEth.updateNtpTime();
|
{
|
||||||
|
mEth.updateNtpTime();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mNtpReceived = false;
|
||||||
|
isOK = true;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
bool isOK = mWifi.getNtpTime();
|
isOK = mWifi.getNtpTime();
|
||||||
#endif
|
#endif
|
||||||
if (isOK || mTimestamp != 0) {
|
if (isOK) {
|
||||||
this->updateNtp();
|
this->updateNtp();
|
||||||
|
|
||||||
nxtTrig = isOK ? (mConfig->ntp.interval * 60) : 60; // depending on NTP update success check again in 12h (depends on setting) or in 1 min
|
nxtTrig = isOK ? (mConfig->ntp.interval * 60) : 60; // depending on NTP update success check again in 12h (depends on setting) or in 1 min
|
||||||
|
@ -563,6 +566,10 @@ void app::resetSystem(void) {
|
||||||
mSaveReboot = false;
|
mSaveReboot = false;
|
||||||
|
|
||||||
mNetworkConnected = false;
|
mNetworkConnected = false;
|
||||||
|
|
||||||
|
#if defined(ETHERNET)
|
||||||
|
mNtpReceived = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -351,6 +351,7 @@ class app : public IApp, public ah::Scheduler {
|
||||||
void tickNtpUpdate(void);
|
void tickNtpUpdate(void);
|
||||||
#if defined(ETHERNET)
|
#if defined(ETHERNET)
|
||||||
void onNtpUpdate(bool gotTime);
|
void onNtpUpdate(bool gotTime);
|
||||||
|
bool mNtpReceived;
|
||||||
#endif /* defined(ETHERNET) */
|
#endif /* defined(ETHERNET) */
|
||||||
void updateNtp(void);
|
void updateNtp(void);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue