LoRaMAC  4.5.2
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;
229 
233 typedef struct sLoRaMacClassBCallback
234 {
240  float ( *GetTemperatureLevel )( void );
247  void ( *MacProcessNotify )( void );
249 
253 typedef struct sLoRaMacClassBParams
254 {
274  uint32_t *LoRaMacDevAddr;
292 
297 typedef void ( *LoRaMacClassBNvmEvent )( void );
298 
306 void LoRaMacClassBInit( LoRaMacClassBParams_t *classBParams, LoRaMacClassBCallback_t *callbacks,
307  LoRaMacClassBNvmData_t* nvm );
308 
314 void LoRaMacClassBSetBeaconState( BeaconState_t beaconState );
315 
321 void LoRaMacClassBSetPingSlotState( PingSlotState_t pingSlotState );
322 
328 void LoRaMacClassBSetMulticastSlotState( PingSlotState_t multicastSlotState );
329 
336 
340 void LoRaMacClassBBeaconTimerEvent( void* context );
341 
345 void LoRaMacClassBPingSlotTimerEvent( void* context );
346 
350 void LoRaMacClassBMulticastSlotTimerEvent( void* context );
351 
359 bool LoRaMacClassBRxBeacon( uint8_t *payload, uint16_t size );
360 
367 bool LoRaMacClassBIsBeaconExpected( void );
368 
375 bool LoRaMacClassBIsPingExpected( void );
376 
384 
391 
398 
402 void LoRaMacClassBHaltBeaconing( void );
403 
407 void LoRaMacClassBResumeBeaconing( void );
408 
414 void LoRaMacClassBSetPingSlotInfo( uint8_t periodicity );
415 
424 
439 
455 
459 void LoRaMacClassBPingSlotInfoAns( void );
460 
469 uint8_t LoRaMacClassBPingSlotChannelReq( uint8_t datarate, uint32_t frequency );
470 
478 void LoRaMacClassBBeaconTimingAns( uint16_t beaconTimingDelay, uint8_t beaconTimingChannel, TimerTime_t lastRxDone );
479 
483 void LoRaMacClassBDeviceTimeAns( void );
484 
492 bool LoRaMacClassBBeaconFreqReq( uint32_t frequency );
493 
501 TimerTime_t LoRaMacClassBIsUplinkCollision( TimerTime_t txTimeOnAir );
502 
507 void LoRaMacClassBStopRxSlots( void );
508 
513 void LoRaMacClassBStartRxSlots( void );
514 
523 void LoRaMacClassBSetMulticastPeriodicity( MulticastCtx_t* multicastChannel );
524 
533 void LoRaMacClassBSetFPendingBit( uint32_t address, uint8_t fPendingSet );
534 
538 void LoRaMacClassBProcess( void );
539 
540 #ifdef __cplusplus
541 }
542 #endif
543 
544 #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:2269
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:253
DeviceClass_t
DeviceClass_t
Definition: LoRaMacTypes.h:571
PingSlotContext_t::NextMulticastChannel
MulticastCtx_t * NextMulticastChannel
Definition: LoRaMacClassB.h:146
LoRaMacFlags_t
Definition: LoRaMac.h:468
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:1286
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:282
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:513
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::NetworkActivation
ActivationType_t * NetworkActivation
Definition: LoRaMacClassB.h:290
LoRaMacClassBParams_t::LoRaMacFlags
LoRaMacFlags_t * LoRaMacFlags
Definition: LoRaMacClassB.h:270
MibRequestConfirm_t
Definition: LoRaMac.h:2237
LoRaMacClassBNvmEvent
void(* LoRaMacClassBNvmEvent)(void)
Definition: LoRaMacClassB.h:297
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:262
ActivationType_t
ActivationType_t
Definition: LoRaMac.h:167
LoRaMacClassBParams_t::MlmeIndication
MlmeIndication_t * MlmeIndication
Definition: LoRaMacClassB.h:258
LoRaMacClassBSetFPendingBit
void LoRaMacClassBSetFPendingBit(uint32_t address, uint8_t fPendingSet)
Sets the FPending bit status of the related downlink slot.
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:1245
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:266
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:278
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:286
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:233
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
LoRaMacClassBProcess
void LoRaMacClassBProcess(void)
Class B process function.
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:274
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:240
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:936
BeaconContext_t::BeaconTimePrecision
SysTime_t BeaconTimePrecision
Definition: LoRaMacClassB.h:227
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:104