1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 22:43:50 +01:00

Merge pull request #11144 from jia200x/pr/netdev_lora_rx_info

netdev/lora: add netdev_lora_rx_info structure for RX info
This commit is contained in:
Alexandre Abadie 2019-03-08 18:36:02 +01:00 committed by GitHub
commit d562af40e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 14 deletions

View File

@ -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 <jose.alamos@haw-hamburg.de>
*/
#ifndef NET_NETDEV_LORA_H
#define NET_NETDEV_LORA_H
#include <stdint.h>
#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 */
/** @} */

View File

@ -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

View File

@ -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"
@ -119,10 +120,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 */

View File

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

View File

@ -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_STARTED:
puts("Data reception started");