tanmatsu(lora): apply runtime radio-config changes to the C6 modem
The Tanmatsu's LoRa modem lives on the C6 coprocessor, shared with the Tanmatsu OS's own LoRa settings. pushConfig() no-op'd once RX polling started (the remote link can block under RX load), so a runtime frequency/SF/BW/CR/power change from the wadamesh radio settings only updated _cfg and took effect on the NEXT REBOOT — the radio stayed on whatever the OS or boot last set. That is the 'change the wadamesh frequency but receive nothing on it' report, and why wadamesh's settings never overrode the Tanmatsu OS's. Now a runtime change marks _cfg dirty and recvRaw() applies it on the RX-poll thread, between polls: drop to STANDBY (so the link isn't under active-RX load and lora_set_config can't block), push, re-arm continuous RX. wadamesh's settings now reach the modem live and win over the OS config. The '0.00001 MHz' the OS page showed is the C6 frequency corrupted by the two configs fighting; wadamesh consistently owning the config should clear it — needs on-device confirmation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7d3b4a4336
commit
11775ce5ac
2 files changed
+26
-5
No files matched your search
@@ -54,6 +54,18 @@ int TanmatsuLoraRadio::recvRaw(uint8_t* bytes, int sz) {
|
||||
// one-shot is enough. It also gates pushConfig from here on (the remote link blocks under RX load).
|
||||
_rx_polling = true;
|
||||
lora_set_mode(&_h, LORA_PROTOCOL_MODE_RX);
|
||||
} else if (_cfg_dirty) {
|
||||
// A runtime setParams()/setTxPower()/setRxBoostedGainMode() (the wadamesh radio
|
||||
// settings save, from the UI or the companion app) changed the PHY config. Apply it
|
||||
// HERE, on the RX-poll thread, so the C6 remote link is never touched cross-thread:
|
||||
// leave RX to STANDBY (so the link isn't under active-RX load and lora_set_config
|
||||
// can't block), push the new config, then re-arm continuous RX. This is what makes a
|
||||
// live frequency / SF / BW / CR / power change actually reach the modem (it used to
|
||||
// need a reboot) AND lets wadamesh's settings override whatever the Tanmatsu OS set.
|
||||
_cfg_dirty = false;
|
||||
lora_set_mode(&_h, LORA_PROTOCOL_MODE_STANDBY_RC);
|
||||
lora_set_config(&_h, &_cfg);
|
||||
lora_set_mode(&_h, LORA_PROTOCOL_MODE_RX);
|
||||
}
|
||||
lora_protocol_lora_packet_t pkt;
|
||||
// Non-blocking poll of the RX queue (timeout 0).
|
||||
|
||||
@@ -56,16 +56,25 @@ public:
|
||||
uint32_t getPacketsSent() const { return _n_sent; }
|
||||
|
||||
private:
|
||||
// Push _cfg to the modem — but ONLY while not yet polling RX. The remote link's
|
||||
// esp_hosted_send_custom_data() blocks indefinitely under continuous-RX load, so a
|
||||
// live reconfig from the UI thread would freeze the app. Boot bring-up (before the
|
||||
// RX loop starts) pushes fine; runtime changes update _cfg and apply on next init.
|
||||
void pushConfig() { if (_started && !_rx_polling) lora_set_config(&_h, &_cfg); }
|
||||
// Push _cfg to the modem. The remote link's esp_hosted_send_custom_data() can block
|
||||
// under continuous-RX load, so a live lora_set_config() from the UI/companion thread
|
||||
// (mid-RX) risked freezing the app — which is why this used to no-op once RX started,
|
||||
// making a frequency/SF/BW change only take effect on the next reboot ("receives
|
||||
// nothing on the new frequency", and wadamesh's settings never overrode the Tanmatsu
|
||||
// OS's). Now: boot bring-up pushes directly; a runtime change marks _cfg dirty and
|
||||
// recvRaw() applies it on the RX-poll thread, between polls (standby → push → re-arm),
|
||||
// so wadamesh's settings actually reach the modem and win.
|
||||
void pushConfig() {
|
||||
if (!_started) return;
|
||||
if (_rx_polling) { _cfg_dirty = true; return; } // defer to recvRaw() (RX-poll thread)
|
||||
lora_set_config(&_h, &_cfg);
|
||||
}
|
||||
|
||||
lora_handle_t _h = {0};
|
||||
lora_protocol_config_params_t _cfg = {0};
|
||||
bool _started = false;
|
||||
bool _rx_polling = false; // set once recvRaw() starts draining — see pushConfig()
|
||||
bool _cfg_dirty = false; // runtime config change pending; applied by recvRaw() between polls
|
||||
bool _sending = false;
|
||||
bool _rx_boost = false;
|
||||
float _last_rssi = 0.0f;
|
||||
|
||||
Reference in new issue
Block a user