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:
commit
d562af40e6
46
drivers/include/net/netdev/lora.h
Normal file
46
drivers/include/net/netdev/lora.h
Normal 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 */
|
||||
/** @} */
|
||||
@ -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
|
||||
|
||||
@ -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 */
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user