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

gnrc_lorawan: add support for RTT

This commit is contained in:
Jose Alamos 2020-07-20 13:25:50 +02:00 committed by Jose Alamos
parent 2f680eaf01
commit dfacff9568
No known key found for this signature in database
GPG Key ID: F483EB800EF89DD9
5 changed files with 10 additions and 37 deletions

View File

@ -34,18 +34,6 @@ extern "C" {
* @ingroup net_gnrc_conf
* @{
*/
/**
* @brief maximum timer drift in per mille
*
* @note this is only a workaround to compensate inaccurate timers.
*
* E.g a value of 1 means there's a positive drift of 0.1% (set timeout to
* 1000 ms => triggers after 1001 ms)
*/
#ifndef CONFIG_GNRC_LORAWAN_TIMER_DRIFT
#define CONFIG_GNRC_LORAWAN_TIMER_DRIFT 10
#endif
/**
* @brief the minimum symbols to detect a LoRa preamble
*/

View File

@ -20,7 +20,7 @@
#include "net/gnrc/lorawan.h"
#include "xtimer.h"
#include "ztimer.h"
#ifdef __cplusplus
extern "C" {
@ -41,8 +41,8 @@ typedef struct {
uint8_t deveui[LORAMAC_DEVEUI_LEN]; /**< Device EUI buffer */
uint8_t appeui[LORAMAC_APPEUI_LEN]; /**< App EUI buffer */
gnrc_lorawan_t mac; /**< gnrc lorawan mac descriptor */
xtimer_t timer; /**< General purpose timer */
xtimer_t backoff_timer; /**< Backoff timer */
ztimer_t timer; /**< General purpose timer */
ztimer_t backoff_timer; /**< Backoff timer */
uint8_t flags; /**< flags for the LoRaWAN interface */
uint8_t demod_margin; /**< value of last demodulation margin */
uint8_t num_gateways; /**< number of gateways of last link check */

View File

@ -25,7 +25,7 @@ ifneq (,$(filter gnrc_gomach,$(USEMODULE)))
endif
ifneq (,$(filter gnrc_lorawan,$(USEMODULE)))
USEMODULE += xtimer
USEMODULE += ztimer_msec
USEMODULE += random
USEMODULE += hashes
USEMODULE += crypto_aes_128

View File

@ -16,16 +16,6 @@ menuconfig KCONFIG_USEMODULE_GNRC_LORAWAN
if KCONFIG_USEMODULE_GNRC_LORAWAN
config GNRC_LORAWAN_TIMER_DRIFT
int "Maximum timer drift"
default 10
range -1000 1000
help
The value is expressed in per mille. This is only a workaround to
compensate inaccurate timers. E.g. a value of 1 means there's a
positive drift of 0.1% (set timeout to 1000 ms => triggers after
1001 ms)
config GNRC_LORAWAN_MIN_SYMBOLS_TIMEOUT
int "Minimum symbols to detect a LoRa preamble"
default 30

View File

@ -32,11 +32,6 @@
#define MSG_TYPE_MLME_BACKOFF_EXPIRE (0x3458) /**< Backoff timer expiration message type */
/* This factor is used for converting "real" seconds into microcontroller
* microseconds. This is done in order to correct timer drift.
*/
#define ADJUST_DRIFT(us) (int) (us * 100 / (100 + (CONFIG_GNRC_LORAWAN_TIMER_DRIFT / 10.0)))
static uint8_t _nwkskey[LORAMAC_NWKSKEY_LEN];
static uint8_t _appskey[LORAMAC_APPSKEY_LEN];
static uint8_t _appkey[LORAMAC_APPKEY_LEN];
@ -86,13 +81,13 @@ void gnrc_lorawan_mlme_confirm(gnrc_lorawan_t *mac, mlme_confirm_t *confirm)
void gnrc_lorawan_set_timer(gnrc_lorawan_t *mac, uint32_t us)
{
gnrc_netif_lorawan_t *lw_netif = container_of(mac, gnrc_netif_lorawan_t, mac);
xtimer_set_msg(&lw_netif->timer, ADJUST_DRIFT(us), &timeout_msg, thread_getpid());
ztimer_set_msg(ZTIMER_MSEC, &lw_netif->timer, us/1000, &timeout_msg, thread_getpid());
}
void gnrc_lorawan_remove_timer(gnrc_lorawan_t *mac)
{
gnrc_netif_lorawan_t *lw_netif = container_of(mac, gnrc_netif_lorawan_t, mac);
xtimer_remove(&lw_netif->timer);
ztimer_remove(ZTIMER_MSEC, &lw_netif->timer);
}
static inline void _set_be_addr(gnrc_lorawan_t *mac, uint8_t *be_addr)
@ -252,8 +247,8 @@ static void _init(gnrc_netif_t *netif)
_set_be_addr(&netif->lorawan.mac, _devaddr);
gnrc_lorawan_init(&netif->lorawan.mac, netif->lorawan.nwkskey, netif->lorawan.appskey);
xtimer_set_msg(&netif->lorawan.backoff_timer,
GNRC_LORAWAN_BACKOFF_WINDOW_TICK,
ztimer_set_msg(ZTIMER_MSEC, &netif->lorawan.backoff_timer,
GNRC_LORAWAN_BACKOFF_WINDOW_TICK / 1000,
&backoff_msg, thread_getpid());
}
@ -305,8 +300,8 @@ static void _msg_handler(gnrc_netif_t *netif, msg_t *msg)
break;
case MSG_TYPE_MLME_BACKOFF_EXPIRE:
gnrc_lorawan_mlme_backoff_expire_cb(&netif->lorawan.mac);
xtimer_set_msg(&netif->lorawan.backoff_timer,
GNRC_LORAWAN_BACKOFF_WINDOW_TICK,
ztimer_set_msg(ZTIMER_MSEC, &netif->lorawan.backoff_timer,
GNRC_LORAWAN_BACKOFF_WINDOW_TICK / 1000,
&backoff_msg, thread_getpid());
default:
break;