29#ifndef _lmic_bandplan_h_
30# define _lmic_bandplan_h_
37# include "lmic_bandplan_eu868.h"
38#elif defined(CFG_us915)
39# include "lmic_bandplan_us915.h"
40#elif defined(CFG_au915)
41# include "lmic_bandplan_au915.h"
42#elif defined(CFG_as923)
43# include "lmic_bandplan_as923.h"
44#elif defined(CFG_kr920)
45# include "lmic_bandplan_kr920.h"
46#elif defined(CFG_in866)
47# include "lmic_bandplan_in866.h"
49# error "CFG_... not properly set for bandplan"
53#ifndef DNW2_SAFETY_ZONE
54# error "DNW2_SAFETY_ZONE not defined by bandplan"
57#ifndef LMICbandplan_maxFrameLen
58# error "LMICbandplan_maxFrameLen() not defined by bandplan"
62# error "pow2dBm() not defined by bandplan"
66# error "dr2hsym() not defined by bandplan"
69#if !defined(LMICbandplan_isValidBeacon1) && !defined(DISABLE_BEACONS)
70# error "LMICbandplan_isValidBeacon1 not defined by bandplan"
73#if !defined(LMICbandplan_isFSK)
74# error "LMICbandplan_isFSK() not defined by bandplan"
77#if !defined(LMICbandplan_txDoneFSK)
78# error "LMICbandplan_txDoneFSK() not defined by bandplan"
81#if !defined(LMICbandplan_joinAcceptChannelClear)
82# error "LMICbandplan_joinAcceptChannelClear() not defined by bandplan"
85#if !defined(LMICbandplan_getInitialDrJoin)
86# error "LMICbandplan_getInitialDrJoin() not defined by bandplan"
89#if !defined(LMICbandplan_hasJoinCFlist)
90# error "LMICbandplan_hasJoinCFlist() not defined by bandplan"
93#if !defined(LMICbandplan_advanceBeaconChannel)
94# error "LMICbandplan_advanceBeaconChannel() not defined by bandplan"
97#if !defined(LMICbandplan_resetDefaultChannels)
98# error "LMICbandplan_resetDefaultChannels() not defined by bandplan"
101#if !defined(LMICbandplan_setSessionInitDefaultChannels)
102# error "LMICbandplan_setSessionInitDefaultChannels() not defined by bandplan"
105#if !defined(LMICbandplan_setBcnRxParams)
106# error "LMICbandplan_setBcnRxParams() not defined by bandplan"
109#if !defined(LMICbandplan_canMapChannels)
110# error "LMICbandplan_canMapChannels() not defined by bandplan"
113#if !defined(LMICbandplan_mapChannels)
114# error "LMICbandplan_mapChannels() not defined by bandplan"
117#if !defined(LMICbandplan_convFreq)
118# error "LMICbandplan_convFreq() not defined by bandplan"
121#if !defined(LMICbandplan_queryMaxRx1DrOffset)
122# error "LMICbandplan_queryMaxRx1DrOffset() not defined by bandplan"
125#if !defined(LMICbandplan_setRx1Params)
126# error "LMICbandplan_setRx1Params() not defined by bandplan"
129#if !defined(LMICbandplan_initJoinLoop)
130# error "LMICbandplan_initJoinLoop() not defined by bandplan"
133#if !defined(LMICbandplan_nextTx)
134# error "LMICbandplan_nextTx() not defined by bandplan"
137#if !defined(LMICbandplan_updateTx)
138# error "LMICbandplan_updateTx() not defined by bandplan"
141#if !defined(LMICbandplan_nextJoinState)
142# error "LMICbandplan_nextJoinState() not defined by bandplan"
145#if !defined(LMICbandplan_initDefaultChannels)
146# error "LMICbandplan_initDefaultChannels() not defined by bandplan"
149#if !defined(LMICbandplan_nextJoinTime)
150# error "LMICbandplan_nextJoinTime() not defined by bandplan"
153#if !defined(LMICbandplan_init)
154# error "LMICbandplan_init() not defined by bandplan"
157#if !defined(LMICbandplan_saveAdrState)
158# error "LMICbandplan_saveAdrState() not defined by bandplan"
161#if !defined(LMICbandplan_compareAdrState)
162# error "LMICbandplan_compareAdrState() not defined by bandplan"
165#if !defined(LMICbandplan_restoreAdrState)
166# error "LMICbandplan_restoreAdrState() not defined by bandplan"
169#if !defined(LMICbandplan_isDataRateFeasible)
170# error "LMICbandplan_isDataRateFeasible() not defined by bandplan"
173#if !defined(LMICbandplan_validDR)
174# error "LMICbandplan_validDR() not defined by bandplan"
177#if !defined(LMICbandplan_processJoinAcceptCFList)
178# error "LMICbandplan_processJoinAcceptCFList() not defined by bandplan"
184#define LMICbandplan_MINRX_SYMS_LoRa_ClassA 6
185#define LMICbandplan_RX_ERROR_ABS_osticks ms2osticks(10)
192#define LMICbandplan_RX_EXTRA_MARGIN_osticks us2osticks(2000)
198#define LMICbandplan_MINRX_SYMS_LoRa_ClassB 5
200#define LMICbandplan_PAMBL_SYMS 8
201#define LMICbandplan_PAMBL_FSK 5
202#define LMICbandplan_PRERX_FSK 1
203#define LMICbandplan_RXLEN_FSK (1+5+2)
206#if !defined(MINRX_SYMS)
207# define MINRX_SYMS LMICbandplan_MINRX_SYMS_LoRa_ClassB
209#define PAMBL_SYMS LMICbandplan_PAMBL_SYMS
210#define PAMBL_FSK LMICbandplan_PAMBL_FSK
211#define PRERX_FSK LMICbandplan_PRERX_FSK
212#define RXLEN_FSK LMICbandplan_RXLEN_FSK
215#if !defined(LMICbandplan_MAX_FCNT_GAP)
216# define LMICbandplan_MAX_FCNT_GAP 16384
220#if !defined(LMICbandplan_TX_RECOVERY_ms)
221# define LMICbandplan_TX_RECOVERY_ms 500
224#define BCN_INTV_osticks sec2osticks(BCN_INTV_sec)
225#define TXRX_GUARD_osticks ms2osticks(TXRX_GUARD_ms)
226#define JOIN_GUARD_osticks ms2osticks(JOIN_GUARD_ms)
227#define DELAY_JACC1_osticks sec2osticks(DELAY_JACC1)
228#define DELAY_JACC2_osticks sec2osticks(DELAY_JACC2)
229#define DELAY_EXTDNW2_osticks sec2osticks(DELAY_EXTDNW2)
230#define BCN_RESERVE_osticks ms2osticks(BCN_RESERVE_ms)
231#define BCN_GUARD_osticks ms2osticks(BCN_GUARD_ms)
232#define BCN_WINDOW_osticks ms2osticks(BCN_WINDOW_ms)
233#define AIRTIME_BCN_osticks us2osticks(AIRTIME_BCN)
236#define isTESTMODE() 0
239ostime_t LMICcore_rndDelay(u1_t secSpan);
240void LMICcore_setDrJoin(u1_t reason, u1_t dr);
248static inline bit_t validDR (dr_t dr) {
return LMICbandplan_validDR(dr); }
251extern CONST_TABLE(u1_t, _DR2RPS_CRC)[];
253static inline rps_t updr2rps (dr_t dr) {
return (rps_t)TABLE_GET_U1(_DR2RPS_CRC, dr+1); }
254static inline rps_t dndr2rps (dr_t dr) {
return setNocrc(updr2rps(dr),1); }
255static inline dr_t incDR (dr_t dr) {
return TABLE_GET_U1(_DR2RPS_CRC, dr+2)==ILLEGAL_RPS ? dr : (dr_t)(dr+1); }
256static inline dr_t decDR (dr_t dr) {
return TABLE_GET_U1(_DR2RPS_CRC, dr )==ILLEGAL_RPS ? dr : (dr_t)(dr-1); }
257static inline dr_t assertDR (dr_t dr) {
return TABLE_GET_U1(_DR2RPS_CRC, dr+1)==ILLEGAL_RPS ? (dr_t)DR_DFLTMIN : dr; }
258static inline dr_t lowerDR (dr_t dr, u1_t n) {
while(n--){dr=decDR(dr);}
return dr; }
ostime_t LMICcore_adjustForDrift(ostime_t delay, ostime_t hsym, rxsyms_t rxsyms_in)
Adjust the delay (in ticks) of the target window-open time from nominal.
Definition lmic.c:1431