Selaa lähdekoodia

* refactor: rtc_clock now defined by variants/*/target modules

Scott Powell 1 vuosi sitten
vanhempi
sitoutus
c0cb57be5c

+ 1 - 1
examples/companion_radio/main.cpp

@@ -1422,7 +1422,7 @@ public:
 
 StdRNG fast_rng;
 SimpleMeshTables tables;
-MyMesh the_mesh(radio_driver, fast_rng, *new VolatileRTCClock(), tables);
+MyMesh the_mesh(radio_driver, fast_rng, *new VolatileRTCClock(), tables); // TODO: test with 'rtc_clock' in target.cpp
 
 void halt() {
   while (1) ;

+ 0 - 12
examples/simple_repeater/main.cpp

@@ -11,7 +11,6 @@
 #include <helpers/StaticPoolPacketManager.h>
 #include <helpers/SimpleMeshTables.h>
 #include <helpers/IdentityStore.h>
-#include <helpers/AutoDiscoverRTCClock.h>
 #include <helpers/AdvertDataHelpers.h>
 #include <helpers/TxtDataHelpers.h>
 #include <helpers/CommonCLI.h>
@@ -600,13 +599,6 @@ public:
 StdRNG fast_rng;
 SimpleMeshTables tables;
 
-#ifdef ESP32
-ESP32RTCClock fallback_clock;
-#else
-VolatileRTCClock fallback_clock;
-#endif
-AutoDiscoverRTCClock rtc_clock(fallback_clock);
-
 MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables);
 
 void halt() {
@@ -620,10 +612,6 @@ void setup() {
   delay(1000);
 
   board.begin();
-#ifdef ESP32
-  fallback_clock.begin();
-#endif
-  rtc_clock.begin(Wire);
 
   if (!radio_init()) { halt(); }
 

+ 0 - 13
examples/simple_room_server/main.cpp

@@ -11,7 +11,6 @@
 #include <helpers/StaticPoolPacketManager.h>
 #include <helpers/SimpleMeshTables.h>
 #include <helpers/IdentityStore.h>
-#include <helpers/AutoDiscoverRTCClock.h>
 #include <helpers/AdvertDataHelpers.h>
 #include <helpers/TxtDataHelpers.h>
 #include <helpers/CommonCLI.h>
@@ -823,14 +822,6 @@ public:
 
 StdRNG fast_rng;
 SimpleMeshTables tables;
-
-#ifdef ESP32
-ESP32RTCClock fallback_clock;
-#else
-VolatileRTCClock fallback_clock;
-#endif
-AutoDiscoverRTCClock rtc_clock(fallback_clock);
-
 MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables);
 
 void halt() {
@@ -844,10 +835,6 @@ void setup() {
   delay(1000);
 
   board.begin();
-#ifdef ESP32
-  fallback_clock.begin();
-#endif
-  rtc_clock.begin(Wire);
 
   if (!radio_init()) { halt(); }
 

+ 1 - 1
examples/simple_secure_chat/main.cpp

@@ -523,7 +523,7 @@ public:
 
 StdRNG fast_rng;
 SimpleMeshTables tables;
-MyMesh the_mesh(radio_driver, fast_rng, *new VolatileRTCClock(), tables);
+MyMesh the_mesh(radio_driver, fast_rng, *new VolatileRTCClock(), tables); // TODO: test with 'rtc_clock' in target.cpp
 
 void halt() {
   while (1) ;

+ 4 - 0
variants/generic_espnow/target.cpp

@@ -6,7 +6,11 @@ ESP32Board board;
 
 ESPNOWRadio radio_driver;
 
+ESP32RTCClock rtc_clock;
+
 bool radio_init() {
+  rtc_clock.begin();
+
   // NOTE: radio_driver.begin() is called by Dispatcher::begin(), so not needed here
   return true;  // success
 }

+ 1 - 0
variants/generic_espnow/target.h

@@ -5,6 +5,7 @@
 
 extern ESP32Board board;
 extern ESPNOWRadio radio_driver;
+extern ESP32RTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/heltec_v2/target.cpp

@@ -12,11 +12,17 @@ HeltecV2Board board;
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+ESP32RTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  fallback_clock.begin();
+  rtc_clock.begin(Wire);
+  
 #if defined(P_LORA_SCLK)
   spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
 #endif

+ 2 - 0
variants/heltec_v2/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/HeltecV2Board.h>
 #include <helpers/CustomSX1276Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern HeltecV2Board board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/heltec_v3/target.cpp

@@ -12,11 +12,17 @@ HeltecV3Board board;
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+ESP32RTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  fallback_clock.begin();
+  rtc_clock.begin(Wire);
+  
 #ifdef SX126X_DIO3_TCXO_VOLTAGE
   float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
 #else

+ 2 - 0
variants/heltec_v3/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/HeltecV3Board.h>
 #include <helpers/CustomSX1262Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern HeltecV3Board board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/lilygo_t3s3/target.cpp

@@ -12,11 +12,17 @@ ESP32Board board;
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+ESP32RTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  fallback_clock.begin();
+  rtc_clock.begin(Wire);
+  
 #ifdef SX126X_DIO3_TCXO_VOLTAGE
   float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
 #else

+ 2 - 0
variants/lilygo_t3s3/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/ESP32Board.h>
 #include <helpers/CustomSX1262Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern ESP32Board board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/lilygo_tbeam/target.cpp

@@ -12,11 +12,17 @@ TBeamBoard board;
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+ESP32RTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  fallback_clock.begin();
+  rtc_clock.begin(Wire);
+  
 #if defined(P_LORA_SCLK)
   spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
 #endif

+ 2 - 0
variants/lilygo_tbeam/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/TBeamBoard.h>
 #include <helpers/CustomSX1276Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern TBeamBoard board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/lilygo_tlora_v2_1/target.cpp

@@ -8,11 +8,17 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DI
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+ESP32RTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  fallback_clock.begin();
+  rtc_clock.begin(Wire);
+  
   spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
   int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8);
   if (status != RADIOLIB_ERR_NONE) {

+ 2 - 0
variants/lilygo_tlora_v2_1/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/LilyGoTLoraBoard.h>
 #include <helpers/CustomSX1276Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern LilyGoTLoraBoard board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/promicro/target.cpp

@@ -1,5 +1,6 @@
 #include <Arduino.h>
 #include "target.h"
+#include <helpers/ArduinoHelpers.h>
 
 FaketecBoard board;
 
@@ -7,11 +8,16 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BU
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+VolatileRTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  rtc_clock.begin(Wire);
+  
 #ifdef SX126X_DIO3_TCXO_VOLTAGE
   float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
 #else

+ 2 - 0
variants/promicro/target.h

@@ -6,9 +6,11 @@
 #include <helpers/nrf52/FaketecBoard.h>
 #include <helpers/CustomSX1262Wrapper.h>
 #include <helpers/CustomLLCC68Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern FaketecBoard board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/rak4631/target.cpp

@@ -1,5 +1,6 @@
 #include <Arduino.h>
 #include "target.h"
+#include <helpers/ArduinoHelpers.h>
 
 RAK4631Board board;
 
@@ -7,11 +8,16 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BU
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+VolatileRTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  rtc_clock.begin(Wire);
+  
 #ifdef SX126X_DIO3_TCXO_VOLTAGE
   float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
 #else

+ 2 - 0
variants/rak4631/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/nrf52/RAK4631Board.h>
 #include <helpers/CustomSX1262Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern RAK4631Board board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/station_g2/target.cpp

@@ -12,11 +12,17 @@ StationG2Board board;
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+ESP32RTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  fallback_clock.begin();
+  rtc_clock.begin(Wire);
+  
 #ifdef SX126X_DIO3_TCXO_VOLTAGE
   float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
 #else

+ 2 - 0
variants/station_g2/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/StationG2Board.h>
 #include <helpers/CustomSX1262Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern StationG2Board board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/t1000-e/target.cpp

@@ -1,5 +1,6 @@
 #include <Arduino.h>
 #include "target.h"
+#include <helpers/ArduinoHelpers.h>
 
 T1000eBoard board;
 
@@ -7,6 +8,9 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BU
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+VolatileRTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
@@ -34,6 +38,8 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
 #endif
 
 bool radio_init() {
+  rtc_clock.begin(Wire);
+  
 #ifdef LR11X0_DIO3_TCXO_VOLTAGE
   float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
 #else

+ 2 - 0
variants/t1000-e/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/nrf52/T1000eBoard.h>
 #include <helpers/CustomLR1110Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern T1000eBoard board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/t114/target.cpp

@@ -1,5 +1,6 @@
 #include <Arduino.h>
 #include "target.h"
+#include <helpers/ArduinoHelpers.h>
 
 T114Board board;
 
@@ -7,11 +8,16 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BU
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+VolatileRTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  rtc_clock.begin(Wire);
+  
 #ifdef SX126X_DIO3_TCXO_VOLTAGE
   float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
 #else

+ 2 - 0
variants/t114/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/nrf52/T114Board.h>
 #include <helpers/CustomSX1262Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern T114Board board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/techo/target.cpp

@@ -1,5 +1,6 @@
 #include <Arduino.h>
 #include "target.h"
+#include <helpers/ArduinoHelpers.h>
 
 TechoBoard board;
 
@@ -7,11 +8,16 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BU
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+VolatileRTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  rtc_clock.begin(Wire);
+  
 #ifdef SX126X_DIO3_TCXO_VOLTAGE
   float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
 #else

+ 2 - 0
variants/techo/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/nrf52/TechoBoard.h>
 #include <helpers/CustomSX1262Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern TechoBoard board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/xiao_c3/target.cpp

@@ -12,11 +12,17 @@ XiaoC3Board board;
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+ESP32RTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  fallback_clock.begin();
+  rtc_clock.begin(Wire);
+  
 #ifdef SX126X_DIO3_TCXO_VOLTAGE
   float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
 #else

+ 2 - 0
variants/xiao_c3/target.h

@@ -6,9 +6,11 @@
 #include <helpers/XiaoC3Board.h>
 #include <helpers/CustomSX1262Wrapper.h>
 #include <helpers/CustomSX1268Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern XiaoC3Board board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();

+ 6 - 0
variants/xiao_s3_wio/target.cpp

@@ -12,11 +12,17 @@ ESP32Board board;
 
 WRAPPER_CLASS radio_driver(radio, board);
 
+ESP32RTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+
 #ifndef LORA_CR
   #define LORA_CR      5
 #endif
 
 bool radio_init() {
+  fallback_clock.begin();
+  rtc_clock.begin(Wire);
+  
 #ifdef SX126X_DIO3_TCXO_VOLTAGE
   float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
 #else

+ 2 - 0
variants/xiao_s3_wio/target.h

@@ -5,9 +5,11 @@
 #include <helpers/RadioLibWrappers.h>
 #include <helpers/ESP32Board.h>
 #include <helpers/CustomSX1262Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
 
 extern ESP32Board board;
 extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
 
 bool radio_init();
 uint32_t radio_get_rng_seed();