mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-10-06 09:46:38 +00:00
feat(radio): honest TX power for GAT562 30S external PA
gat562_30s_mesh_kit has an always-on external PA rated at +30dBm, but the firmware wrote tx_power_dbm straight to the SX1262 register (capped at 22), so the app/CLI/UI never matched the real radiated power and couldn't ask for more than 22 even though the hardware supports it. Add a generic, macro-gated PA gain-curve resolution in RadioLibWrapper::setTxPower() (the single choke point every TX-power path already funnels through), reusable by any future board with a similar PA. For this board, reuse the vendor-measured 869MHz curve from the open upstream Meshtastic PR that added it for the same physical module (meshtastic/firmware#11212): pick the lowest SX1262 setting whose measured output reaches the requested dBm, clamped at the PA's saturation knee. Bump LORA_TX_POWER/MAX_LORA_TX_POWER to 30 for this variant only -- the other three GAT562 boards use the SX1262's own PA_BOOST (22dBm, no external PA) and are unaffected. Since a request below the PA's floor gain (14dBm) still radiates at that floor, also make CommonCLICallbacks::setTxPower() return what was actually applied, and have every setter (BLE CMD_SET_RADIO_TX_POWER, CLI "tx", simple_repeater/room_server/sensor) persist and report that value instead of the raw request -- so tx_power_dbm never silently disagrees with the physical output in either direction. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2488,9 +2488,11 @@ void MyMesh::handleCmdFrame(size_t len) {
|
||||
if (power < -9 || power > MAX_LORA_TX_POWER) {
|
||||
writeErrFrame(ERR_CODE_ILLEGAL_ARG);
|
||||
} else {
|
||||
_prefs.tx_power_dbm = power;
|
||||
radio_driver.setTxPower(power);
|
||||
// Store what the radio actually applied, not the raw request -- on a
|
||||
// board with an external-PA gain curve those can differ (see setTxPower()).
|
||||
_prefs.tx_power_dbm = radio_driver.getTxPower();
|
||||
savePrefs();
|
||||
radio_driver.setTxPower(_prefs.tx_power_dbm);
|
||||
writeOKFrame();
|
||||
}
|
||||
} else if (cmd_frame[0] == CMD_SET_TUNING_PARAMS) {
|
||||
|
||||
@@ -1095,8 +1095,9 @@ void MyMesh::dumpLogFile() {
|
||||
}
|
||||
}
|
||||
|
||||
void MyMesh::setTxPower(int8_t power_dbm) {
|
||||
int8_t MyMesh::setTxPower(int8_t power_dbm) {
|
||||
radio_driver.setTxPower(power_dbm);
|
||||
return radio_driver.getTxPower();
|
||||
}
|
||||
|
||||
bool MyMesh::setRxBoostedGain(bool enable) {
|
||||
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
}
|
||||
|
||||
void dumpLogFile() override;
|
||||
void setTxPower(int8_t power_dbm) override;
|
||||
int8_t setTxPower(int8_t power_dbm) override;
|
||||
void formatNeighborsReply(char *reply) override;
|
||||
void removeNeighbor(const uint8_t* pubkey, int key_len) override;
|
||||
void formatStatsReply(char *reply) override;
|
||||
|
||||
@@ -839,8 +839,9 @@ void MyMesh::dumpLogFile() {
|
||||
}
|
||||
}
|
||||
|
||||
void MyMesh::setTxPower(int8_t power_dbm) {
|
||||
int8_t MyMesh::setTxPower(int8_t power_dbm) {
|
||||
radio_driver.setTxPower(power_dbm);
|
||||
return radio_driver.getTxPower();
|
||||
}
|
||||
|
||||
bool MyMesh::setRxBoostedGain(bool enable) {
|
||||
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
}
|
||||
|
||||
void dumpLogFile() override;
|
||||
void setTxPower(int8_t power_dbm) override;
|
||||
int8_t setTxPower(int8_t power_dbm) override;
|
||||
bool setRxBoostedGain(bool enable) override;
|
||||
|
||||
void formatNeighborsReply(char *reply) override {
|
||||
|
||||
@@ -848,8 +848,9 @@ void SensorMesh::updateFloodAdvertTimer() {
|
||||
}
|
||||
}
|
||||
|
||||
void SensorMesh::setTxPower(int8_t power_dbm) {
|
||||
int8_t SensorMesh::setTxPower(int8_t power_dbm) {
|
||||
radio_driver.setTxPower(power_dbm);
|
||||
return radio_driver.getTxPower();
|
||||
}
|
||||
|
||||
void SensorMesh::formatStatsReply(char *reply) {
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
void setLoggingOn(bool enable) override { }
|
||||
void eraseLogFile() override { }
|
||||
void dumpLogFile() override { }
|
||||
void setTxPower(int8_t power_dbm) override;
|
||||
int8_t setTxPower(int8_t power_dbm) override;
|
||||
void formatNeighborsReply(char *reply) override {
|
||||
strcpy(reply, "not supported");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user