Merge pull request #11133 from bergzand/pr/nrf802154/radio_info

nrf802154: Add rssi/lqi to received frames
This commit is contained in:
Semjon Kerner 2019-03-15 11:46:17 +01:00 committed by GitHub
commit 6d3b625f3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,6 +60,9 @@ netdev_ieee802154_t nrf802154_dev = {
static uint8_t rxbuf[IEEE802154_FRAME_LEN_MAX + 3]; /* len PHR + PSDU + LQI */ static uint8_t rxbuf[IEEE802154_FRAME_LEN_MAX + 3]; /* len PHR + PSDU + LQI */
static uint8_t txbuf[IEEE802154_FRAME_LEN_MAX + 3]; /* len PHR + PSDU + LQI */ static uint8_t txbuf[IEEE802154_FRAME_LEN_MAX + 3]; /* len PHR + PSDU + LQI */
#define ED_RSSISCALE (4U)
#define ED_RSSIOFFS (92U)
#define RX_COMPLETE (0x1) #define RX_COMPLETE (0x1)
#define TX_COMPLETE (0x2) #define TX_COMPLETE (0x2)
#define LIFS (40U) #define LIFS (40U)
@ -317,6 +320,20 @@ static int _recv(netdev_t *dev, void *buf, size_t len, void *info)
else { else {
DEBUG("[nrf802154] recv: reading packet of length %i\n", pktlen); DEBUG("[nrf802154] recv: reading packet of length %i\n", pktlen);
memcpy(buf, &rxbuf[1], pktlen); memcpy(buf, &rxbuf[1], pktlen);
if (info != NULL) {
netdev_ieee802154_rx_info_t *radio_info = info;
/* Hardware link quality indicator */
uint8_t hwlqi = rxbuf[pktlen + 1];
/* Convert to 802.15.4 LQI (page 319 of product spec v1.1) */
radio_info->lqi = (uint8_t)(hwlqi > UINT8_MAX/ED_RSSISCALE
? UINT8_MAX
: hwlqi * ED_RSSISCALE);
/* Calculate RSSI by substracting the offset from the datasheet.
* Intentionally using a different calculation than the one from
* figure 122 of the v1.1 product specification. This appears to
* match real world performance better */
radio_info->rssi = (int16_t)hwlqi - ED_RSSIOFFS;
}
} }
_reset_rx(); _reset_rx();