Skip to content

Commit e8646f5

Browse files
committed
Parse as signed int
1 parent d0720c6 commit e8646f5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

examples/companion_radio/MyMesh.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,10 +1228,11 @@ void MyMesh::handleCmdFrame(size_t len) {
12281228
writeErrFrame(ERR_CODE_ILLEGAL_ARG);
12291229
}
12301230
} else if (cmd_frame[0] == CMD_SET_RADIO_TX_POWER) {
1231-
if (cmd_frame[1] > MAX_LORA_TX_POWER) {
1231+
int8_t power = (int8_t)cmd_frame[1];
1232+
if (power < -9 || power > MAX_LORA_TX_POWER) {
12321233
writeErrFrame(ERR_CODE_ILLEGAL_ARG);
12331234
} else {
1234-
_prefs.tx_power_dbm = cmd_frame[1];
1235+
_prefs.tx_power_dbm = power;
12351236
savePrefs();
12361237
radio_set_tx_power(_prefs.tx_power_dbm);
12371238
writeOKFrame();

0 commit comments

Comments
 (0)