Merge pull request #15616 from fjmolinas/pr_ieee802154_rssi_conversion

sys/inet/ieee802154/radio: fix wrong rssi conversions treewide
This commit is contained in:
José Alamos 2021-01-13 20:38:22 +01:00 committed by GitHub
commit db449673f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 8 deletions

View File

@ -185,10 +185,15 @@ static int _read(ieee802154_dev_t *dev, void *buf, size_t size, ieee802154_rx_in
/* The number of dB above maximum sensitivity detected for the /* The number of dB above maximum sensitivity detected for the
* received packet */ * received packet */
info->rssi = -CC2538_RSSI_OFFSET + rssi_val + IEEE802154_RADIO_RSSI_OFFSET; /* Make sure there is no overflow even if no signal with such
low sensitivity should be detected */
const int hw_rssi_min = IEEE802154_RADIO_RSSI_OFFSET -
CC2538_RSSI_OFFSET;
int8_t hw_rssi = rssi_val > hw_rssi_min ?
(CC2538_RSSI_OFFSET + rssi_val) : IEEE802154_RADIO_RSSI_OFFSET;
info->rssi = hw_rssi - IEEE802154_RADIO_RSSI_OFFSET;
corr_val = rfcore_read_byte() & CC2538_CORR_VAL_MASK; corr_val = rfcore_read_byte() & CC2538_CORR_VAL_MASK;
if (corr_val < CC2538_CORR_VAL_MIN) { if (corr_val < CC2538_CORR_VAL_MIN) {
corr_val = CC2538_CORR_VAL_MIN; corr_val = CC2538_CORR_VAL_MIN;
} }

View File

@ -230,11 +230,10 @@ static int _read(ieee802154_dev_t *dev, void *buf, size_t max_size,
radio_info->lqi = (uint8_t)(hwlqi > UINT8_MAX/ED_RSSISCALE radio_info->lqi = (uint8_t)(hwlqi > UINT8_MAX/ED_RSSISCALE
? UINT8_MAX ? UINT8_MAX
: hwlqi * ED_RSSISCALE); : hwlqi * ED_RSSISCALE);
/* Calculate RSSI by subtracting the offset from the datasheet. /* We calculate RSSI from LQI, since it's already 8-bit
* Intentionally using a different calculation than the one from saturated (see page 321 of product spec v1.1) */
* figure 122 of the v1.1 product specification. This appears to radio_info->rssi = _hwval_to_ieee802154_dbm(radio_info->lqi)
* match real world performance better */ + IEEE802154_RADIO_RSSI_OFFSET;
radio_info->rssi = _hwval_to_ieee802154_dbm(hwlqi) + IEEE802154_RADIO_RSSI_OFFSET;
} }
memcpy(buf, &rxbuf[1], pktlen); memcpy(buf, &rxbuf[1], pktlen);
} }

View File

@ -310,7 +310,7 @@ void radio_getReceivedFrame(uint8_t *bufRead,
OpenWSN includes IEEE802154_FCS_LEN in its length value */ OpenWSN includes IEEE802154_FCS_LEN in its length value */
*lenRead = size + IEEE802154_FCS_LEN; *lenRead = size + IEEE802154_FCS_LEN;
/* get rssi, lqi & crc */ /* get rssi, lqi & crc */
*rssi = rx_info.rssi; *rssi = ieee802154_rssi_to_dbm(rx_info.rssi);
*lqi = rx_info.lqi; *lqi = rx_info.lqi;
/* only valid crc frames are currently accepted */ /* only valid crc frames are currently accepted */
*crc = 1; *crc = 1;