19#ifndef SEMTECH_LORAMAC_H
20#define SEMTECH_LORAMAC_H
37#define MSG_TYPE_ISR (0x3456)
38#define MSG_TYPE_RX_TIMEOUT (0x3457)
39#define MSG_TYPE_TX_TIMEOUT (0x3458)
40#define MSG_TYPE_MAC_TIMEOUT (0x3459)
41#define MSG_TYPE_LORAMAC_CMD (0x3460)
42#define MSG_TYPE_LORAMAC_JOIN_STATUS (0x3461)
43#define MSG_TYPE_LORAMAC_TX_STATUS (0x3462)
44#define MSG_TYPE_LORAMAC_MLME_CONFIRM (0x3463)
45#define MSG_TYPE_LORAMAC_MLME_INDICATION (0x3464)
46#define MSG_TYPE_LORAMAC_MCPS_CONFIRM (0x3465)
47#define MSG_TYPE_LORAMAC_MCPS_INDICATION (0x3466)
53#define LORAWAN_APP_DATA_MAX_SIZE (242U)
79 SEMTECH_LORAMAC_STATE_IDLE = 0,
80 SEMTECH_LORAMAC_STATE_BUSY
100#if defined(MODULE_SEMTECH_LORAMAC_RX) || DOXYGEN
117#if defined(MODULE_SEMTECH_LORAMAC_RX) || DOXYGEN
125#if defined(MODULE_SEMTECH_LORAMAC_RX) || DOXYGEN
179#if defined(MODULE_SEMTECH_LORAMAC_RX) || DOXYGEN
215#if defined(MODULE_SEMTECH_LORAMAC_RX) || DOXYGEN
531#ifdef MODULE_PERIPH_EEPROM
535#ifndef SEMTECH_LORAMAC_EEPROM_MAGIC
536#define SEMTECH_LORAMAC_EEPROM_MAGIC {0x52, 0x49, 0x4F, 0x54}
542#ifndef SEMTECH_LORAMAC_EEPROM_MAGIC_LEN
543#define SEMTECH_LORAMAC_EEPROM_MAGIC_LEN 4
549#ifndef SEMTECH_LORAMAC_EEPROM_START
550#define SEMTECH_LORAMAC_EEPROM_START (0)
563void semtech_loramac_erase_config(
void);
Definitions low-level network driver interface.
#define LORAMAC_APPKEY_LEN
Application key length in bytes.
#define LORAMAC_APPEUI_LEN
Application EUI length in bytes.
#define LORAMAC_DEVEUI_LEN
Device EUI length in bytes.
loramac_class_t
Device class.
Adds include for missing inttype definitions.
LoRaMAC header definitions.
Mutex for thread synchronization.
#define LORAWAN_APP_DATA_MAX_SIZE
Maximum payload size of a LoRaWAN application data.
loramac_class_t semtech_loramac_get_class(semtech_loramac_t *mac)
Gets the device class.
uint32_t semtech_loramac_get_uplink_counter(semtech_loramac_t *mac)
Gets the Uplink Frame Counter.
uint8_t semtech_loramac_join(semtech_loramac_t *mac, uint8_t type)
Starts a LoRaWAN network join procedure.
void semtech_loramac_set_rx2_dr(semtech_loramac_t *mac, uint8_t dr)
Sets the RX2 datarate.
uint8_t semtech_loramac_get_tx_mode(semtech_loramac_t *mac)
Gets the TX confirmable mode.
void semtech_loramac_set_devaddr(semtech_loramac_t *mac, const uint8_t *addr)
Sets the device address.
void semtech_loramac_get_appeui(const semtech_loramac_t *mac, uint8_t *eui)
Gets the application EUI.
uint8_t semtech_loramac_get_tx_port(semtech_loramac_t *mac)
Gets the TX application port.
void semtech_loramac_get_appkey(const semtech_loramac_t *mac, uint8_t *key)
Gets the application key.
void semtech_loramac_set_deveui(semtech_loramac_t *mac, const uint8_t *eui)
Sets the device EUI.
uint32_t semtech_loramac_get_rx2_freq(semtech_loramac_t *mac)
Gets the RX2 frequency.
void semtech_loramac_set_min_rx_symbols(semtech_loramac_t *mac, uint8_t min_rx)
Sets the minimum required number of symbols to detect a frame.
uint8_t semtech_loramac_recv(semtech_loramac_t *mac)
Wait for a message sent by the LoRaWAN network.
void semtech_loramac_set_appskey(semtech_loramac_t *mac, const uint8_t *skey)
Sets the application session key.
void semtech_loramac_get_nwkskey(semtech_loramac_t *mac, uint8_t *skey)
Gets the network session key.
void semtech_loramac_set_tx_port(semtech_loramac_t *mac, uint8_t port)
Sets the TX application port.
void semtech_loramac_set_class(semtech_loramac_t *mac, loramac_class_t cls)
Sets the device class.
uint8_t semtech_loramac_get_tx_power(semtech_loramac_t *mac)
Gets the channels TX power index.
void semtech_loramac_set_public_network(semtech_loramac_t *mac, bool public)
Enable/disable the public network mode.
void semtech_loramac_get_devaddr(semtech_loramac_t *mac, uint8_t *addr)
Gets the device address.
void semtech_loramac_get_deveui(const semtech_loramac_t *mac, uint8_t *eui)
Gets the device EUI.
uint8_t semtech_loramac_send(semtech_loramac_t *mac, uint8_t *data, uint8_t len)
Sends data to the LoRaWAN network.
bool semtech_loramac_get_adr(semtech_loramac_t *mac)
Checks if adaptive datarate is set.
void semtech_loramac_set_appeui(semtech_loramac_t *mac, const uint8_t *eui)
Sets the application EUI.
void semtech_loramac_set_nwkskey(semtech_loramac_t *mac, const uint8_t *skey)
Sets the network session key.
void semtech_loramac_set_appkey(semtech_loramac_t *mac, const uint8_t *key)
Sets the application key.
void semtech_loramac_set_channels_mask(semtech_loramac_t *mac, uint16_t *mask)
Sets the Channels Mask.
void semtech_loramac_set_tx_mode(semtech_loramac_t *mac, uint8_t mode)
Sets the TX confirmable mode.
int semtech_loramac_init(semtech_loramac_t *mac)
Initializes the semtech loramac mac.
void semtech_loramac_set_dr(semtech_loramac_t *mac, uint8_t dr)
Sets the channels datarate.
uint8_t semtech_loramac_get_dr(semtech_loramac_t *mac)
Gets the channels datarate.
uint32_t semtech_loramac_get_netid(semtech_loramac_t *mac)
Gets the NetID.
void semtech_loramac_set_netid(semtech_loramac_t *mac, uint32_t netid)
Sets the NetID (only useful with ABP join procedure)
void semtech_loramac_get_appskey(semtech_loramac_t *mac, uint8_t *skey)
Gets the application session key.
bool semtech_loramac_is_mac_joined(semtech_loramac_t *mac)
Check if network is already joined.
bool semtech_loramac_get_public_network(semtech_loramac_t *mac)
Checks if public network is set.
@ SEMTECH_LORAMAC_BUSY
Internal MAC is busy.
@ SEMTECH_LORAMAC_RX_DATA
Data received.
@ SEMTECH_LORAMAC_TX_ERROR
Error in TX (invalid param, unknown service)
@ SEMTECH_LORAMAC_JOIN_FAILED
Join procedure failed.
@ SEMTECH_LORAMAC_TX_OK
Transmission is in progress.
@ SEMTECH_LORAMAC_RX_LINK_CHECK
Link check info received.
@ SEMTECH_LORAMAC_NOT_JOINED
MAC is not joined.
@ SEMTECH_LORAMAC_TX_CNF_FAILED
Confirmable transmission failed.
@ SEMTECH_LORAMAC_RX_CONFIRMED
Confirmed ACK received.
@ SEMTECH_LORAMAC_ALREADY_JOINED
MAC is already joined.
@ SEMTECH_LORAMAC_TX_DONE
Transmission completed.
@ SEMTECH_LORAMAC_DUTYCYCLE_RESTRICTED
Restricted access to channels.
@ SEMTECH_LORAMAC_TX_SCHEDULE
TX needs reschedule.
@ SEMTECH_LORAMAC_JOIN_SUCCEEDED
Join procedure succeeded.
void semtech_loramac_set_uplink_counter(semtech_loramac_t *mac, uint32_t counter)
Sets the Uplink Frame Counter.
void semtech_loramac_request_link_check(semtech_loramac_t *mac)
Requests a LoRaWAN link check.
void semtech_loramac_get_channels_mask(semtech_loramac_t *mac, uint16_t *mask)
Gets the Channels Mask.
uint8_t semtech_loramac_get_rx2_dr(semtech_loramac_t *mac)
Gets the RX2 datarate.
void semtech_loramac_set_tx_power(semtech_loramac_t *mac, uint8_t power)
Sets the channels TX power index.
void semtech_loramac_set_rx2_freq(semtech_loramac_t *mac, uint32_t freq)
Sets the RX2 frequency.
void semtech_loramac_set_adr(semtech_loramac_t *mac, bool adr)
Enables/disable adaptive datarate.
void semtech_loramac_set_system_max_rx_error(semtech_loramac_t *mac, uint32_t error)
Sets the maximum system overall timing error for RX (in ms)
Structure to hold driver state.
LoRaMAC channel radio parameters.
uint32_t frequency
channel center frequency
uint8_t datarate
channel datarate
LoRaMAC link check information.
uint8_t nb_gateways
number of LoRa gateways found
uint8_t demod_margin
Demodulation margin.
Structure containing LoRaWAN RX data.
uint8_t payload_len
Length of the RX payload.
Semtech LoRaMAC descriptor.
uint8_t rx_pid
pid of receiver thread
uint8_t tx_pid
pid of sender thread
uint8_t cnf
enable/disable confirmable messages
mutex_t lock
loramac access lock
netdev_t * netdev
pointer to internal radio device
semtech_loramac_link_check_info_t link_chk
link check information
uint8_t port
application TX port
semtech_loramac_rx_data_t rx_data
struct handling the RX data