sys/net: add NETOPT_RSSI for wireless channels

This commit is contained in:
Gunar Schorcht 2020-03-31 07:29:01 +02:00
parent 660a852935
commit c95ebb63b4
3 changed files with 17 additions and 0 deletions

View File

@ -729,6 +729,17 @@ typedef enum {
*/ */
NETOPT_LINK_CHECK, NETOPT_LINK_CHECK,
/**
* @brief (int8_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
* a given unit, for example milliwatts. With a device-dependent scaling
* factor, the RSSI value can be expressed as power level in the unit
* dBm or ASU (Arbitrary Strength Unit).
*/
NETOPT_RSSI,
/** /**
* @brief maximum number of options defined here. * @brief maximum number of options defined here.
* *

View File

@ -120,6 +120,7 @@ static const char *_netopt_strmap[] = {
[NETOPT_DEMOD_MARGIN] = "NETOPT_DEMOD_MARGIN", [NETOPT_DEMOD_MARGIN] = "NETOPT_DEMOD_MARGIN",
[NETOPT_NUM_GATEWAYS] = "NETOPT_NUM_GATEWAYS", [NETOPT_NUM_GATEWAYS] = "NETOPT_NUM_GATEWAYS",
[NETOPT_LINK_CHECK] = "NETOPT_LINK_CHECK", [NETOPT_LINK_CHECK] = "NETOPT_LINK_CHECK",
[NETOPT_RSSI] = "NETOPT_RSSI",
[NETOPT_NUMOF] = "NETOPT_NUMOF", [NETOPT_NUMOF] = "NETOPT_NUMOF",
}; };

View File

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