L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
lora_info.c
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
2/**
3 ******************************************************************************
4 * @file lora_info.c
5 * @author MCD Application Team
6 * @brief To give info to the application about LoRaWAN configuration
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/* USER CODE END Header */
20
21/* Includes ------------------------------------------------------------------*/
22#include "LoRaMac.h"
23#include "lora_info.h"
24#include "lorawan_conf.h"
25#include "sys_app.h" /* APP_PRINTF */
26
27/* USER CODE BEGIN Includes */
28
29/* USER CODE END Includes */
30
31/* Private typedef -----------------------------------------------------------*/
32
33/* USER CODE BEGIN PTD */
34
35/* USER CODE END PTD */
36
37/* Private define ------------------------------------------------------------*/
38
39/* USER CODE BEGIN PD */
40
41/* USER CODE END PD */
42
43/* Private macro -------------------------------------------------------------*/
44
45/* USER CODE BEGIN PM */
46
47/* USER CODE END PM */
48
49/* Private variables ---------------------------------------------------------*/
50static LoraInfo_t loraInfo = {0, 0};
51
52/* USER CODE BEGIN PV */
53
54/* USER CODE END PV */
55
56/* Private function prototypes -----------------------------------------------*/
57
58/* USER CODE BEGIN PFP */
59
60/* USER CODE END PFP */
61
62/* Exported variables --------------------------------------------------------*/
63
64/* USER CODE BEGIN EV */
65
66/* USER CODE END EV */
67
68/* Exported functions --------------------------------------------------------*/
69void LoraInfo_Init(void)
70{
71 loraInfo.ContextManagement = 0;
72 loraInfo.Region = 0;
73 loraInfo.ClassB = 0;
74 loraInfo.Kms = 0;
75 /* USER CODE BEGIN LoraInfo_Init_1 */
76
77 /* USER CODE END LoraInfo_Init_1 */
78
79#ifdef REGION_AS923
80 loraInfo.Region |= (1 << LORAMAC_REGION_AS923);
81#endif /* REGION_AS923 */
82#ifdef REGION_AU915
83 loraInfo.Region |= (1 << LORAMAC_REGION_AU915);
84#endif /* REGION_AU915 */
85#ifdef REGION_CN470
86 loraInfo.Region |= (1 << LORAMAC_REGION_CN470);
87#endif /* REGION_CN470 */
88#ifdef REGION_CN779
89 loraInfo.Region |= (1 << LORAMAC_REGION_CN779);
90#endif /* REGION_CN779 */
91#ifdef REGION_EU433
92 loraInfo.Region |= (1 << LORAMAC_REGION_EU433);
93#endif /* REGION_EU433 */
94#ifdef REGION_EU868
95 loraInfo.Region |= (1 << LORAMAC_REGION_EU868);
96#endif /* REGION_EU868 */
97#ifdef REGION_KR920
98 loraInfo.Region |= (1 << LORAMAC_REGION_KR920);
99#endif /* REGION_KR920 */
100#ifdef REGION_IN865
101 loraInfo.Region |= (1 << LORAMAC_REGION_IN865);
102#endif /* REGION_IN865 */
103#ifdef REGION_US915
104 loraInfo.Region |= (1 << LORAMAC_REGION_US915);
105#endif /* REGION_US915 */
106#ifdef REGION_RU864
107 loraInfo.Region |= (1 << LORAMAC_REGION_RU864);
108#endif /* REGION_RU864 */
109
110 if (loraInfo.Region == 0)
111 {
112 APP_PRINTF("error: At least one region shall be defined in the MW: check lorawan_conf.h \r\n");
113 while (1 != UTIL_ADV_TRACE_IsBufferEmpty())
114 {
115 /* Wait that all printfs are completed*/
116 }
117 while (1) {} /* At least one region shall be defined */
118 }
119
120#if ( LORAMAC_CLASSB_ENABLED == 1 )
121 loraInfo.ClassB = 1;
122#elif !defined (LORAMAC_CLASSB_ENABLED)
123#error LORAMAC_CLASSB_ENABLED not defined ( shall be <0 or 1> )
124#endif /* LORAMAC_CLASSB_ENABLED */
125
126#if (!defined (LORAWAN_KMS) || (LORAWAN_KMS == 0))
127 loraInfo.Kms = 0;
128#else /* LORAWAN_KMS == 1 */
129 loraInfo.Kms = 1;
130#endif /* LORAWAN_KMS */
131
132#if (!defined (CONTEXT_MANAGEMENT_ENABLED) || (CONTEXT_MANAGEMENT_ENABLED == 0))
133 loraInfo.ContextManagement = 0;
134#else /* CONTEXT_MANAGEMENT_ENABLED == 1 */
135 loraInfo.ContextManagement = 1;
136#endif /* CONTEXT_MANAGEMENT_ENABLED */
137
138 /* USER CODE BEGIN LoraInfo_Init_2 */
139
140 /* USER CODE END LoraInfo_Init_2 */
141}
142
144{
145 /* USER CODE BEGIN LoraInfo_GetPtr */
146
147 /* USER CODE END LoraInfo_GetPtr */
148 return &loraInfo;
149}
150
151/* USER CODE BEGIN EF */
152
153/* USER CODE END EF */
154
155/* Private functions --------------------------------------------------------*/
156
157/* USER CODE BEGIN PF */
158
159/* USER CODE END PF */
static LoraInfo_t loraInfo
Definition lora_info.c:50
LoraInfo_t * LoraInfo_GetPtr(void)
returns the pointer to the LoraInfo capabilities table
Definition lora_info.c:143
void LoraInfo_Init(void)
initialize the LoraInfo table
Definition lora_info.c:69
To give info to the application about LoRaWAN configuration.
Header for LoRaWAN middleware instances.
Function prototypes for sys_app.c file.
#define APP_PRINTF(...)
Definition sys_app.h:61