Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
lora.h File Reference

Public LoRa APIs. More...

#include <zephyr/types.h>
#include <device.h>

Go to the source code of this file.

Data Structures

struct  lora_modem_config
 
struct  lora_driver_api
 

Typedefs

typedef int(* lora_api_config) (const struct device *dev, struct lora_modem_config *config)
 Callback API for configuring the LoRa module. More...
 
typedef int(* lora_api_send) (const struct device *dev, uint8_t *data, uint32_t data_len)
 Callback API for sending data over LoRa. More...
 
typedef int(* lora_api_send_async) (const struct device *dev, uint8_t *data, uint32_t data_len, struct k_poll_signal *async)
 Callback API for sending data asynchronously over LoRa. More...
 
typedef int(* lora_api_recv) (const struct device *dev, uint8_t *data, uint8_t size, k_timeout_t timeout, int16_t *rssi, int8_t *snr)
 Callback API for receiving data over LoRa. More...
 
typedef int(* lora_api_test_cw) (const struct device *dev, uint32_t frequency, int8_t tx_power, uint16_t duration)
 Callback API for transmitting a continuous wave. More...
 

Enumerations

enum  lora_signal_bandwidth { BW_125_KHZ = 0 , BW_250_KHZ , BW_500_KHZ }
 
enum  lora_datarate {
  SF_6 = 6 , SF_7 , SF_8 , SF_9 ,
  SF_10 , SF_11 , SF_12
}
 
enum  lora_coding_rate { CR_4_5 = 1 , CR_4_6 = 2 , CR_4_7 = 3 , CR_4_8 = 4 }
 

Functions

static int lora_config (const struct device *dev, struct lora_modem_config *config)
 Configure the LoRa modem. More...
 
static int lora_send (const struct device *dev, uint8_t *data, uint32_t data_len)
 Send data over LoRa. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

Public LoRa APIs.

Typedef Documentation

◆ lora_api_config

lora_api_config

Callback API for configuring the LoRa module.

See also
lora_config() for argument descriptions.

◆ lora_api_recv

lora_api_recv

Callback API for receiving data over LoRa.

See also
lora_recv() for argument descriptions.

◆ lora_api_send

lora_api_send

Callback API for sending data over LoRa.

See also
lora_send() for argument descriptions.

◆ lora_api_send_async

lora_api_send_async

Callback API for sending data asynchronously over LoRa.

See also
lora_send_async() for argument descriptions.

◆ lora_api_test_cw

lora_api_test_cw

Callback API for transmitting a continuous wave.

See also
lora_test_cw() for argument descriptions.

Enumeration Type Documentation

◆ lora_coding_rate

Enumerator
CR_4_5 
CR_4_6 
CR_4_7 
CR_4_8 

◆ lora_datarate

Enumerator
SF_6 
SF_7 
SF_8 
SF_9 
SF_10 
SF_11 
SF_12 

◆ lora_signal_bandwidth

Enumerator
BW_125_KHZ 
BW_250_KHZ 
BW_500_KHZ 

Function Documentation

◆ lora_config()

static int lora_config ( const struct device dev,
struct lora_modem_config config 
)
inlinestatic

Configure the LoRa modem.

Parameters
devLoRa device
configData structure containing the intended configuration for the modem
Returns
0 on success, negative on error

◆ lora_recv()

static int lora_recv ( const struct device dev,
uint8_t data,
uint8_t  size,
k_timeout_t  timeout,
int16_t rssi,
int8_t snr 
)
inlinestatic

Receive data over LoRa.

Note
This is a blocking call.
Parameters
devLoRa device
dataBuffer to hold received data
sizeSize of the buffer to hold the received data. Max size allowed is 255.
timeoutDuration to wait for a packet.
rssiRSSI of received data
snrSNR of received data
Returns
Length of the data received on success, negative on error

◆ lora_send()

static int lora_send ( const struct device dev,
uint8_t data,
uint32_t  data_len 
)
inlinestatic

Send data over LoRa.

Note
This blocks until transmission is complete.
Parameters
devLoRa device
dataData to be sent
data_lenLength of the data to be sent
Returns
0 on success, negative on error

◆ lora_send_async()

static int lora_send_async ( const struct device dev,
uint8_t data,
uint32_t  data_len,
struct k_poll_signal async 
)
inlinestatic

Asynchronously send data over LoRa.

Note
This returns immediately after starting transmission, and locks the LoRa modem until the transmission completes.
Parameters
devLoRa device
dataData to be sent
data_lenLength of the data to be sent
asyncA pointer to a valid and ready to be signaled struct k_poll_signal. (Note: if NULL this function will not notify the end of the transmission).
Returns
0 on success, negative on error

◆ lora_test_cw()

static int lora_test_cw ( const struct device dev,
uint32_t  frequency,
int8_t  tx_power,
uint16_t  duration 
)
inlinestatic

Transmit an unmodulated continuous wave at a given frequency.

Note
Only use this functionality in a test setup where the transmission does not interfere with other devices.
Parameters
devLoRa device
frequencyOutput frequency (Hertz)
tx_powerTX power (dBm)
durationTransmission duration in seconds.
Returns
0 on success, negative on error