L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
lora_app.c
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
2/**
3 ******************************************************************************
4 * @file lora_app.c
5 * @author MCD Application Team
6 * @brief Application of the LRWAN Middleware
7 ******************************************************************************
8 * @attention
9 *
10 * Copyright (c) 2026 STMicroelectronics.
11 * All rights reserved.
12 *
13 * This software is licensed under terms that can be found in the LICENSE file
14 * in the root directory of this software component.
15 * If no LICENSE file comes with this software, it is provided AS-IS.
16 *
17 ******************************************************************************
18 */
19
20/* USER CODE END Header */
21
22/* Includes ------------------------------------------------------------------*/
23#include "platform.h"
24#include "sys_app.h"
25#include "lora_app.h"
26#include "stm32_seq.h"
27#include "stm32_timer.h"
28#include "utilities_def.h"
29#include "app_version.h"
30#include "lorawan_version.h"
31#include "subghz_phy_version.h"
32#include "lora_info.h"
33#include "LmHandler.h"
34#include "adc_if.h"
35#include "CayenneLpp.h"
36#include "sys_sensors.h"
37#include "flash_if.h"
38
39/* USER CODE BEGIN Includes */
40#include "secure-element.h"
41#include "mylora_process.h"
42#include "mysensors_base.h"
43/* USER CODE END Includes */
44
45/* External variables ---------------------------------------------------------*/
46/* USER CODE BEGIN EV */
47
48/* USER CODE END EV */
49
50/* Private typedef -----------------------------------------------------------*/
51/**
52 * @brief LoRa State Machine states
53 */
54typedef enum TxEventType_e
55{
56 /**
57 * @brief Appdata Transmission issue based on timer every TxDutyCycleTime
58 */
60 /**
61 * @brief Appdata Transmission external event plugged on OnSendEvent( )
62 */
64 /* USER CODE BEGIN TxEventType_t */
65
66 /* USER CODE END TxEventType_t */
68
69/* USER CODE BEGIN PTD */
70
71/* USER CODE END PTD */
72
73/* Private define ------------------------------------------------------------*/
74/**
75 * LEDs period value of the timer in ms
76 */
77#define LED_PERIOD_TIME 500
78
79/**
80 * Join switch period value of the timer in ms
81 */
82#define JOIN_TIME 2000
83
84/*---------------------------------------------------------------------------*/
85/* LoRaWAN NVM configuration */
86/*---------------------------------------------------------------------------*/
87/**
88 * @brief LoRaWAN NVM Flash address
89 * @note last 2 sector of a 128kBytes device
90 */
91#define LORAWAN_NVM_BASE_ADDRESS ((void *)0x0803F000UL)
92
93/* USER CODE BEGIN PD */
94
95/* USER CODE END PD */
96
97/* Private macro -------------------------------------------------------------*/
98/* USER CODE BEGIN PM */
99
100/* USER CODE END PM */
101
102/* Private function prototypes -----------------------------------------------*/
103/**
104 * @brief LoRa End Node send request
105 */
106static void SendTxData(void);
107
108/**
109 * @brief TX timer callback function
110 * @param context ptr of timer context
111 */
112static void OnTxTimerEvent(void *context);
113
114/**
115 * @brief join event callback function
116 * @param joinParams status of join
117 */
118static void OnJoinRequest(LmHandlerJoinParams_t *joinParams);
119
120/**
121 * @brief callback when LoRaWAN application has sent a frame
122 * @brief tx event callback function
123 * @param params status of last Tx
124 */
125static void OnTxData(LmHandlerTxParams_t *params);
126
127/**
128 * @brief callback when LoRaWAN application has received a frame
129 * @param appData data received in the last Rx
130 * @param params status of last Rx
131 */
132static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params);
133
134/**
135 * @brief callback when LoRaWAN Beacon status is updated
136 * @param params status of Last Beacon
137 */
138static void OnBeaconStatusChange(LmHandlerBeaconParams_t *params);
139
140/**
141 * @brief callback when system time has been updated
142 */
143static void OnSysTimeUpdate(void);
144
145/**
146 * @brief callback when LoRaWAN application Class is changed
147 * @param deviceClass new class
148 */
149static void OnClassChange(DeviceClass_t deviceClass);
150
151/**
152 * @brief LoRa store context in Non Volatile Memory
153 */
154static void StoreContext(void);
155
156/**
157 * @brief stop current LoRa execution to switch into non default Activation mode
158 */
159static void StopJoin(void);
160
161/**
162 * @brief Join switch timer callback function
163 * @param context ptr of Join switch context
164 */
165static void OnStopJoinTimerEvent(void *context);
166
167/**
168 * @brief Notifies the upper layer that the NVM context has changed
169 * @param state Indicates if we are storing (true) or restoring (false) the NVM context
170 */
171static void OnNvmDataChange(LmHandlerNvmContextStates_t state);
172
173/**
174 * @brief Store the NVM Data context to the Flash
175 * @param nvm ptr on nvm structure
176 * @param nvm_size number of data bytes which were stored
177 */
178static void OnStoreContextRequest(void *nvm, uint32_t nvm_size);
179
180/**
181 * @brief Restore the NVM Data context from the Flash
182 * @param nvm ptr on nvm structure
183 * @param nvm_size number of data bytes which were restored
184 */
185static void OnRestoreContextRequest(void *nvm, uint32_t nvm_size);
186
187/**
188 * Will be called each time a Radio IRQ is handled by the MAC layer
189 *
190 */
191static void OnMacProcessNotify(void);
192
193/**
194 * @brief Change the periodicity of the uplink frames
195 * @param periodicity uplink frames period in ms
196 * @note Compliance test protocol callbacks
197 */
198static void OnTxPeriodicityChanged(uint32_t periodicity);
199
200/**
201 * @brief Change the confirmation control of the uplink frames
202 * @param isTxConfirmed Indicates if the uplink requires an acknowledgement
203 * @note Compliance test protocol callbacks
204 */
205static void OnTxFrameCtrlChanged(LmHandlerMsgTypes_t isTxConfirmed);
206
207/**
208 * @brief Change the periodicity of the ping slot frames
209 * @param pingSlotPeriodicity ping slot frames period in ms
210 * @note Compliance test protocol callbacks
211 */
212static void OnPingSlotPeriodicityChanged(uint8_t pingSlotPeriodicity);
213
214/**
215 * @brief Will be called to reset the system
216 * @note Compliance test protocol callbacks
217 */
218static void OnSystemReset(void);
219
220/* USER CODE BEGIN PFP */
221
222/* USER CODE END PFP */
223
224/* Private variables ---------------------------------------------------------*/
225/**
226 * @brief LoRaWAN default activation type
227 */
229
230/**
231 * @brief LoRaWAN force rejoin even if the NVM context is restored
232 */
234
235/**
236 * @brief LoRaWAN handler Callbacks
237 */
238static LmHandlerCallbacks_t LmHandlerCallbacks =
239{
240 .GetBatteryLevel = GetBatteryLevel,
241 .GetTemperature = GetTemperatureLevel,
242 .GetUniqueId = GetUniqueId,
243 .GetDevAddr = GetDevAddr,
244 .OnRestoreContextRequest = OnRestoreContextRequest,
245 .OnStoreContextRequest = OnStoreContextRequest,
246 .OnMacProcess = OnMacProcessNotify,
247 .OnNvmDataChange = OnNvmDataChange,
248 .OnJoinRequest = OnJoinRequest,
249 .OnTxData = OnTxData,
250 .OnRxData = OnRxData,
251 .OnBeaconStatusChange = OnBeaconStatusChange,
252 .OnSysTimeUpdate = OnSysTimeUpdate,
253 .OnClassChange = OnClassChange,
254 .OnTxPeriodicityChanged = OnTxPeriodicityChanged,
255 .OnTxFrameCtrlChanged = OnTxFrameCtrlChanged,
256 .OnPingSlotPeriodicityChanged = OnPingSlotPeriodicityChanged,
257 .OnSystemReset = OnSystemReset,
258};
259
260/**
261 * @brief LoRaWAN handler parameters
262 */
263static LmHandlerParams_t LmHandlerParams =
264{
265 .ActiveRegion = ACTIVE_REGION,
266 .DefaultClass = LORAWAN_DEFAULT_CLASS,
267 .AdrEnable = LORAWAN_ADR_STATE,
269 .TxDatarate = LORAWAN_DEFAULT_DATA_RATE,
270 .TxPower = LORAWAN_DEFAULT_TX_POWER,
271 .PingSlotPeriodicity = LORAWAN_DEFAULT_PING_SLOT_PERIODICITY,
273};
274
275/**
276 * @brief Type of Event to generate application Tx
277 */
279
280/**
281 * @brief Timer to handle the application Tx
282 */
283static UTIL_TIMER_Object_t TxTimer;
284
285/**
286 * @brief Tx Timer period
287 */
288static UTIL_TIMER_Time_t TxPeriodicity = APP_TX_DUTYCYCLE;
289
290/**
291 * @brief Join Timer period
292 */
293static UTIL_TIMER_Object_t StopJoinTimer;
294
295/* USER CODE BEGIN PV */
296/* USER CODE END PV */
297
298/* Exported functions ---------------------------------------------------------*/
299/* USER CODE BEGIN EF */
301{
302 LmHandlerParams.AdrEnable = (_systemParams.LoRaAdaptiveDataRate != 0);
303 LmHandlerParams.TxDatarate = _systemParams.LoRaDataRate;
304 LmHandlerParams.TxPower = _systemParams.LoRaTxPower;
305 LmHandlerParams.DefaultClass = (DeviceClass_t)_systemParams.LoRaClass;
306 LmHandlerParams.ActiveRegion = (LoRaMacRegion_t)_systemParams.LoRaRegion;
307}
308/* USER CODE END EF */
309
310void LoRaWAN_Init(void)
311{
312 /* USER CODE BEGIN LoRaWAN_Init_LV */
313 APP_LOG(TS_OFF, VLEVEL_M, "LoRaWAN_Init IN ...\r\n");
314 /* USER CODE END LoRaWAN_Init_LV */
315
316 /* USER CODE BEGIN LoRaWAN_Init_1 */
317 //EventType = TX_ON_EVENT; // MT 26.1.2026 - event controlled LoRa, no timer cez MX
318 /* USER CODE END LoRaWAN_Init_1 */
319
320 UTIL_TIMER_Create(&StopJoinTimer, JOIN_TIME, UTIL_TIMER_ONESHOT, OnStopJoinTimerEvent, NULL);
321
322 UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_LmHandlerProcess), UTIL_SEQ_RFU, LmHandlerProcess);
323
324 UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), UTIL_SEQ_RFU, SendTxData);
325 UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_LoRaStoreContextEvent), UTIL_SEQ_RFU, StoreContext);
326 UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_LoRaStopJoinEvent), UTIL_SEQ_RFU, StopJoin);
327
328 /* Init Info table used by LmHandler*/
330
331 /* Init the Lora Stack*/
332 LmHandlerInit(&LmHandlerCallbacks, APP_VERSION);
333
334 LmHandlerConfigure(&LmHandlerParams);
335
336 /* USER CODE BEGIN LoRaWAN_Init_2 */
337 // MT 27.1.2025
338// SecureElementSetDevEui(getAppDevEUI());
339 LmHandlerSetKey(APP_KEY, systemParams_getAppKey());
340 LmHandlerSetKey(NWK_KEY, systemParams_getAppKey());
341 LmHandlerSetDevEUI(systemParams_getAppDevEUI());
342 LmHandlerSetAppEUI(systemParams_getAppEUI());
343 //SecureElementSetJoinEui(getAppEUI()); toto je druha moznost
344 SecureElementPrintKeys(); // again print after change of DevEUI
345 /* USER CODE END LoRaWAN_Init_2 */
346
347 LmHandlerJoin(ActivationType, ForceRejoin);
348
349 if (EventType == TX_ON_TIMER)
350 {
351 /* send every time timer elapses */
352 UTIL_TIMER_Create(&TxTimer, TxPeriodicity, UTIL_TIMER_ONESHOT, OnTxTimerEvent, NULL);
353 UTIL_TIMER_Start(&TxTimer);
354 }
355 else
356 {
357 /* USER CODE BEGIN LoRaWAN_Init_3 */
358
359 /* USER CODE END LoRaWAN_Init_3 */
360 }
361
362 /* USER CODE BEGIN LoRaWAN_Init_Last */
363 APP_LOG(TS_OFF, VLEVEL_M, "LoRaWAN_Init OUT ...\r\n");
364
365 /* USER CODE END LoRaWAN_Init_Last */
366}
367
368/* USER CODE BEGIN PB_Callbacks */
369
370#if 0 /* User should remove the #if 0 statement and adapt the below code according with his needs*/
371void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
372{
373 switch (GPIO_Pin)
374 {
375 case BUT1_Pin:
376 /* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
377 if (EventType == TX_ON_EVENT)
378 {
380 }
381 break;
382 case BUT2_Pin:
383 UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStopJoinEvent), CFG_SEQ_Prio_0);
384 break;
385 case BUT3_Pin:
386 UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStoreContextEvent), CFG_SEQ_Prio_0);
387 break;
388 default:
389 break;
390 }
391}
392#endif
393
394/* USER CODE END PB_Callbacks */
395
396/* Private functions ---------------------------------------------------------*/
397/* USER CODE BEGIN PrFD */
398
399/* USER CODE END PrFD */
400
401static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
402{
403 /* USER CODE BEGIN OnRxData_1 */
404 // Call the user-defined handler in main.c
405 OnLoRaWANRxData(appData, params);
406 /* USER CODE END OnRxData_1 */
407}
408
409static void SendTxData(void)
410{
411 /* USER CODE BEGIN SendTxData_1 */
412
413 /* USER CODE END SendTxData_1 */
414}
415
416static void OnTxTimerEvent(void *context)
417{
418 /* USER CODE BEGIN OnTxTimerEvent_1 */
419
420 /* USER CODE END OnTxTimerEvent_1 */
422
423 /*Wait for next tx slot*/
424 UTIL_TIMER_Start(&TxTimer);
425 /* USER CODE BEGIN OnTxTimerEvent_2 */
426
427 /* USER CODE END OnTxTimerEvent_2 */
428}
429
430/* USER CODE BEGIN PrFD_LedEvents */
431
432/* USER CODE END PrFD_LedEvents */
433
434static void OnTxData(LmHandlerTxParams_t *params)
435{
436 /* USER CODE BEGIN OnTxData_1 */
437 // Call the user-defined handler in main.c
438 OnLoRaWANTxData(params);
439 /* USER CODE END OnTxData_1 */
440}
441
442static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
443{
444 /* USER CODE BEGIN OnJoinRequest_1 */
445 if (joinParams != NULL && joinParams->Status == LORAMAC_HANDLER_SUCCESS)
446 {
447 /* Call the user function when LoRaWAN successfully connects */
449 }
450 /* USER CODE END OnJoinRequest_1 */
451}
452
453static void OnBeaconStatusChange(LmHandlerBeaconParams_t *params)
454{
455 /* USER CODE BEGIN OnBeaconStatusChange_1 */
456 /* USER CODE END OnBeaconStatusChange_1 */
457}
458
459static void OnSysTimeUpdate(void)
460{
461 /* USER CODE BEGIN OnSysTimeUpdate_1 */
463 /* USER CODE END OnSysTimeUpdate_1 */
464}
465
466static void OnClassChange(DeviceClass_t deviceClass)
467{
468 /* USER CODE BEGIN OnClassChange_1 */
469 /* USER CODE END OnClassChange_1 */
470}
471
472static void OnMacProcessNotify(void)
473{
474 /* USER CODE BEGIN OnMacProcessNotify_1 */
475
476 /* USER CODE END OnMacProcessNotify_1 */
477 UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LmHandlerProcess), CFG_SEQ_Prio_0);
478
479 /* USER CODE BEGIN OnMacProcessNotify_2 */
480
481 /* USER CODE END OnMacProcessNotify_2 */
482}
483
484static void OnTxPeriodicityChanged(uint32_t periodicity)
485{
486 /* USER CODE BEGIN OnTxPeriodicityChanged_1 */
487
488 /* USER CODE END OnTxPeriodicityChanged_1 */
489 TxPeriodicity = periodicity;
490
491 if (TxPeriodicity == 0)
492 {
493 /* Revert to application default periodicity */
495 }
496
497 /* Update timer periodicity */
498 UTIL_TIMER_Stop(&TxTimer);
499 UTIL_TIMER_SetPeriod(&TxTimer, TxPeriodicity);
500 UTIL_TIMER_Start(&TxTimer);
501 /* USER CODE BEGIN OnTxPeriodicityChanged_2 */
502
503 /* USER CODE END OnTxPeriodicityChanged_2 */
504}
505
506static void OnTxFrameCtrlChanged(LmHandlerMsgTypes_t isTxConfirmed)
507{
508 /* USER CODE BEGIN OnTxFrameCtrlChanged_1 */
509
510 /* USER CODE END OnTxFrameCtrlChanged_1 */
511 LmHandlerParams.IsTxConfirmed = isTxConfirmed;
512 /* USER CODE BEGIN OnTxFrameCtrlChanged_2 */
513
514 /* USER CODE END OnTxFrameCtrlChanged_2 */
515}
516
517static void OnPingSlotPeriodicityChanged(uint8_t pingSlotPeriodicity)
518{
519 /* USER CODE BEGIN OnPingSlotPeriodicityChanged_1 */
520
521 /* USER CODE END OnPingSlotPeriodicityChanged_1 */
522 LmHandlerParams.PingSlotPeriodicity = pingSlotPeriodicity;
523 /* USER CODE BEGIN OnPingSlotPeriodicityChanged_2 */
524
525 /* USER CODE END OnPingSlotPeriodicityChanged_2 */
526}
527
528static void OnSystemReset(void)
529{
530 /* USER CODE BEGIN OnSystemReset_1 */
531
532 /* USER CODE END OnSystemReset_1 */
533 if ((LORAMAC_HANDLER_SUCCESS == LmHandlerHalt()) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET))
534 {
535 NVIC_SystemReset();
536 }
537 /* USER CODE BEGIN OnSystemReset_Last */
538
539 /* USER CODE END OnSystemReset_Last */
540}
541
542static void StopJoin(void)
543{
544 /* USER CODE BEGIN StopJoin_1 */
545
546 /* USER CODE END StopJoin_1 */
547
548 UTIL_TIMER_Stop(&TxTimer);
549
550 if (LORAMAC_HANDLER_SUCCESS != LmHandlerStop())
551 {
552 APP_LOG(TS_OFF, VLEVEL_M, "LmHandler Stop on going ...\r\n");
553 }
554 else
555 {
556 APP_LOG(TS_OFF, VLEVEL_M, "LmHandler Stopped\r\n");
557 if (LORAWAN_DEFAULT_ACTIVATION_TYPE == ACTIVATION_TYPE_ABP)
558 {
559 ActivationType = ACTIVATION_TYPE_OTAA;
560 APP_LOG(TS_OFF, VLEVEL_M, "LmHandler switch to OTAA mode\r\n");
561 }
562 else
563 {
564 ActivationType = ACTIVATION_TYPE_ABP;
565 APP_LOG(TS_OFF, VLEVEL_M, "LmHandler switch to ABP mode\r\n");
566 }
567 LmHandlerConfigure(&LmHandlerParams);
568 LmHandlerJoin(ActivationType, true);
569 UTIL_TIMER_Start(&TxTimer);
570 }
571 UTIL_TIMER_Start(&StopJoinTimer);
572 /* USER CODE BEGIN StopJoin_Last */
573
574 /* USER CODE END StopJoin_Last */
575}
576
577static void OnStopJoinTimerEvent(void *context)
578{
579 /* USER CODE BEGIN OnStopJoinTimerEvent_1 */
580
581 /* USER CODE END OnStopJoinTimerEvent_1 */
583 {
584 UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStopJoinEvent), CFG_SEQ_Prio_0);
585 }
586 /* USER CODE BEGIN OnStopJoinTimerEvent_Last */
587
588 /* USER CODE END OnStopJoinTimerEvent_Last */
589}
590
591static void StoreContext(void)
592{
593 LmHandlerErrorStatus_t status = LORAMAC_HANDLER_ERROR;
594
595 /* USER CODE BEGIN StoreContext_1 */
596
597 /* USER CODE END StoreContext_1 */
598 status = LmHandlerNvmDataStore();
599
600 if (status == LORAMAC_HANDLER_NVM_DATA_UP_TO_DATE)
601 {
602 APP_LOG(TS_OFF, VLEVEL_M, "NVM DATA UP TO DATE\r\n");
603 }
604 else if (status == LORAMAC_HANDLER_ERROR)
605 {
606 APP_LOG(TS_OFF, VLEVEL_M, "NVM DATA STORE FAILED\r\n");
607 }
608 /* USER CODE BEGIN StoreContext_Last */
609
610 /* USER CODE END StoreContext_Last */
611}
612
613static void OnNvmDataChange(LmHandlerNvmContextStates_t state)
614{
615 /* USER CODE BEGIN OnNvmDataChange_1 */
616
617 /* USER CODE END OnNvmDataChange_1 */
618 if (state == LORAMAC_HANDLER_NVM_STORE)
619 {
620 APP_LOG(TS_OFF, VLEVEL_M, "NVM DATA STORED\r\n");
621 }
622 else
623 {
624 APP_LOG(TS_OFF, VLEVEL_M, "NVM DATA RESTORED\r\n");
625 }
626 /* USER CODE BEGIN OnNvmDataChange_Last */
627
628 /* USER CODE END OnNvmDataChange_Last */
629}
630
631static void OnStoreContextRequest(void *nvm, uint32_t nvm_size)
632{
633 /* USER CODE BEGIN OnStoreContextRequest_1 */
634
635 /* USER CODE END OnStoreContextRequest_1 */
636 FLASH_IF_Write(LORAWAN_NVM_BASE_ADDRESS, (const void *)nvm, nvm_size);
637
638 /* USER CODE BEGIN OnStoreContextRequest_Last */
639
640 /* USER CODE END OnStoreContextRequest_Last */
641}
642
643static void OnRestoreContextRequest(void *nvm, uint32_t nvm_size)
644{
645 /* USER CODE BEGIN OnRestoreContextRequest_1 */
646
647 /* USER CODE END OnRestoreContextRequest_1 */
649 /* USER CODE BEGIN OnRestoreContextRequest_Last */
650
651 /* USER CODE END OnRestoreContextRequest_Last */
652}
653
Implements the Cayenne Low Power Protocol.
Header for ADC interface configuration.
Definition the version of the application.
#define APP_VERSION
Application version.
Definition app_version.h:64
This file contains definitions for FLASH Interface functionalities.
FLASH_IF_StatusTypedef FLASH_IF_Write(void *pDestination, const void *pSource, uint32_t uLength)
This function writes a data buffer in internal or external flash.
Definition flash_if.c:143
FLASH_IF_StatusTypedef FLASH_IF_Read(void *pDestination, const void *pSource, uint32_t uLength)
This function reads a amount of data from flash and copy into the output data buffer.
Definition flash_if.c:159
static ActivationType_t ActivationType
LoRaWAN default activation type.
Definition lora_app.c:228
static UTIL_TIMER_Time_t TxPeriodicity
Tx Timer period.
Definition lora_app.c:288
static void OnSysTimeUpdate(void)
callback when system time has been updated
Definition lora_app.c:459
static void OnTxData(LmHandlerTxParams_t *params)
callback when LoRaWAN application has sent a frame
Definition lora_app.c:434
static void OnSystemReset(void)
Will be called to reset the system.
Definition lora_app.c:528
static void OnTxFrameCtrlChanged(LmHandlerMsgTypes_t isTxConfirmed)
Change the confirmation control of the uplink frames.
Definition lora_app.c:506
static void OnStoreContextRequest(void *nvm, uint32_t nvm_size)
Store the NVM Data context to the Flash.
Definition lora_app.c:631
static LmHandlerCallbacks_t LmHandlerCallbacks
LoRaWAN handler Callbacks.
Definition lora_app.c:238
static void OnNvmDataChange(LmHandlerNvmContextStates_t state)
Notifies the upper layer that the NVM context has changed.
Definition lora_app.c:613
#define JOIN_TIME
Definition lora_app.c:82
static TxEventType_t EventType
Type of Event to generate application Tx.
Definition lora_app.c:278
static LmHandlerParams_t LmHandlerParams
LoRaWAN handler parameters.
Definition lora_app.c:263
static void OnStopJoinTimerEvent(void *context)
Join switch timer callback function.
Definition lora_app.c:577
static void OnTxTimerEvent(void *context)
TX timer callback function.
Definition lora_app.c:416
static void StopJoin(void)
stop current LoRa execution to switch into non default Activation mode
Definition lora_app.c:542
static void OnClassChange(DeviceClass_t deviceClass)
callback when LoRaWAN application Class is changed
Definition lora_app.c:466
TxEventType_t
LoRa State Machine states.
Definition lora_app.c:55
@ TX_ON_EVENT
Appdata Transmission external event plugged on OnSendEvent( ).
Definition lora_app.c:63
@ TX_ON_TIMER
Appdata Transmission issue based on timer every TxDutyCycleTime.
Definition lora_app.c:59
#define LORAWAN_NVM_BASE_ADDRESS
LoRaWAN NVM Flash address.
Definition lora_app.c:91
static UTIL_TIMER_Object_t StopJoinTimer
Join Timer period.
Definition lora_app.c:293
static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
callback when LoRaWAN application has received a frame
Definition lora_app.c:401
static void OnMacProcessNotify(void)
Definition lora_app.c:472
static void OnTxPeriodicityChanged(uint32_t periodicity)
Change the periodicity of the uplink frames.
Definition lora_app.c:484
void LoRaWAN_Init(void)
Init Lora Application.
Definition lora_app.c:310
static void OnPingSlotPeriodicityChanged(uint8_t pingSlotPeriodicity)
Change the periodicity of the ping slot frames.
Definition lora_app.c:517
static void OnRestoreContextRequest(void *nvm, uint32_t nvm_size)
Restore the NVM Data context from the Flash.
Definition lora_app.c:643
static void SendTxData(void)
LoRa End Node send request.
Definition lora_app.c:409
static void OnBeaconStatusChange(LmHandlerBeaconParams_t *params)
callback when LoRaWAN Beacon status is updated
Definition lora_app.c:453
static bool ForceRejoin
LoRaWAN force rejoin even if the NVM context is restored.
Definition lora_app.c:233
static void StoreContext(void)
LoRa store context in Non Volatile Memory.
Definition lora_app.c:591
static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
join event callback function
Definition lora_app.c:442
void systemParams_SetLoRaWanParams()
set the lorawan parameters from _systemParams before start of loraWan
Definition lora_app.c:300
static UTIL_TIMER_Object_t TxTimer
Timer to handle the application Tx.
Definition lora_app.c:283
Header of application of the LRWAN Middleware.
#define LORAWAN_DEFAULT_ACTIVATION_TYPE
Definition lora_app.h:100
#define APP_TX_DUTYCYCLE
Definition lora_app.h:54
#define LORAWAN_ADR_STATE
Definition lora_app.h:82
#define LORAWAN_DEFAULT_CLASS_B_C_RESP_TIMEOUT
Definition lora_app.h:128
#define LORAWAN_DEFAULT_PING_SLOT_PERIODICITY
Definition lora_app.h:119
#define ACTIVE_REGION
Definition lora_app.h:42
#define LORAWAN_DEFAULT_DATA_RATE
Definition lora_app.h:88
#define LORAWAN_FORCE_REJOIN_AT_BOOT
Definition lora_app.h:106
#define LORAWAN_DEFAULT_CONFIRMED_MSG_STATE
Definition lora_app.h:76
#define LORAWAN_DEFAULT_CLASS
Definition lora_app.h:71
#define LORAWAN_DEFAULT_TX_POWER
Definition lora_app.h:95
void LoraInfo_Init(void)
initialize the LoraInfo table
Definition lora_info.c:69
To give info to the application about LoRaWAN configuration.
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
called from GPIO interrupt
Definition main.c:133
void OnTimeSynchronized(void)
Called after date/time has been synchronized from LoRaWAN.
void OnLoRaWANRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
Handle received downlink data from LoRaWAN server.
void OnLoRaWanConnected(void)
Called after LoRaWAN successfully connects to the server.
void OnLoRaWANTxData(LmHandlerTxParams_t *params)
Handle transmission event callback.
systemParams_t _systemParams
uint8_t * systemParams_getAppKey()
Return a pointer to the AppKey stored in _systemParams. Used by the LoRaWAN stack to derive session k...
uint8_t * systemParams_getAppEUI()
Return a pointer to the AppEUI (JoinEUI) stored in _systemParams. Used by the LoRaWAN stack during th...
uint8_t * systemParams_getAppDevEUI()
Return a pointer to the DevEUI stored in _systemParams. The DevEUI is auto-generated from the chip UI...
Header for General HW instances configuration.
Function prototypes for sys_app.c file.
void GetDevAddr(uint32_t *devAddr)
callback to get the board 32 bits unique ID (LSB)
Definition sys_app.c:239
#define APP_LOG(TS, VL,...)
Definition sys_app.h:66
int16_t GetTemperatureLevel(void)
callback to get the current temperature in the MCU
Definition sys_app.c:184
void GetUniqueId(uint8_t *id)
callback to get the board 64 bits unique ID
Definition sys_app.c:198
uint8_t GetBatteryLevel(void)
callback to get the battery level in % of full charge (254 full charge, 0 no charge)
Definition sys_app.c:152
Header for sensors application.
#define VLEVEL_M
#define TS_OFF
Definitions for modules requiring utilities.
@ CFG_SEQ_Prio_0
@ CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent
@ CFG_SEQ_Task_LoRaStopJoinEvent
@ CFG_SEQ_Task_LoRaStoreContextEvent
@ CFG_SEQ_Task_LmHandlerProcess