12#ifndef ZEPHYR_INCLUDE_DRIVERS_LORA_H_
13#define ZEPHYR_INCLUDE_DRIVERS_LORA_H_
226typedef void (*lora_cad_cb)(
const struct device *dev,
bool activity_detected,
235typedef int (*lora_api_config)(
const struct device *dev,
252typedef int (*lora_api_send)(
const struct device *dev,
261typedef int (*lora_api_send_async)(
const struct device *dev,
282typedef int (*lora_api_recv_async)(
const struct device *dev, lora_recv_cb cb,
299typedef int (*lora_api_cad_async)(
const struct device *dev, lora_cad_cb cb,
308typedef int (*lora_api_recv_duty_cycle)(
const struct device *dev,
311 lora_recv_cb cb,
void *user_data);
319typedef int (*lora_api_test_cw)(
const struct device *dev,
uint32_t frequency,
322__subsystem
struct lora_driver_api {
323 lora_api_config config;
324 lora_api_airtime airtime;
326 lora_api_send_async send_async;
328 lora_api_recv_async recv_async;
330 lora_api_cad_async cad_async;
331 lora_api_recv_duty_cycle recv_duty_cycle;
332 lora_api_test_cw test_cw;
348 const struct lora_driver_api *api =
349 (
const struct lora_driver_api *)dev->
api;
351 return api->config(dev, config);
365 const struct lora_driver_api *api =
366 (
const struct lora_driver_api *)dev->
api;
368 return api->airtime(dev, data_len);
386 const struct lora_driver_api *api =
387 (
const struct lora_driver_api *)dev->
api;
389 return api->send(dev, data, data_len);
412 const struct lora_driver_api *api =
413 (
const struct lora_driver_api *)dev->
api;
415 return api->send_async(dev, data, data_len, async);
438 const struct lora_driver_api *api =
439 (
const struct lora_driver_api *)dev->
api;
441 return api->recv(dev, data, size, timeout, rssi, snr);
462 const struct lora_driver_api *api =
463 (
const struct lora_driver_api *)dev->
api;
465 return api->recv_async(dev, cb, user_data);
486 const struct lora_driver_api *api =
487 (
const struct lora_driver_api *)dev->
api;
489 if (api->cad ==
NULL) {
493 return api->cad(dev, timeout);
513 const struct lora_driver_api *api =
514 (
const struct lora_driver_api *)dev->
api;
516 if (api->cad_async ==
NULL) {
520 return api->cad_async(dev, cb, user_data);
544 lora_recv_cb cb,
void *user_data)
546 const struct lora_driver_api *api =
547 (
const struct lora_driver_api *)dev->
api;
549 if (api->recv_duty_cycle ==
NULL) {
553 return api->recv_duty_cycle(dev, rx_period, sleep_period, cb, user_data);
571 const struct lora_driver_api *api =
572 (
const struct lora_driver_api *)dev->
api;
574 if (api->test_cw ==
NULL) {
578 return api->test_cw(dev, frequency, tx_power, duration);
lora_cad_symbol_num
Number of symbols used for Channel Activity Detection.
Definition lora.h:99
lora_cad_mode
Channel Activity Detection mode.
Definition lora.h:113
static int lora_test_cw(const struct device *dev, uint32_t frequency, int8_t tx_power, uint16_t duration)
Transmit an unmodulated continuous wave at a given frequency.
Definition lora.h:568
static int lora_recv(const struct device *dev, uint8_t *data, uint8_t size, k_timeout_t timeout, int16_t *rssi, int8_t *snr)
Receive data over LoRa.
Definition lora.h:434
lora_datarate
LoRa data-rate.
Definition lora.h:66
static int lora_cad_async(const struct device *dev, lora_cad_cb cb, void *user_data)
Perform Channel Activity Detection asynchronously.
Definition lora.h:510
static int lora_send_async(const struct device *dev, uint8_t *data, uint32_t data_len, struct k_poll_signal *async)
Asynchronously send data over LoRa.
Definition lora.h:408
static int lora_cad(const struct device *dev, k_timeout_t timeout)
Perform Channel Activity Detection.
Definition lora.h:484
lora_coding_rate
LoRa coding rate.
Definition lora.h:86
lora_signal_bandwidth
LoRa signal bandwidth.
Definition lora.h:40
static int lora_recv_duty_cycle(const struct device *dev, k_timeout_t rx_period, k_timeout_t sleep_period, lora_recv_cb cb, void *user_data)
Start receive duty cycling (wake-on-radio).
Definition lora.h:541
static int lora_config(const struct device *dev, struct lora_modem_config *config)
Configure the LoRa modem.
Definition lora.h:345
static int lora_send(const struct device *dev, uint8_t *data, uint32_t data_len)
Send data over LoRa.
Definition lora.h:383
static uint32_t lora_airtime(const struct device *dev, uint32_t data_len)
Query the airtime of a packet with a given length.
Definition lora.h:363
static int lora_recv_async(const struct device *dev, lora_recv_cb cb, void *user_data)
Receive data asynchronously over LoRa.
Definition lora.h:459
@ LORA_CAD_SYMB_8
8 symbols
Definition lora.h:103
@ LORA_CAD_SYMB_16
16 symbols
Definition lora.h:104
@ LORA_CAD_SYMB_2
2 symbols
Definition lora.h:101
@ LORA_CAD_SYMB_4
4 symbols
Definition lora.h:102
@ LORA_CAD_SYMB_1
1 symbol
Definition lora.h:100
@ LORA_CAD_MODE_RX
CAD before receive: lora_recv() performs CAD first and returns 0 immediately if no activity is detect...
Definition lora.h:123
@ LORA_CAD_MODE_NONE
No CAD (default).
Definition lora.h:115
@ LORA_CAD_MODE_LBT
Listen Before Talk: lora_send() performs CAD before transmitting and returns -EBUSY if the channel is...
Definition lora.h:129
@ SF_5
Spreading factor 5 (fastest, shortest range).
Definition lora.h:67
@ SF_12
Spreading factor 12 (slowest, longest range).
Definition lora.h:74
@ SF_8
Spreading factor 8.
Definition lora.h:70
@ SF_11
Spreading factor 11.
Definition lora.h:73
@ SF_10
Spreading factor 10.
Definition lora.h:72
@ SF_9
Spreading factor 9.
Definition lora.h:71
@ SF_6
Spreading factor 6.
Definition lora.h:68
@ SF_7
Spreading factor 7.
Definition lora.h:69
@ CR_4_5
Coding rate 4/5 (4 information bits, 1 error correction bit).
Definition lora.h:87
@ CR_4_6
Coding rate 4/6 (4 information bits, 2 error correction bits).
Definition lora.h:88
@ CR_4_8
Coding rate 4/8 (4 information bits, 4 error correction bits).
Definition lora.h:90
@ CR_4_7
Coding rate 4/7 (4 information bits, 3 error correction bits).
Definition lora.h:89
@ BW_200_KHZ
203 kHz
Definition lora.h:49
@ BW_250_KHZ
250 kHz
Definition lora.h:50
@ BW_10_KHZ
10.42 kHz
Definition lora.h:42
@ BW_31_KHZ
31.25 kHz
Definition lora.h:45
@ BW_125_KHZ
125 kHz
Definition lora.h:48
@ BW_400_KHZ
406 kHz
Definition lora.h:51
@ BW_800_KHZ
812 kHz
Definition lora.h:53
@ BW_41_KHZ
41.67 kHz
Definition lora.h:46
@ BW_500_KHZ
500 kHz
Definition lora.h:52
@ BW_62_KHZ
62.5 kHz
Definition lora.h:47
@ BW_7_KHZ
7.81 kHz
Definition lora.h:41
@ BW_1600_KHZ
1625 kHz
Definition lora.h:55
@ BW_15_KHZ
15.63 kHz
Definition lora.h:43
@ BW_20_KHZ
20.83 kHz
Definition lora.h:44
@ BW_1000_KHZ
1000 kHz
Definition lora.h:54
#define ENOSYS
Function not implemented.
Definition errno.h:82
#define NULL
Definition iar_missing_defs.h:20
ssize_t send(int sock, const void *buf, size_t len, int flags)
ssize_t recv(int sock, void *buf, size_t max_len, int flags)
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT8_TYPE__ int8_t
Definition stdint.h:72
__INT16_TYPE__ int16_t
Definition stdint.h:73
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
void * data
Address of the device instance private data.
Definition device.h:523
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:519
Kernel timeout type.
Definition clock.h:65
Structure containing the configuration of a LoRa modem.
Definition lora.h:136
struct lora_modem_config::@115122161215247245016110057201332052344206077034 cad
Channel Activity Detection parameters.
uint32_t frequency
Frequency in Hz to use for transceiving.
Definition lora.h:138
enum lora_signal_bandwidth bandwidth
The bandwidth to use for transceiving.
Definition lora.h:141
bool tx
Set to true for transmission, false for receiving.
Definition lora.h:156
bool packet_crc_disable
Set to true to disable the 16-bit payload CRC.
Definition lora.h:179
int8_t tx_power
TX-power in dBm to use for transmission.
Definition lora.h:153
uint8_t detection_peak
Detection peak threshold (hardware-specific, dimensionless).
Definition lora.h:193
bool iq_inverted
Invert the In-Phase and Quadrature (IQ) signals.
Definition lora.h:165
enum lora_coding_rate coding_rate
The coding rate to use for transceiving.
Definition lora.h:147
uint16_t preamble_len
Length of the preamble.
Definition lora.h:150
enum lora_cad_symbol_num symbol_num
Number of symbols for CAD detection.
Definition lora.h:187
enum lora_cad_mode mode
CAD mode.
Definition lora.h:184
enum lora_datarate datarate
The data-rate to use for transceiving.
Definition lora.h:144
uint8_t detection_minimum
Minimum detection threshold (hardware-specific, dimensionless).
Definition lora.h:199
bool public_network
Sets the sync-byte to use:
Definition lora.h:176