lora.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 Inria
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
20 #include <stdint.h>
21 #include <stdlib.h>
22 
23 #include "modules.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
34 #ifndef LORA_FREQUENCY_RESOLUTION_NANOHERTZ_DEFAULT
40 #define LORA_FREQUENCY_RESOLUTION_NANOHERTZ_DEFAULT 61035156250
41 #endif
42 
54 #ifndef CONFIG_LORA_PREAMBLE_LENGTH_DEFAULT
55 #define CONFIG_LORA_PREAMBLE_LENGTH_DEFAULT (8U)
56 #endif
57 
63 #ifndef CONFIG_LORA_SYMBOL_TIMEOUT_DEFAULT
64 #define CONFIG_LORA_SYMBOL_TIMEOUT_DEFAULT (10U)
65 #endif
66 
72 #if IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_125)
73 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_125_KHZ)
74 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_250)
75 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_250_KHZ)
76 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_500)
77 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_500_KHZ)
78 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_200)
79 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_200_KHZ)
80 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_400)
81 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_400_KHZ)
82 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_800)
83 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_800_KHZ)
84 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_1600)
85 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_1600_KHZ)
86 #endif
87 
88 #ifndef CONFIG_LORA_BW_DEFAULT
89 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_125_KHZ)
90 #endif
91 
102 #if IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF6)
103 #define CONFIG_LORA_SF_DEFAULT (LORA_SF6)
104 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF7)
105 #define CONFIG_LORA_SF_DEFAULT (LORA_SF7)
106 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF8)
107 #define CONFIG_LORA_SF_DEFAULT (LORA_SF8)
108 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF9)
109 #define CONFIG_LORA_SF_DEFAULT (LORA_SF9)
110 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF10)
111 #define CONFIG_LORA_SF_DEFAULT (LORA_SF10)
112 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF11)
113 #define CONFIG_LORA_SF_DEFAULT (LORA_SF11)
114 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF12)
115 #define CONFIG_LORA_SF_DEFAULT (LORA_SF12)
116 #endif
117 
118 #ifndef CONFIG_LORA_SF_DEFAULT
119 #define CONFIG_LORA_SF_DEFAULT (LORA_SF7)
120 #endif
121 
134 #if IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_4_5)
135 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_4_5)
136 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_4_6)
137 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_4_6)
138 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_4_7)
139 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_4_7)
140 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_4_8)
141 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_4_8)
142 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_LI_4_5)
143 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_LI_4_5)
144 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_LI_4_6)
145 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_LI_4_6)
146 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_LI_4_8)
147 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_LI_4_8)
148 #endif
149 
150 #ifndef CONFIG_LORA_CR_DEFAULT
151 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_4_5)
152 #endif
153 
159 #ifdef DOXYGEN
160 #define CONFIG_LORA_IQ_INVERTED_DEFAULT
161 #endif
162 
169 #ifdef DOXYGEN
170 #define CONFIG_LORA_FREQUENCY_HOPPING_DEFAULT
171 #endif
172 
179 #ifndef CONFIG_LORA_FREQUENCY_HOPPING_PERIOD_DEFAULT
180 #define CONFIG_LORA_FREQUENCY_HOPPING_PERIOD_DEFAULT (0U)
181 #endif
182 
190 #ifdef DOXYGEN
191 #define CONFIG_LORA_FIXED_HEADER_LEN_MODE_DEFAULT
192 #endif
193 
197 #ifdef DOXYGEN
198 #define CONFIG_LORA_PAYLOAD_CRC_OFF_DEFAULT
199 #endif
200 
207 #ifndef CONFIG_LORA_PAYLOAD_LENGTH_DEFAULT
208 #define CONFIG_LORA_PAYLOAD_LENGTH_DEFAULT (0U)
209 #endif
216 #define LORA_SYNCWORD_PUBLIC (0x34)
217 #define LORA_SYNCWORD_PRIVATE (0x12)
218 /* see https://lora-developers.semtech.com/documentation/tech-papers-and-guides/physical-layer-proposal-2.4ghz */
219 #define LORA_SYNCWORD_ISM2400_PUBLIC (0x21)
228 #define LORA_ISM2400_FREQUENCY_LOW 2400000000
229 #define LORA_ISM2400_FREQUENCY_HIGH 2500000000
239 enum {
247 };
248 
252 enum {
253  LORA_SF5 = 5,
260  LORA_SF12
261 };
262 
266 enum {
274 };
277 #ifdef __cplusplus
278 }
279 #endif
280 
@ LORA_SF7
spreading factor 7
Definition: lora.h:255
@ LORA_SF6
spreading factor 6
Definition: lora.h:254
@ LORA_SF10
spreading factor 10
Definition: lora.h:258
@ LORA_SF12
spreading factor 12
Definition: lora.h:260
@ LORA_SF11
spreading factor 11
Definition: lora.h:259
@ LORA_SF8
spreading factor 8
Definition: lora.h:256
@ LORA_SF5
spreading factor 5, sx126x and sx1280
Definition: lora.h:253
@ LORA_SF9
spreading factor 9
Definition: lora.h:257
@ LORA_BW_125_KHZ
125 kHz bandwidth
Definition: lora.h:240
@ LORA_BW_400_KHZ
400 kHz bandwidth, only 2.4Ghz
Definition: lora.h:244
@ LORA_BW_200_KHZ
200 kHz bandwidth, only 2.4Ghz
Definition: lora.h:243
@ LORA_BW_1600_KHZ
1600 kHz bandwidth, only 2.4Ghz
Definition: lora.h:246
@ LORA_BW_800_KHZ
800 kHz bandwidth, only 2.4Ghz
Definition: lora.h:245
@ LORA_BW_250_KHZ
250 kHz bandwidth
Definition: lora.h:241
@ LORA_BW_500_KHZ
500 kHz bandwidth
Definition: lora.h:242
@ LORA_CR_LI_4_6
coding rate long interleaving 4/6
Definition: lora.h:272
@ LORA_CR_4_6
coding rate 4/6
Definition: lora.h:268
@ LORA_CR_4_7
coding rate 4/7
Definition: lora.h:269
@ LORA_CR_4_5
coding rate 4/5
Definition: lora.h:267
@ LORA_CR_LI_4_8
coding rate long interleaving 4/8
Definition: lora.h:273
@ LORA_CR_4_8
coding rate 4/8
Definition: lora.h:270
@ LORA_CR_LI_4_5
coding rate long interleaving 4/5
Definition: lora.h:271
Common macros and compiler attributes/pragmas configuration.