1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00

[treewide] lora: use int16_t for RSSI value

The RSSI values reported by LoRa transceiver can be less than -127.
Therefore, `int8_t` is not enough. This commit defines the RSSI of
`netdev_lora_rx_info` as `int16_t` and adapt the drivers accordingly
(sx126x, sx127x).
This commit is contained in:
Jose Alamos 2022-01-10 13:13:44 +01:00
parent f33b3ad10d
commit 9955a35c63
No known key found for this signature in database
GPG Key ID: F483EB800EF89DD9
6 changed files with 11 additions and 12 deletions

View File

@ -32,7 +32,7 @@ extern "C" {
* @brief Received LoRa packet status information
*/
typedef struct {
uint8_t rssi; /**< RSSI of a received packet */
int16_t rssi; /**< RSSI of a received packet */
int8_t snr; /**< S/N ratio */
} netdev_lora_rx_info_t;

View File

@ -291,9 +291,9 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
return sizeof(netopt_enable_t);
case NETOPT_RSSI:
assert(max_len >= sizeof(int8_t));
assert(max_len >= sizeof(int16_t));
sx126x_get_rssi_inst(dev, ((int16_t *)val));
return sizeof(int8_t);
return sizeof(int16_t);
default:
break;

View File

@ -345,9 +345,9 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
return sizeof(netopt_enable_t);
case NETOPT_RSSI:
assert(max_len >= sizeof(int8_t));
*((int8_t *)val) = sx127x_read_rssi(dev);
return sizeof(int8_t);
assert(max_len >= sizeof(int16_t));
*((int16_t *)val) = sx127x_read_rssi(dev);
return sizeof(int16_t);
default:
break;

View File

@ -205,8 +205,8 @@ void SX127XStartCad(void)
int16_t SX127XRssi(RadioModems_t modem)
{
(void)modem;
int8_t rssi;
loramac_netdev_ptr->driver->get(loramac_netdev_ptr, NETOPT_RSSI, &rssi, sizeof(int8_t));
int16_t rssi;
loramac_netdev_ptr->driver->get(loramac_netdev_ptr, NETOPT_RSSI, &rssi, sizeof(int16_t));
return rssi;
}

View File

@ -772,7 +772,7 @@ typedef enum {
NETOPT_LINK_CHECK,
/**
* @brief (int8_t) Received Signal Strength Indicator (RSSI)
* @brief (int16_t) Received Signal Strength Indicator (RSSI)
*
* The RSSI is an indicator for the received field strength in wireless
* channels. It is often represented as the ratio of received power to

View File

@ -607,7 +607,6 @@ static void _netif_list(netif_t *iface)
uint16_t u16;
int16_t i16;
uint8_t u8;
int8_t i8;
int res;
netopt_state_t state;
unsigned line_thresh = 1;
@ -639,9 +638,9 @@ static void _netif_list(netif_t *iface)
if (res >= 0) {
printf(" NID: 0x%" PRIx16 " ", u16);
}
res = netif_get_opt(iface, NETOPT_RSSI, 0, &i8, sizeof(i8));
res = netif_get_opt(iface, NETOPT_RSSI, 0, &i16, sizeof(i16));
if (res >= 0) {
printf(" RSSI: %d ", i8);
printf(" RSSI: %d ", i16);
}
#ifdef MODULE_GNRC_NETIF_CMD_LORA
res = netif_get_opt(iface, NETOPT_BANDWIDTH, 0, &u8, sizeof(u8));