Skip to content

Wrong RSSI calculation for the nrf802154 #20803

@N11cc00

Description

@N11cc00

Description

The RSSI code and the extracted values for the nrf802154 with IEEE802154 are wrong. The respective lines that are responsible for the calculation can be found here. The commit that changed the line for calculation is 6d4d00e in PR #15616, the old calculation seems more correct.

Hardware specifications can be found here:
https://docs.nordicsemi.com/bundle/ps_nrf52840/page/radio.html#ariaid-title20
https://docs.nordicsemi.com/bundle/ps_nrf52840/page/radio.html#ieee802154_ed__fig_sample_ed

I want to thank @mguetschow for some initial research into the issue.

Steps to reproduce the issue

Sending packets between two sensor nodes with the nrf802154 via GNRC and extracting the RSSI from the GNRC header.

Expected results

The RSSI should be obtained by mapping the hwval/LQI of the radio to a value between 0 and 255. An actual mapping isn't mentioned in the product specification of the radio. The LQI value seems fine, so some form of conversion should be possible.

Actual results

The RSSI value jumps around and overflows. This is because the current calculation method is guaranteed to overflow the signed 8 bit integer return value for LQI > 55.

The _hwval_to_ieee802154_dbm function

static inline int8_t _hwval_to_ieee802154_dbm(uint8_t hwval)
{
    return (ED_RSSISCALE * hwval) + ED_RSSIOFFS;
}

converts the input to dbm. In the invocation of this function the hwval is the LQI, so a value between 0 and 255. Multiplying this value by the constant value ED_RSSISCALE, which is 4, leads to an overflow for LQI > 55.

The GNRC header uses an entirely different datatype for the RSSI value: a signed 16 bit integer, while the LQI remains an unsigned 8 bit integer.

Versions

Operating System Environment
----------------------------
         Operating System: "Arch Linux" 
                   Kernel: Linux 6.9.9-arch1-1 x86_64 unknown
             System shell: GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu)
             make's shell: GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu)

Installed compiler toolchains
-----------------------------
               native gcc: gcc (GCC) 14.1.1 20240522
        arm-none-eabi-gcc: arm-none-eabi-gcc (Arch Repository) 14.1.0
                  avr-gcc: missing
           msp430-elf-gcc: missing
       riscv-none-elf-gcc: missing
  riscv64-unknown-elf-gcc: missing
      riscv32-esp-elf-gcc: missing
     xtensa-esp32-elf-gcc: missing
   xtensa-esp32s2-elf-gcc: missing
   xtensa-esp32s3-elf-gcc: missing
   xtensa-esp8266-elf-gcc: missing
                    clang: clang version 18.1.8

Installed compiler libs
-----------------------
     arm-none-eabi-newlib: "4.4.0"
        msp430-elf-newlib: missing
    riscv-none-elf-newlib: missing
riscv64-unknown-elf-newlib: missing
   riscv32-esp-elf-newlib: missing
  xtensa-esp32-elf-newlib: missing
xtensa-esp32s2-elf-newlib: missing
xtensa-esp32s3-elf-newlib: missing
xtensa-esp8266-elf-newlib: missing
                 avr-libc: missing (missing)

Installed development tools
---------------------------
                   ccache: missing
                    cmake: cmake version 3.30.0
                 cppcheck: missing
                  doxygen: 1.11.0
                      git: git version 2.45.2
                     make: GNU Make 4.4.1
                  openocd: Open On-Chip Debugger 0.12.0
                   python: Python 3.12.4
                  python2: missing
                  python3: Python 3.12.4
                   flake8: 7.1.0 (mccabe: 0.7.0, pycodestyle: 2.11.1, pyflakes: 3.2.0) CPython 3.12.4 on
               coccinelle: missing

Metadata

Metadata

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