[riot-notifications] [RIOT-OS/RIOT] nrf802154: Add rssi/lqi to received frames (#11133)

Koen Zandberg notifications at github.com
Thu Mar 7 21:22:30 CET 2019

bergzand commented on this pull request.

> @@ -317,6 +320,17 @@ static int _recv(netdev_t *dev, void *buf, size_t len, void *info)
     else {
         DEBUG("[nrf802154] recv: reading packet of length %i\n", 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 the datasheet) */
+            radio_info->lqi = (uint8_t)(hwlqi > UINT8_MAX/ED_RSSISCALE
+                                       ? UINT8_MAX
+                                       : hwlqi * ED_RSSISCALE);
+            /* Calculate RSSI by substracting the offset from the datasheet */
+            radio_info->rssi = (int16_t)hwlqi - ED_RSSIOFFS;

I initially had exactly what the datasheet specifies, I then "measured" values in the range of 100-150dbm (unrealistic measurements) when the other node (a samr21-xpro) was in the range of a few cm from the nrf52840. I've changed it to the current calculation because it gave me the most realistic match between behaviour and calculated rssi.
 - around -10dbm to -20dbm when the other node is really close by (antenna's almost touch), other node transmitting at 0dbm.
 - connectivity drops when the calculation indicates around -90dbm
 - when reducing the output power of the samr21-xpro by an arbitrary number of dbm, the reported rssi of the nrf52840 drops with a similar amount (±1dbm variation).

IMHO the calculation in the datasheet is *wrong* because 802.15.4 lqi is specified as between 0 and 255 where 0 is a really bad connection and 255 is a perfect connection. Adding 255 to `ED_RSSIOFFS` would give an RSSI of 165dbm :-/

I couldn't find anything in the errata, in the datasheet or with a quick web search on this though. 

Please let me know what you think and if you can reproduce my findings.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190307/7aaea21f/attachment.html>

More information about the notifications mailing list