1 /*!
2 * \file Region.c
3 *
4 * \brief Region implementation.
5 *
6 * \copyright Revised BSD License, see section \ref LICENSE.
7 *
8 * \code
9 * ______ _
10 * / _____) _ | |
11 * ( (____ _____ ____ _| |_ _____ ____| |__
12 * \____ \| ___ | (_ _) ___ |/ ___) _ \
13 * _____) ) ____| | | || |_| ____( (___| | | |
14 * (______/|_____)_|_|_| \__)_____)\____)_| |_|
15 * (C)2013-2017 Semtech
16 *
17 * ___ _____ _ ___ _ _____ ___ ___ ___ ___
18 * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
19 * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
20 * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
21 * embedded.connectivity.solutions===============
22 *
23 * \endcode
24 *
25 * \author Miguel Luis ( Semtech )
26 *
27 * \author Gregory Cristian ( Semtech )
28 *
29 * \author Daniel Jaeckle ( STACKFORCE )
30 */
31 #include "LoRaMac.h"
32
33 // Setup regions
34 #ifdef REGION_AS923
35 #include "RegionAS923.h"
36 #define AS923_CASE case LORAMAC_REGION_AS923:
37 #define AS923_IS_ACTIVE( ) AS923_CASE { return true; }
38 #define AS923_GET_PHY_PARAM( ) AS923_CASE { return RegionAS923GetPhyParam( getPhy ); }
39 #define AS923_SET_BAND_TX_DONE( ) AS923_CASE { RegionAS923SetBandTxDone( txDone ); break; }
40 #define AS923_INIT_DEFAULTS( ) AS923_CASE { RegionAS923InitDefaults( params ); break; }
41 #define AS923_VERIFY( ) AS923_CASE { return RegionAS923Verify( verify, phyAttribute ); }
42 #define AS923_APPLY_CF_LIST( ) AS923_CASE { RegionAS923ApplyCFList( applyCFList ); break; }
43 #define AS923_CHAN_MASK_SET( ) AS923_CASE { return RegionAS923ChanMaskSet( chanMaskSet ); }
44 #define AS923_COMPUTE_RX_WINDOW_PARAMETERS( ) AS923_CASE { RegionAS923ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; }
45 #define AS923_RX_CONFIG( ) AS923_CASE { return RegionAS923RxConfig( rxConfig, datarate ); }
46 #define AS923_TX_CONFIG( ) AS923_CASE { return RegionAS923TxConfig( txConfig, txPower, txTimeOnAir ); }
47 #define AS923_LINK_ADR_REQ( ) AS923_CASE { return RegionAS923LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); }
48 #define AS923_RX_PARAM_SETUP_REQ( ) AS923_CASE { return RegionAS923RxParamSetupReq( rxParamSetupReq ); }
49 #define AS923_NEW_CHANNEL_REQ( ) AS923_CASE { return RegionAS923NewChannelReq( newChannelReq ); }
50 #define AS923_TX_PARAM_SETUP_REQ( ) AS923_CASE { return RegionAS923TxParamSetupReq( txParamSetupReq ); }
51 #define AS923_DL_CHANNEL_REQ( ) AS923_CASE { return RegionAS923DlChannelReq( dlChannelReq ); }
52 #define AS923_ALTERNATE_DR( ) AS923_CASE { return RegionAS923AlternateDr( currentDr, type ); }
53 #define AS923_NEXT_CHANNEL( ) AS923_CASE { return RegionAS923NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); }
54 #define AS923_CHANNEL_ADD( ) AS923_CASE { return RegionAS923ChannelAdd( channelAdd ); }
55 #define AS923_CHANNEL_REMOVE( ) AS923_CASE { return RegionAS923ChannelsRemove( channelRemove ); }
56 #define AS923_APPLY_DR_OFFSET( ) AS923_CASE { return RegionAS923ApplyDrOffset( downlinkDwellTime, dr, drOffset ); }
57 #define AS923_RX_BEACON_SETUP( ) AS923_CASE { RegionAS923RxBeaconSetup( rxBeaconSetup, outDr ); break; }
58 #else
59 #define AS923_IS_ACTIVE( )
60 #define AS923_GET_PHY_PARAM( )
61 #define AS923_SET_BAND_TX_DONE( )
62 #define AS923_INIT_DEFAULTS( )
63 #define AS923_GET_NVM_CTX( )
64 #define AS923_VERIFY( )
65 #define AS923_APPLY_CF_LIST( )
66 #define AS923_CHAN_MASK_SET( )
67 #define AS923_COMPUTE_RX_WINDOW_PARAMETERS( )
68 #define AS923_RX_CONFIG( )
69 #define AS923_TX_CONFIG( )
70 #define AS923_LINK_ADR_REQ( )
71 #define AS923_RX_PARAM_SETUP_REQ( )
72 #define AS923_NEW_CHANNEL_REQ( )
73 #define AS923_TX_PARAM_SETUP_REQ( )
74 #define AS923_DL_CHANNEL_REQ( )
75 #define AS923_ALTERNATE_DR( )
76 #define AS923_NEXT_CHANNEL( )
77 #define AS923_CHANNEL_ADD( )
78 #define AS923_CHANNEL_REMOVE( )
79 #define AS923_APPLY_DR_OFFSET( )
80 #define AS923_RX_BEACON_SETUP( )
81 #endif
82
83 #ifdef REGION_AU915
84 #include "RegionAU915.h"
85 #define AU915_CASE case LORAMAC_REGION_AU915:
86 #define AU915_IS_ACTIVE( ) AU915_CASE { return true; }
87 #define AU915_GET_PHY_PARAM( ) AU915_CASE { return RegionAU915GetPhyParam( getPhy ); }
88 #define AU915_SET_BAND_TX_DONE( ) AU915_CASE { RegionAU915SetBandTxDone( txDone ); break; }
89 #define AU915_INIT_DEFAULTS( ) AU915_CASE { RegionAU915InitDefaults( params ); break; }
90 #define AU915_VERIFY( ) AU915_CASE { return RegionAU915Verify( verify, phyAttribute ); }
91 #define AU915_APPLY_CF_LIST( ) AU915_CASE { RegionAU915ApplyCFList( applyCFList ); break; }
92 #define AU915_CHAN_MASK_SET( ) AU915_CASE { return RegionAU915ChanMaskSet( chanMaskSet ); }
93 #define AU915_COMPUTE_RX_WINDOW_PARAMETERS( ) AU915_CASE { RegionAU915ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; }
94 #define AU915_RX_CONFIG( ) AU915_CASE { return RegionAU915RxConfig( rxConfig, datarate ); }
95 #define AU915_TX_CONFIG( ) AU915_CASE { return RegionAU915TxConfig( txConfig, txPower, txTimeOnAir ); }
96 #define AU915_LINK_ADR_REQ( ) AU915_CASE { return RegionAU915LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); }
97 #define AU915_RX_PARAM_SETUP_REQ( ) AU915_CASE { return RegionAU915RxParamSetupReq( rxParamSetupReq ); }
98 #define AU915_NEW_CHANNEL_REQ( ) AU915_CASE { return RegionAU915NewChannelReq( newChannelReq ); }
99 #define AU915_TX_PARAM_SETUP_REQ( ) AU915_CASE { return RegionAU915TxParamSetupReq( txParamSetupReq ); }
100 #define AU915_DL_CHANNEL_REQ( ) AU915_CASE { return RegionAU915DlChannelReq( dlChannelReq ); }
101 #define AU915_ALTERNATE_DR( ) AU915_CASE { return RegionAU915AlternateDr( currentDr, type ); }
102 #define AU915_NEXT_CHANNEL( ) AU915_CASE { return RegionAU915NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); }
103 #define AU915_CHANNEL_ADD( ) AU915_CASE { return RegionAU915ChannelAdd( channelAdd ); }
104 #define AU915_CHANNEL_REMOVE( ) AU915_CASE { return RegionAU915ChannelsRemove( channelRemove ); }
105 #define AU915_APPLY_DR_OFFSET( ) AU915_CASE { return RegionAU915ApplyDrOffset( downlinkDwellTime, dr, drOffset ); }
106 #define AU915_RX_BEACON_SETUP( ) AU915_CASE { RegionAU915RxBeaconSetup( rxBeaconSetup, outDr ); break; }
107 #else
108 #define AU915_IS_ACTIVE( )
109 #define AU915_GET_PHY_PARAM( )
110 #define AU915_SET_BAND_TX_DONE( )
111 #define AU915_INIT_DEFAULTS( )
112 #define AU915_GET_NVM_CTX( )
113 #define AU915_VERIFY( )
114 #define AU915_APPLY_CF_LIST( )
115 #define AU915_CHAN_MASK_SET( )
116 #define AU915_COMPUTE_RX_WINDOW_PARAMETERS( )
117 #define AU915_RX_CONFIG( )
118 #define AU915_TX_CONFIG( )
119 #define AU915_LINK_ADR_REQ( )
120 #define AU915_RX_PARAM_SETUP_REQ( )
121 #define AU915_NEW_CHANNEL_REQ( )
122 #define AU915_TX_PARAM_SETUP_REQ( )
123 #define AU915_DL_CHANNEL_REQ( )
124 #define AU915_ALTERNATE_DR( )
125 #define AU915_NEXT_CHANNEL( )
126 #define AU915_CHANNEL_ADD( )
127 #define AU915_CHANNEL_REMOVE( )
128 #define AU915_APPLY_DR_OFFSET( )
129 #define AU915_RX_BEACON_SETUP( )
130 #endif
131
132 #ifdef REGION_CN470
133 #include "RegionCN470.h"
134 #define CN470_CASE case LORAMAC_REGION_CN470:
135 #define CN470_IS_ACTIVE( ) CN470_CASE { return true; }
136 #define CN470_GET_PHY_PARAM( ) CN470_CASE { return RegionCN470GetPhyParam( getPhy ); }
137 #define CN470_SET_BAND_TX_DONE( ) CN470_CASE { RegionCN470SetBandTxDone( txDone ); break; }
138 #define CN470_INIT_DEFAULTS( ) CN470_CASE { RegionCN470InitDefaults( params ); break; }
139 #define CN470_VERIFY( ) CN470_CASE { return RegionCN470Verify( verify, phyAttribute ); }
140 #define CN470_APPLY_CF_LIST( ) CN470_CASE { RegionCN470ApplyCFList( applyCFList ); break; }
141 #define CN470_CHAN_MASK_SET( ) CN470_CASE { return RegionCN470ChanMaskSet( chanMaskSet ); }
142 #define CN470_COMPUTE_RX_WINDOW_PARAMETERS( ) CN470_CASE { RegionCN470ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; }
143 #define CN470_RX_CONFIG( ) CN470_CASE { return RegionCN470RxConfig( rxConfig, datarate ); }
144 #define CN470_TX_CONFIG( ) CN470_CASE { return RegionCN470TxConfig( txConfig, txPower, txTimeOnAir ); }
145 #define CN470_LINK_ADR_REQ( ) CN470_CASE { return RegionCN470LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); }
146 #define CN470_RX_PARAM_SETUP_REQ( ) CN470_CASE { return RegionCN470RxParamSetupReq( rxParamSetupReq ); }
147 #define CN470_NEW_CHANNEL_REQ( ) CN470_CASE { return RegionCN470NewChannelReq( newChannelReq ); }
148 #define CN470_TX_PARAM_SETUP_REQ( ) CN470_CASE { return RegionCN470TxParamSetupReq( txParamSetupReq ); }
149 #define CN470_DL_CHANNEL_REQ( ) CN470_CASE { return RegionCN470DlChannelReq( dlChannelReq ); }
150 #define CN470_ALTERNATE_DR( ) CN470_CASE { return RegionCN470AlternateDr( currentDr, type ); }
151 #define CN470_NEXT_CHANNEL( ) CN470_CASE { return RegionCN470NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); }
152 #define CN470_CHANNEL_ADD( ) CN470_CASE { return RegionCN470ChannelAdd( channelAdd ); }
153 #define CN470_CHANNEL_REMOVE( ) CN470_CASE { return RegionCN470ChannelsRemove( channelRemove ); }
154 #define CN470_APPLY_DR_OFFSET( ) CN470_CASE { return RegionCN470ApplyDrOffset( downlinkDwellTime, dr, drOffset ); }
155 #define CN470_RX_BEACON_SETUP( ) CN470_CASE { RegionCN470RxBeaconSetup( rxBeaconSetup, outDr ); break; }
156 #else
157 #define CN470_IS_ACTIVE( )
158 #define CN470_GET_PHY_PARAM( )
159 #define CN470_SET_BAND_TX_DONE( )
160 #define CN470_INIT_DEFAULTS( )
161 #define CN470_GET_NVM_CTX( )
162 #define CN470_VERIFY( )
163 #define CN470_APPLY_CF_LIST( )
164 #define CN470_CHAN_MASK_SET( )
165 #define CN470_COMPUTE_RX_WINDOW_PARAMETERS( )
166 #define CN470_RX_CONFIG( )
167 #define CN470_TX_CONFIG( )
168 #define CN470_LINK_ADR_REQ( )
169 #define CN470_RX_PARAM_SETUP_REQ( )
170 #define CN470_NEW_CHANNEL_REQ( )
171 #define CN470_TX_PARAM_SETUP_REQ( )
172 #define CN470_DL_CHANNEL_REQ( )
173 #define CN470_ALTERNATE_DR( )
174 #define CN470_NEXT_CHANNEL( )
175 #define CN470_CHANNEL_ADD( )
176 #define CN470_CHANNEL_REMOVE( )
177 #define CN470_APPLY_DR_OFFSET( )
178 #define CN470_RX_BEACON_SETUP( )
179 #endif
180
181 #ifdef REGION_CN779
182 #include "RegionCN779.h"
183 #define CN779_CASE case LORAMAC_REGION_CN779:
184 #define CN779_IS_ACTIVE( ) CN779_CASE { return true; }
185 #define CN779_GET_PHY_PARAM( ) CN779_CASE { return RegionCN779GetPhyParam( getPhy ); }
186 #define CN779_SET_BAND_TX_DONE( ) CN779_CASE { RegionCN779SetBandTxDone( txDone ); break; }
187 #define CN779_INIT_DEFAULTS( ) CN779_CASE { RegionCN779InitDefaults( params ); break; }
188 #define CN779_VERIFY( ) CN779_CASE { return RegionCN779Verify( verify, phyAttribute ); }
189 #define CN779_APPLY_CF_LIST( ) CN779_CASE { RegionCN779ApplyCFList( applyCFList ); break; }
190 #define CN779_CHAN_MASK_SET( ) CN779_CASE { return RegionCN779ChanMaskSet( chanMaskSet ); }
191 #define CN779_COMPUTE_RX_WINDOW_PARAMETERS( ) CN779_CASE { RegionCN779ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; }
192 #define CN779_RX_CONFIG( ) CN779_CASE { return RegionCN779RxConfig( rxConfig, datarate ); }
193 #define CN779_TX_CONFIG( ) CN779_CASE { return RegionCN779TxConfig( txConfig, txPower, txTimeOnAir ); }
194 #define CN779_LINK_ADR_REQ( ) CN779_CASE { return RegionCN779LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); }
195 #define CN779_RX_PARAM_SETUP_REQ( ) CN779_CASE { return RegionCN779RxParamSetupReq( rxParamSetupReq ); }
196 #define CN779_NEW_CHANNEL_REQ( ) CN779_CASE { return RegionCN779NewChannelReq( newChannelReq ); }
197 #define CN779_TX_PARAM_SETUP_REQ( ) CN779_CASE { return RegionCN779TxParamSetupReq( txParamSetupReq ); }
198 #define CN779_DL_CHANNEL_REQ( ) CN779_CASE { return RegionCN779DlChannelReq( dlChannelReq ); }
199 #define CN779_ALTERNATE_DR( ) CN779_CASE { return RegionCN779AlternateDr( currentDr, type ); }
200 #define CN779_NEXT_CHANNEL( ) CN779_CASE { return RegionCN779NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); }
201 #define CN779_CHANNEL_ADD( ) CN779_CASE { return RegionCN779ChannelAdd( channelAdd ); }
202 #define CN779_CHANNEL_REMOVE( ) CN779_CASE { return RegionCN779ChannelsRemove( channelRemove ); }
203 #define CN779_APPLY_DR_OFFSET( ) CN779_CASE { return RegionCN779ApplyDrOffset( downlinkDwellTime, dr, drOffset ); }
204 #define CN779_RX_BEACON_SETUP( ) CN779_CASE { RegionCN779RxBeaconSetup( rxBeaconSetup, outDr ); break; }
205 #else
206 #define CN779_IS_ACTIVE( )
207 #define CN779_GET_PHY_PARAM( )
208 #define CN779_SET_BAND_TX_DONE( )
209 #define CN779_INIT_DEFAULTS( )
210 #define CN779_GET_NVM_CTX( )
211 #define CN779_VERIFY( )
212 #define CN779_APPLY_CF_LIST( )
213 #define CN779_CHAN_MASK_SET( )
214 #define CN779_COMPUTE_RX_WINDOW_PARAMETERS( )
215 #define CN779_RX_CONFIG( )
216 #define CN779_TX_CONFIG( )
217 #define CN779_LINK_ADR_REQ( )
218 #define CN779_RX_PARAM_SETUP_REQ( )
219 #define CN779_NEW_CHANNEL_REQ( )
220 #define CN779_TX_PARAM_SETUP_REQ( )
221 #define CN779_DL_CHANNEL_REQ( )
222 #define CN779_ALTERNATE_DR( )
223 #define CN779_NEXT_CHANNEL( )
224 #define CN779_CHANNEL_ADD( )
225 #define CN779_CHANNEL_REMOVE( )
226 #define CN779_APPLY_DR_OFFSET( )
227 #define CN779_RX_BEACON_SETUP( )
228 #endif
229
230 #ifdef REGION_EU433
231 #include "RegionEU433.h"
232 #define EU433_CASE case LORAMAC_REGION_EU433:
233 #define EU433_IS_ACTIVE( ) EU433_CASE { return true; }
234 #define EU433_GET_PHY_PARAM( ) EU433_CASE { return RegionEU433GetPhyParam( getPhy ); }
235 #define EU433_SET_BAND_TX_DONE( ) EU433_CASE { RegionEU433SetBandTxDone( txDone ); break; }
236 #define EU433_INIT_DEFAULTS( ) EU433_CASE { RegionEU433InitDefaults( params ); break; }
237 #define EU433_VERIFY( ) EU433_CASE { return RegionEU433Verify( verify, phyAttribute ); }
238 #define EU433_APPLY_CF_LIST( ) EU433_CASE { RegionEU433ApplyCFList( applyCFList ); break; }
239 #define EU433_CHAN_MASK_SET( ) EU433_CASE { return RegionEU433ChanMaskSet( chanMaskSet ); }
240 #define EU433_COMPUTE_RX_WINDOW_PARAMETERS( ) EU433_CASE { RegionEU433ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; }
241 #define EU433_RX_CONFIG( ) EU433_CASE { return RegionEU433RxConfig( rxConfig, datarate ); }
242 #define EU433_TX_CONFIG( ) EU433_CASE { return RegionEU433TxConfig( txConfig, txPower, txTimeOnAir ); }
243 #define EU433_LINK_ADR_REQ( ) EU433_CASE { return RegionEU433LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); }
244 #define EU433_RX_PARAM_SETUP_REQ( ) EU433_CASE { return RegionEU433RxParamSetupReq( rxParamSetupReq ); }
245 #define EU433_NEW_CHANNEL_REQ( ) EU433_CASE { return RegionEU433NewChannelReq( newChannelReq ); }
246 #define EU433_TX_PARAM_SETUP_REQ( ) EU433_CASE { return RegionEU433TxParamSetupReq( txParamSetupReq ); }
247 #define EU433_DL_CHANNEL_REQ( ) EU433_CASE { return RegionEU433DlChannelReq( dlChannelReq ); }
248 #define EU433_ALTERNATE_DR( ) EU433_CASE { return RegionEU433AlternateDr( currentDr, type ); }
249 #define EU433_NEXT_CHANNEL( ) EU433_CASE { return RegionEU433NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); }
250 #define EU433_CHANNEL_ADD( ) EU433_CASE { return RegionEU433ChannelAdd( channelAdd ); }
251 #define EU433_CHANNEL_REMOVE( ) EU433_CASE { return RegionEU433ChannelsRemove( channelRemove ); }
252 #define EU433_APPLY_DR_OFFSET( ) EU433_CASE { return RegionEU433ApplyDrOffset( downlinkDwellTime, dr, drOffset ); }
253 #define EU433_RX_BEACON_SETUP( ) EU433_CASE { RegionEU433RxBeaconSetup( rxBeaconSetup, outDr ); break; }
254 #else
255 #define EU433_IS_ACTIVE( )
256 #define EU433_GET_PHY_PARAM( )
257 #define EU433_SET_BAND_TX_DONE( )
258 #define EU433_INIT_DEFAULTS( )
259 #define EU433_GET_NVM_CTX( )
260 #define EU433_VERIFY( )
261 #define EU433_APPLY_CF_LIST( )
262 #define EU433_CHAN_MASK_SET( )
263 #define EU433_COMPUTE_RX_WINDOW_PARAMETERS( )
264 #define EU433_RX_CONFIG( )
265 #define EU433_TX_CONFIG( )
266 #define EU433_LINK_ADR_REQ( )
267 #define EU433_RX_PARAM_SETUP_REQ( )
268 #define EU433_NEW_CHANNEL_REQ( )
269 #define EU433_TX_PARAM_SETUP_REQ( )
270 #define EU433_DL_CHANNEL_REQ( )
271 #define EU433_ALTERNATE_DR( )
272 #define EU433_NEXT_CHANNEL( )
273 #define EU433_CHANNEL_ADD( )
274 #define EU433_CHANNEL_REMOVE( )
275 #define EU433_APPLY_DR_OFFSET( )
276 #define EU433_RX_BEACON_SETUP( )
277 #endif
278
279 #ifdef REGION_EU868
280 #include "RegionEU868.h"
281 #define EU868_CASE case LORAMAC_REGION_EU868:
282 #define EU868_IS_ACTIVE( ) EU868_CASE { return true; }
283 #define EU868_GET_PHY_PARAM( ) EU868_CASE { return RegionEU868GetPhyParam( getPhy ); }
284 #define EU868_SET_BAND_TX_DONE( ) EU868_CASE { RegionEU868SetBandTxDone( txDone ); break; }
285 #define EU868_INIT_DEFAULTS( ) EU868_CASE { RegionEU868InitDefaults( params ); break; }
286 #define EU868_VERIFY( ) EU868_CASE { return RegionEU868Verify( verify, phyAttribute ); }
287 #define EU868_APPLY_CF_LIST( ) EU868_CASE { RegionEU868ApplyCFList( applyCFList ); break; }
288 #define EU868_CHAN_MASK_SET( ) EU868_CASE { return RegionEU868ChanMaskSet( chanMaskSet ); }
289 #define EU868_COMPUTE_RX_WINDOW_PARAMETERS( ) EU868_CASE { RegionEU868ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; }
290 #define EU868_RX_CONFIG( ) EU868_CASE { return RegionEU868RxConfig( rxConfig, datarate ); }
291 #define EU868_TX_CONFIG( ) EU868_CASE { return RegionEU868TxConfig( txConfig, txPower, txTimeOnAir ); }
292 #define EU868_LINK_ADR_REQ( ) EU868_CASE { return RegionEU868LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); }
293 #define EU868_RX_PARAM_SETUP_REQ( ) EU868_CASE { return RegionEU868RxParamSetupReq( rxParamSetupReq ); }
294 #define EU868_NEW_CHANNEL_REQ( ) EU868_CASE { return RegionEU868NewChannelReq( newChannelReq ); }
295 #define EU868_TX_PARAM_SETUP_REQ( ) EU868_CASE { return RegionEU868TxParamSetupReq( txParamSetupReq ); }
296 #define EU868_DL_CHANNEL_REQ( ) EU868_CASE { return RegionEU868DlChannelReq( dlChannelReq ); }
297 #define EU868_ALTERNATE_DR( ) EU868_CASE { return RegionEU868AlternateDr( currentDr, type ); }
298 #define EU868_NEXT_CHANNEL( ) EU868_CASE { return RegionEU868NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); }
299 #define EU868_CHANNEL_ADD( ) EU868_CASE { return RegionEU868ChannelAdd( channelAdd ); }
300 #define EU868_CHANNEL_REMOVE( ) EU868_CASE { return RegionEU868ChannelsRemove( channelRemove ); }
301 #define EU868_APPLY_DR_OFFSET( ) EU868_CASE { return RegionEU868ApplyDrOffset( downlinkDwellTime, dr, drOffset ); }
302 #define EU868_RX_BEACON_SETUP( ) EU868_CASE { RegionEU868RxBeaconSetup( rxBeaconSetup, outDr ); break; }
303 #else
304 #define EU868_IS_ACTIVE( )
305 #define EU868_GET_PHY_PARAM( )
306 #define EU868_SET_BAND_TX_DONE( )
307 #define EU868_INIT_DEFAULTS( )
308 #define EU868_GET_NVM_CTX( )
309 #define EU868_VERIFY( )
310 #define EU868_APPLY_CF_LIST( )
311 #define EU868_CHAN_MASK_SET( )
312 #define EU868_COMPUTE_RX_WINDOW_PARAMETERS( )
313 #define EU868_RX_CONFIG( )
314 #define EU868_TX_CONFIG( )
315 #define EU868_LINK_ADR_REQ( )
316 #define EU868_RX_PARAM_SETUP_REQ( )
317 #define EU868_NEW_CHANNEL_REQ( )
318 #define EU868_TX_PARAM_SETUP_REQ( )
319 #define EU868_DL_CHANNEL_REQ( )
320 #define EU868_ALTERNATE_DR( )
321 #define EU868_NEXT_CHANNEL( )
322 #define EU868_CHANNEL_ADD( )
323 #define EU868_CHANNEL_REMOVE( )
324 #define EU868_APPLY_DR_OFFSET( )
325 #define EU868_RX_BEACON_SETUP( )
326 #endif
327
328 #ifdef REGION_KR920
329 #include "RegionKR920.h"
330 #define KR920_CASE case LORAMAC_REGION_KR920:
331 #define KR920_IS_ACTIVE( ) KR920_CASE { return true; }
332 #define KR920_GET_PHY_PARAM( ) KR920_CASE { return RegionKR920GetPhyParam( getPhy ); }
333 #define KR920_SET_BAND_TX_DONE( ) KR920_CASE { RegionKR920SetBandTxDone( txDone ); break; }
334 #define KR920_INIT_DEFAULTS( ) KR920_CASE { RegionKR920InitDefaults( params ); break; }
335 #define KR920_VERIFY( ) KR920_CASE { return RegionKR920Verify( verify, phyAttribute ); }
336 #define KR920_APPLY_CF_LIST( ) KR920_CASE { RegionKR920ApplyCFList( applyCFList ); break; }
337 #define KR920_CHAN_MASK_SET( ) KR920_CASE { return RegionKR920ChanMaskSet( chanMaskSet ); }
338 #define KR920_COMPUTE_RX_WINDOW_PARAMETERS( ) KR920_CASE { RegionKR920ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; }
339 #define KR920_RX_CONFIG( ) KR920_CASE { return RegionKR920RxConfig( rxConfig, datarate ); }
340 #define KR920_TX_CONFIG( ) KR920_CASE { return RegionKR920TxConfig( txConfig, txPower, txTimeOnAir ); }
341 #define KR920_LINK_ADR_REQ( ) KR920_CASE { return RegionKR920LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); }
342 #define KR920_RX_PARAM_SETUP_REQ( ) KR920_CASE { return RegionKR920RxParamSetupReq( rxParamSetupReq ); }
343 #define KR920_NEW_CHANNEL_REQ( ) KR920_CASE { return RegionKR920NewChannelReq( newChannelReq ); }
344 #define KR920_TX_PARAM_SETUP_REQ( ) KR920_CASE { return RegionKR920TxParamSetupReq( txParamSetupReq ); }
345 #define KR920_DL_CHANNEL_REQ( ) KR920_CASE { return RegionKR920DlChannelReq( dlChannelReq ); }
346 #define KR920_ALTERNATE_DR( ) KR920_CASE { return RegionKR920AlternateDr( currentDr, type ); }
347 #define KR920_NEXT_CHANNEL( ) KR920_CASE { return RegionKR920NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); }
348 #define KR920_CHANNEL_ADD( ) KR920_CASE { return RegionKR920ChannelAdd( channelAdd ); }
349 #define KR920_CHANNEL_REMOVE( ) KR920_CASE { return RegionKR920ChannelsRemove( channelRemove ); }
350 #define KR920_APPLY_DR_OFFSET( ) KR920_CASE { return RegionKR920ApplyDrOffset( downlinkDwellTime, dr, drOffset ); }
351 #define KR920_RX_BEACON_SETUP( ) KR920_CASE { RegionKR920RxBeaconSetup( rxBeaconSetup, outDr ); break; }
352 #else
353 #define KR920_IS_ACTIVE( )
354 #define KR920_GET_PHY_PARAM( )
355 #define KR920_SET_BAND_TX_DONE( )
356 #define KR920_INIT_DEFAULTS( )
357 #define KR920_GET_NVM_CTX( )
358 #define KR920_VERIFY( )
359 #define KR920_APPLY_CF_LIST( )
360 #define KR920_CHAN_MASK_SET( )
361 #define KR920_COMPUTE_RX_WINDOW_PARAMETERS( )
362 #define KR920_RX_CONFIG( )
363 #define KR920_TX_CONFIG( )
364 #define KR920_LINK_ADR_REQ( )
365 #define KR920_RX_PARAM_SETUP_REQ( )
366 #define KR920_NEW_CHANNEL_REQ( )
367 #define KR920_TX_PARAM_SETUP_REQ( )
368 #define KR920_DL_CHANNEL_REQ( )
369 #define KR920_ALTERNATE_DR( )
370 #define KR920_NEXT_CHANNEL( )
371 #define KR920_CHANNEL_ADD( )
372 #define KR920_CHANNEL_REMOVE( )
373 #define KR920_APPLY_DR_OFFSET( )
374 #define KR920_RX_BEACON_SETUP( )
375 #endif
376
377 #ifdef REGION_IN865
378 #include "RegionIN865.h"
379 #define IN865_CASE case LORAMAC_REGION_IN865:
380 #define IN865_IS_ACTIVE( ) IN865_CASE { return true; }
381 #define IN865_GET_PHY_PARAM( ) IN865_CASE { return RegionIN865GetPhyParam( getPhy ); }
382 #define IN865_SET_BAND_TX_DONE( ) IN865_CASE { RegionIN865SetBandTxDone( txDone ); break; }
383 #define IN865_INIT_DEFAULTS( ) IN865_CASE { RegionIN865InitDefaults( params ); break; }
384 #define IN865_VERIFY( ) IN865_CASE { return RegionIN865Verify( verify, phyAttribute ); }
385 #define IN865_APPLY_CF_LIST( ) IN865_CASE { RegionIN865ApplyCFList( applyCFList ); break; }
386 #define IN865_CHAN_MASK_SET( ) IN865_CASE { return RegionIN865ChanMaskSet( chanMaskSet ); }
387 #define IN865_COMPUTE_RX_WINDOW_PARAMETERS( ) IN865_CASE { RegionIN865ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; }
388 #define IN865_RX_CONFIG( ) IN865_CASE { return RegionIN865RxConfig( rxConfig, datarate ); }
389 #define IN865_TX_CONFIG( ) IN865_CASE { return RegionIN865TxConfig( txConfig, txPower, txTimeOnAir ); }
390 #define IN865_LINK_ADR_REQ( ) IN865_CASE { return RegionIN865LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); }
391 #define IN865_RX_PARAM_SETUP_REQ( ) IN865_CASE { return RegionIN865RxParamSetupReq( rxParamSetupReq ); }
392 #define IN865_NEW_CHANNEL_REQ( ) IN865_CASE { return RegionIN865NewChannelReq( newChannelReq ); }
393 #define IN865_TX_PARAM_SETUP_REQ( ) IN865_CASE { return RegionIN865TxParamSetupReq( txParamSetupReq ); }
394 #define IN865_DL_CHANNEL_REQ( ) IN865_CASE { return RegionIN865DlChannelReq( dlChannelReq ); }
395 #define IN865_ALTERNATE_DR( ) IN865_CASE { return RegionIN865AlternateDr( currentDr, type ); }
396 #define IN865_NEXT_CHANNEL( ) IN865_CASE { return RegionIN865NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); }
397 #define IN865_CHANNEL_ADD( ) IN865_CASE { return RegionIN865ChannelAdd( channelAdd ); }
398 #define IN865_CHANNEL_REMOVE( ) IN865_CASE { return RegionIN865ChannelsRemove( channelRemove ); }
399 #define IN865_APPLY_DR_OFFSET( ) IN865_CASE { return RegionIN865ApplyDrOffset( downlinkDwellTime, dr, drOffset ); }
400 #define IN865_RX_BEACON_SETUP( ) IN865_CASE { RegionIN865RxBeaconSetup( rxBeaconSetup, outDr ); break; }
401 #else
402 #define IN865_IS_ACTIVE( )
403 #define IN865_GET_PHY_PARAM( )
404 #define IN865_SET_BAND_TX_DONE( )
405 #define IN865_INIT_DEFAULTS( )
406 #define IN865_GET_NVM_CTX( )
407 #define IN865_VERIFY( )
408 #define IN865_APPLY_CF_LIST( )
409 #define IN865_CHAN_MASK_SET( )
410 #define IN865_COMPUTE_RX_WINDOW_PARAMETERS( )
411 #define IN865_RX_CONFIG( )
412 #define IN865_TX_CONFIG( )
413 #define IN865_LINK_ADR_REQ( )
414 #define IN865_RX_PARAM_SETUP_REQ( )
415 #define IN865_NEW_CHANNEL_REQ( )
416 #define IN865_TX_PARAM_SETUP_REQ( )
417 #define IN865_DL_CHANNEL_REQ( )
418 #define IN865_ALTERNATE_DR( )
419 #define IN865_NEXT_CHANNEL( )
420 #define IN865_CHANNEL_ADD( )
421 #define IN865_CHANNEL_REMOVE( )
422 #define IN865_APPLY_DR_OFFSET( )
423 #define IN865_RX_BEACON_SETUP( )
424 #endif
425
426 #ifdef REGION_US915
427 #include "RegionUS915.h"
428 #define US915_CASE case LORAMAC_REGION_US915:
429 #define US915_IS_ACTIVE( ) US915_CASE { return true; }
430 #define US915_GET_PHY_PARAM( ) US915_CASE { return RegionUS915GetPhyParam( getPhy ); }
431 #define US915_SET_BAND_TX_DONE( ) US915_CASE { RegionUS915SetBandTxDone( txDone ); break; }
432 #define US915_INIT_DEFAULTS( ) US915_CASE { RegionUS915InitDefaults( params ); break; }
433 #define US915_VERIFY( ) US915_CASE { return RegionUS915Verify( verify, phyAttribute ); }
434 #define US915_APPLY_CF_LIST( ) US915_CASE { RegionUS915ApplyCFList( applyCFList ); break; }
435 #define US915_CHAN_MASK_SET( ) US915_CASE { return RegionUS915ChanMaskSet( chanMaskSet ); }
436 #define US915_COMPUTE_RX_WINDOW_PARAMETERS( ) US915_CASE { RegionUS915ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; }
437 #define US915_RX_CONFIG( ) US915_CASE { return RegionUS915RxConfig( rxConfig, datarate ); }
438 #define US915_TX_CONFIG( ) US915_CASE { return RegionUS915TxConfig( txConfig, txPower, txTimeOnAir ); }
439 #define US915_LINK_ADR_REQ( ) US915_CASE { return RegionUS915LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); }
440 #define US915_RX_PARAM_SETUP_REQ( ) US915_CASE { return RegionUS915RxParamSetupReq( rxParamSetupReq ); }
441 #define US915_NEW_CHANNEL_REQ( ) US915_CASE { return RegionUS915NewChannelReq( newChannelReq ); }
442 #define US915_TX_PARAM_SETUP_REQ( ) US915_CASE { return RegionUS915TxParamSetupReq( txParamSetupReq ); }
443 #define US915_DL_CHANNEL_REQ( ) US915_CASE { return RegionUS915DlChannelReq( dlChannelReq ); }
444 #define US915_ALTERNATE_DR( ) US915_CASE { return RegionUS915AlternateDr( currentDr, type ); }
445 #define US915_NEXT_CHANNEL( ) US915_CASE { return RegionUS915NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); }
446 #define US915_CHANNEL_ADD( ) US915_CASE { return RegionUS915ChannelAdd( channelAdd ); }
447 #define US915_CHANNEL_REMOVE( ) US915_CASE { return RegionUS915ChannelsRemove( channelRemove ); }
448 #define US915_APPLY_DR_OFFSET( ) US915_CASE { return RegionUS915ApplyDrOffset( downlinkDwellTime, dr, drOffset ); }
449 #define US915_RX_BEACON_SETUP( ) US915_CASE { RegionUS915RxBeaconSetup( rxBeaconSetup, outDr ); break; }
450 #else
451 #define US915_IS_ACTIVE( )
452 #define US915_GET_PHY_PARAM( )
453 #define US915_SET_BAND_TX_DONE( )
454 #define US915_INIT_DEFAULTS( )
455 #define US915_GET_NVM_CTX( )
456 #define US915_VERIFY( )
457 #define US915_APPLY_CF_LIST( )
458 #define US915_CHAN_MASK_SET( )
459 #define US915_COMPUTE_RX_WINDOW_PARAMETERS( )
460 #define US915_RX_CONFIG( )
461 #define US915_TX_CONFIG( )
462 #define US915_LINK_ADR_REQ( )
463 #define US915_RX_PARAM_SETUP_REQ( )
464 #define US915_NEW_CHANNEL_REQ( )
465 #define US915_TX_PARAM_SETUP_REQ( )
466 #define US915_DL_CHANNEL_REQ( )
467 #define US915_ALTERNATE_DR( )
468 #define US915_NEXT_CHANNEL( )
469 #define US915_CHANNEL_ADD( )
470 #define US915_CHANNEL_REMOVE( )
471 #define US915_APPLY_DR_OFFSET( )
472 #define US915_RX_BEACON_SETUP( )
473 #endif
474
475 #ifdef REGION_RU864
476 #include "RegionRU864.h"
477 #define RU864_CASE case LORAMAC_REGION_RU864:
478 #define RU864_IS_ACTIVE( ) RU864_CASE { return true; }
479 #define RU864_GET_PHY_PARAM( ) RU864_CASE { return RegionRU864GetPhyParam( getPhy ); }
480 #define RU864_SET_BAND_TX_DONE( ) RU864_CASE { RegionRU864SetBandTxDone( txDone ); break; }
481 #define RU864_INIT_DEFAULTS( ) RU864_CASE { RegionRU864InitDefaults( params ); break; }
482 #define RU864_VERIFY( ) RU864_CASE { return RegionRU864Verify( verify, phyAttribute ); }
483 #define RU864_APPLY_CF_LIST( ) RU864_CASE { RegionRU864ApplyCFList( applyCFList ); break; }
484 #define RU864_CHAN_MASK_SET( ) RU864_CASE { return RegionRU864ChanMaskSet( chanMaskSet ); }
485 #define RU864_COMPUTE_RX_WINDOW_PARAMETERS( ) RU864_CASE { RegionRU864ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; }
486 #define RU864_RX_CONFIG( ) RU864_CASE { return RegionRU864RxConfig( rxConfig, datarate ); }
487 #define RU864_TX_CONFIG( ) RU864_CASE { return RegionRU864TxConfig( txConfig, txPower, txTimeOnAir ); }
488 #define RU864_LINK_ADR_REQ( ) RU864_CASE { return RegionRU864LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); }
489 #define RU864_RX_PARAM_SETUP_REQ( ) RU864_CASE { return RegionRU864RxParamSetupReq( rxParamSetupReq ); }
490 #define RU864_NEW_CHANNEL_REQ( ) RU864_CASE { return RegionRU864NewChannelReq( newChannelReq ); }
491 #define RU864_TX_PARAM_SETUP_REQ( ) RU864_CASE { return RegionRU864TxParamSetupReq( txParamSetupReq ); }
492 #define RU864_DL_CHANNEL_REQ( ) RU864_CASE { return RegionRU864DlChannelReq( dlChannelReq ); }
493 #define RU864_ALTERNATE_DR( ) RU864_CASE { return RegionRU864AlternateDr( currentDr, type ); }
494 #define RU864_NEXT_CHANNEL( ) RU864_CASE { return RegionRU864NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); }
495 #define RU864_CHANNEL_ADD( ) RU864_CASE { return RegionRU864ChannelAdd( channelAdd ); }
496 #define RU864_CHANNEL_REMOVE( ) RU864_CASE { return RegionRU864ChannelsRemove( channelRemove ); }
497 #define RU864_APPLY_DR_OFFSET( ) RU864_CASE { return RegionRU864ApplyDrOffset( downlinkDwellTime, dr, drOffset ); }
498 #define RU864_RX_BEACON_SETUP( ) RU864_CASE { RegionRU864RxBeaconSetup( rxBeaconSetup, outDr ); break; }
499 #else
500 #define RU864_IS_ACTIVE( )
501 #define RU864_GET_PHY_PARAM( )
502 #define RU864_SET_BAND_TX_DONE( )
503 #define RU864_INIT_DEFAULTS( )
504 #define RU864_GET_NVM_CTX( )
505 #define RU864_VERIFY( )
506 #define RU864_APPLY_CF_LIST( )
507 #define RU864_CHAN_MASK_SET( )
508 #define RU864_COMPUTE_RX_WINDOW_PARAMETERS( )
509 #define RU864_RX_CONFIG( )
510 #define RU864_TX_CONFIG( )
511 #define RU864_LINK_ADR_REQ( )
512 #define RU864_RX_PARAM_SETUP_REQ( )
513 #define RU864_NEW_CHANNEL_REQ( )
514 #define RU864_TX_PARAM_SETUP_REQ( )
515 #define RU864_DL_CHANNEL_REQ( )
516 #define RU864_ALTERNATE_DR( )
517 #define RU864_NEXT_CHANNEL( )
518 #define RU864_CHANNEL_ADD( )
519 #define RU864_CHANNEL_REMOVE( )
520 #define RU864_APPLY_DR_OFFSET( )
521 #define RU864_RX_BEACON_SETUP( )
522 #endif
523
RegionIsActive(LoRaMacRegion_t region)524 bool RegionIsActive( LoRaMacRegion_t region )
525 {
526 switch( region )
527 {
528 AS923_IS_ACTIVE( );
529 AU915_IS_ACTIVE( );
530 CN470_IS_ACTIVE( );
531 CN779_IS_ACTIVE( );
532 EU433_IS_ACTIVE( );
533 EU868_IS_ACTIVE( );
534 KR920_IS_ACTIVE( );
535 IN865_IS_ACTIVE( );
536 US915_IS_ACTIVE( );
537 RU864_IS_ACTIVE( );
538 default:
539 {
540 return false;
541 }
542 }
543 }
544
RegionGetPhyParam(LoRaMacRegion_t region,GetPhyParams_t * getPhy)545 PhyParam_t RegionGetPhyParam( LoRaMacRegion_t region, GetPhyParams_t* getPhy )
546 {
547 PhyParam_t phyParam = { 0 };
548 switch( region )
549 {
550 AS923_GET_PHY_PARAM( );
551 AU915_GET_PHY_PARAM( );
552 CN470_GET_PHY_PARAM( );
553 CN779_GET_PHY_PARAM( );
554 EU433_GET_PHY_PARAM( );
555 EU868_GET_PHY_PARAM( );
556 KR920_GET_PHY_PARAM( );
557 IN865_GET_PHY_PARAM( );
558 US915_GET_PHY_PARAM( );
559 RU864_GET_PHY_PARAM( );
560 default:
561 {
562 return phyParam;
563 }
564 }
565 }
566
RegionSetBandTxDone(LoRaMacRegion_t region,SetBandTxDoneParams_t * txDone)567 void RegionSetBandTxDone( LoRaMacRegion_t region, SetBandTxDoneParams_t* txDone )
568 {
569 switch( region )
570 {
571 AS923_SET_BAND_TX_DONE( );
572 AU915_SET_BAND_TX_DONE( );
573 CN470_SET_BAND_TX_DONE( );
574 CN779_SET_BAND_TX_DONE( );
575 EU433_SET_BAND_TX_DONE( );
576 EU868_SET_BAND_TX_DONE( );
577 KR920_SET_BAND_TX_DONE( );
578 IN865_SET_BAND_TX_DONE( );
579 US915_SET_BAND_TX_DONE( );
580 RU864_SET_BAND_TX_DONE( );
581 default:
582 {
583 return;
584 }
585 }
586 }
587
RegionInitDefaults(LoRaMacRegion_t region,InitDefaultsParams_t * params)588 void RegionInitDefaults( LoRaMacRegion_t region, InitDefaultsParams_t* params )
589 {
590 switch( region )
591 {
592 AS923_INIT_DEFAULTS( );
593 AU915_INIT_DEFAULTS( );
594 CN470_INIT_DEFAULTS( );
595 CN779_INIT_DEFAULTS( );
596 EU433_INIT_DEFAULTS( );
597 EU868_INIT_DEFAULTS( );
598 KR920_INIT_DEFAULTS( );
599 IN865_INIT_DEFAULTS( );
600 US915_INIT_DEFAULTS( );
601 RU864_INIT_DEFAULTS( );
602 default:
603 {
604 break;
605 }
606 }
607 }
608
RegionVerify(LoRaMacRegion_t region,VerifyParams_t * verify,PhyAttribute_t phyAttribute)609 bool RegionVerify( LoRaMacRegion_t region, VerifyParams_t* verify, PhyAttribute_t phyAttribute )
610 {
611 switch( region )
612 {
613 AS923_VERIFY( );
614 AU915_VERIFY( );
615 CN470_VERIFY( );
616 CN779_VERIFY( );
617 EU433_VERIFY( );
618 EU868_VERIFY( );
619 KR920_VERIFY( );
620 IN865_VERIFY( );
621 US915_VERIFY( );
622 RU864_VERIFY( );
623 default:
624 {
625 return false;
626 }
627 }
628 }
629
RegionApplyCFList(LoRaMacRegion_t region,ApplyCFListParams_t * applyCFList)630 void RegionApplyCFList( LoRaMacRegion_t region, ApplyCFListParams_t* applyCFList )
631 {
632 switch( region )
633 {
634 AS923_APPLY_CF_LIST( );
635 AU915_APPLY_CF_LIST( );
636 CN470_APPLY_CF_LIST( );
637 CN779_APPLY_CF_LIST( );
638 EU433_APPLY_CF_LIST( );
639 EU868_APPLY_CF_LIST( );
640 KR920_APPLY_CF_LIST( );
641 IN865_APPLY_CF_LIST( );
642 US915_APPLY_CF_LIST( );
643 RU864_APPLY_CF_LIST( );
644 default:
645 {
646 break;
647 }
648 }
649 }
650
RegionChanMaskSet(LoRaMacRegion_t region,ChanMaskSetParams_t * chanMaskSet)651 bool RegionChanMaskSet( LoRaMacRegion_t region, ChanMaskSetParams_t* chanMaskSet )
652 {
653 switch( region )
654 {
655 AS923_CHAN_MASK_SET( );
656 AU915_CHAN_MASK_SET( );
657 CN470_CHAN_MASK_SET( );
658 CN779_CHAN_MASK_SET( );
659 EU433_CHAN_MASK_SET( );
660 EU868_CHAN_MASK_SET( );
661 KR920_CHAN_MASK_SET( );
662 IN865_CHAN_MASK_SET( );
663 US915_CHAN_MASK_SET( );
664 RU864_CHAN_MASK_SET( );
665 default:
666 {
667 return false;
668 }
669 }
670 }
671
RegionComputeRxWindowParameters(LoRaMacRegion_t region,int8_t datarate,uint8_t minRxSymbols,uint32_t rxError,RxConfigParams_t * rxConfigParams)672 void RegionComputeRxWindowParameters( LoRaMacRegion_t region, int8_t datarate, uint8_t minRxSymbols, uint32_t rxError, RxConfigParams_t *rxConfigParams )
673 {
674 switch( region )
675 {
676 AS923_COMPUTE_RX_WINDOW_PARAMETERS( );
677 AU915_COMPUTE_RX_WINDOW_PARAMETERS( );
678 CN470_COMPUTE_RX_WINDOW_PARAMETERS( );
679 CN779_COMPUTE_RX_WINDOW_PARAMETERS( );
680 EU433_COMPUTE_RX_WINDOW_PARAMETERS( );
681 EU868_COMPUTE_RX_WINDOW_PARAMETERS( );
682 KR920_COMPUTE_RX_WINDOW_PARAMETERS( );
683 IN865_COMPUTE_RX_WINDOW_PARAMETERS( );
684 US915_COMPUTE_RX_WINDOW_PARAMETERS( );
685 RU864_COMPUTE_RX_WINDOW_PARAMETERS( );
686 default:
687 {
688 break;
689 }
690 }
691 }
692
RegionRxConfig(LoRaMacRegion_t region,RxConfigParams_t * rxConfig,int8_t * datarate)693 bool RegionRxConfig( LoRaMacRegion_t region, RxConfigParams_t* rxConfig, int8_t* datarate )
694 {
695 switch( region )
696 {
697 AS923_RX_CONFIG( );
698 AU915_RX_CONFIG( );
699 CN470_RX_CONFIG( );
700 CN779_RX_CONFIG( );
701 EU433_RX_CONFIG( );
702 EU868_RX_CONFIG( );
703 KR920_RX_CONFIG( );
704 IN865_RX_CONFIG( );
705 US915_RX_CONFIG( );
706 RU864_RX_CONFIG( );
707 default:
708 {
709 return false;
710 }
711 }
712 }
713
RegionTxConfig(LoRaMacRegion_t region,TxConfigParams_t * txConfig,int8_t * txPower,TimerTime_t * txTimeOnAir)714 bool RegionTxConfig( LoRaMacRegion_t region, TxConfigParams_t* txConfig, int8_t* txPower, TimerTime_t* txTimeOnAir )
715 {
716 switch( region )
717 {
718 AS923_TX_CONFIG( );
719 AU915_TX_CONFIG( );
720 CN470_TX_CONFIG( );
721 CN779_TX_CONFIG( );
722 EU433_TX_CONFIG( );
723 EU868_TX_CONFIG( );
724 KR920_TX_CONFIG( );
725 IN865_TX_CONFIG( );
726 US915_TX_CONFIG( );
727 RU864_TX_CONFIG( );
728 default:
729 {
730 return false;
731 }
732 }
733 }
734
RegionLinkAdrReq(LoRaMacRegion_t region,LinkAdrReqParams_t * linkAdrReq,int8_t * drOut,int8_t * txPowOut,uint8_t * nbRepOut,uint8_t * nbBytesParsed)735 uint8_t RegionLinkAdrReq( LoRaMacRegion_t region, LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
736 {
737 switch( region )
738 {
739 AS923_LINK_ADR_REQ( );
740 AU915_LINK_ADR_REQ( );
741 CN470_LINK_ADR_REQ( );
742 CN779_LINK_ADR_REQ( );
743 EU433_LINK_ADR_REQ( );
744 EU868_LINK_ADR_REQ( );
745 KR920_LINK_ADR_REQ( );
746 IN865_LINK_ADR_REQ( );
747 US915_LINK_ADR_REQ( );
748 RU864_LINK_ADR_REQ( );
749 default:
750 {
751 return 0;
752 }
753 }
754 }
755
RegionRxParamSetupReq(LoRaMacRegion_t region,RxParamSetupReqParams_t * rxParamSetupReq)756 uint8_t RegionRxParamSetupReq( LoRaMacRegion_t region, RxParamSetupReqParams_t* rxParamSetupReq )
757 {
758 switch( region )
759 {
760 AS923_RX_PARAM_SETUP_REQ( );
761 AU915_RX_PARAM_SETUP_REQ( );
762 CN470_RX_PARAM_SETUP_REQ( );
763 CN779_RX_PARAM_SETUP_REQ( );
764 EU433_RX_PARAM_SETUP_REQ( );
765 EU868_RX_PARAM_SETUP_REQ( );
766 KR920_RX_PARAM_SETUP_REQ( );
767 IN865_RX_PARAM_SETUP_REQ( );
768 US915_RX_PARAM_SETUP_REQ( );
769 RU864_RX_PARAM_SETUP_REQ( );
770 default:
771 {
772 return 0;
773 }
774 }
775 }
776
RegionNewChannelReq(LoRaMacRegion_t region,NewChannelReqParams_t * newChannelReq)777 int8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq )
778 {
779 switch( region )
780 {
781 AS923_NEW_CHANNEL_REQ( );
782 AU915_NEW_CHANNEL_REQ( );
783 CN470_NEW_CHANNEL_REQ( );
784 CN779_NEW_CHANNEL_REQ( );
785 EU433_NEW_CHANNEL_REQ( );
786 EU868_NEW_CHANNEL_REQ( );
787 KR920_NEW_CHANNEL_REQ( );
788 IN865_NEW_CHANNEL_REQ( );
789 US915_NEW_CHANNEL_REQ( );
790 RU864_NEW_CHANNEL_REQ( );
791 default:
792 {
793 return 0;
794 }
795 }
796 }
797
RegionTxParamSetupReq(LoRaMacRegion_t region,TxParamSetupReqParams_t * txParamSetupReq)798 int8_t RegionTxParamSetupReq( LoRaMacRegion_t region, TxParamSetupReqParams_t* txParamSetupReq )
799 {
800 switch( region )
801 {
802 AS923_TX_PARAM_SETUP_REQ( );
803 AU915_TX_PARAM_SETUP_REQ( );
804 CN470_TX_PARAM_SETUP_REQ( );
805 CN779_TX_PARAM_SETUP_REQ( );
806 EU433_TX_PARAM_SETUP_REQ( );
807 EU868_TX_PARAM_SETUP_REQ( );
808 KR920_TX_PARAM_SETUP_REQ( );
809 IN865_TX_PARAM_SETUP_REQ( );
810 US915_TX_PARAM_SETUP_REQ( );
811 RU864_TX_PARAM_SETUP_REQ( );
812 default:
813 {
814 return 0;
815 }
816 }
817 }
818
RegionDlChannelReq(LoRaMacRegion_t region,DlChannelReqParams_t * dlChannelReq)819 int8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq )
820 {
821 switch( region )
822 {
823 AS923_DL_CHANNEL_REQ( );
824 AU915_DL_CHANNEL_REQ( );
825 CN470_DL_CHANNEL_REQ( );
826 CN779_DL_CHANNEL_REQ( );
827 EU433_DL_CHANNEL_REQ( );
828 EU868_DL_CHANNEL_REQ( );
829 KR920_DL_CHANNEL_REQ( );
830 IN865_DL_CHANNEL_REQ( );
831 US915_DL_CHANNEL_REQ( );
832 RU864_DL_CHANNEL_REQ( );
833 default:
834 {
835 return 0;
836 }
837 }
838 }
839
RegionAlternateDr(LoRaMacRegion_t region,int8_t currentDr,AlternateDrType_t type)840 int8_t RegionAlternateDr( LoRaMacRegion_t region, int8_t currentDr, AlternateDrType_t type )
841 {
842 switch( region )
843 {
844 AS923_ALTERNATE_DR( );
845 AU915_ALTERNATE_DR( );
846 CN470_ALTERNATE_DR( );
847 CN779_ALTERNATE_DR( );
848 EU433_ALTERNATE_DR( );
849 EU868_ALTERNATE_DR( );
850 KR920_ALTERNATE_DR( );
851 IN865_ALTERNATE_DR( );
852 US915_ALTERNATE_DR( );
853 RU864_ALTERNATE_DR( );
854 default:
855 {
856 return 0;
857 }
858 }
859 }
860
RegionNextChannel(LoRaMacRegion_t region,NextChanParams_t * nextChanParams,uint8_t * channel,TimerTime_t * time,TimerTime_t * aggregatedTimeOff)861 LoRaMacStatus_t RegionNextChannel( LoRaMacRegion_t region, NextChanParams_t* nextChanParams, uint8_t* channel, TimerTime_t* time, TimerTime_t* aggregatedTimeOff )
862 {
863 switch( region )
864 {
865 AS923_NEXT_CHANNEL( );
866 AU915_NEXT_CHANNEL( );
867 CN470_NEXT_CHANNEL( );
868 CN779_NEXT_CHANNEL( );
869 EU433_NEXT_CHANNEL( );
870 EU868_NEXT_CHANNEL( );
871 KR920_NEXT_CHANNEL( );
872 IN865_NEXT_CHANNEL( );
873 US915_NEXT_CHANNEL( );
874 RU864_NEXT_CHANNEL( );
875 default:
876 {
877 return LORAMAC_STATUS_REGION_NOT_SUPPORTED;
878 }
879 }
880 }
881
RegionChannelAdd(LoRaMacRegion_t region,ChannelAddParams_t * channelAdd)882 LoRaMacStatus_t RegionChannelAdd( LoRaMacRegion_t region, ChannelAddParams_t* channelAdd )
883 {
884 switch( region )
885 {
886 AS923_CHANNEL_ADD( );
887 AU915_CHANNEL_ADD( );
888 CN470_CHANNEL_ADD( );
889 CN779_CHANNEL_ADD( );
890 EU433_CHANNEL_ADD( );
891 EU868_CHANNEL_ADD( );
892 KR920_CHANNEL_ADD( );
893 IN865_CHANNEL_ADD( );
894 US915_CHANNEL_ADD( );
895 RU864_CHANNEL_ADD( );
896 default:
897 {
898 return LORAMAC_STATUS_PARAMETER_INVALID;
899 }
900 }
901 }
902
RegionChannelsRemove(LoRaMacRegion_t region,ChannelRemoveParams_t * channelRemove)903 bool RegionChannelsRemove( LoRaMacRegion_t region, ChannelRemoveParams_t* channelRemove )
904 {
905 switch( region )
906 {
907 AS923_CHANNEL_REMOVE( );
908 AU915_CHANNEL_REMOVE( );
909 CN470_CHANNEL_REMOVE( );
910 CN779_CHANNEL_REMOVE( );
911 EU433_CHANNEL_REMOVE( );
912 EU868_CHANNEL_REMOVE( );
913 KR920_CHANNEL_REMOVE( );
914 IN865_CHANNEL_REMOVE( );
915 US915_CHANNEL_REMOVE( );
916 RU864_CHANNEL_REMOVE( );
917 default:
918 {
919 return false;
920 }
921 }
922 }
923
RegionApplyDrOffset(LoRaMacRegion_t region,uint8_t downlinkDwellTime,int8_t dr,int8_t drOffset)924 uint8_t RegionApplyDrOffset( LoRaMacRegion_t region, uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset )
925 {
926 switch( region )
927 {
928 AS923_APPLY_DR_OFFSET( );
929 AU915_APPLY_DR_OFFSET( );
930 CN470_APPLY_DR_OFFSET( );
931 CN779_APPLY_DR_OFFSET( );
932 EU433_APPLY_DR_OFFSET( );
933 EU868_APPLY_DR_OFFSET( );
934 KR920_APPLY_DR_OFFSET( );
935 IN865_APPLY_DR_OFFSET( );
936 US915_APPLY_DR_OFFSET( );
937 RU864_APPLY_DR_OFFSET( );
938 default:
939 {
940 return dr;
941 }
942 }
943 }
944
RegionRxBeaconSetup(LoRaMacRegion_t region,RxBeaconSetup_t * rxBeaconSetup,uint8_t * outDr)945 void RegionRxBeaconSetup( LoRaMacRegion_t region, RxBeaconSetup_t* rxBeaconSetup, uint8_t* outDr )
946 {
947 switch( region )
948 {
949 AS923_RX_BEACON_SETUP( );
950 AU915_RX_BEACON_SETUP( );
951 CN470_RX_BEACON_SETUP( );
952 CN779_RX_BEACON_SETUP( );
953 EU433_RX_BEACON_SETUP( );
954 EU868_RX_BEACON_SETUP( );
955 KR920_RX_BEACON_SETUP( );
956 IN865_RX_BEACON_SETUP( );
957 US915_RX_BEACON_SETUP( );
958 RU864_RX_BEACON_SETUP( );
959 default:
960 {
961 break;
962 }
963 }
964 }
965
RegionGetVersion(void)966 Version_t RegionGetVersion( void )
967 {
968 Version_t version;
969
970 version.Value = REGION_VERSION;
971
972 return version;
973 }
974
975