Skip to content

[Dev] CommonRadioPrefs::getTxPower() reports negative dBm values as unsigned #3318

Description

@agessaman

Description

CommonRadioPrefs::getTxPower() and setTxPower() use uint8_t, although valid radio TX power values can be negative.

For example, a configured value of -9 dBm is converted to 247. This can produce incorrect CLI output and break preference serialization or round-tripping on radios that support negative TX power.

Root cause

The TX power interface is unsigned while the underlying configuration represents dBm as a signed value.

The issue was introduced in upstream commit b4f7e941, “CommonRadioPrefs refactors done”, on August 23.
That commit added these unsigned interfaces:

virtual uint8_t getTxPower() const = 0;
virtual void setTxPower(uint8_t dbm) = 0;

It also added matching unsigned implementations in CommonCLI and NodePrefs.

Proposed fix

Change the TX power getter, setter, and corresponding overrides from uint8_t to int8_t.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions