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