From 893707a590fe3883b487ebde5c74810a5c49920e Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Fri, 8 Mar 2019 17:45:08 +0100 Subject: [PATCH 1/5] netdev/lora: add netdev_lora_rx_info structure --- drivers/include/net/netdev/lora.h | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 drivers/include/net/netdev/lora.h diff --git a/drivers/include/net/netdev/lora.h b/drivers/include/net/netdev/lora.h new file mode 100644 index 000000000000..fa9cb2b027f0 --- /dev/null +++ b/drivers/include/net/netdev/lora.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2019 HAW Hamburg + * + * This file is subject to the terms and conditions of the GNU Lesser General + * Public License v2.1. See the file LICENSE in the top level directory for + * more details. + */ + +/** + * @defgroup drivers_netdev_lora LoRa drivers + * @ingroup drivers_netdev_api + * @{ + * + * @file + * @brief Definitions for netdev common LoRa code + * + * @author José Ignacio Alamos + */ + + +#ifndef NET_NETDEV_LORA_H +#define NET_NETDEV_LORA_H + +#include + +#include "net/netdev.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Received LoRa packet status information + */ +typedef struct { + uint8_t rssi; /**< RSSI of a received packet */ + int8_t snr; /**< S/N ratio */ +} netdev_lora_rx_info_t; + + +#ifdef __cplusplus +} +#endif + +#endif /* NET_NETDEV_LORA_H */ +/** @} */ From 80ae186d7a884636f01d419cdb9a5879762bc97f Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Fri, 8 Mar 2019 17:47:05 +0100 Subject: [PATCH 2/5] drivers/sx127x: use netdev_lora_rx_info structure for RX info --- drivers/sx127x/sx127x_netdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/sx127x/sx127x_netdev.c b/drivers/sx127x/sx127x_netdev.c index e9c533719ed8..c94772077efd 100644 --- a/drivers/sx127x/sx127x_netdev.c +++ b/drivers/sx127x/sx127x_netdev.c @@ -23,6 +23,7 @@ #include "net/netopt.h" #include "net/netdev.h" +#include "net/netdev/lora.h" #include "net/lora.h" #include "sx127x_registers.h" @@ -138,10 +139,8 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info) return -EBADMSG; } - netdev_sx127x_lora_packet_info_t *packet_info = info; + netdev_lora_rx_info_t *packet_info = info; if (packet_info) { - /* there is no LQI for LoRa */ - packet_info->lqi = 0; uint8_t snr_value = sx127x_reg_read(dev, SX127X_REG_LR_PKTSNRVALUE); if (snr_value & 0x80) { /* The SNR is negative */ /* Invert and divide by 4 */ From dd2e0bb7a708fe2302a4a6269e0c33a40fc19de1 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Fri, 8 Mar 2019 17:47:22 +0100 Subject: [PATCH 3/5] pkg/semtech_loramac: use netdev_lora_rx_info structure for RX info --- pkg/semtech-loramac/contrib/semtech_loramac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/semtech-loramac/contrib/semtech_loramac.c b/pkg/semtech-loramac/contrib/semtech_loramac.c index 7e14f352426d..d9620ef294d8 100644 --- a/pkg/semtech-loramac/contrib/semtech_loramac.c +++ b/pkg/semtech-loramac/contrib/semtech_loramac.c @@ -31,6 +31,7 @@ #include "mutex.h" #include "net/netdev.h" +#include "net/netdev/lora.h" #include "net/loramac.h" #include "sx127x.h" @@ -579,7 +580,7 @@ static void _semtech_loramac_call(semtech_loramac_func_t func, void *arg) static void _semtech_loramac_event_cb(netdev_t *dev, netdev_event_t event) { - netdev_sx127x_lora_packet_info_t packet_info; + netdev_lora_rx_info_t packet_info; msg_t msg; msg.content.ptr = dev; From 2fd59067b48294cf91073020c25877d22734c34b Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Fri, 8 Mar 2019 17:47:43 +0100 Subject: [PATCH 4/5] drivers/sx127x: remove netdev_sx127x_lora_packet_info structure --- drivers/sx127x/include/sx127x_netdev.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/sx127x/include/sx127x_netdev.h b/drivers/sx127x/include/sx127x_netdev.h index 7d3c8ec71646..45ec875b3479 100644 --- a/drivers/sx127x/include/sx127x_netdev.h +++ b/drivers/sx127x/include/sx127x_netdev.h @@ -31,15 +31,6 @@ extern "C" { */ extern const netdev_driver_t sx127x_driver; -/** - * @brief Received LoRa packet status information - */ -typedef struct netdev_radio_lora_packet_info { - uint8_t rssi; /**< RSSI of a received packet */ - uint8_t lqi; /**< LQI of a received packet */ - int8_t snr; /**< S/N ratio */ -} netdev_sx127x_lora_packet_info_t; - #ifdef __cplusplus } #endif From d3de1d7aec3f601bde93695c2500dc4264b6450d Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 8 Mar 2019 18:20:34 +0100 Subject: [PATCH 5/5] tests/driver_sx127x: use netdev_lora_rx_info structure for RX info --- tests/driver_sx127x/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/driver_sx127x/main.c b/tests/driver_sx127x/main.c index 5261b869d223..c46fe0fa839f 100644 --- a/tests/driver_sx127x/main.c +++ b/tests/driver_sx127x/main.c @@ -32,6 +32,7 @@ #include "shell_commands.h" #include "net/netdev.h" +#include "net/netdev/lora.h" #include "net/lora.h" #include "board.h" @@ -324,7 +325,7 @@ static void _event_cb(netdev_t *dev, netdev_event_t event) } else { size_t len; - netdev_sx127x_lora_packet_info_t packet_info; + netdev_lora_rx_info_t packet_info; switch (event) { case NETDEV_EVENT_RX_COMPLETE: len = dev->driver->recv(dev, NULL, 0, 0);