Skip to content

Commit 076dcef

Browse files
committed
cpu/nrf52: fix RSSI calculation in nrf802154_radio
1 parent b056060 commit 076dcef

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

cpu/nrf52/radio/nrf802154/nrf802154_radio.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,13 @@ static int _read(ieee802154_dev_t *dev, void *buf, size_t max_size,
337337
radio_info->lqi = (uint8_t)(hwlqi > UINT8_MAX/ED_RSSISCALE
338338
? UINT8_MAX
339339
: hwlqi * ED_RSSISCALE);
340-
/* We calculate RSSI from LQI, since it's already 8-bit
341-
saturated (see page 321 of product spec v1.1) */
342-
radio_info->rssi = _hwval_to_ieee802154_dbm(radio_info->lqi)
343-
+ IEEE802154_RADIO_RSSI_OFFSET;
340+
/* Converting the hardware-provided LQI value back to the
341+
original RSSI value is not properly documented in the PS.
342+
The linear mapping used here has been found empirically
343+
through comparison with the RSSI value provided by NRF_RADIO->RSSISAMPLE
344+
after enabling the ADDRESS_RSSISTART short. */
345+
int8_t rssi_dbm = hwlqi + ED_RSSIOFFS - 1;
346+
radio_info->rssi = ieee802154_dbm_to_rssi(rssi_dbm);
344347
}
345348
memcpy(buf, &rxbuf[1], pktlen);
346349
}

0 commit comments

Comments
 (0)