Skip to content

Fix unsigned conversion of negative TX power in CommonRadioPrefs - #3615

Merged
liamcottle merged 2 commits into
meshcore-dev:devfrom
radek-sixi:fix/common-radio-prefs-signed-tx-power
Oct 27, 2026
Merged

liamcottle merged 2 commits into
meshcore-dev:devfrom
radek-sixi:fix/common-radio-prefs-signed-tx-power

Conversation

@radek-sixi

@radek-sixi radek-sixi commented Oct 17, 2026 •

Copy link
Copy Markdown

Fixes #3318

Problem

NodePrefs::tx_power_dbm and RadioLibWrapper::setTxPower() represent TX power as a signed int8_t (for radios such as SX126x/LR11xx that support negative TX power down to -9 dBm). However, CommonRadioPrefs::getTxPower() and CommonRadioPrefs::setTxPower() (along with their overrides in CommonCLI.h and examples/companion_radio/NodePrefs.h) were declared with uint8_t.

As a result, negative TX power values such as -9 dBm were converted to 247 when accessed via CommonRadioPrefs::getTxPower() (e.g. get tx formatting (int32_t) getTxPower() as > 247).

Fix

  • Change CommonRadioPrefs::getTxPower() and CommonRadioPrefs::setTxPower() and their overrides in CommonCLI::NodePrefs::RadioPrefs and companion_radio's NodePrefs::RadioPrefs from uint8_t to int8_t.

@ripplebiz ripplebiz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall a 'good catch', but I'd probably drop the unit tests

Comment thread test/test_companion_node_prefs/test_companion_node_prefs.cpp Outdated
Comment thread test/test_companion_node_prefs/test_companion_node_prefs.cpp Outdated
@radek-sixi

Copy link
Copy Markdown
Author

Thanks for the review @ripplebiz — dropped the unit tests as suggested.

@liamcottle
liamcottle merged commit fd56b1a into meshcore-dev:dev Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants