helium / sx1302_hal

SX1302 Hardware Abstraction Layer and Tools (packet forwarder...)
Other
36 stars 44 forks source link

TX_POWER is an error #35

Closed mawdegroot closed 10 months ago

mawdegroot commented 1 year ago

TX_POWER is an error when there is no lower or equal power level available. TX_POWER is a warning when there is a lower or equal power level available.

ke6jjj commented 1 year ago

For context, this PR fixes a bug in the packet forwarder where it accidentally transmits a packet at a higher power than requested when it ought to have returned an error condition instead. This is a bug in the power LUT table processing and how it handles the condition of falling off of the edge of the table.

mawdegroot commented 1 year ago

Fixed a final bug where it also made TX_POWER an error when there was a lower value available. The following was obtained using a global_conf with values between 16 and 10 dBm.

(miner@127.0.0.1)41> gen_server:call(miner_lora_light, {send, <<"...">>, immediate, fun(_) -> 867.9 end, "SF11BW125", 20, false, undefined}, 11000).
{warning,{tx_power_corrected,16}}
(miner@127.0.0.1)42> gen_server:call(miner_lora_light, {send, <<"...">>, immediate, fun(_) -> 867.9 end, "SF11BW125", 6, false, undefined}, 11000).
{error,bad_tx_power}
(miner@127.0.0.1)43> gen_server:call(miner_lora_light, {send, <<"...">>, immediate, fun(_) -> 867.9 end, "SF11BW125", 16, false, undefined}, 11000).
ok
mawdegroot commented 1 year ago

Rebased and retested.