Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong RSSI calculation for the nrf802154 #20803

Closed
KSKNico opened this issue Jul 31, 2024 · 0 comments · Fixed by #20839
Closed

Wrong RSSI calculation for the nrf802154 #20803

KSKNico opened this issue Jul 31, 2024 · 0 comments · Fixed by #20839
Assignees

Comments

@KSKNico
Copy link
Contributor

KSKNico commented Jul 31, 2024

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
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 a pull request may close this issue.

4 participants