Station G3: Expose, persist, and apply FEM gain preferences - #3137
Station G3: Expose, persist, and apply FEM gain preferences#3137agessaman wants to merge 2 commits into
Conversation
PA PL1 re-targets the PA's DC-DC supply rail rather than selecting a logic-level gain, and the serial CLI is serviced on every main-loop pass regardless of whether a transmit is in flight. A `set radio.fem.txgain` write could therefore move the rail mid-transmit, while the SX1262 was still driving the PA at full input power. Record the requested level in setPAGainEnable() and drive the pin from setTxModeEnable(), which runs from onBeforeTransmit() ahead of startTransmit(). The level only matters while transmitting, so deferring costs nothing. Document that the pref is saved immediately but applied at the next transmit, so `get radio.fem.txgain` can lead the hardware until then.
|
This addresses #3123. |
|
@ripplebiz This also contains a small bugfix for the new config serializer. (The second bullet point listed.) |
I will take note of this PR during my build. |
|
Added a host-side regression test for the Result
Host: g++ 15.2.0, The test drives the real Two things were needed to compile the header on the host, both contained in the test file:
Use it if it is helpful — happy to open it as a PR against your branch, or you can paste it in.
|
|
Separate observation from grepping this branch, almost certainly out of scope for this PR — flagging only in case it is unintended.
Verified on
So after this PR the key |
Adds
radio.fem.txgainso the Station G3's FEM transmit gain can be set from the CLI and persisted, plus two fixes I hit on the way.What's here
set/get radio.fem.txgain on|offdrives PA PL1, which picks between power levels 1/2 and 3/4 (the PA PL2 jumper decides which pair). Saved asfem_txgain. Other boards hit the existingcanControlLoRaFemPaGain()default and report unsupported, so nothing changes for them.fem_rxgainwas being serialized fromrx_boosted_gaininstead ofradio_fem_rxgain, soset radio.fem.rxgainnever survived a reboot. Fixed.setcould drop the rail mid-transmit with the SX1262 still driving the PA.setPAGainEnable()just records the value now, and the pin gets written fromsetTxModeEnable(), which runs beforestartTransmit(). The level only matters during TX so waiting costs nothing. I couldn't reproduce the resulting reboot on demand (it needs the write to land inside a transmit), but the sequencing is wrong either way.Also moves the Station G3 FEM pin handling into
LoRaFEMControllike the Heltec variants, and documents both commands.Testing
Bench-tested on a Station G3 (ESP32-S3 + BQ35LORA900V1M). I hung an INA219 on the input rail and temporarily logged idle vs peak power per transmit, to confirm the pin really does change the PA level and isn't just wiggling a GPIO. With
fem_txgain=on: 0.38 W idle, 8.14 W TX peak (14.62 V / 0.56 A), which lines up with the 6.330 W the Neil quotes for power level 1. That test isn't in the PR, it came back out once it had done its job.Repeater firmware builds clean, and the setting round-trips and survives a reboot.
For reviewers
The
fem_rxgainfix changes what an existing key means on upgrade, for the boards with FEM LNA control (heltec_t096, heltec_v4, heltec_tracker_v2). All three build withSX126X_RX_BOOSTED_GAIN=1, so the value that migrates in is the default anyway. Only someone who had turnedradio.rxgainoff would end up with a 0 and want to flip it back.