From 6eb1facac5d0da0a1795a2802fc491bf33393be5 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sun, 1 Apr 2018 20:06:16 +0200 Subject: [PATCH] pkg/semtech-loramac: adapt to v4.4.1 --- pkg/semtech-loramac/Makefile | 4 +- pkg/semtech-loramac/Makefile.loramac | 4 +- pkg/semtech-loramac/Makefile.loramac_arch | 2 + pkg/semtech-loramac/Makefile.loramac_crypto | 2 + pkg/semtech-loramac/Makefile.loramac_mac | 3 + pkg/semtech-loramac/Makefile.loramac_region | 3 + pkg/semtech-loramac/contrib/Makefile | 3 +- pkg/semtech-loramac/contrib/semtech_loramac.c | 148 +++++++++--------- .../contrib/semtech_loramac_getset.c | 1 - .../contrib/semtech_loramac_radio.c | 67 +++++--- .../contrib/semtech_loramac_timer.c | 12 +- .../include/semtech-loramac/board.h | 54 ------- pkg/semtech-loramac/include/semtech_loramac.h | 4 +- .../patches/0001-adapt-for-RIOT.patch | Bin 9736 -> 0 bytes .../patches/0001-adapt-to-riot.patch | Bin 0 -> 4521 bytes .../0002-adapt-utilities-to-riot.patch | Bin 0 -> 2091 bytes .../patches/0002-eu868-join-retries.patch | Bin 911 -> 0 bytes .../0003-adapt-utilities-functions.patch | Bin 2006 -> 0 bytes .../0004-fix-uninitialized-variable.patch | Bin 636 -> 0 bytes 19 files changed, 144 insertions(+), 163 deletions(-) delete mode 100644 pkg/semtech-loramac/include/semtech-loramac/board.h delete mode 100644 pkg/semtech-loramac/patches/0001-adapt-for-RIOT.patch create mode 100644 pkg/semtech-loramac/patches/0001-adapt-to-riot.patch create mode 100644 pkg/semtech-loramac/patches/0002-adapt-utilities-to-riot.patch delete mode 100644 pkg/semtech-loramac/patches/0002-eu868-join-retries.patch delete mode 100644 pkg/semtech-loramac/patches/0003-adapt-utilities-functions.patch delete mode 100644 pkg/semtech-loramac/patches/0004-fix-uninitialized-variable.patch diff --git a/pkg/semtech-loramac/Makefile b/pkg/semtech-loramac/Makefile index f6a13c5edb..aab8f6235e 100644 --- a/pkg/semtech-loramac/Makefile +++ b/pkg/semtech-loramac/Makefile @@ -1,6 +1,6 @@ PKG_NAME=semtech-loramac PKG_URL=https://github.com/Lora-net/LoRaMac-node.git -PKG_VERSION=f42be67be402a40b3586724800771bfe13fb18e6 +PKG_VERSION=1cdd9ccec4c9f05b616e7112059be4a9e358c571 PKG_LICENSE=BSD-3-Clause .PHONY: all @@ -10,7 +10,7 @@ all: git-download @cp Makefile.loramac_mac $(PKG_BUILDDIR)/src/mac/Makefile @cp Makefile.loramac_region $(PKG_BUILDDIR)/src/mac/region/Makefile @cp Makefile.loramac_crypto $(PKG_BUILDDIR)/src/system/crypto/Makefile - @cp Makefile.loramac_arch $(PKG_BUILDDIR)/src/boards/mcu/stm32/Makefile + @cp Makefile.loramac_arch $(PKG_BUILDDIR)/src/boards/mcu/Makefile "$(MAKE)" -C $(PKG_BUILDDIR) include $(RIOTBASE)/pkg/pkg.mk diff --git a/pkg/semtech-loramac/Makefile.loramac b/pkg/semtech-loramac/Makefile.loramac index 75be4c5d20..f69a33033f 100644 --- a/pkg/semtech-loramac/Makefile.loramac +++ b/pkg/semtech-loramac/Makefile.loramac @@ -1,10 +1,10 @@ DIRS += src/mac DIRS += src/mac/region DIRS += src/system/crypto -DIRS += src/boards/mcu/stm32 +DIRS += src/boards/mcu INCLUDES += -I$(PKGDIRBASE)/semtech-loramac/src/mac \ - -I$(PKGDIRBASE)/semtech-loramac/src/boards/mcu/stm32 \ + -I$(PKGDIRBASE)/semtech-loramac/src/boards/mcu \ -I$(PKGDIRBASE)/semtech-loramac/src/system/crypto \ -I$(PKGDIRBASE)/semtech-loramac/src diff --git a/pkg/semtech-loramac/Makefile.loramac_arch b/pkg/semtech-loramac/Makefile.loramac_arch index da78e4622e..322226aa18 100644 --- a/pkg/semtech-loramac/Makefile.loramac_arch +++ b/pkg/semtech-loramac/Makefile.loramac_arch @@ -4,4 +4,6 @@ SRCS := utilities.c CFLAGS += -Wno-sign-compare +INCLUDES += -I$(PKGDIRBASE)/semtech-loramac/src/boards + include $(RIOTBASE)/Makefile.base diff --git a/pkg/semtech-loramac/Makefile.loramac_crypto b/pkg/semtech-loramac/Makefile.loramac_crypto index 57f8f7ef1e..d191c20add 100644 --- a/pkg/semtech-loramac/Makefile.loramac_crypto +++ b/pkg/semtech-loramac/Makefile.loramac_crypto @@ -1,3 +1,5 @@ MODULE := semtech_loramac_crypto +INCLUDES += -I$(PKGDIRBASE)/semtech-loramac/src/boards + include $(RIOTBASE)/Makefile.base diff --git a/pkg/semtech-loramac/Makefile.loramac_mac b/pkg/semtech-loramac/Makefile.loramac_mac index 87382dacb0..3fd69001a4 100644 --- a/pkg/semtech-loramac/Makefile.loramac_mac +++ b/pkg/semtech-loramac/Makefile.loramac_mac @@ -2,4 +2,7 @@ MODULE := semtech_loramac_mac CFLAGS += -Wno-sign-compare +INCLUDES += -I$(PKGDIRBASE)/semtech-loramac/src/boards \ + -I$(PKGDIRBASE)/semtech-loramac/src/radio + include $(RIOTBASE)/Makefile.base diff --git a/pkg/semtech-loramac/Makefile.loramac_region b/pkg/semtech-loramac/Makefile.loramac_region index 3d0769944e..1d9ce93aa2 100644 --- a/pkg/semtech-loramac/Makefile.loramac_region +++ b/pkg/semtech-loramac/Makefile.loramac_region @@ -2,4 +2,7 @@ MODULE := semtech_loramac_mac_region CFLAGS += -Wno-missing-field-initializers -Wno-unused-parameter -Wno-sign-compare +INCLUDES += -I$(PKGDIRBASE)/semtech-loramac/src/boards \ + -I$(PKGDIRBASE)/semtech-loramac/src/radio + include $(RIOTBASE)/Makefile.base diff --git a/pkg/semtech-loramac/contrib/Makefile b/pkg/semtech-loramac/contrib/Makefile index a8321f21eb..baadd04b0b 100644 --- a/pkg/semtech-loramac/contrib/Makefile +++ b/pkg/semtech-loramac/contrib/Makefile @@ -1,7 +1,8 @@ MODULE := semtech_loramac_contrib INCLUDES += -I$(PKGDIRBASE)/semtech-loramac/src/mac \ - -I$(PKGDIRBASE)/semtech-loramac/src/boards/mcu/stm32 \ + -I$(PKGDIRBASE)/semtech-loramac/src/boards \ + -I$(PKGDIRBASE)/semtech-loramac/src/radio \ -I$(PKGDIRBASE)/semtech-loramac/src/system/crypto \ -I$(PKGDIRBASE)/semtech-loramac/src diff --git a/pkg/semtech-loramac/contrib/semtech_loramac.c b/pkg/semtech-loramac/contrib/semtech_loramac.c index 0114d65576..468535aacc 100644 --- a/pkg/semtech-loramac/contrib/semtech_loramac.c +++ b/pkg/semtech-loramac/contrib/semtech_loramac.c @@ -38,30 +38,12 @@ #include "sx127x_netdev.h" #include "semtech_loramac.h" -#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "region/Region.h" #define ENABLE_DEBUG (0) #include "debug.h" -#define LORAWAN_MAX_JOIN_RETRIES (3U) - -#if defined(REGION_EU868) -#define LORAWAN_DUTYCYCLE_ON (true) -#define USE_SEMTECH_DEFAULT_CHANNEL_LINEUP (1) - -#if (USE_SEMTECH_DEFAULT_CHANNEL_LINEUP) -#define LC4 { 867100000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } -#define LC5 { 867300000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } -#define LC6 { 867500000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } -#define LC7 { 867700000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } -#define LC8 { 867900000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } -#define LC9 { 868800000, 0, { ( ( DR_7 << 4 ) | DR_7 ) }, 2 } -#define LC10 { 868300000, 0, { ( ( DR_6 << 4 ) | DR_6 ) }, 1 } -#endif /* USE_SEMTECH_DEFAULT_CHANNEL_LINEUP */ -#endif /* REGION_EU868 */ - #define SEMTECH_LORAMAC_MSG_QUEUE (16U) #define SEMTECH_LORAMAC_LORAMAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT) static msg_t _semtech_loramac_msg_queue[SEMTECH_LORAMAC_MSG_QUEUE]; @@ -210,6 +192,20 @@ static void mcps_indication(McpsIndication_t *indication) } } + /* Check Multicast + Check Port + Check Datarate + Check FramePending */ + if (indication->FramePending == true) { + /* The server signals that it has pending data to be sent. + We schedule an uplink as soon as possible to flush the server. */ + DEBUG("[semtech-loramac] MCPS indication: pending data, schedule an " + "uplink\n"); + msg_t msg; + msg.type = MSG_TYPE_LORAMAC_TX_SCHEDULE; + msg_send(&msg, semtech_loramac_pid); + } + msg_t msg; if (indication->RxData) { DEBUG("[semtech-loramac] MCPS indication: data received\n"); @@ -222,7 +218,7 @@ static void mcps_indication(McpsIndication_t *indication) msg_send(&msg, semtech_loramac_pid); } -/*MLME-Confirm event function */ +/* MLME-Confirm event function */ static void mlme_confirm(MlmeConfirm_t *confirm) { DEBUG("[semtech-loramac] MLME confirm event\n"); @@ -260,6 +256,23 @@ static void mlme_confirm(MlmeConfirm_t *confirm) } } +/* MLME-Indication event function */ +static void mlme_indication(MlmeIndication_t *indication) +{ + switch (indication->MlmeIndication) { + case MLME_SCHEDULE_UPLINK: + /* The MAC signals that we shall provide an uplink + as soon as possible */ + DEBUG("[semtech-loramac] MLME indication: schedule an uplink\n"); + msg_t msg; + msg.type = MSG_TYPE_LORAMAC_TX_SCHEDULE; + msg_send(&msg, semtech_loramac_pid); + break; + default: + break; + } +} + void _init_loramac(semtech_loramac_t *mac, LoRaMacPrimitives_t * primitives, LoRaMacCallback_t *callbacks) { @@ -268,59 +281,11 @@ void _init_loramac(semtech_loramac_t *mac, primitives->MacMcpsConfirm = mcps_confirm; primitives->MacMcpsIndication = mcps_indication; primitives->MacMlmeConfirm = mlme_confirm; -#if defined(REGION_AS923) - DEBUG("[semtech-loramac] initialize loramac for AS923 region\n"); + primitives->MacMlmeIndication = mlme_indication; LoRaMacInitialization(&semtech_loramac_radio_events, primitives, callbacks, - LORAMAC_REGION_AS923); -#elif defined(REGION_AU915) - DEBUG("[semtech-loramac] initialize loramac for AU915 region\n"); - LoRaMacInitialization(&semtech_loramac_radio_events, primitives, callbacks, - LORAMAC_REGION_AU915); -#elif defined(REGION_CN779) - DEBUG("[semtech-loramac] initialize loramac for CN779 region\n"); - LoRaMacInitialization(&semtech_loramac_radio_events, primitives, callbacks, - LORAMAC_REGION_CN779); -#elif defined(REGION_EU868) - DEBUG("[semtech-loramac] initialize loramac for EU868 region\n"); - LoRaMacInitialization(&semtech_loramac_radio_events, primitives, callbacks, - LORAMAC_REGION_EU868); -#elif defined(REGION_IN865) - DEBUG("[semtech-loramac] initialize loramac for IN865 region\n"); - LoRaMacInitialization(&semtech_loramac_radio_events, primitives, callbacks, - LORAMAC_REGION_IN865); -#elif defined(REGION_KR920) - DEBUG("[semtech-loramac] initialize loramac for KR920 region\n"); - LoRaMacInitialization(&semtech_loramac_radio_events, primitives, callbacks, - LORAMAC_REGION_KR920); -#elif defined(REGION_US915) - DEBUG("[semtech-loramac] initialize loramac for US915 region\n"); - LoRaMacInitialization(&semtech_loramac_radio_events, primitives, callbacks, - LORAMAC_REGION_US915); -#elif defined(REGION_US915_HYBRID) - DEBUG("[semtech-loramac] initialize loramac for US915 hybrid region\n"); - LoRaMacInitialization(&semtech_loramac_radio_events, primitives, callbacks, - LORAMAC_REGION_US915_HYBRID); -#else -#error "Please define a region in the compiler options." -#endif + LORAMAC_ACTIVE_REGION); mutex_unlock(&mac->lock); -#if defined(REGION_EU868) && USE_SEMTECH_DEFAULT_CHANNEL_LINEUP - DEBUG("[semtech-loramac] EU868 region: use default channels\n"); - mutex_lock(&mac->lock); - LoRaMacChannelAdd(3, (ChannelParams_t)LC4); - LoRaMacChannelAdd(4, (ChannelParams_t)LC5); - LoRaMacChannelAdd(5, (ChannelParams_t)LC6); - LoRaMacChannelAdd(6, (ChannelParams_t)LC7); - LoRaMacChannelAdd(7, (ChannelParams_t)LC8); - LoRaMacChannelAdd(8, (ChannelParams_t)LC9); - LoRaMacChannelAdd(9, (ChannelParams_t)LC10); - mutex_unlock(&mac->lock); - - semtech_loramac_set_rx2_dr(mac, LORAMAC_DEFAULT_RX2_DR); - semtech_loramac_set_rx2_freq(mac, LORAMAC_DEFAULT_RX2_FREQ); -#endif - semtech_loramac_set_dr(mac, LORAMAC_DEFAULT_DR); semtech_loramac_set_adr(mac, LORAMAC_DEFAULT_ADR); semtech_loramac_set_public_network(mac, LORAMAC_DEFAULT_PUBLIC_NETWORK); @@ -334,6 +299,8 @@ static void _join_otaa(semtech_loramac_t *mac) { DEBUG("[semtech-loramac] starting OTAA join\n"); + uint8_t dr = semtech_loramac_get_dr(mac); + mutex_lock(&mac->lock); MibRequestConfirm_t mibReq; mibReq.Type = MIB_NETWORK_JOINED; @@ -345,9 +312,35 @@ static void _join_otaa(semtech_loramac_t *mac) mlmeReq.Req.Join.DevEui = mac->deveui; mlmeReq.Req.Join.AppEui = mac->appeui; mlmeReq.Req.Join.AppKey = mac->appkey; - mlmeReq.Req.Join.NbTrials = LORAWAN_MAX_JOIN_RETRIES; - LoRaMacMlmeRequest(&mlmeReq); - mutex_unlock(&mac->lock); + mlmeReq.Req.Join.Datarate = dr; + uint8_t ret = LoRaMacMlmeRequest(&mlmeReq); + switch(ret) { + case LORAMAC_STATUS_OK: + mutex_unlock(&mac->lock); + return; + case LORAMAC_STATUS_DUTYCYCLE_RESTRICTED: + { + mutex_unlock(&mac->lock); + DEBUG("[semtech-loramac] Duty cycle restricted\n"); + /* Cannot join. */ + msg_t msg; + msg.type = MSG_TYPE_LORAMAC_JOIN; + msg.content.value = SEMTECH_LORAMAC_RESTRICTED; + msg_send(&msg, semtech_loramac_pid); + return; + } + default: + { + mutex_unlock(&mac->lock); + DEBUG("[semtech-loramac] join not successful: %d\n", ret); + /* Cannot join. */ + msg_t msg; + msg.type = MSG_TYPE_LORAMAC_JOIN; + msg.content.value = SEMTECH_LORAMAC_JOIN_FAILED; + msg_send(&msg, semtech_loramac_pid); + return; + } + } } static void _join_abp(semtech_loramac_t *mac) @@ -560,6 +553,15 @@ void *_semtech_loramac_event_loop(void *arg) mac->state = SEMTECH_LORAMAC_STATE_IDLE; break; } + case MSG_TYPE_LORAMAC_TX_SCHEDULE: + { + DEBUG("[semtech-loramac] schedule immediate TX\n"); + uint8_t prev_port = mac->port; + mac->port = 0; + _semtech_loramac_send(mac, NULL, 0); + mac->port = prev_port; + break; + } case MSG_TYPE_LORAMAC_TX_CNF_FAILED: DEBUG("[semtech-loramac] loramac TX failed\n"); msg_t msg_ret; @@ -702,7 +704,7 @@ uint8_t semtech_loramac_recv(semtech_loramac_t *mac) default: ret = SEMTECH_LORAMAC_TX_DONE; break; - } + } DEBUG("[semtech-loramac] MAC reply received: %d\n", ret); diff --git a/pkg/semtech-loramac/contrib/semtech_loramac_getset.c b/pkg/semtech-loramac/contrib/semtech_loramac_getset.c index dda98097f7..e007d77bf8 100644 --- a/pkg/semtech-loramac/contrib/semtech_loramac_getset.c +++ b/pkg/semtech-loramac/contrib/semtech_loramac_getset.c @@ -24,7 +24,6 @@ #include "net/loramac.h" -#include "semtech-loramac/board.h" #include "LoRaMac.h" #define ENABLE_DEBUG (0) diff --git a/pkg/semtech-loramac/contrib/semtech_loramac_radio.c b/pkg/semtech-loramac/contrib/semtech_loramac_radio.c index a81c1ad823..0ba549cd90 100644 --- a/pkg/semtech-loramac/contrib/semtech_loramac_radio.c +++ b/pkg/semtech-loramac/contrib/semtech_loramac_radio.c @@ -26,8 +26,6 @@ #include "sx127x_internal.h" #include "sx127x_netdev.h" -#include "semtech-loramac/board.h" - #include "radio/radio.h" #define ENABLE_DEBUG (0) @@ -35,8 +33,6 @@ extern sx127x_t sx127x; -#define LORAMAC_RX_WINDOW_DURATION (600UL * US_PER_MS) - /* * Radio driver functions implementation wrappers, the netdev2 object * is known within the scope of the function @@ -88,7 +84,6 @@ void SX127XSetRxConfig(RadioModems_t modem, uint32_t bandwidth, bool iqInverted, bool rxContinuous) { (void) bandwidthAfc; - (void) symbTimeout; (void) fixLen; sx127x_set_modem(&sx127x, modem); sx127x_set_bandwidth(&sx127x, bandwidth); @@ -101,9 +96,8 @@ void SX127XSetRxConfig(RadioModems_t modem, uint32_t bandwidth, sx127x_set_freq_hop(&sx127x, freqHopOn); sx127x_set_hop_period(&sx127x, hopPeriod); sx127x_set_iq_invert(&sx127x, iqInverted); - sx127x_set_rx_timeout(&sx127x, LORAMAC_RX_WINDOW_DURATION); + sx127x_set_symbol_timeout(&sx127x, 2 * symbTimeout); sx127x_set_rx_single(&sx127x, !rxContinuous); - sx127x_set_rx(&sx127x); } void SX127XSetTxConfig(RadioModems_t modem, int8_t power, uint32_t fdev, @@ -131,7 +125,7 @@ void SX127XSetTxConfig(RadioModems_t modem, int8_t power, uint32_t fdev, sx127x_set_tx_timeout(&sx127x, timeout * US_PER_MS); /* base unit us, LoRaMAC ms */ } -uint32_t SX127XGetTimeOnAir(RadioModems_t modem, uint8_t pktLen) +uint32_t SX127XTimeOnAir(RadioModems_t modem, uint8_t pktLen) { (void) modem; return sx127x_get_time_on_air(&sx127x, pktLen); @@ -147,19 +141,19 @@ void SX127XSend(uint8_t *buffer, uint8_t size) dev->driver->send(dev, &iol); } -void SX127XSetSleep(void) +void SX127XSleep(void) { sx127x_set_sleep(&sx127x); } -void SX127XSetStby(void) +void SX127XStandby(void) { sx127x_set_standby(&sx127x); } -void SX127XSetRx(uint32_t timeout) +void SX127XRx(uint32_t timeout) { - (void) timeout; + sx127x_set_rx_timeout(&sx127x, timeout * US_PER_MS); sx127x_set_rx(&sx127x); } @@ -168,28 +162,28 @@ void SX127XStartCad(void) sx127x_start_cad(&sx127x); } -int16_t SX127XReadRssi(RadioModems_t modem) +int16_t SX127XRssi(RadioModems_t modem) { sx127x_set_modem(&sx127x, (uint8_t)modem); return sx127x_read_rssi(&sx127x); } -void SX127XWrite(uint8_t addr, uint8_t data) +void SX127XWrite(uint16_t addr, uint8_t data) { sx127x_reg_write(&sx127x, addr, data); } -uint8_t SX127XRead(uint8_t addr) +uint8_t SX127XRead(uint16_t addr) { return sx127x_reg_read(&sx127x, addr); } -void SX127XWriteBuffer(uint8_t addr, uint8_t *buffer, uint8_t size) +void SX127XWriteBuffer(uint16_t addr, uint8_t *buffer, uint8_t size) { sx127x_reg_write_burst(&sx127x, addr, buffer, size); } -void SX127XReadBuffer(uint8_t addr, uint8_t *buffer, uint8_t size) +void SX127XReadBuffer(uint16_t addr, uint8_t *buffer, uint8_t size) { sx127x_reg_read_burst(&sx127x, addr, buffer, size); } @@ -227,6 +221,29 @@ void SX127XSetPublicNetwork(bool enable) } } +uint32_t SX127XGetWakeupTime(void) +{ + return 0; +} + +void SX127XIrqProcess(void) +{ + return; +} + +void SX127XRxBoosted(uint32_t timeout) +{ + (void) timeout; + return; +} + +void SX127XSetRxDutyCycle(uint32_t rx_time, uint32_t sleep_time) +{ + (void) rx_time; + (void) sleep_time; + return; +} + /** * LoRa function callbacks */ @@ -241,18 +258,22 @@ const struct Radio_s Radio = SX127XSetRxConfig, SX127XSetTxConfig, SX127XCheckRfFrequency, - SX127XGetTimeOnAir, + SX127XTimeOnAir, SX127XSend, - SX127XSetSleep, - SX127XSetStby, - SX127XSetRx, + SX127XSleep, + SX127XStandby, + SX127XRx, SX127XStartCad, SX127XSetTxContinuousWave, - SX127XReadRssi, + SX127XRssi, SX127XWrite, SX127XRead, SX127XWriteBuffer, SX127XReadBuffer, SX127XSetMaxPayloadLength, - SX127XSetPublicNetwork + SX127XSetPublicNetwork, + SX127XGetWakeupTime, + SX127XIrqProcess, + SX127XRxBoosted, + SX127XSetRxDutyCycle, }; diff --git a/pkg/semtech-loramac/contrib/semtech_loramac_timer.c b/pkg/semtech-loramac/contrib/semtech_loramac_timer.c index 0c62722c7d..9fda0f40a6 100644 --- a/pkg/semtech-loramac/contrib/semtech_loramac_timer.c +++ b/pkg/semtech-loramac/contrib/semtech_loramac_timer.c @@ -19,9 +19,9 @@ * @} */ -#include "semtech-loramac/board.h" #include "xtimer.h" #include "thread.h" +#include "semtech-loramac/timer.h" extern kernel_pid_t semtech_loramac_pid; @@ -62,27 +62,27 @@ void TimerSetValue(TimerEvent_t *obj, uint32_t value) /* According to the lorawan specifications, the data sent from the gateway could arrive with a short shift in time of +/- 20ms. Here the timeout is - triggered 50ms in advance to make sure the radio switches to RX mode on + triggered 22ms in advance to make sure the radio switches to RX mode on time and doesn't miss any downlink messages. */ - obj->timeout = (value - 50) * 1000; + obj->timeout = (value - 22) * US_PER_MS; } TimerTime_t TimerGetCurrentTime(void) { uint64_t CurrentTime = xtimer_now_usec64(); - return (TimerTime_t)CurrentTime; + return (TimerTime_t)CurrentTime / US_PER_MS; } TimerTime_t TimerGetElapsedTime(TimerTime_t savedTime) { uint64_t CurrentTime = xtimer_now_usec64(); - return (TimerTime_t)(CurrentTime - savedTime); + return (TimerTime_t)(CurrentTime - savedTime) / US_PER_MS; } TimerTime_t TimerGetFutureTime(TimerTime_t eventInFuture) { uint64_t CurrentTime = xtimer_now_usec64(); - return (TimerTime_t)(CurrentTime + eventInFuture); + return (TimerTime_t)(CurrentTime + eventInFuture) / US_PER_MS; } void TimerLowPowerHandler( void ) diff --git a/pkg/semtech-loramac/include/semtech-loramac/board.h b/pkg/semtech-loramac/include/semtech-loramac/board.h deleted file mode 100644 index 279abe2a48..0000000000 --- a/pkg/semtech-loramac/include/semtech-loramac/board.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2017 Fundacion Inria Chile - * 2017 Inria - * - * 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. - */ - -/** - * @ingroup pkg_semtech-loramac - * @brief Internal required Semtech LoRaMAC definitions for radio - * @{ - * - * @file - * - * @author José Ignacio Alamos - * @author Alexandre Abadie - * @author Francisco Molina - */ - -#ifndef SEMTECH_LORAMAC_BOARD_H -#define SEMTECH_LORAMAC_BOARD_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include "semtech-loramac/timer.h" - -/** - * @brief Radio wakeup time from SLEEP mode - */ -#define RADIO_OSC_STARTUP (1U) /* [ms] */ - -/** - * @brief Radio PLL lock and Mode Ready delay which can vary with the temperature - */ -#define RADIO_SLEEP_TO_RX (2U) /* [ms] */ - -/** - * @brief Radio complete Wake-up Time with margin for temperature compensation - */ -#define RADIO_WAKEUP_TIME ( RADIO_OSC_STARTUP + RADIO_SLEEP_TO_RX ) - -#ifdef __cplusplus -} -#endif - -#endif /* SEMTECH_LORAMAC_BOARD_H */ -/** @} */ diff --git a/pkg/semtech-loramac/include/semtech_loramac.h b/pkg/semtech-loramac/include/semtech_loramac.h index c0e07750cf..f9aaff738c 100644 --- a/pkg/semtech-loramac/include/semtech_loramac.h +++ b/pkg/semtech-loramac/include/semtech_loramac.h @@ -46,6 +46,7 @@ extern "C" { #define MSG_TYPE_LORAMAC_RX (0x3463) /**< Some data received */ #define MSG_TYPE_LORAMAC_LINK_CHECK (0x3464) /**< Link check info received */ #define MSG_TYPE_LORAMAC_TX_CNF_FAILED (0x3465) /**< MAC TX confirmed failed */ +#define MSG_TYPE_LORAMAC_TX_SCHEDULE (0x3466) /**< MAC TX schedule */ /** @} */ /** @@ -64,7 +65,8 @@ enum { SEMTECH_LORAMAC_TX_DONE, /**< Transmission completed */ SEMTECH_LORAMAC_TX_CNF_FAILED, /**< Confirmable transmission failed */ SEMTECH_LORAMAC_DATA_RECEIVED, /**< Data received */ - SEMTECH_LORAMAC_BUSY /**< Internal MAC is busy */ + SEMTECH_LORAMAC_BUSY, /**< Internal MAC is busy */ + SEMTECH_LORAMAC_RESTRICTED /**< Restricted access to channels */ }; /** diff --git a/pkg/semtech-loramac/patches/0001-adapt-for-RIOT.patch b/pkg/semtech-loramac/patches/0001-adapt-for-RIOT.patch deleted file mode 100644 index ab230c87840bd3132f9b8db55bcdcb5fbbd90e37..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9736 zcmeHNQFEh45`I_J{)axN>dLk(3o_O@1$wY$#RmQRwCt4dO;0S1di2Hk)hJIVd` z>ltQ1$P(sZQ+HJ{WhBw_(aiMM)7>-p1556~HT$NaQ-?af<>PNB^!kLjerUKJaY-2J zmeJEa7p{^RrgQ~{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1?zlb$Bc-N2@4gD>xB?bIa>qP_Y0hJWUvMWK?8&YiFAXboQT}_E0 Pm=Tx*%y)U@a>o7ve;8A~ literal 0 HcmV?d00001 diff --git a/pkg/semtech-loramac/patches/0002-eu868-join-retries.patch b/pkg/semtech-loramac/patches/0002-eu868-join-retries.patch deleted file mode 100644 index 6365d3698da32de54288885fe592b56d7a3664d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 911 zcmah{+isgc5Pe@M|8O2{W3I-4X%yMLM2Xe9R_s=)s>)hm*4dPRwLp}p?Z0<%Y?b;U zSs@KOoXgBGm#VynA0`u#aBq}QCPYA9G!6qVbiIkogOrDpal}U{=lE0>SkVq{2*-){ z4?M?l*`=0=G0W+Z7nvf=5}rxIIX`ABzRyf$p(MA2x?t~lO>wI@M1(mnw2&LYbz*-U zdl3xBbsV;8k~>Q47~hw(^}DMd;Au*`8a&T&SIPp4Y9*<{1J4^BbmqgCD2Ny{O_QNg zseR8=ThUgQg?+ORdw`YVH$oVO#mg#HQo zl-(-mm1tA}p-J@S1h0$x&n;2Je`=7?5|76obl2>#Sp)k7b+D;b)4CkF=(eAc;7wk4 R+ih{D1)5-<<@%P(*k9|S_}l;h diff --git a/pkg/semtech-loramac/patches/0003-adapt-utilities-functions.patch b/pkg/semtech-loramac/patches/0003-adapt-utilities-functions.patch deleted file mode 100644 index 9b03b14d182c7765e95bb7ea0207035a7b9811ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2006 zcmbtU+iu%N5Pe_3|1eb$m=wj!k}^dpHyaMpps0hO&RbCgOL8e~KrW5tGEtJ|-#fb^ zb#dJ$XbF=bk7v%DIWwzQs%?PMdBUn?97kCaEh83Xi(yzj%ilGO)KG+ z-vM1f6s_zZ#8E`aE2LS$Rn50dmWsnw&Pu`IDI1Z1S>#ekC0J0Y=j0{Rd}3C^k&4d5Ich5VGUS)^a>| z2FV;sUh^H`yM&aYs=)WxLIVrGt0Vtz2obX6TgbAM#>qtx@FZF0>;ll2bUruj{y-gq zox%^)y1WFR&Sx2T_@oiw_YD(LF(4sgWqv*PPkeTHi#IxUzaFb&TL zJQA{~`w}PL>9Q7iuz7wT6|DvRedxrFE7(lVh_?qZUkSOsmp?fS@-%$X@kaAv%+zcXT-Rc z%x4!dcu6{oGh-W?mc;M1WuXpyY()t!F$L|bWkkFm<2ueU0RR2OtS4j*iLqDXPwD+z~a z*JNW8E<8rG!Ehgt0X#f6E8+-*vq!wHM}YAJ`d() z=<&4d^b86-{@NO9F+6%R`$ba>>BJX)(#)p~9&E?rc!JP)Yx-!uan7*fsd)xdr1Ct| ziGj@^@U|W8lsLA$t!K)(82ON3wAr-!Uj<_k)MB0jnAX5e{9GqJ;@%Ety0sI z%>~EczVDh9G^o9d3uw@h3l>HPj1&8PMkhM1|2C7c;g75~Kk?@Ce~-g*ja?7Z@Np=E zw{JwA*F1jBx7QnXWXI$2_X?wiC8%02Sv8d>eU(qHXx^+<;u6NqC-zw`hw6{5aD3OvBrcbBxyWO;(QF(EoJ*_0nwn8~#0T z?@sV6#?|TO;Nw)_xaA$wuZzjSd_0;LT+&dxY$CklnsAC$)ed#hymP2%yX6Mc@a3L@ d9ChP=;sfNxfxg4Mh}^|Z##e!e0;K~f#1q>6t_%PG