77 #include < SPIFFS.h>
88#endif
99
10- #define RADIOLIB_STATIC_ONLY 1
11- #include < RadioLib.h>
12- #include < helpers/RadioLibWrappers.h>
1310#include < helpers/ArduinoHelpers.h>
1411#include < helpers/StaticPoolPacketManager.h>
1512#include < helpers/SimpleMeshTables.h>
@@ -89,11 +86,11 @@ static uint32_t _atoi(const char* sp) {
8986#define FIRMWARE_VER_CODE 3
9087
9188#ifndef FIRMWARE_BUILD_DATE
92- #define FIRMWARE_BUILD_DATE " 25 Mar 2025"
89+ #define FIRMWARE_BUILD_DATE " 30 Mar 2025"
9390#endif
9491
9592#ifndef FIRMWARE_VERSION
96- #define FIRMWARE_VERSION " v1.4.1 "
93+ #define FIRMWARE_VERSION " v1.4.2 "
9794#endif
9895
9996#define CMD_APP_START 1
@@ -197,7 +194,6 @@ struct NodePrefs { // persisted to file
197194
198195class MyMesh : public BaseChatMesh {
199196 FILESYSTEM* _fs;
200- RADIO_CLASS* _phy;
201197 IdentityStore* _identity_store;
202198 NodePrefs _prefs;
203199 uint32_t pending_login;
@@ -229,9 +225,9 @@ class MyMesh : public BaseChatMesh {
229225 AckTableEntry expected_ack_table[EXPECTED_ACK_TABLE_SIZE]; // circular table
230226 int next_ack_idx;
231227
232- void loadMainIdentity (mesh::RNG& trng ) {
228+ void loadMainIdentity () {
233229 if (!_identity_store->load (" _main" , self_id)) {
234- self_id = mesh::LocalIdentity (&trng ); // create new random identity
230+ self_id = radio_new_identity ( ); // create new random identity
235231 saveMainIdentity (self_id);
236232 }
237233 }
@@ -488,7 +484,7 @@ class MyMesh : public BaseChatMesh {
488484 }
489485
490486 void logRxRaw (float snr, float rssi, const uint8_t raw[], int len) override {
491- if (_serial->isConnected ()) {
487+ if (_serial->isConnected () && len+ 3 <= MAX_FRAME_SIZE ) {
492488 int i = 0 ;
493489 out_frame[i++] = PUSH_CODE_LOG_RX_DATA;
494490 out_frame[i++] = (int8_t )(snr * 4 );
@@ -709,8 +705,8 @@ class MyMesh : public BaseChatMesh {
709705
710706public:
711707
712- MyMesh (RADIO_CLASS& phy, RadioLibWrapper& rw , mesh::RNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables)
713- : BaseChatMesh(rw , *new ArduinoMillis(), rng, rtc, *new StaticPoolPacketManager(16 ), tables), _serial(NULL ), _phy(&phy )
708+ MyMesh (mesh::Radio& radio , mesh::RNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables)
709+ : BaseChatMesh(radio , *new ArduinoMillis(), rng, rtc, *new StaticPoolPacketManager(16 ), tables), _serial(NULL )
714710 {
715711 _iter_started = false ;
716712 offline_queue_len = 0 ;
@@ -767,7 +763,7 @@ class MyMesh : public BaseChatMesh {
767763 }
768764 }
769765
770- void begin (FILESYSTEM& fs, mesh::RNG& trng, bool has_display) {
766+ void begin (FILESYSTEM& fs, bool has_display) {
771767 _fs = &fs;
772768
773769 BaseChatMesh::begin ();
@@ -778,7 +774,7 @@ class MyMesh : public BaseChatMesh {
778774 _identity_store = new IdentityStore (fs, " /identity" );
779775 #endif
780776
781- loadMainIdentity (trng );
777+ loadMainIdentity ();
782778
783779 // load persisted prefs
784780 if (_fs->exists (" /new_prefs" )) {
@@ -793,7 +789,8 @@ class MyMesh : public BaseChatMesh {
793789 if (_prefs.ble_pin == 0 ) {
794790 #ifdef HAS_UI
795791 if (has_display) {
796- _active_ble_pin = trng.nextInt (100000 , 999999 ); // random pin each session
792+ StdRNG rng;
793+ _active_ble_pin = rng.nextInt (100000 , 999999 ); // random pin each session
797794 } else {
798795 _active_ble_pin = BLE_PIN_CODE; // otherwise static pin
799796 }
@@ -814,11 +811,8 @@ class MyMesh : public BaseChatMesh {
814811 addChannel (" Public" , PUBLIC_GROUP_PSK); // pre-configure Andy's public channel
815812 loadChannels ();
816813
817- _phy->setFrequency (_prefs.freq );
818- _phy->setSpreadingFactor (_prefs.sf );
819- _phy->setBandwidth (_prefs.bw );
820- _phy->setCodingRate (_prefs.cr );
821- _phy->setOutputPower (_prefs.tx_power_dbm );
814+ radio_set_params (_prefs.freq , _prefs.bw , _prefs.sf , _prefs.cr );
815+ radio_set_tx_power (_prefs.tx_power_dbm );
822816 }
823817
824818 const char * getNodeName () { return _prefs.node_name ; }
@@ -1153,10 +1147,7 @@ class MyMesh : public BaseChatMesh {
11531147 _prefs.bw = (float )bw / 1000.0 ;
11541148 savePrefs ();
11551149
1156- _phy->setFrequency (_prefs.freq );
1157- _phy->setSpreadingFactor (_prefs.sf );
1158- _phy->setBandwidth (_prefs.bw );
1159- _phy->setCodingRate (_prefs.cr );
1150+ radio_set_params (_prefs.freq , _prefs.bw , _prefs.sf , _prefs.cr );
11601151 MESH_DEBUG_PRINTLN (" OK: CMD_SET_RADIO_PARAMS: f=%d, bw=%d, sf=%d, cr=%d" , freq, bw, (uint32_t )sf, (uint32_t )cr);
11611152
11621153 writeOKFrame ();
@@ -1170,7 +1161,7 @@ class MyMesh : public BaseChatMesh {
11701161 } else {
11711162 _prefs.tx_power_dbm = cmd_frame[1 ];
11721163 savePrefs ();
1173- _phy-> setOutputPower (_prefs.tx_power_dbm );
1164+ radio_set_tx_power (_prefs.tx_power_dbm );
11741165 writeOKFrame ();
11751166 }
11761167 } else if (cmd_frame[0 ] == CMD_SET_TUNING_PARAMS) {
@@ -1431,7 +1422,7 @@ class MyMesh : public BaseChatMesh {
14311422
14321423StdRNG fast_rng;
14331424SimpleMeshTables tables;
1434- MyMesh the_mesh (radio, * new WRAPPER_CLASS(radio, board), fast_rng, *new VolatileRTCClock(), tables);
1425+ MyMesh the_mesh (radio_driver, fast_rng, *new VolatileRTCClock(), tables); // TODO: test with 'rtc_clock' in target.cpp
14351426
14361427void halt () {
14371428 while (1 ) ;
@@ -1444,9 +1435,7 @@ void setup() {
14441435
14451436 if (!radio_init ()) { halt (); }
14461437
1447- fast_rng.begin (radio.random (0x7FFFFFFF ));
1448-
1449- RadioNoiseListener trng (radio);
1438+ fast_rng.begin (radio_get_rng_seed ());
14501439
14511440#ifdef HAS_UI
14521441 DisplayDriver* disp = NULL ;
@@ -1459,7 +1448,7 @@ void setup() {
14591448
14601449#if defined(NRF52_PLATFORM)
14611450 InternalFS.begin ();
1462- the_mesh.begin (InternalFS, trng,
1451+ the_mesh.begin (InternalFS,
14631452 #ifdef HAS_UI
14641453 disp != NULL
14651454 #else
@@ -1477,7 +1466,7 @@ void setup() {
14771466 the_mesh.startInterface (serial_interface);
14781467#elif defined(ESP32)
14791468 SPIFFS.begin (true );
1480- the_mesh.begin (SPIFFS, trng,
1469+ the_mesh.begin (SPIFFS,
14811470 #ifdef HAS_UI
14821471 disp != NULL
14831472 #else
0 commit comments