From 497c0b7a477ceb84ad80050f58c2634c9fac7ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 17:38:53 +0200 Subject: [PATCH 1/5] don't rush failed time updates --- src/mesh/eth/ethClient.cpp | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index 1bd8ea96e..935793b36 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -4,6 +4,7 @@ #include "concurrency/Periodic.h" #include #include +#include #include "target_specific.h" #include "mesh/eth/ethServerAPI.h" #include "mqtt/MQTT.h" @@ -13,15 +14,10 @@ // NTP EthernetUDP ntpUDP; - NTPClient timeClient(ntpUDP, config.network.ntp_server); - uint32_t ntp_renew = 0; #endif -// Stores our hostname -char ourHost[16]; - bool ethStartupComplete = 0; using namespace concurrency; @@ -36,22 +32,11 @@ static int32_t reconnectETH() // Start web server DEBUG_MSG("... Starting network services\n"); - // // start mdns - // 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 +#ifndef DISABLE_NTP DEBUG_MSG("Starting NTP time client\n"); timeClient.begin(); timeClient.setUpdateInterval(60 * 60); // Update once an hour - #endif - +#endif // initWebServer(); initApiServer(); @@ -66,7 +51,8 @@ static int32_t reconnectETH() #ifndef DISABLE_NTP 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()) { DEBUG_MSG("NTP Request Success - Setting RTCQualityNTP if needed\n"); @@ -76,10 +62,11 @@ static int32_t reconnectETH() perhapsSetRTC(RTCQualityNTP, &tv); - ntp_renew = millis() + 43200 * 1000; // every 12 hours + ntp_renew = millis() + 43200 * 1000; // success, refresh every 12 hours } else { DEBUG_MSG("NTP Update failed\n"); + ntp_renew = millis() + 300 * 1000; // failure, retry every 5 minutes } } #endif @@ -91,8 +78,8 @@ static int32_t reconnectETH() bool initEthernet() { - // config.network.eth_enabled = true; - // config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP; + config.network.eth_enabled = true; + config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP; if (config.network.eth_enabled) { @@ -112,6 +99,7 @@ bool initEthernet() // createSSLCert(); 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) { DEBUG_MSG("starting Ethernet DHCP\n"); From a1256818d96a560f316e2a0c700b2766dd624536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 18:25:31 +0200 Subject: [PATCH 2/5] update library location --- platformio.ini | 2 +- variants/rak4631/platformio.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 527bce0d0..034cff8bc 100644 --- a/platformio.ini +++ b/platformio.ini @@ -68,7 +68,7 @@ lib_deps = ${env.lib_deps} ; Portduino is using meshtastic fork for now jgromes/RadioLib@5.4.1 - https://github.com/caveman99/SparkFun_ATECCX08a_Arduino_Library.git#008e7f9d40bad66b2f7a0074aaac05b7c424339d + https://github.com/meshtastic/SparkFun_ATECCX08a_Arduino_Library.git#52b5282639d08a8cbd4b748363089eed6102dc76 build_flags = ${env.build_flags} -Os -DRADIOLIB_SPI_PARANOID=0 diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index fccffb51f..3521a43ff 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -8,7 +8,7 @@ lib_deps = ${nrf52840_base.lib_deps} ${networking_base.lib_deps} melopero/Melopero RV3028@^1.1.0 - https://github.com/caveman99/RAK13800-W5100S.git#main + https://github.com/meshtastic/RAK13800-W5100S.git#b680706eb8006cd62c919ac74c8af1950eb82c81 debug_tool = jlink ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) ;upload_protocol = jlink \ No newline at end of file From d5c407c098607fae89fd5ff30f42271876e7e8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 18:36:41 +0200 Subject: [PATCH 3/5] remove accidental commit --- src/mesh/eth/ethClient.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index 935793b36..a082925dc 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -4,7 +4,6 @@ #include "concurrency/Periodic.h" #include #include -#include #include "target_specific.h" #include "mesh/eth/ethServerAPI.h" #include "mqtt/MQTT.h" From 74177294820d5693734f4e2bd52ee9bef12dfc04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 18:37:20 +0200 Subject: [PATCH 4/5] debug removed --- src/mesh/eth/ethClient.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index a082925dc..c055206b1 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -76,10 +76,6 @@ static int32_t reconnectETH() // Startup Ethernet bool initEthernet() { - - config.network.eth_enabled = true; - config.network.eth_mode = Config_NetworkConfig_EthMode_DHCP; - if (config.network.eth_enabled) { #ifdef PIN_ETHERNET_RESET From d5a9e3114abf5aa4f416d8d7883da1b8ba5ee9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 26 Oct 2022 18:37:51 +0200 Subject: [PATCH 5/5] Update ethClient.cpp --- src/mesh/eth/ethClient.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index c055206b1..cbfc1c554 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -94,7 +94,6 @@ bool initEthernet() // createSSLCert(); 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) { DEBUG_MSG("starting Ethernet DHCP\n");