Skip to content

Commit 70d0306

Browse files
authored
Merge pull request #23 from giulcioffi/update_1.3.1
ST fw update for band selection at runtime
2 parents 2b551f1 + a37d89d commit 70d0306

File tree

9 files changed

+164
-120
lines changed

9 files changed

+164
-120
lines changed

Middlewares/Third_Party/LoRaWAN/Mac/LoRaMac.h

+51-46
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,53 @@
172172
*/
173173
#define LORAMAC_CRYPTO_MULTICAST_KEYS 127
174174

175+
/*!
176+
* LoRaMAC region enumeration
177+
*/
178+
typedef enum eLoRaMacRegion_t
179+
{
180+
/*!
181+
* AS band on 923MHz
182+
*/
183+
LORAMAC_REGION_AS923,
184+
/*!
185+
* Australian band on 915MHz
186+
*/
187+
LORAMAC_REGION_AU915,
188+
/*!
189+
* Chinese band on 470MHz
190+
*/
191+
LORAMAC_REGION_CN470,
192+
/*!
193+
* Chinese band on 779MHz
194+
*/
195+
LORAMAC_REGION_CN779,
196+
/*!
197+
* European band on 433MHz
198+
*/
199+
LORAMAC_REGION_EU433,
200+
/*!
201+
* European band on 868MHz
202+
*/
203+
LORAMAC_REGION_EU868,
204+
/*!
205+
* South korean band on 920MHz
206+
*/
207+
LORAMAC_REGION_KR920,
208+
/*!
209+
* India band on 865MHz
210+
*/
211+
LORAMAC_REGION_IN865,
212+
/*!
213+
* North american band on 915MHz
214+
*/
215+
LORAMAC_REGION_US915,
216+
/*!
217+
* Russia band on 864MHz
218+
*/
219+
LORAMAC_REGION_RU864,
220+
}LoRaMacRegion_t;
221+
175222
/*!
176223
* End-Device activation type
177224
*/
@@ -915,6 +962,10 @@ typedef struct sMcpsIndication
915962
* Set if a DeviceTimeAns MAC command was received.
916963
*/
917964
bool DeviceTimeAnsReceived;
965+
/*!
966+
* Set the region currently in use
967+
*/
968+
LoRaMacRegion_t Region;
918969
}McpsIndication_t;
919970

920971
/*!
@@ -2244,52 +2295,6 @@ typedef enum eLoRaMacStatus
22442295
LORAMAC_STATUS_ERROR
22452296
}LoRaMacStatus_t;
22462297

2247-
/*!
2248-
* LoRaMAC region enumeration
2249-
*/
2250-
typedef enum eLoRaMacRegion_t
2251-
{
2252-
/*!
2253-
* AS band on 923MHz
2254-
*/
2255-
LORAMAC_REGION_AS923,
2256-
/*!
2257-
* Australian band on 915MHz
2258-
*/
2259-
LORAMAC_REGION_AU915,
2260-
/*!
2261-
* Chinese band on 470MHz
2262-
*/
2263-
LORAMAC_REGION_CN470,
2264-
/*!
2265-
* Chinese band on 779MHz
2266-
*/
2267-
LORAMAC_REGION_CN779,
2268-
/*!
2269-
* European band on 433MHz
2270-
*/
2271-
LORAMAC_REGION_EU433,
2272-
/*!
2273-
* European band on 868MHz
2274-
*/
2275-
LORAMAC_REGION_EU868,
2276-
/*!
2277-
* South korean band on 920MHz
2278-
*/
2279-
LORAMAC_REGION_KR920,
2280-
/*!
2281-
* India band on 865MHz
2282-
*/
2283-
LORAMAC_REGION_IN865,
2284-
/*!
2285-
* North american band on 915MHz
2286-
*/
2287-
LORAMAC_REGION_US915,
2288-
/*!
2289-
* Russia band on 864MHz
2290-
*/
2291-
LORAMAC_REGION_RU864,
2292-
}LoRaMacRegion_t;
22932298

22942299
/*!
22952300
* Enumeration of modules which have a context

Projects/B-L072Z-LRWAN1/Applications/LoRa/AT_Slave/Core/inc/mlm32l0xx_hw_conf.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ extern "C" {
7878
#define RADIO_DIO_5_PORT GPIOA
7979
#define RADIO_DIO_5_PIN GPIO_PIN_4
8080

81-
#define RADIO_TCXO_VCC_PORT GPIOA
82-
#define RADIO_TCXO_VCC_PIN GPIO_PIN_12
81+
#define RADIO_TCXO_VCC_PORT GPIOB
82+
#define RADIO_TCXO_VCC_PIN GPIO_PIN_6
8383

8484
#define RADIO_ANT_SWITCH_PORT_RX GPIOA //CRF1
8585
#define RADIO_ANT_SWITCH_PIN_RX GPIO_PIN_1

Projects/B-L072Z-LRWAN1/Applications/LoRa/AT_Slave/LoRaWAN/App/inc/at.h

+15
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ typedef enum eATEerror
5555

5656
/* AT Command strings. Commands start with AT */
5757
#define AT_RESET "Z"
58+
#define AT_BAND "+BAND"
5859
#define AT_DEUI "+DEUI"
5960
#define AT_DADDR "+DADDR"
6061
#define AT_APPKEY "+APPKEY"
@@ -131,6 +132,20 @@ ATEerror_t at_return_error(const char *param);
131132
*/
132133
ATEerror_t at_reset(const char *param);
133134

135+
/**
136+
* @brief Print RF Band in use
137+
* @param Param string of the AT command
138+
* @retval AT_OK if OK, or an appropriate AT_xxx error code
139+
*/
140+
ATEerror_t at_Band_get(const char *param);
141+
142+
/**
143+
* @brief Set RF Band in use
144+
* @param Param string of the AT command
145+
* @retval AT_OK if OK, or an appropriate AT_xxx error code
146+
*/
147+
ATEerror_t at_Band_set(const char *param);
148+
134149
/**
135150
* @brief Print Device EUI
136151
* @param Param string of the AT command - unused

Projects/B-L072Z-LRWAN1/Applications/LoRa/AT_Slave/LoRaWAN/App/inc/lora.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ typedef struct sLoRaMainCallback
222222
* @param [IN] application parmaters
223223
* @retval none
224224
*/
225-
void LORA_Init(LoRaMainCallback_t *callbacks, LoRaParam_t *LoRaParam);
225+
void LORA_Init(LoRaMainCallback_t *callbacks, LoRaParam_t *LoRaParam, LoRaMacRegion_t region);
226226

227227
/**
228228
* @brief run Lora classA state Machine
@@ -388,6 +388,13 @@ int8_t lora_config_tx_datarate_get(void);
388388
*/
389389
LoRaMacRegion_t lora_region_get(void);
390390

391+
/**
392+
* @brief triggers a reinit when band gets changed
393+
* @param none
394+
* @retval none
395+
*/
396+
void TriggerReinit( LoRaMacRegion_t region );
397+
391398
#ifdef __cplusplus
392399
}
393400
#endif

Projects/B-L072Z-LRWAN1/Applications/LoRa/AT_Slave/LoRaWAN/App/src/at.c

+27
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,13 @@ ATEerror_t at_JoinEUI_set(const char *param)
361361
return AT_PARAM_ERROR;
362362
}
363363

364+
MibRequestConfirm_t mib;
365+
LoRaMacStatus_t status;
364366
lora_config_joineui_set(JoinEui);
367+
mib.Type = MIB_JOIN_EUI;
368+
mib.Param.JoinEui = JoinEui;
369+
status = LoRaMacMibSetRequestConfirm(&mib);
370+
CHECK_STATUS(status);
365371
return AT_OK;
366372
}
367373

@@ -410,6 +416,27 @@ ATEerror_t at_AppKey_set(const char *param)
410416
return AT_OK;
411417
}
412418

419+
extern LoRaMacRegion_t globalRegion;
420+
ATEerror_t at_Band_get(const char *param)
421+
{
422+
print_d(globalRegion);
423+
return AT_OK;
424+
}
425+
426+
ATEerror_t at_Band_set(const char *param)
427+
{
428+
LoRaMacRegion_t region;
429+
if (tiny_sscanf(param, "%hhu", &region) != 1)
430+
{
431+
return AT_PARAM_ERROR;
432+
}
433+
if (region != globalRegion) {
434+
globalRegion = region;
435+
TriggerReinit(globalRegion);
436+
}
437+
return AT_OK;
438+
}
439+
413440
ATEerror_t at_NwkSKey_get(const char *param)
414441
{
415442
MibRequestConfirm_t mib;

Projects/B-L072Z-LRWAN1/Applications/LoRa/AT_Slave/LoRaWAN/App/src/command.c

+13
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@ static const struct ATCommand_s ATCommand[] =
109109
},
110110
#endif
111111

112+
#ifndef NO_BAND_RUNTIME_SWITCH
113+
{
114+
.string = AT_BAND,
115+
.size_string = sizeof(AT_BAND) - 1,
116+
#ifndef NO_HELP
117+
.help_string = "AT"AT_BAND ": Get or Set the Regional Band\r\n",
118+
#endif
119+
.get = at_Band_get,
120+
.set = at_Band_set,
121+
.run = at_return_error,
122+
},
123+
#endif
124+
112125
#ifndef NO_KEY_ADDR_EUI
113126
{
114127
.string = AT_APPKEY,

0 commit comments

Comments
 (0)