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

Semjon Kerner notifications at github.com
Thu Mar 7 21:12:05 CET 2019


SemjonKerner commented on this pull request.

Great work, thank you.
Code looks good, nothing serious. But it would be good if you could double check the RSSI calculation.
I can test functionality next week.

> @@ -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 txbuf[IEEE802154_FRAME_LEN_MAX + 3]; /* len PHR + PSDU + LQI */
 
+#define ED_RSSISCALE 4

a bit nitpicky: indention of the values, parentheses and maybe also make them unsigned?

> @@ -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) */

Ahhh, took me a moment to realize there is a newer version online. Please also specify version number v1.1 (or delete page number).

> @@ -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;

Did you mean `radio_info->lqi` here rather than `hwlqi`? From figure 122 on page 320 of the datasheet, i understand that the RSSI in dbm is  again calculated from `(hwlqi * ED_RSSISCALE) - 92`.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11133#pullrequestreview-211970250
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190307/5fcb5cb7/attachment.html>


More information about the notifications mailing list