kiss_modem: reach FEM gain through the board's radio.fem CLI commands

Boards own their FEM control through handleCommand() ("get/set
radio.fem.rxgain|txgain"). Use that instead of a parallel set of FEM
virtuals on MainBoard, so any board that implements the commands works
in KISS with no extra code.

- Remove the six FEM virtuals from MainBoard and the board overrides.
- KissModem talks to the board in one adapter. A gain counts as
  controllable only if "get" replies exactly "> on" or "> off". "set"
  is checked by reading the state back, never by its reply wording.
- SetFemState always replies with the read-back state once the
  requested bits pass the capability check.
- Guard the boards' prefs writes against a NULL store. KISS attaches
  no prefs, so "set radio.fem.*" would dereference NULL.
- Wio Tracker L1 1W TX gain is exposed again, matching its CLI.
This commit is contained in:
agessaman committed 2026-09-23 17:31:20 -07:00
1 parent 8cefda9612
commit 7652ec5c26
18 files changed
+161 -100

No files matched your search

+8 -5
View File
@@ -100,6 +100,9 @@
#define HW_FEM_RX_GAIN (1 << 0)
#define HW_FEM_TX_GAIN (1 << 1)
/* Matches the CLI reply buffer boards write into from handleCommand() */
#define KISS_BOARD_REPLY_SIZE 160
#define KISS_AGC_RESET_DEFAULT_SEC 30
#define KISS_AGC_RESET_MAX_SEC 1020
#define KISS_AGC_RESET_STEP_SEC 4
@@ -173,7 +176,6 @@ class KissModem {
uint8_t _fem_deferred_apply;
uint8_t _fem_deferred_value;
bool _fem_reply_pending;
bool _fem_reply_ok;
uint8_t _fem_deferred_gets;
uint8_t _tx_frame_buf[KISS_TX_FRAME_QUEUE_DEPTH][KISS_MAX_ENCODED_FRAME_SIZE];
uint16_t _tx_frame_len[KISS_TX_FRAME_QUEUE_DEPTH];
@@ -202,10 +204,11 @@ class KissModem {
void handleHardwareCommand(uint8_t sub_cmd, const uint8_t* data, uint16_t len);
void processTx();
void maybeResetAgc();
uint8_t femCapabilityMask() const;
uint8_t femValueMask() const;
bool queueFemReply(bool ok, bool mark_busy_error);
bool applyFemState(uint8_t apply_mask, uint8_t value_mask);
bool queryFemGain(uint8_t bit, bool* enabled);
bool setFemGain(uint8_t bit, bool enable);
void readFemState(uint8_t* caps, uint8_t* values);
bool queueFemReply(bool mark_busy_error);
void applyFemState(uint8_t apply_mask, uint8_t value_mask);
bool isFemReplyQueued() const { return _fem_deferred || _fem_reply_pending || _fem_deferred_gets > 0; }
void processDeferredFem();