![]() |
LoRaMAC
4.4.7
Documentation of the API
|
This module specifies the API implementation of the LoRaMAC Class B layer. This is a placeholder for a detailed description of the LoRaMac layer and the supported features. More...
Data Structures | |
struct | PingSlotContext_t |
struct | BeaconContext_t |
struct | BeaconContext_t::sBeaconCtrl |
struct | LoRaMacClassBCallback_t |
struct | LoRaMacClassBParams_t |
struct | LoRaMacClassBPingSlotNvmData_t |
struct | LoRaMacClassBPingSlotNvmData_t::sPingSlotCtrlNvm |
struct | LoRaMacClassBBeaconNvmData_t |
struct | LoRaMacClassBBeaconNvmData_t::sBeaconCtrlNvm |
struct | LoRaMacClassBNvmData_t |
Macros | |
#define | CLASSB_BEACON_INTERVAL 128000 |
#define | CLASSB_BEACON_RESERVED 2120 |
#define | CLASSB_BEACON_GUARD 3000 |
#define | CLASSB_BEACON_WINDOW 122880 |
#define | CLASSB_BEACON_WINDOW_SLOTS 4096 |
#define | CLASSB_PING_SLOT_WINDOW 30 |
#define | CLASSB_MAX_BEACON_LESS_PERIOD 7200000 |
#define | CLASSB_BEACON_DELAY_BEACON_TIMING_ANS 30 |
#define | CLASSB_BEACON_SYMBOL_TO_DEFAULT 8 |
#define | CLASSB_BEACON_SYMBOL_TO_EXPANSION_MAX 255 |
#define | CLASSB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX 30 |
#define | CLASSB_BEACON_SYMBOL_TO_EXPANSION_FACTOR 2 |
#define | CLASSB_WINDOW_MOVE_DEFAULT 2 |
#define | CLASSB_WINDOW_MOVE_EXPANSION_MAX 256 |
#define | CLASSB_WINDOW_MOVE_EXPANSION_FACTOR 2 |
Typedefs | |
typedef void(* | LoRaMacClassBNvmEvent) (void) |
Functions | |
void | LoRaMacClassBInit (LoRaMacClassBParams_t *classBParams, LoRaMacClassBCallback_t *callbacks, LoRaMacClassBNvmData_t *nvm) |
Initialize LoRaWAN Class B. More... | |
void | LoRaMacClassBSetBeaconState (BeaconState_t beaconState) |
Set the state of the beacon state machine. More... | |
void | LoRaMacClassBSetPingSlotState (PingSlotState_t pingSlotState) |
Set the state of the ping slot state machine. More... | |
void | LoRaMacClassBSetMulticastSlotState (PingSlotState_t multicastSlotState) |
Set the state of the multicast slot state machine. More... | |
bool | LoRaMacClassBIsAcquisitionInProgress (void) |
Verifies if an acquisition procedure is in progress. More... | |
void | LoRaMacClassBBeaconTimerEvent (void *context) |
State machine of the Class B for beaconing. | |
void | LoRaMacClassBPingSlotTimerEvent (void *context) |
State machine of the Class B for ping slots. | |
void | LoRaMacClassBMulticastSlotTimerEvent (void *context) |
State machine of the Class B for multicast slots. | |
bool | LoRaMacClassBRxBeacon (uint8_t *payload, uint16_t size) |
Receives and decodes the beacon frame. More... | |
bool | LoRaMacClassBIsBeaconExpected (void) |
The function validates, if the node expects a beacon at the current time. More... | |
bool | LoRaMacClassBIsPingExpected (void) |
The function validates, if the node expects a ping slot at the current time. More... | |
bool | LoRaMacClassBIsMulticastExpected (void) |
The function validates, if the node expects a multicast slot at the current time. More... | |
bool | LoRaMacClassBIsAcquisitionPending (void) |
Verifies if the acquisition pending bit is set. More... | |
bool | LoRaMacClassBIsBeaconModeActive (void) |
Verifies if the beacon mode active bit is set. More... | |
void | LoRaMacClassBHaltBeaconing (void) |
Stops the beacon and ping slot operation. | |
void | LoRaMacClassBResumeBeaconing (void) |
Resumes the beacon and ping slot operation. | |
void | LoRaMacClassBSetPingSlotInfo (uint8_t periodicity) |
Sets the periodicity of the ping slots. More... | |
LoRaMacStatus_t | LoRaMacClassBSwitchClass (DeviceClass_t nextClass) |
Switches the device class. More... | |
LoRaMacStatus_t | LoRaMacClassBMibGetRequestConfirm (MibRequestConfirm_t *mibGet) |
LoRaMAC ClassB MIB-Get. More... | |
LoRaMacStatus_t | LoRaMacMibClassBSetRequestConfirm (MibRequestConfirm_t *mibSet) |
LoRaMAC Class B MIB-Set. More... | |
void | LoRaMacClassBPingSlotInfoAns (void) |
This function handles the PING_SLOT_FREQ_ANS. | |
uint8_t | LoRaMacClassBPingSlotChannelReq (uint8_t datarate, uint32_t frequency) |
This function handles the PING_SLOT_CHANNEL_REQ. More... | |
void | LoRaMacClassBBeaconTimingAns (uint16_t beaconTimingDelay, uint8_t beaconTimingChannel, TimerTime_t lastRxDone) |
This function handles the BEACON_TIMING_ANS. More... | |
void | LoRaMacClassBDeviceTimeAns (void) |
This function handles the ClassB DEVICE_TIME_ANS. | |
bool | LoRaMacClassBBeaconFreqReq (uint32_t frequency) |
This function handles the BEACON_FREQ_REQ. More... | |
TimerTime_t | LoRaMacClassBIsUplinkCollision (TimerTime_t txTimeOnAir) |
Queries the ping slot window time. More... | |
void | LoRaMacClassBStopRxSlots (void) |
Stops the timers for the RX slots. This includes the timers for ping and multicast slots. | |
void | LoRaMacClassBStartRxSlots (void) |
Starts the timers for the RX slots. This includes the timers for ping and multicast slots. | |
void | LoRaMacClassBSetMulticastPeriodicity (MulticastCtx_t *multicastChannel) |
Starts the timers for the RX slots. This includes the timers for ping and multicast slots. More... | |
void | LoRaMacClassBProcess (void) |
This module specifies the API implementation of the LoRaMAC Class B layer. This is a placeholder for a detailed description of the LoRaMac layer and the supported features.
This header file contains parameters to configure the class b operation. By default, all parameters are set according to the specification.
struct PingSlotContext_t |
Class B ping slot context structure
Data Fields | ||
---|---|---|
uint32_t | PingSlotWindow |
Ping slot length time in ms |
uint16_t | PingOffset |
Ping offset |
uint16_t | SymbolTimeout |
Current symbol timeout. The node enlarges this variable in case of beacon loss. |
MulticastCtx_t * | NextMulticastChannel |
The multicast channel which will be enabled next. |
struct BeaconContext_t |
Class B beacon context structure
Data Fields | ||
---|---|---|
struct sBeaconCtrl | Ctrl | |
float | Temperature |
Current temperature |
SysTime_t | BeaconTime |
Beacon time received with the beacon frame |
SysTime_t | LastBeaconRx |
Time when the last beacon was received |
SysTime_t | NextBeaconRx |
Time when the next beacon will be received |
TimerTime_t | NextBeaconRxAdjusted |
This is the time where the RX window will be opened. Its base is NextBeaconRx with temperature compensations and RX window movement. |
uint16_t | SymbolTimeout |
Current symbol timeout. The node enlarges this variable in case of beacon loss. |
TimerTime_t | BeaconWindowMovement |
Specifies how much time the beacon window will be moved. |
uint8_t | BeaconTimingChannel |
Beacon timing channel for next beacon |
TimerTime_t | BeaconTimingDelay |
Delay for next beacon in ms |
TimerTime_t | TimeStamp |
struct BeaconContext_t::sBeaconCtrl |
struct LoRaMacClassBParams_t |
Data structure which pointers to the properties LoRaMAC
Data Fields | ||
---|---|---|
MlmeIndication_t * | MlmeIndication |
Pointer to the MlmeIndication structure |
McpsIndication_t * | McpsIndication |
Pointer to the McpsIndication structure |
MlmeConfirm_t * | MlmeConfirm |
Pointer to the MlmeConfirm structure |
LoRaMacFlags_t * | LoRaMacFlags |
Pointer to the LoRaMacFlags structure |
uint32_t * | LoRaMacDevAddr |
Pointer to the LoRaMac device address |
LoRaMacRegion_t * | LoRaMacRegion |
Pointer to the LoRaMac region definition |
LoRaMacParams_t * | LoRaMacParams |
Pointer to the LoRaMacParams structure |
MulticastCtx_t * | MulticastChannels |
Pointer to the multicast channel list |
struct LoRaMacClassBPingSlotNvmData_t |
LoRaMac Class B Context structure for NVM parameters related to ping slots
Data Fields | ||
---|---|---|
struct sPingSlotCtrlNvm | Ctrl | |
uint8_t | PingNb |
Number of ping slots |
uint16_t | PingPeriod |
Period of the ping slots |
uint32_t | Frequency |
Reception frequency of the ping slot windows |
int8_t | Datarate |
Datarate of the ping slot |
struct LoRaMacClassBPingSlotNvmData_t::sPingSlotCtrlNvm |
struct LoRaMacClassBBeaconNvmData_t |
LoRaMac Class B Context structure for NVM parameters related to beaconing
Data Fields | ||
---|---|---|
struct sBeaconCtrlNvm | Ctrl | |
uint32_t | Frequency |
Beacon reception frequency |
struct LoRaMacClassBBeaconNvmData_t::sBeaconCtrlNvm |
struct LoRaMacClassBNvmData_t |
LoRaMac Class B Context structure
Data Fields | ||
---|---|---|
LoRaMacClassBPingSlotNvmData_t | PingSlotCtx |
Class B ping slot context |
LoRaMacClassBBeaconNvmData_t | BeaconCtx |
Class B beacon context |
uint32_t | Crc32 |
CRC32 value of the ClassB data structure. |
#define CLASSB_BEACON_INTERVAL 128000 |
Defines the beacon interval in ms
#define CLASSB_BEACON_RESERVED 2120 |
Beacon reserved time in ms
#define CLASSB_BEACON_GUARD 3000 |
Beacon guard time in ms
#define CLASSB_BEACON_WINDOW 122880 |
Beacon window time in ms
#define CLASSB_BEACON_WINDOW_SLOTS 4096 |
Beacon window time in numer of slots
#define CLASSB_PING_SLOT_WINDOW 30 |
Ping slot length time in ms
#define CLASSB_MAX_BEACON_LESS_PERIOD 7200000 |
Maximum allowed beacon less time in ms
#define CLASSB_BEACON_DELAY_BEACON_TIMING_ANS 30 |
Delay time for the BeaconTimingAns in ms
#define CLASSB_BEACON_SYMBOL_TO_DEFAULT 8 |
Default symbol timeout for beacons and ping slot windows
#define CLASSB_BEACON_SYMBOL_TO_EXPANSION_MAX 255 |
Maximum symbol timeout for beacons
#define CLASSB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX 30 |
Maximum symbol timeout for ping slots
#define CLASSB_BEACON_SYMBOL_TO_EXPANSION_FACTOR 2 |
Symbol expansion value for beacon windows in case of beacon loss in symbols
#define CLASSB_WINDOW_MOVE_DEFAULT 2 |
Defines the default window movement time
#define CLASSB_WINDOW_MOVE_EXPANSION_MAX 256 |
Defines the maximum time for the beacon movement
#define CLASSB_WINDOW_MOVE_EXPANSION_FACTOR 2 |
Defines the expansion factor for the beacon movement
typedef void( * LoRaMacClassBNvmEvent) (void) |
Signature of callback function to be called by this module when the non-volatile needs to be saved.
enum BeaconState_t |
States of the class B beacon acquisition and tracking
enum PingSlotState_t |
void LoRaMacClassBInit | ( | LoRaMacClassBParams_t * | classBParams, |
LoRaMacClassBCallback_t * | callbacks, | ||
LoRaMacClassBNvmData_t * | nvm | ||
) |
Initialize LoRaWAN Class B.
[IN] | classBParams Information and feedback parameter |
[IN] | callbacks Contains the callback which the Class B implementation needs |
[IN] | nvm Pointer to an external non-volatile memory data structure. |
void LoRaMacClassBSetBeaconState | ( | BeaconState_t | beaconState | ) |
Set the state of the beacon state machine.
[IN] | beaconState Beacon state. |
void LoRaMacClassBSetPingSlotState | ( | PingSlotState_t | pingSlotState | ) |
Set the state of the ping slot state machine.
[IN] | pingSlotState Ping slot state. |
void LoRaMacClassBSetMulticastSlotState | ( | PingSlotState_t | multicastSlotState | ) |
Set the state of the multicast slot state machine.
[IN] | pingSlotState multicast slot state. |
bool LoRaMacClassBIsAcquisitionInProgress | ( | void | ) |
Verifies if an acquisition procedure is in progress.
[true,if | the acquisition is in progress; false, if not] |
bool LoRaMacClassBRxBeacon | ( | uint8_t * | payload, |
uint16_t | size | ||
) |
Receives and decodes the beacon frame.
[IN] | payload Pointer to the payload |
[IN] | size Size of the payload |
[true,if | the node has received a beacon; false, if not] |
bool LoRaMacClassBIsBeaconExpected | ( | void | ) |
The function validates, if the node expects a beacon at the current time.
[true,if | the node expects a beacon; false, if not] |
bool LoRaMacClassBIsPingExpected | ( | void | ) |
The function validates, if the node expects a ping slot at the current time.
[true,if | the node expects a ping slot; false, if not] |
bool LoRaMacClassBIsMulticastExpected | ( | void | ) |
The function validates, if the node expects a multicast slot at the current time.
[true,if | the node expects a multicast slot; false, if not] |
bool LoRaMacClassBIsAcquisitionPending | ( | void | ) |
Verifies if the acquisition pending bit is set.
[true,if | the bit is set; false, if not] |
bool LoRaMacClassBIsBeaconModeActive | ( | void | ) |
Verifies if the beacon mode active bit is set.
[true,if | the bit is set; false, if not] |
void LoRaMacClassBSetPingSlotInfo | ( | uint8_t | periodicity | ) |
Sets the periodicity of the ping slots.
[IN] | periodicity Periodicity |
LoRaMacStatus_t LoRaMacClassBSwitchClass | ( | DeviceClass_t | nextClass | ) |
Switches the device class.
[IN] | nextClass Device class to switch to |
LoRaMacStatus_t | Status of the operation. |
LoRaMacStatus_t LoRaMacClassBMibGetRequestConfirm | ( | MibRequestConfirm_t * | mibGet | ) |
LoRaMAC ClassB MIB-Get.
The mac information base service to get attributes of the LoRaMac Class B layer.
[IN] | mibRequest - MIB-GET-Request to perform. Refer to MibRequestConfirm_t. |
LoRaMacStatus_t | Status of the operation. Possible returns are: LORAMAC_STATUS_OK, LORAMAC_STATUS_SERVICE_UNKNOWN, LORAMAC_STATUS_PARAMETER_INVALID. |
LoRaMacStatus_t LoRaMacMibClassBSetRequestConfirm | ( | MibRequestConfirm_t * | mibSet | ) |
LoRaMAC Class B MIB-Set.
The mac information base service to set attributes of the LoRaMac Class B layer.
[IN] | mibRequest - MIB-SET-Request to perform. Refer to MibRequestConfirm_t. |
LoRaMacStatus_t | Status of the operation. Possible returns are: LORAMAC_STATUS_OK, LORAMAC_STATUS_BUSY, LORAMAC_STATUS_SERVICE_UNKNOWN, LORAMAC_STATUS_PARAMETER_INVALID. |
uint8_t LoRaMacClassBPingSlotChannelReq | ( | uint8_t | datarate, |
uint32_t | frequency | ||
) |
This function handles the PING_SLOT_CHANNEL_REQ.
[IN] | datarate Device class to switch to |
[IN] | frequency Device class to switch to |
Status | for the MAC answer. |
void LoRaMacClassBBeaconTimingAns | ( | uint16_t | beaconTimingDelay, |
uint8_t | beaconTimingChannel, | ||
TimerTime_t | lastRxDone | ||
) |
This function handles the BEACON_TIMING_ANS.
[IN] | beaconTimingDelay The beacon timing delay |
[IN] | beaconTimingChannel The beacon timing channel |
[IN] | lastRxDone The time of the last frame reception |
bool LoRaMacClassBBeaconFreqReq | ( | uint32_t | frequency | ) |
This function handles the BEACON_FREQ_REQ.
[IN] | frequency Frequency to set |
[true,if | MAC shall send an answer; false, if not] |
TimerTime_t LoRaMacClassBIsUplinkCollision | ( | TimerTime_t | txTimeOnAir | ) |
Queries the ping slot window time.
[IN] | txTimeOnAir TX time on air for the next uplink |
Returns | the time the uplink should be delayed |
void LoRaMacClassBSetMulticastPeriodicity | ( | MulticastCtx_t * | multicastChannel | ) |
Starts the timers for the RX slots. This includes the timers for ping and multicast slots.
[IN] | periodicity Downlink periodicity |
[IN] | multicastChannel Related multicast channel |
uint32_t PingSlotWindow |
Ping slot length time in ms
uint16_t PingOffset |
Ping offset
uint16_t SymbolTimeout |
Current symbol timeout. The node enlarges this variable in case of beacon loss.
MulticastCtx_t* NextMulticastChannel |
The multicast channel which will be enabled next.
uint8_t BeaconMode |
Set if the node receives beacons
uint8_t BeaconAcquired |
Set if the node has acquired the beacon
uint8_t BeaconDelaySet |
Set if a beacon delay was set for the beacon acquisition
uint8_t BeaconChannelSet |
Set if a beacon channel was set for the beacon acquisition
uint8_t AcquisitionPending |
Set if beacon acquisition is pending
uint8_t ResumeBeaconing |
Set if the beacon state machine will be resumed
struct BeaconContext_t::sBeaconCtrl Ctrl |
float Temperature |
Current temperature
SysTime_t BeaconTime |
Beacon time received with the beacon frame
SysTime_t LastBeaconRx |
Time when the last beacon was received
SysTime_t NextBeaconRx |
Time when the next beacon will be received
TimerTime_t NextBeaconRxAdjusted |
This is the time where the RX window will be opened. Its base is NextBeaconRx with temperature compensations and RX window movement.
uint16_t SymbolTimeout |
Current symbol timeout. The node enlarges this variable in case of beacon loss.
TimerTime_t BeaconWindowMovement |
Specifies how much time the beacon window will be moved.
uint8_t BeaconTimingChannel |
Beacon timing channel for next beacon
TimerTime_t BeaconTimingDelay |
Delay for next beacon in ms
TimerTime_t TimeStamp |
float( * GetTemperatureLevel) (void) |
Measures the temperature level.
Temperature | level |
void( * MacProcessNotify) (void) |
Will be called each time a Radio IRQ is handled by the MAC layer.
MlmeIndication_t* MlmeIndication |
Pointer to the MlmeIndication structure
McpsIndication_t* McpsIndication |
Pointer to the McpsIndication structure
MlmeConfirm_t* MlmeConfirm |
Pointer to the MlmeConfirm structure
LoRaMacFlags_t* LoRaMacFlags |
Pointer to the LoRaMacFlags structure
uint32_t* LoRaMacDevAddr |
Pointer to the LoRaMac device address
LoRaMacRegion_t* LoRaMacRegion |
Pointer to the LoRaMac region definition
LoRaMacParams_t* LoRaMacParams |
Pointer to the LoRaMacParams structure
MulticastCtx_t* MulticastChannels |
Pointer to the multicast channel list
uint8_t Assigned |
Set when the server assigned a ping slot to the node
uint8_t CustomFreq |
Set when a custom frequency is used
struct LoRaMacClassBPingSlotNvmData_t::sPingSlotCtrlNvm Ctrl |
uint8_t PingNb |
Number of ping slots
uint16_t PingPeriod |
Period of the ping slots
uint32_t Frequency |
Reception frequency of the ping slot windows
int8_t Datarate |
Datarate of the ping slot
uint8_t CustomFreq |
Set if the node has a custom frequency for beaconing and ping slots
struct LoRaMacClassBBeaconNvmData_t::sBeaconCtrlNvm Ctrl |
uint32_t Frequency |
Beacon reception frequency
LoRaMacClassBPingSlotNvmData_t PingSlotCtx |
Class B ping slot context
LoRaMacClassBBeaconNvmData_t BeaconCtx |
Class B beacon context
uint32_t Crc32 |
CRC32 value of the ClassB data structure.