LoRaMAC  4.4.7
Documentation of the API
LoRaMacClassB.h
Go to the documentation of this file.
1 
37 #ifndef __LORAMACCLASSB_H__
38 #define __LORAMACCLASSB_H__
39 
40 #ifdef __cplusplus
41 extern "C"
42 {
43 #endif
44 
45 #include "systime.h"
46 #include "LoRaMacTypes.h"
47 
51 typedef enum eBeaconState
52 {
100 
104 typedef enum ePingSlotState
105 {
123 
127 typedef struct sPingSlotContext
128 {
129 
133  uint32_t PingSlotWindow;
137  uint16_t PingOffset;
142  uint16_t SymbolTimeout;
148 
149 
153 typedef struct sBeaconContext
154 {
155  struct sBeaconCtrl
156  {
160  uint8_t BeaconMode : 1;
164  uint8_t BeaconAcquired : 1;
168  uint8_t BeaconDelaySet : 1;
172  uint8_t BeaconChannelSet : 1;
176  uint8_t AcquisitionPending : 1;
180  uint8_t ResumeBeaconing : 1;
181  }Ctrl;
182 
186  float Temperature;
190  SysTime_t BeaconTime;
194  SysTime_t LastBeaconRx;
198  SysTime_t NextBeaconRx;
204  TimerTime_t NextBeaconRxAdjusted;
209  uint16_t SymbolTimeout;
213  TimerTime_t BeaconWindowMovement;
221  TimerTime_t BeaconTimingDelay;
222  TimerTime_t TimeStamp;
224 
228 typedef struct sLoRaMacClassBCallback
229 {
235  float ( *GetTemperatureLevel )( void );
242  void ( *MacProcessNotify )( void );
244 
248 typedef struct sLoRaMacClassBParams
249 {
269  uint32_t *LoRaMacDevAddr;
283 
288 typedef void ( *LoRaMacClassBNvmEvent )( void );
289 
297 void LoRaMacClassBInit( LoRaMacClassBParams_t *classBParams, LoRaMacClassBCallback_t *callbacks,
298  LoRaMacClassBNvmData_t* nvm );
299 
305 void LoRaMacClassBSetBeaconState( BeaconState_t beaconState );
306 
312 void LoRaMacClassBSetPingSlotState( PingSlotState_t pingSlotState );
313 
319 void LoRaMacClassBSetMulticastSlotState( PingSlotState_t multicastSlotState );
320 
327 
331 void LoRaMacClassBBeaconTimerEvent( void* context );
332 
336 void LoRaMacClassBPingSlotTimerEvent( void* context );
337 
341 void LoRaMacClassBMulticastSlotTimerEvent( void* context );
342 
350 bool LoRaMacClassBRxBeacon( uint8_t *payload, uint16_t size );
351 
358 bool LoRaMacClassBIsBeaconExpected( void );
359 
366 bool LoRaMacClassBIsPingExpected( void );
367 
375 
382 
389 
393 void LoRaMacClassBHaltBeaconing( void );
394 
398 void LoRaMacClassBResumeBeaconing( void );
399 
405 void LoRaMacClassBSetPingSlotInfo( uint8_t periodicity );
406 
415 
430 
446 
450 void LoRaMacClassBPingSlotInfoAns( void );
451 
460 uint8_t LoRaMacClassBPingSlotChannelReq( uint8_t datarate, uint32_t frequency );
461 
469 void LoRaMacClassBBeaconTimingAns( uint16_t beaconTimingDelay, uint8_t beaconTimingChannel, TimerTime_t lastRxDone );
470 
474 void LoRaMacClassBDeviceTimeAns( void );
475 
483 bool LoRaMacClassBBeaconFreqReq( uint32_t frequency );
484 
492 TimerTime_t LoRaMacClassBIsUplinkCollision( TimerTime_t txTimeOnAir );
493 
498 void LoRaMacClassBStopRxSlots( void );
499 
504 void LoRaMacClassBStartRxSlots( void );
505 
514 void LoRaMacClassBSetMulticastPeriodicity( MulticastCtx_t* multicastChannel );
515 
516 void LoRaMacClassBProcess( void );
517 
518 #ifdef __cplusplus
519 }
520 #endif
521 
522 #endif // __LORAMACCLASSB_H__
LoRaMacClassBIsBeaconModeActive
bool LoRaMacClassBIsBeaconModeActive(void)
Verifies if the beacon mode active bit is set.
LoRaMacClassBSetBeaconState
void LoRaMacClassBSetBeaconState(BeaconState_t beaconState)
Set the state of the beacon state machine.
BeaconContext_t::sBeaconCtrl::BeaconDelaySet
uint8_t BeaconDelaySet
Definition: LoRaMacClassB.h:168
LoRaMacClassBIsAcquisitionPending
bool LoRaMacClassBIsAcquisitionPending(void)
Verifies if the acquisition pending bit is set.
BeaconContext_t
Definition: LoRaMacClassB.h:153
LoRaMacClassBResumeBeaconing
void LoRaMacClassBResumeBeaconing(void)
Resumes the beacon and ping slot operation.
BeaconContext_t::NextBeaconRx
SysTime_t NextBeaconRx
Definition: LoRaMacClassB.h:198
LoRaMacStatus_t
LoRaMacStatus_t
Definition: LoRaMac.h:2227
BeaconContext_t::NextBeaconRxAdjusted
TimerTime_t NextBeaconRxAdjusted
Definition: LoRaMacClassB.h:204
LoRaMacClassBDeviceTimeAns
void LoRaMacClassBDeviceTimeAns(void)
This function handles the ClassB DEVICE_TIME_ANS.
LoRaMacClassBParams_t
Definition: LoRaMacClassB.h:248
DeviceClass_t
DeviceClass_t
Definition: LoRaMacTypes.h:571
PingSlotContext_t::NextMulticastChannel
MulticastCtx_t * NextMulticastChannel
Definition: LoRaMacClassB.h:146
LoRaMacFlags_t
Definition: LoRaMac.h:454
BeaconContext_t::sBeaconCtrl
Definition: LoRaMacClassB.h:155
LoRaMacTypes.h
LoRa MAC layer internal types definition. Please do not include in application sources.
MlmeIndication_t
Definition: LoRaMac.h:1270
LoRaMacClassBSetPingSlotInfo
void LoRaMacClassBSetPingSlotInfo(uint8_t periodicity)
Sets the periodicity of the ping slots.
LoRaMacClassBSwitchClass
LoRaMacStatus_t LoRaMacClassBSwitchClass(DeviceClass_t nextClass)
Switches the device class.
BeaconContext_t::LastBeaconRx
SysTime_t LastBeaconRx
Definition: LoRaMacClassB.h:194
BEACON_STATE_HALT
Definition: LoRaMacClassB.h:81
BeaconContext_t::BeaconTime
SysTime_t BeaconTime
Definition: LoRaMacClassB.h:190
PINGSLOT_STATE_CALC_PING_OFFSET
Definition: LoRaMacClassB.h:109
LoRaMacClassBStopRxSlots
void LoRaMacClassBStopRxSlots(void)
Stops the timers for the RX slots. This includes the timers for ping and multicast slots.
LoRaMacClassBIsMulticastExpected
bool LoRaMacClassBIsMulticastExpected(void)
The function validates, if the node expects a multicast slot at the current time.
BEACON_STATE_ACQUISITION
Definition: LoRaMacClassB.h:56
LoRaMacClassBParams_t::LoRaMacParams
LoRaMacParams_t * LoRaMacParams
Definition: LoRaMacClassB.h:277
LoRaMacClassBMibGetRequestConfirm
LoRaMacStatus_t LoRaMacClassBMibGetRequestConfirm(MibRequestConfirm_t *mibGet)
LoRaMAC ClassB MIB-Get.
LoRaMacClassBBeaconTimingAns
void LoRaMacClassBBeaconTimingAns(uint16_t beaconTimingDelay, uint8_t beaconTimingChannel, TimerTime_t lastRxDone)
This function handles the BEACON_TIMING_ANS.
BeaconContext_t::BeaconWindowMovement
TimerTime_t BeaconWindowMovement
Definition: LoRaMacClassB.h:213
BeaconContext_t::sBeaconCtrl::BeaconChannelSet
uint8_t BeaconChannelSet
Definition: LoRaMacClassB.h:172
LoRaMacRegion_t
LoRaMacRegion_t
Definition: LoRaMac.h:495
PingSlotContext_t
Definition: LoRaMacClassB.h:127
PINGSLOT_STATE_IDLE
Definition: LoRaMacClassB.h:117
LoRaMacClassBIsBeaconExpected
bool LoRaMacClassBIsBeaconExpected(void)
The function validates, if the node expects a beacon at the current time.
LoRaMacClassBPingSlotTimerEvent
void LoRaMacClassBPingSlotTimerEvent(void *context)
State machine of the Class B for ping slots.
PINGSLOT_STATE_RX
Definition: LoRaMacClassB.h:121
BeaconContext_t::sBeaconCtrl::AcquisitionPending
uint8_t AcquisitionPending
Definition: LoRaMacClassB.h:176
LoRaMacClassBIsUplinkCollision
TimerTime_t LoRaMacClassBIsUplinkCollision(TimerTime_t txTimeOnAir)
Queries the ping slot window time.
LoRaMacClassBRxBeacon
bool LoRaMacClassBRxBeacon(uint8_t *payload, uint16_t size)
Receives and decodes the beacon frame.
LoRaMacClassBParams_t::LoRaMacFlags
LoRaMacFlags_t * LoRaMacFlags
Definition: LoRaMacClassB.h:265
MibRequestConfirm_t
Definition: LoRaMac.h:2195
LoRaMacClassBNvmEvent
void(* LoRaMacClassBNvmEvent)(void)
Definition: LoRaMacClassB.h:288
LoRaMacClassBMulticastSlotTimerEvent
void LoRaMacClassBMulticastSlotTimerEvent(void *context)
State machine of the Class B for multicast slots.
PingSlotContext_t::PingSlotWindow
uint32_t PingSlotWindow
Definition: LoRaMacClassB.h:133
MulticastCtx_t
Definition: LoRaMacTypes.h:901
LoRaMacClassBParams_t::McpsIndication
McpsIndication_t * McpsIndication
Definition: LoRaMacClassB.h:257
LoRaMacClassBParams_t::MlmeIndication
MlmeIndication_t * MlmeIndication
Definition: LoRaMacClassB.h:253
LoRaMacClassBPingSlotChannelReq
uint8_t LoRaMacClassBPingSlotChannelReq(uint8_t datarate, uint32_t frequency)
This function handles the PING_SLOT_CHANNEL_REQ.
BEACON_STATE_LOST
Definition: LoRaMacClassB.h:98
MlmeConfirm_t
Definition: LoRaMac.h:1229
BEACON_STATE_IDLE
Definition: LoRaMacClassB.h:86
LoRaMacClassBPingSlotInfoAns
void LoRaMacClassBPingSlotInfoAns(void)
This function handles the PING_SLOT_FREQ_ANS.
LoRaMacClassBIsPingExpected
bool LoRaMacClassBIsPingExpected(void)
The function validates, if the node expects a ping slot at the current time.
LoRaMacClassBParams_t::MlmeConfirm
MlmeConfirm_t * MlmeConfirm
Definition: LoRaMacClassB.h:261
BEACON_STATE_RX
Definition: LoRaMacClassB.h:94
LoRaMacClassBInit
void LoRaMacClassBInit(LoRaMacClassBParams_t *classBParams, LoRaMacClassBCallback_t *callbacks, LoRaMacClassBNvmData_t *nvm)
Initialize LoRaWAN Class B.
LoRaMacClassBParams_t::LoRaMacRegion
LoRaMacRegion_t * LoRaMacRegion
Definition: LoRaMacClassB.h:273
BeaconContext_t::BeaconTimingDelay
TimerTime_t BeaconTimingDelay
Definition: LoRaMacClassB.h:221
BEACON_STATE_ACQUISITION_BY_TIME
Definition: LoRaMacClassB.h:60
BEACON_STATE_REACQUISITION
Definition: LoRaMacClassB.h:73
LoRaMacClassBParams_t::MulticastChannels
MulticastCtx_t * MulticastChannels
Definition: LoRaMacClassB.h:281
BEACON_STATE_TIMEOUT
Definition: LoRaMacClassB.h:64
LoRaMacMibClassBSetRequestConfirm
LoRaMacStatus_t LoRaMacMibClassBSetRequestConfirm(MibRequestConfirm_t *mibSet)
LoRaMAC Class B MIB-Set.
LoRaMacClassBBeaconTimerEvent
void LoRaMacClassBBeaconTimerEvent(void *context)
State machine of the Class B for beaconing.
BeaconContext_t::sBeaconCtrl::BeaconAcquired
uint8_t BeaconAcquired
Definition: LoRaMacClassB.h:164
PingSlotContext_t::PingOffset
uint16_t PingOffset
Definition: LoRaMacClassB.h:137
LoRaMacClassBHaltBeaconing
void LoRaMacClassBHaltBeaconing(void)
Stops the beacon and ping slot operation.
LoRaMacClassBCallback_t
Definition: LoRaMacClassB.h:228
LoRaMacClassBBeaconFreqReq
bool LoRaMacClassBBeaconFreqReq(uint32_t frequency)
This function handles the BEACON_FREQ_REQ.
BeaconContext_t::sBeaconCtrl::BeaconMode
uint8_t BeaconMode
Definition: LoRaMacClassB.h:160
BeaconContext_t::BeaconTimingChannel
uint8_t BeaconTimingChannel
Definition: LoRaMacClassB.h:217
PINGSLOT_STATE_SET_TIMER
Definition: LoRaMacClassB.h:113
PingSlotState_t
PingSlotState_t
Definition: LoRaMacClassB.h:104
LoRaMacClassBParams_t::LoRaMacDevAddr
uint32_t * LoRaMacDevAddr
Definition: LoRaMacClassB.h:269
LoRaMacClassBSetPingSlotState
void LoRaMacClassBSetPingSlotState(PingSlotState_t pingSlotState)
Set the state of the ping slot state machine.
LoRaMacClassBSetMulticastPeriodicity
void LoRaMacClassBSetMulticastPeriodicity(MulticastCtx_t *multicastChannel)
Starts the timers for the RX slots. This includes the timers for ping and multicast slots.
LoRaMacParams_t
Definition: LoRaMac.h:233
BEACON_STATE_GUARD
Definition: LoRaMacClassB.h:90
BeaconState_t
BeaconState_t
Definition: LoRaMacClassB.h:51
PingSlotContext_t::SymbolTimeout
uint16_t SymbolTimeout
Definition: LoRaMacClassB.h:142
BEACON_STATE_LOCKED
Definition: LoRaMacClassB.h:77
McpsIndication_t
Definition: LoRaMac.h:926
LoRaMacClassBSetMulticastSlotState
void LoRaMacClassBSetMulticastSlotState(PingSlotState_t multicastSlotState)
Set the state of the multicast slot state machine.
LoRaMacClassBIsAcquisitionInProgress
bool LoRaMacClassBIsAcquisitionInProgress(void)
Verifies if an acquisition procedure is in progress.
BEACON_STATE_BEACON_MISSED
Definition: LoRaMacClassB.h:68
BeaconContext_t::Temperature
float Temperature
Definition: LoRaMacClassB.h:186
LoRaMacClassBStartRxSlots
void LoRaMacClassBStartRxSlots(void)
Starts the timers for the RX slots. This includes the timers for ping and multicast slots.
BeaconContext_t::sBeaconCtrl::ResumeBeaconing
uint8_t ResumeBeaconing
Definition: LoRaMacClassB.h:180
LoRaMacClassBNvmData_t
Definition: LoRaMacClassBNvm.h:100