-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathll_ifc_no_mac.h
492 lines (459 loc) · 11.9 KB
/
ll_ifc_no_mac.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
#ifndef __LL_IFC_NO_MAC_H
#define __LL_IFC_NO_MAC_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup Link_Labs_Interface_Library
* @{
*/
/**
* @defgroup NoMac_Interface NoMAC
*
* @brief Perform low-level communication operations.
*
* NoMAC mode disables the media access control (MAC) firmware and allows
* the external host to directly issue low-level commands. NoMAC mode gives
* the external host direct control of the module's radio parameters,
* without any automatic network control. NoMAC is useful for network
* research and development while designing or experimenting with new MAC
* protocols. However, most products should use one of the provided MACs
* such as Symphony Link or LoRaWAN.
*
* @{
*/
/**
* @brief
* RSSI Scan set
*
* @param[in] u1 Status u1 (sent little-endian)
* @param[in] u2 Status u2 (sent little-endian)
* @param[in] u3 Status u3 (sent little-endian)
* @param[in] u4 Status u4 (sent little-endian)
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_rssi_scan_set(uint32_t u1, uint32_t u2, uint32_t u3, uint32_t u4);
/**
* @brief
* RSSI Scan get
*
* @param[out] buf
* byte array containing the data payload
*
* @param[in] len
* size of the output buffer in bytes,
*
* @param[out] bytes_received
* number of bytes received
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_rssi_scan_get(uint8_t buf[], uint16_t len, uint8_t *bytes_received);
/**
* @brief
* Gets the radio parameters of the module
*
* @details
*
* @param[out] sf: 6..12
*
* @param[out] cr: 1=CR4/5 ... 4=CR4/8
*
* @param[out] bw: 0=62.5kHz ... 3=500kHz
*
* @param[out] freq: center frequency in Hz
*
* @param[out] preamble_syms: length of preamble in number of symbols
*
* @param[out] header_enabled: boolean indicating whether LoRa header is enabled
*
* @param[out] crc_enabled: boolean indicating whether LoRa CRC is enabled
*
* @param[out] iq_inverted: boolean indicating whether IQ inversion is enabled
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_radio_params_get(uint8_t *sf, uint8_t *cr, uint8_t *bw, uint32_t *freq,
uint16_t *preamble_syms, uint8_t *header_enabled, uint8_t *crc_enabled,
uint8_t *iq_inverted);
/**
* @brief
* Sets multiple radio parameters at once
*
* @details
*
* @param[in] flags A bit mask which indicates which parameters to set.
* The available flag bits are:
* - RADIO_PARAM_FLAGS_SF
* - RADIO_PARAM_FLAGS_CR
* - RADIO_PARAM_FLAGS_BW
* - RADIO_PARAM_FLAGS_FREQ
* - RADIO_PARAM_FLAGS_PREAMBLE
* - RADIO_PARAM_FLAGS_HEADER
* - RADIO_PARAM_FLAGS_CRC
* - RADIO_PARAM_FLAGS_IQ
*
* @param[in] sf: 6..12
*
* @param[in] cr: 1=CR4/5 ... 4=CR4/8
*
* @param[in] bw: 0=62.5kHz ... 3=500kHz
*
* @param[in] freq: center frequency in Hz
*
* @param[in] preamble_syms The number of symbols to send in the preamble.
*
* @param[in] enable_header When nonzero, send the packet header.
* When zero, do not send a packet header.
*
* @param[in] enable_crc When non-zero, send a packet CRC. When zero, do not
* send a CRC.
*
* @param[in] enable_iq_inversion When non-zero, enable IQ inversion on the
* quadrature RF signal. When zero, use normal IQ.
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_radio_params_set(uint8_t flags, uint8_t sf, uint8_t cr, uint8_t bw, uint32_t freq,
uint16_t preamble_syms, uint8_t enable_header, uint8_t enable_crc,
uint8_t enable_iq_inversion);
/**
* @brief
* Set the RF bandwidth to a number between 0 and 3 corresponding to the
* bandwidths listed below.
*
* @details
* This function sets the RF bandwidth.
* - 0 - 62.5 kHz
* - 1 - 125 kHz
* - 2 - 250 kHz
* - 3 - 500 kHz
*
* @param[in] bandwidth
* bandwidth index (0 to 3)
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_bandwidth_set(uint8_t bandwidth);
/**
* @brief
* Set the spreading factor for the modulation. Both the receiver and the transmitter must have the same
* setting.
*
* @details
* This function sets the modulation spreading factor and must be a number in the range 6 to 12.
*
* @param[in] sf
* spreading factor number 6 to 12
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_spreading_factor_set(uint8_t sf);
/**
* @brief
* Set the coding rate. Both the receiver and the transmitter must have the same
* setting.
*
* @details
* This function sets the coding rate from 4/5 to 4/8:
* - 1 - 4/5
* - 2 - 4/6
* - 3 - 4/7
* - 4 - 4/8
*
* @param[in] coding_rate
* coding_rate number from 1 to 4
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_coding_rate_set(uint8_t coding_rate);
/**
* @brief
* Set the transmitter output power.
*
* @details
* This function sets the tx output power
*
* @param[in] pwr
* tx power in dBm
* - For the low power module, +2 to 20 dBm
* - For the high power module, +10 to 26 dBm
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_tx_power_set(int8_t pwr);
/**
* @brief
* Get the transmitter output power.
*
* @details
* Get the tx output power
*
* @param[out] pwr
* tx power in dBm
* - For the low power module, +2 to 20 dBm
* - For the high power module, +10 to 26 dBm
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_tx_power_get(int8_t *pwr);
/**
* @brief
* Set the tuned frequency. Both the receiver and the transmitter
* must have the same setting.
*
* @details
* This function sets the RF frequency
*
* @param[in] freq
* frequency in Hz - 820 MHz to 1020 MHz
*
* @note
* The modules is only designed for the 902 to 928 MHz band
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_frequency_set(uint32_t freq);
/**
* @brief
* Set the preamble length.
*
* @details
* This function sets the length of the LoRa preamble, in number of symbols.
*
* @param[in] num_syms
* length of the preamble in symbols.
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_preamble_syms_set(uint16_t num_syms);
/**
* @brief
* Enable or disable the LoRa header
*
* @details
* This function enables or disable the LoRa header. This is also known as the 'fixed-length' LoRa option.
*
* @param[in] enabled
* Boolean indicating whether to enable or disable the header.
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_header_enabled_set(uint8_t enabled);
/**
* @brief
* Enable or disable the LoRa CRC
*
* @details
* This function enables or disable the CRC attached to every LoRa packet.
*
* @param[in] enabled
* Boolean indicating whether to enable or disable the CRC.
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_crc_enabled_set(uint8_t enabled);
/**
* @brief
* Enable or disable the I/Q inversion.
*
* @param[in] inverted
* Boolean. A non-zero value indicates that I/Q inversion will be turned on.
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_iq_inversion_set(uint8_t inverted);
/**
* @brief
* Set the No MAC sync word
*
* @details
* This function sets the LoRa sync word
*
* @param[in] sync_word
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_sync_word_set(uint8_t sync_word);
/**
* @brief
* Get the LoRa sync word
*
* @details
* Get the LoRa sync word
*
* @param[out] sync_word
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_sync_word_get(uint8_t *sync_word);
/**
* @brief
* Put the module into echo mode
*
* @details
* In echo mode, the module is in a continous Receive mode. When a packet
* is received, it transmits the payload and received RSSI, SNR.
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_echo_mode();
/**
* @deprecated
* Cancel any active receive window and send a single Tx packet immediately.
* This just calls ll_packet_send_queue
*/
int32_t ll_packet_send(uint8_t buf[], uint16_t len);
/**
* @brief
* Cancel any active receive window and queue a packet for Tx.
*
* @details
* When the packet finishes transmission the module will return to the idle state.
*
* @param[in] buf
* byte array containing the data payload
*
* @param[in] len
* length of the input buffer in bytes
*
* @return
* int32_t 1 if packet queued
* int32_t 0 if queue is full
* negative if an error occured
*/
int32_t ll_packet_send_queue(uint8_t buf[], uint16_t len);
/**
* @brief
* Cancel any active receive window and queue a packet for transmission
* at a specified time.
*
* @details
* When the packet finishes transmission the module will return to the
* idle state. Also see ll_packet_send_queue().
*
* @param[in] timestamp_us
* The timestamp in microseconds when the next packet will be
* transmitted. Use ll_timestamp_get() and ll_timestamp_set()
* to determine the desired timestamp.
*
* @param[in] buf
* byte array containing the data payload
*
* @param[in] len
* length of the input buffer in bytes
*
* @return
* int32_t 1 if packet queued
* int32_t 0 if queue is full
* negative if an error occurred
*/
int32_t ll_packet_send_timestamp(uint32_t timestamp_us, uint8_t buf[], uint16_t len);
/**
* Commands the module to transmit a CW at the current frequency and power.
*/
int32_t ll_transmit_cw(void);
/**
* @brief
* Receive over-the-air data from the module continuously, with RSSI and SNR prepended to the payload
*
* @details
* This function puts the module into continuous receive mode and checks for any new packets.
* Once in continuous receive mode, this function must be called to poll for new packets.
*
* @param[out] buf
* byte array containing the data payload
*
* @param[in] len
* size of the output buffer in bytes,
*
* @param[out] bytes_received
* number of bytes received
*
* @note
* The first 2 bytes of the payload will be the int16_t rssi in units of dBm
* The third byte of the payload will be the estimated SnR
* The remaining bytes are the user payload
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_packet_recv_cont(uint8_t buf[], uint16_t len, uint8_t *bytes_received);
/**
* @brief
* Receive over-the-air data from the module
*
* @details
* This function puts the module into receive mode and checks for any new packets.
* Once in receive mode, this function must be called to poll for new packets.
*
* @param[in] num_timeout_symbols
* When search for a preamble, the modem will timeout after this number of symbols
*
* @param[out] buf
* byte array containing the data payload
*
* @param[in] len
* size of the output buffer in bytes,
*
* @param[out] bytes_received
* number of bytes received
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_packet_recv(uint16_t num_timeout_symbols, uint8_t buf[], uint16_t len, uint8_t *bytes_received);
/**
* @brief
* Receive over-the-air data from the module with RSSI and SNR prepended to the payload
*
* @details
* This function puts the module into receive mode and checks for any new packets.
* Once in receive mode, this function must be called to poll for new packets.
*
* @param[in] num_timeout_symbols
* When search for a preamble, the modem will timeout after this number of symbols
*
* @param[out] buf
* byte array containing the data payload
*
* @param[in] len
* size of the output buffer in bytes,
*
* @param[out] bytes_received
* number of bytes received
*
* @note
* The first 2 bytes of the payload will be the int16_t rssi in units of dBm
* The third byte of the payload will be the estimated SnR
* The remaining bytes are the user payload
*
* @return
* 0 - success, negative otherwise
*/
int32_t ll_packet_recv_with_rssi(uint16_t num_timeout_symbols, uint8_t buf[], uint16_t len, uint8_t *bytes_received);
/** @} (end defgroup NoMac_Interface) */
/** @} (end addtogroup Link_Labs_Interface_Library) */
#ifdef __cplusplus
}
#endif
#endif