1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #17497 from jia200x/pr/lora/fix_rssi_val

[treewide] lora: use int16_t for RSSI value
This commit is contained in:
Alexandre Abadie 2022-01-17 18:57:37 +01:00 committed by GitHub
commit 75f5048b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 15 deletions

View File

@ -372,7 +372,7 @@ static int _atwinc15x0_get(netdev_t *netdev, netopt_t opt, void *val,
return sizeof(uint16_t);
case NETOPT_RSSI:
assert(max_len == sizeof(int8_t));
assert(max_len == sizeof(int16_t));
_rssi_info_ready = false;
/* trigger the request current RSSI (asynchronous function) */
if (m2m_wifi_req_curr_rssi() != M2M_SUCCESS) {
@ -384,8 +384,8 @@ static int _atwinc15x0_get(netdev_t *netdev, netopt_t opt, void *val,
ztimer_sleep(ZTIMER_MSEC, ATWINC15X0_WAIT_TIME_MS);
}
/* return the RSSI */
*((int8_t *)val) = dev->rssi;
return sizeof(int8_t);
*((int16_t *)val) = dev->rssi;
return sizeof(int16_t);
default:
return netdev_eth_get(netdev, opt, val, max_len);

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