@@ -120,7 +120,7 @@ struct NeighbourInfo {
120120 int8_t snr; // multiplied by 4, user should divide to get float value
121121};
122122
123- #define CLI_REPLY_DELAY_MILLIS 1000
123+ #define CLI_REPLY_DELAY_MILLIS 600
124124
125125class MyMesh : public mesh ::Mesh, public CommonCLICallbacks {
126126 FILESYSTEM* _fs;
@@ -134,6 +134,11 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
134134 NeighbourInfo neighbours[MAX_NEIGHBOURS];
135135#endif
136136 CayenneLPP telemetry;
137+ unsigned long set_radio_at, revert_radio_at;
138+ float pending_freq;
139+ float pending_bw;
140+ uint8_t pending_sf;
141+ uint8_t pending_cr;
137142
138143 ClientInfo* putClient (const mesh::Identity& id) {
139144 uint32_t min_time = 0xFFFFFFFF ;
@@ -558,6 +563,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
558563 {
559564 memset (known_clients, 0 , sizeof (known_clients));
560565 next_local_advert = next_flood_advert = 0 ;
566+ set_radio_at = revert_radio_at = 0 ;
561567 _logging = false ;
562568
563569 #if MAX_NEIGHBOURS
@@ -609,6 +615,16 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
609615 _cli.savePrefs (_fs);
610616 }
611617
618+ void applyTempRadioParams (float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) override {
619+ set_radio_at = futureMillis (2000 ); // give CLI reply some time to be sent back, before applying temp radio params
620+ pending_freq = freq;
621+ pending_bw = bw;
622+ pending_sf = sf;
623+ pending_cr = cr;
624+
625+ revert_radio_at = futureMillis (2000 + timeout_mins*60 *1000 ); // schedule when to revert radio params
626+ }
627+
612628 bool formatFileSystem () override {
613629#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
614630 return InternalFS.format ();
@@ -734,6 +750,19 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
734750
735751 updateAdvertTimer (); // schedule next local advert
736752 }
753+
754+ if (set_radio_at && millisHasNowPassed (set_radio_at)) { // apply pending (temporary) radio params
755+ set_radio_at = 0 ; // clear timer
756+ radio_set_params (pending_freq, pending_bw, pending_sf, pending_cr);
757+ MESH_DEBUG_PRINTLN (" Temp radio params" );
758+ }
759+
760+ if (revert_radio_at && millisHasNowPassed (revert_radio_at)) { // revert radio params to orig
761+ revert_radio_at = 0 ; // clear timer
762+ radio_set_params (_prefs.freq , _prefs.bw , _prefs.sf , _prefs.cr );
763+ MESH_DEBUG_PRINTLN (" Radio params restored" );
764+ }
765+
737766 #ifdef DISPLAY_CLASS
738767 ui_task.loop ();
739768 #endif
0 commit comments