mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-03 04:23:52 +00:00
don't rush failed time updates
This commit is contained in:
parent
3de0a3adfc
commit
497c0b7a47
@ -4,6 +4,7 @@
|
|||||||
#include "concurrency/Periodic.h"
|
#include "concurrency/Periodic.h"
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <RAK13800_W5100S.h>
|
#include <RAK13800_W5100S.h>
|
||||||
|
#include <ArduinoMDNS.h>
|
||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
#include "mesh/eth/ethServerAPI.h"
|
#include "mesh/eth/ethServerAPI.h"
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
@ -13,15 +14,10 @@
|
|||||||
|
|
||||||
// NTP
|
// NTP
|
||||||
EthernetUDP ntpUDP;
|
EthernetUDP ntpUDP;
|
||||||
|
|
||||||
NTPClient timeClient(ntpUDP, config.network.ntp_server);
|
NTPClient timeClient(ntpUDP, config.network.ntp_server);
|
||||||
|
|
||||||
uint32_t ntp_renew = 0;
|
uint32_t ntp_renew = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Stores our hostname
|
|
||||||
char ourHost[16];
|
|
||||||
|
|
||||||
bool ethStartupComplete = 0;
|
bool ethStartupComplete = 0;
|
||||||
|
|
||||||
using namespace concurrency;
|
using namespace concurrency;
|
||||||
@ -36,22 +32,11 @@ static int32_t reconnectETH()
|
|||||||
// Start web server
|
// Start web server
|
||||||
DEBUG_MSG("... Starting network services\n");
|
DEBUG_MSG("... Starting network services\n");
|
||||||
|
|
||||||
// // start mdns
|
#ifndef DISABLE_NTP
|
||||||
// if (!MDNS.begin("Meshtastic")) {
|
|
||||||
// DEBUG_MSG("Error setting up MDNS responder!\n");
|
|
||||||
// } else {
|
|
||||||
// DEBUG_MSG("mDNS responder started\n");
|
|
||||||
// DEBUG_MSG("mDNS Host: Meshtastic.local\n");
|
|
||||||
// MDNS.addService("http", "tcp", 80);
|
|
||||||
// MDNS.addService("https", "tcp", 443);
|
|
||||||
// }
|
|
||||||
|
|
||||||
#ifndef DISABLE_NTP
|
|
||||||
DEBUG_MSG("Starting NTP time client\n");
|
DEBUG_MSG("Starting NTP time client\n");
|
||||||
timeClient.begin();
|
timeClient.begin();
|
||||||
timeClient.setUpdateInterval(60 * 60); // Update once an hour
|
timeClient.setUpdateInterval(60 * 60); // Update once an hour
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// initWebServer();
|
// initWebServer();
|
||||||
initApiServer();
|
initApiServer();
|
||||||
|
|
||||||
@ -66,7 +51,8 @@ static int32_t reconnectETH()
|
|||||||
|
|
||||||
#ifndef DISABLE_NTP
|
#ifndef DISABLE_NTP
|
||||||
if (isEthernetAvailable() && (ntp_renew < millis())) {
|
if (isEthernetAvailable() && (ntp_renew < millis())) {
|
||||||
DEBUG_MSG("Updating NTP time\n");
|
|
||||||
|
DEBUG_MSG("Updating NTP time from %s\n", config.network.ntp_server);
|
||||||
if (timeClient.update()) {
|
if (timeClient.update()) {
|
||||||
DEBUG_MSG("NTP Request Success - Setting RTCQualityNTP if needed\n");
|
DEBUG_MSG("NTP Request Success - Setting RTCQualityNTP if needed\n");
|
||||||
|
|
||||||
@ -76,10 +62,11 @@ static int32_t reconnectETH()
|
|||||||
|
|
||||||
perhapsSetRTC(RTCQualityNTP, &tv);
|
perhapsSetRTC(RTCQualityNTP, &tv);
|
||||||
|
|
||||||
ntp_renew = millis() + 43200 * 1000; // every 12 hours
|
ntp_renew = millis() + 43200 * 1000; // success, refresh every 12 hours
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("NTP Update failed\n");
|
DEBUG_MSG("NTP Update failed\n");
|
||||||
|
ntp_renew = millis() + 300 * 1000; // failure, retry every 5 minutes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -91,8 +78,8 @@ static int32_t reconnectETH()
|
|||||||
bool initEthernet()
|
bool initEthernet()
|
||||||
{
|
{
|
||||||
|
|
||||||
// config.network.eth_enabled = true;
|
config.network.eth_enabled = true;
|
||||||
// config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP;
|
config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP;
|
||||||
|
|
||||||
if (config.network.eth_enabled) {
|
if (config.network.eth_enabled) {
|
||||||
|
|
||||||
@ -112,6 +99,7 @@ bool initEthernet()
|
|||||||
// createSSLCert();
|
// createSSLCert();
|
||||||
|
|
||||||
getMacAddr(mac); // FIXME use the BLE MAC for now...
|
getMacAddr(mac); // FIXME use the BLE MAC for now...
|
||||||
|
sprintf(ourHost, "Meshtastic-%02x%02x", mac[4], mac[5]);
|
||||||
|
|
||||||
if (config.network.eth_mode == Config_NetworkConfig_EthMode_DHCP) {
|
if (config.network.eth_mode == Config_NetworkConfig_EthMode_DHCP) {
|
||||||
DEBUG_MSG("starting Ethernet DHCP\n");
|
DEBUG_MSG("starting Ethernet DHCP\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user