From 4482c9851a4a4af51fb9a59ddb344267ef06ee73 Mon Sep 17 00:00:00 2001 From: Josarn Date: Fri, 6 Jul 2018 14:15:44 +0200 Subject: [PATCH] at86rf2xx: correct rssi AT86RF231 MAN. p.89 8.3.2 Reading RSSI AT86RF232 MAN. p.88 8.3.2 Reading RSSI AT86RF233 MAN. p.99 8.4.2 Reading RSSI "It is not recommended reading the RSSI value when using the Extended Operating Modes, use ED instead" --- drivers/at86rf2xx/at86rf2xx_netdev.c | 29 ++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/at86rf2xx/at86rf2xx_netdev.c b/drivers/at86rf2xx/at86rf2xx_netdev.c index 24a959227b..a8dd416855 100644 --- a/drivers/at86rf2xx/at86rf2xx_netdev.c +++ b/drivers/at86rf2xx/at86rf2xx_netdev.c @@ -166,18 +166,39 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info) at86rf2xx_fb_read(dev, tmp, 2); (void)tmp; + /* at86rf212 RSSI_BASE_VAL +3.1*RSSI, base varies for diff. modulation and datarates + * at86RF232 RSSI_BASE_VAL +3.0*RSSI, base -91dBm + * at86RF233 RSSI_BASE_VAL +3.0*RSSI, base -94dBm + * at86RF231 RSSI_BASE_VAL +3.0*(RSSI-1), base -91dBm + * at***RFR2 RSSI_BASE_VAL +3.0*(RSSI-1), base -90dBm + * + * AT86RF231 MAN. p.89 8.3.2 Reading RSSI + * AT86RF232 MAN. p.88 8.3.2 Reading RSSI + * AT86RF233 MAN. p.99 8.4.2 Reading RSSI + * "It is not recommended reading the RSSI value when using the Extended + * Operating Modes, use ED instead" + * at86RF231 RSSI_BASE_VAL +ED, base -90dBm + * at86RF232 RSSI_BASE_VAL +ED, base -91dBm + * at86RF233 RSSI_BASE_VAL +ED, base -94dBm + * at***RFR2 RSSI_BASE_VAL +ED, base -90dBm + */ if (info != NULL) { uint8_t rssi = 0; netdev_ieee802154_rx_info_t *radio_info = info; + +#if defined(MODULE_AT86RF231) || defined(MODULE_AT86RF232) || defined(MODULE_AT86RF233) at86rf2xx_fb_read(dev, &(radio_info->lqi), 1); -#ifndef MODULE_AT86RF231 - at86rf2xx_fb_read(dev, &(rssi), 1); - at86rf2xx_fb_stop(dev); -#else at86rf2xx_fb_stop(dev); rssi = at86rf2xx_reg_read(dev, AT86RF2XX_REG__PHY_ED_LEVEL); +#else + at86rf2xx_fb_read(dev, &(radio_info->lqi), 1); + at86rf2xx_fb_read(dev, &(rssi), 1); + at86rf2xx_fb_stop(dev); + rssi = 3 * rssi; #endif radio_info->rssi = RSSI_BASE_VAL + rssi; + DEBUG("[at86rf2xx] LQI:%d high is good, RSSI:%d high is either good or" + "too much interference.\n", radio_info->lqi, radio_info->rssi); } else { at86rf2xx_fb_stop(dev);