RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
LoRaWANNode Class Reference

LoRaWAN-compatible node (class A device). More...

#include <LoRaWAN.h>

Public Types

typedef void(* BufferCb_t) (uint8_t *buf, size_t len)
 Callback signature for buffer save/load operations.
typedef void(* SleepCb_t) (RadioLibTime_t ms)
 Callback to a user-provided sleep function.

Public Member Functions

 LoRaWANNode (PhysicalLayer *phy, const LoRaWANBand_t *band, uint8_t subBand=0)
 Default constructor.
void clearSession ()
 Clear an active session. This requires the device to rejoin the network.
void setCallbackStorePersistence (BufferCb_t cb)
 Register a callback invoked by the library when the persistence buffer needs to be saved. The callback receives a pointer to the serialized buffer and its length; the user should write this data to non-volatile storage (flash, EEPROM, etc.).
void setCallbackRestorePersistence (BufferCb_t cb)
 Register a callback invoked by the library when the persistence buffer needs to be loaded. The callback receives a pointer to the buffer and its length; the user should fill it with data previously saved by the savePersistenceBuffer callback.
void setCallbackStoreSession (BufferCb_t cb)
 Register a callback invoked by the library when the session buffer needs to be saved. The callback receives a pointer to the serialized buffer and its length; the user should write this data to persistent RAM on platforms that do not retain normal RAM during sleep.
void setCallbackRestoreSession (BufferCb_t cb)
 Register a callback invoked by the library when the session buffer needs to be loaded. The callback receives a pointer to the buffer and its length; the user should fill it with data previously saved by the savePersistenceBuffer callback.
int16_t loadBuffers ()
 Trigger the registered buffer callbacks to restore persistence and session buffers.
int16_t beginOTAA (uint64_t joinEUI, uint64_t devEUI, const uint8_t *nwkKey, const uint8_t *appKey)
 Set the device credentials and activation configuration.
int16_t beginABP (uint32_t addr, const uint8_t *fNwkSIntKey, const uint8_t *sNwkSIntKey, const uint8_t *nwkSEncKey, const uint8_t *appSKey)
 Set the device credentials and activation configuration.
int16_t activateOTAA (LoRaWANJoinEvent_t *joinEvent=NULL)
 Join network by restoring OTAA session or performing over-the-air activation. By this procedure, the device will perform an exchange with the network server and set all necessary configuration.
int16_t activateABP ()
 Join network by restoring ABP session or performing over-the-air activation. In this procedure, all necessary configuration must be provided by the user.
bool isActivated ()
 Whether there is an ongoing session active.
int16_t setClass (uint8_t cls)
 Configure class (RADIOLIB_LORAWAN_CLASS_A or RADIOLIB_LORAWAN_CLASS_C).
int16_t startMulticastSession (uint8_t cls, uint32_t mcAddr, const uint8_t *mcAppSKey, const uint8_t *mcNwkSKey, uint32_t mcFCntMin=0, uint32_t mcFCntMax=0xFFFFFFFF, uint32_t mcFreq=0, uint8_t mcDr=RADIOLIB_LORAWAN_DATA_RATE_UNUSED)
 Start a Multicast session.
int16_t startMulticastSession (uint8_t id, MulticastGroup_t *mcGroup)
 Start a Multicast session.
bool stopMulticastSession (uint8_t id, bool addRxFCnt=false)
 Stop an ongoing multicast session.
virtual int16_t sendReceive (const char *strUp, uint8_t fPort, bool isConfirmed=false, LoRaWANEvent_t *eventUp=NULL, LoRaWANEvent_t *eventDown=NULL)
 Send a message to the server and wait for a downlink during Rx1 and/or Rx2 window.
virtual int16_t sendReceive (const char *strUp, uint8_t fPort, uint8_t *dataDown, size_t *lenDown, bool isConfirmed=false, LoRaWANEvent_t *eventUp=NULL, LoRaWANEvent_t *eventDown=NULL)
 Send a message to the server and wait for a downlink during Rx1 and/or Rx2 window.
virtual int16_t sendReceive (const uint8_t *dataUp, size_t lenUp, uint8_t fPort=1, bool isConfirmed=false, LoRaWANEvent_t *eventUp=NULL, LoRaWANEvent_t *eventDown=NULL)
 Send a message to the server and wait for a downlink but don't bother the user with downlink contents.
virtual int16_t sendReceive (const uint8_t *dataUp, size_t lenUp, uint8_t fPort, uint8_t *dataDown, size_t *lenDown, bool isConfirmed=false, LoRaWANEvent_t *eventUp=NULL, LoRaWANEvent_t *eventDown=NULL)
 Send a message to the server and wait for a downlink during Rx1 and/or Rx2 window.
int16_t getDownlinkClassC (uint8_t *dataDown, size_t *lenDown, LoRaWANEvent_t *eventDown=NULL)
 Check if there is an RxC downlink and parse it if available.
int16_t sendMacCommandReq (uint8_t cid)
 Add a MAC command to the uplink queue. Only LinkCheck and DeviceTime are available to the user. Other commands are ignored; duplicate MAC commands are discarded.
int16_t getMacLinkCheckAns (uint8_t *margin, uint8_t *gwCnt)
 Returns the quality of connectivity after requesting a LinkCheck MAC command.
int16_t getMacDeviceTimeAns (uint32_t *timestamp, uint16_t *milliseconds, bool returnUnix=true)
 Returns the network time after requesting a DeviceTime MAC command. Note: the network returns the time at the end of the uplink transmission. The return value of this function automatically adjusts to the current time. This time is supposed to be <100ms accurate, but may be accurate to 1 second.
int16_t setBand (const LoRaWANBand_t *band, uint8_t subBand=0)
 Set LoRaWAN (sub)band. This cannot be done during an active session.
int16_t setDatarate (uint8_t drUp)
 Set uplink datarate. This should not be used when ADR is enabled.
int16_t setTxPower (int8_t txPower)
 Configure TX power of the radio module.
int16_t setRx2Dr (uint8_t dr)
 Configure the Rx2 datarate for ABP mode. This should not be needed for LoRaWAN 1.1 as it is configured through the first downlink.
void setADR (bool enable=true)
 Toggle ADR to on or off.
void setDutyCycle (bool enable=true, RadioLibTime_t msPerHour=0)
 Toggle adherence to dutyCycle limits to on or off.
void setDwellTime (bool enable, RadioLibTime_t msPerUplink=0)
 Set or disable uplink dwell time limitation; enabled by default if mandatory.
void setCSMA (bool csmaEnabled, uint8_t maxChanges=4, uint8_t backoffMax=0, uint8_t difsSlots=2)
 Configures CSMA for LoRaWAN as per TR013, LoRa Alliance.
void setDeviceStatus (uint8_t battLevel)
 Set device status.
void setActivityLeds (const uint32_t pins[4])
 Set pins for activity LEDs that will indicate when the radio is transmitting (Tx) or receiving (Rx).
void getPersistencePackage (uint8_t pIndex, uint8_t *buff)
 Get the persistent buffer for a certain package. NOTE: Do NOT use, for Packages only!
void setPersistencePackage (uint8_t pIndex, const uint8_t *buff)
 Set the persistent buffer for a certain package. NOTE: Do NOT use, for Packages only!
void scheduleTransmission (RadioLibTime_t tUplink)
 Set the exact time a transmission should occur. Note: this is the internal clock time. On Arduino platforms, this is the usual time supplied by millis(). If the supplied time is larger than the current time, sendReceive() or uplink() will delay until the scheduled time. The scheduled time must be within ~24 days of the current time (half of the 32-bit millis() range).
const LoRaWANBand_t * getBand ()
 Get the LoRaWAN band used by this node.
uint8_t getUnicastClass ()
 Get the LoRaWAN class of this node.
uint8_t getMulticastClass ()
 Request the currently configured class for Multicast.
uint8_t getClass ()
 Get the LoRaWAN class of this node.
uint8_t getVersionMajor ()
 Get the LoRaWAN version of this node.
uint32_t getFCntUp ()
 Returns the last uplink's frame counter; also 0 if no uplink occured yet.
uint32_t getNFCntDown ()
 Returns the last network downlink's frame counter; also 0 if no network downlink occured yet.
uint32_t getAFCntDown ()
 Returns the last application downlink's frame counter; also 0 if no application downlink occured yet.
uint32_t getRxFCnt ()
 Returns the number of received application downlinks.
uint32_t getRxFCntMulticast (uint8_t mcGroupId)
 Returns the number of received downlinks for a certain multicast group.
uint32_t getDevAddr ()
 Returns the DevAddr of the device, regardless of OTAA or ABP mode.
RadioLibTime_t getLastToA ()
 Get the Time-on-air of the last uplink message (in milliseconds).
RadioLibTime_t getLastDuration (bool seconds=false)
 Get the duration of the last uplink/downlink cycle.
RadioLibTime_t timeUntilUplink (bool seconds=false)
 Calculate the time until next uplink is available under dutyCycle limits.
void syncClock ()
 Reset the internal timestamps after a clock synchronization.
uint8_t getMacUplinkLen ()
 Get the length of the pending MAC uplink payload.
RadioLibTime_t dutyCycleInterval (RadioLibTime_t msPerHour, RadioLibTime_t airtime)
 Calculate the minimum interval to adhere to a certain dutyCycle. This interval is based on the ToA of one uplink and does not actually keep track of total airtime.
virtual uint8_t getMaxPayloadLen ()
 Returns the maximum allowed uplink payload size given the current MAC state. Most importantly, this includes dwell time limitations and ADR.
virtual int16_t testPayloadLength (uint8_t len)
 Test whether a certain payload length can be transmitted. Three options: NONE (ok), MAC_ANSWERS_PENDING (send MAC-only uplink first) or PACKET_TOO_LONG.
void setSleepFunction (SleepCb_t cb)
 Set custom delay/sleep function callback. If set, LoRaWAN node will call this function to wait for periods of time longer than RADIOLIB_LORAWAN_DELAY_SLEEP_THRESHOLD. This can be used to lower the power consumption by putting the host microcontroller to sleep. NOTE: Since this method will call a user-provided function, it is up to the user to ensure that the time duration spent in that sleep function is accurate to at least 1 ms!
int16_t addAppPackage (uint8_t fPort)
 Enable a reserved FPort that can be used for application traffic.
int16_t addNwkPackage (uint8_t fPort)
 Enable a reserved FPort that can be used for network traffic.
void removePackage (uint8_t fPort)
 Disable a package that was previously added.

Public Attributes

RadioLibTime_t scanGuardA = 0
 Class A Rx window padding in milliseconds. NOTE: If your clock has a stable drift, use RADIOLIB_CLOCK_DRIFT_MS instead (see BuildOpt.h). On any modern microcontroller it should not be necessary to use scanGuardA. However, if your clock is unstable, you can use e.g. scanGuardA = 20 to widen the Rx window by 20 milliseconds (open 10ms early, close 10ms late). 500 is the maximum value, but it is not a good idea to go anywhere near that. If you have to go above 50 you probably have a bug somewhere. Check your device timing.
RadioLibTime_t scanGuardC = 50
 Class C inverse Rx window padding in milliseconds. The Class C receive window should close early enough to prepare for Rx1 and Rx2. This switchover time depends on MCU clock speed and SPI clock speed. Increase this value if you encounter RADIOLIB_ERR_NO_RX_WINDOW.

Detailed Description

LoRaWAN-compatible node (class A device).

Constructor & Destructor Documentation

◆ LoRaWANNode()

LoRaWANNode::LoRaWANNode ( PhysicalLayer * phy,
const LoRaWANBand_t * band,
uint8_t subBand = 0 )

Default constructor.

Parameters
phyPointer to the PhysicalLayer radio module.
bandPointer to the LoRaWAN band to use.
subBandThe sub-band to be used (starting from 1!)

Member Function Documentation

◆ activateABP()

int16_t LoRaWANNode::activateABP ( )

Join network by restoring ABP session or performing over-the-air activation. In this procedure, all necessary configuration must be provided by the user.

Returns
Status Codes

◆ activateOTAA()

int16_t LoRaWANNode::activateOTAA ( LoRaWANJoinEvent_t * joinEvent = NULL)

Join network by restoring OTAA session or performing over-the-air activation. By this procedure, the device will perform an exchange with the network server and set all necessary configuration.

Returns
Status Codes

◆ addAppPackage()

int16_t LoRaWANNode::addAppPackage ( uint8_t fPort)

Enable a reserved FPort that can be used for application traffic.

Parameters
fPortFPort number in reserved range (>= RADIOLIB_LORAWAN_FPORT_RESERVED).
Returns
Status Codes

◆ addNwkPackage()

int16_t LoRaWANNode::addNwkPackage ( uint8_t fPort)

Enable a reserved FPort that can be used for network traffic.

Parameters
fPortFPort number in reserved range (>= RADIOLIB_LORAWAN_FPORT_RESERVED).
Returns
Status Codes

◆ beginABP()

int16_t LoRaWANNode::beginABP ( uint32_t addr,
const uint8_t * fNwkSIntKey,
const uint8_t * sNwkSIntKey,
const uint8_t * nwkSEncKey,
const uint8_t * appSKey )

Set the device credentials and activation configuration.

Parameters
addrDevice address.
fNwkSIntKeyPointer to the Forwarding network session (LoRaWAN 1.1), NULL for LoRaWAN 1.0.
sNwkSIntKeyPointer to the Serving network session (LoRaWAN 1.1), NULL for LoRaWAN 1.0.
nwkSEncKeyPointer to the MAC command network session key [NwkSEncKey] (LoRaWAN 1.1) or network session AES-128 key [NwkSKey] (LoRaWAN 1.0).
appSKeyPointer to the application session AES-128 key.
Returns
Status Codes

◆ beginOTAA()

int16_t LoRaWANNode::beginOTAA ( uint64_t joinEUI,
uint64_t devEUI,
const uint8_t * nwkKey,
const uint8_t * appKey )

Set the device credentials and activation configuration.

Parameters
joinEUI8-byte application identifier.
devEUI8-byte device identifier.
nwkKeyPointer to the network AES-128 key.
appKeyPointer to the application AES-128 key.
Returns
Status Codes

◆ dutyCycleInterval()

RadioLibTime_t LoRaWANNode::dutyCycleInterval ( RadioLibTime_t msPerHour,
RadioLibTime_t airtime )

Calculate the minimum interval to adhere to a certain dutyCycle. This interval is based on the ToA of one uplink and does not actually keep track of total airtime.

Parameters
msPerHourThe maximum allowed duty cycle (in milliseconds per hour).
airtimeThe airtime of the uplink.
Returns
Required interval (delay) in milliseconds between consecutive uplinks.

◆ getBand()

const LoRaWANBand_t * LoRaWANNode::getBand ( )

Get the LoRaWAN band used by this node.

Returns
Pointer to the used band.

◆ getClass()

uint8_t LoRaWANNode::getClass ( )

Get the LoRaWAN class of this node.

Returns
Class type (RADIOLIB_LORAWAN_CLASS_*).

◆ getDevAddr()

uint32_t LoRaWANNode::getDevAddr ( )

Returns the DevAddr of the device, regardless of OTAA or ABP mode.

Returns
4-byte DevAddr

◆ getDownlinkClassC()

int16_t LoRaWANNode::getDownlinkClassC ( uint8_t * dataDown,
size_t * lenDown,
LoRaWANEvent_t * eventDown = NULL )

Check if there is an RxC downlink and parse it if available.

Parameters
dataDownBuffer to save received data into.
lenDownPointer to variable that will be used to save the number of received bytes.
eventDownPointer to a structure to store extra information about the downlink event (fPort, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
Returns
Window number > 0 if downlink was received, 0 is no downlink was received, otherwise Status Codes

◆ getLastDuration()

RadioLibTime_t LoRaWANNode::getLastDuration ( bool seconds = false)

Get the duration of the last uplink/downlink cycle.

Parameters
secondsSet to true to get time in seconds (rounded down).
Returns
Duration of last sendReceive call (default unit: milliseconds).

◆ getLastToA()

RadioLibTime_t LoRaWANNode::getLastToA ( )

Get the Time-on-air of the last uplink message (in milliseconds).

Returns
(RadioLibTime_t) time-on-air (ToA) of last uplink message (in milliseconds).

◆ getMacDeviceTimeAns()

int16_t LoRaWANNode::getMacDeviceTimeAns ( uint32_t * timestamp,
uint16_t * milliseconds,
bool returnUnix = true )

Returns the network time after requesting a DeviceTime MAC command. Note: the network returns the time at the end of the uplink transmission. The return value of this function automatically adjusts to the current time. This time is supposed to be <100ms accurate, but may be accurate to 1 second.

Parameters
timestampNumber of seconds since GPS epoch (Jan. 6th 1980).
millisecondsMilliseconds on top of the timestamp.
returnUnixIf true, returns Unix timestamp instead of GPS (default true).
Returns
Status Codes

◆ getMacLinkCheckAns()

int16_t LoRaWANNode::getMacLinkCheckAns ( uint8_t * margin,
uint8_t * gwCnt )

Returns the quality of connectivity after requesting a LinkCheck MAC command.

Parameters
marginLink margin in dB of LinkCheckReq demodulation at gateway side.
gwCntNumber of gateways that received the LinkCheckReq.
Returns
Status Codes

◆ getMacUplinkLen()

uint8_t LoRaWANNode::getMacUplinkLen ( )

Get the length of the pending MAC uplink payload.

Returns
Number of bytes of MAC uplink payload

◆ getMulticastClass()

uint8_t LoRaWANNode::getMulticastClass ( )

Request the currently configured class for Multicast.

Returns
Class C if configured, otherwise Class A (B is not supported)

◆ getUnicastClass()

uint8_t LoRaWANNode::getUnicastClass ( )

Get the LoRaWAN class of this node.

Returns
Class type (RADIOLIB_LORAWAN_CLASS_*).

◆ getVersionMajor()

uint8_t LoRaWANNode::getVersionMajor ( )

Get the LoRaWAN version of this node.

Returns
Version major number (0 for LoRaWAN 1.0.x, 1 for LoRaWAN 1.1).

◆ loadBuffers()

int16_t LoRaWANNode::loadBuffers ( )

Trigger the registered buffer callbacks to restore persistence and session buffers.

Returns
Status Codes

◆ removePackage()

void LoRaWANNode::removePackage ( uint8_t fPort)

Disable a package that was previously added.

Parameters
fPortFPort number in reserved range (>= RADIOLIB_LORAWAN_FPORT_RESERVED).

◆ scheduleTransmission()

void LoRaWANNode::scheduleTransmission ( RadioLibTime_t tUplink)

Set the exact time a transmission should occur. Note: this is the internal clock time. On Arduino platforms, this is the usual time supplied by millis(). If the supplied time is larger than the current time, sendReceive() or uplink() will delay until the scheduled time. The scheduled time must be within ~24 days of the current time (half of the 32-bit millis() range).

Parameters
tUplinkTransmission time in milliseconds, based on internal clock.

◆ sendMacCommandReq()

int16_t LoRaWANNode::sendMacCommandReq ( uint8_t cid)

Add a MAC command to the uplink queue. Only LinkCheck and DeviceTime are available to the user. Other commands are ignored; duplicate MAC commands are discarded.

Parameters
cidID of the MAC command
Returns
Status Codes

◆ sendReceive() [1/4]

int16_t LoRaWANNode::sendReceive ( const char * strUp,
uint8_t fPort,
bool isConfirmed = false,
LoRaWANEvent_t * eventUp = NULL,
LoRaWANEvent_t * eventDown = NULL )
virtual

Send a message to the server and wait for a downlink during Rx1 and/or Rx2 window.

Parameters
strUpC-string that will be transmitted.
fPortPort number to send the message to.
isConfirmedWhether to send a confirmed uplink or not.
eventUpPointer to a structure to store extra information about the uplink event (fPort, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
eventDownPointer to a structure to store extra information about the downlink event (fPort, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
Returns
Window number > 0 if downlink was received, 0 is no downlink was received, otherwise Status Codes

◆ sendReceive() [2/4]

int16_t LoRaWANNode::sendReceive ( const char * strUp,
uint8_t fPort,
uint8_t * dataDown,
size_t * lenDown,
bool isConfirmed = false,
LoRaWANEvent_t * eventUp = NULL,
LoRaWANEvent_t * eventDown = NULL )
virtual

Send a message to the server and wait for a downlink during Rx1 and/or Rx2 window.

Parameters
strUpC-string that will be transmitted.
fPortPort number to send the message to.
dataDownBuffer to save received data into.
lenDownPointer to variable that will be used to save the number of received bytes.
isConfirmedWhether to send a confirmed uplink or not.
eventUpPointer to a structure to store extra information about the uplink event (fPort, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
eventDownPointer to a structure to store extra information about the downlink event (fPort, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
Returns
Window number > 0 if downlink was received, 0 is no downlink was received, otherwise Status Codes

◆ sendReceive() [3/4]

int16_t LoRaWANNode::sendReceive ( const uint8_t * dataUp,
size_t lenUp,
uint8_t fPort,
uint8_t * dataDown,
size_t * lenDown,
bool isConfirmed = false,
LoRaWANEvent_t * eventUp = NULL,
LoRaWANEvent_t * eventDown = NULL )
virtual

Send a message to the server and wait for a downlink during Rx1 and/or Rx2 window.

Parameters
dataUpData to send.
lenUpLength of the data.
fPortPort number to send the message to.
dataDownBuffer to save received data into.
lenDownPointer to variable that will be used to save the number of received bytes.
isConfirmedWhether to send a confirmed uplink or not.
eventUpPointer to a structure to store extra information about the uplink event (fPort, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
eventDownPointer to a structure to store extra information about the downlink event (fPort, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
Returns
Window number > 0 if downlink was received, 0 is no downlink was received, otherwise Status Codes

◆ sendReceive() [4/4]

int16_t LoRaWANNode::sendReceive ( const uint8_t * dataUp,
size_t lenUp,
uint8_t fPort = 1,
bool isConfirmed = false,
LoRaWANEvent_t * eventUp = NULL,
LoRaWANEvent_t * eventDown = NULL )
virtual

Send a message to the server and wait for a downlink but don't bother the user with downlink contents.

Parameters
dataUpData to send.
lenUpLength of the data.
fPortPort number to send the message to.
isConfirmedWhether to send a confirmed uplink or not.
eventUpPointer to a structure to store extra information about the uplink event (fPort, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
eventDownPointer to a structure to store extra information about the downlink event (fPort, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
Returns
Window number > 0 if downlink was received, 0 is no downlink was received, otherwise Status Codes

◆ setActivityLeds()

void LoRaWANNode::setActivityLeds ( const uint32_t pins[4])

Set pins for activity LEDs that will indicate when the radio is transmitting (Tx) or receiving (Rx).

Parameters
pinsArray of 4 pin numbers: [Tx, Rx1, Rx2, RxBC]. Use RADIOLIB_NC to disable individual indicators.

◆ setADR()

void LoRaWANNode::setADR ( bool enable = true)

Toggle ADR to on or off.

Parameters
enableWhether to disable ADR or not.

◆ setBand()

int16_t LoRaWANNode::setBand ( const LoRaWANBand_t * band,
uint8_t subBand = 0 )

Set LoRaWAN (sub)band. This cannot be done during an active session.

Parameters
bandLoRaWAN band / region (e.g. EU868 or US915).
subBandSubband for fixed regions (such as US915).
Returns
Status Codes

◆ setCSMA()

void LoRaWANNode::setCSMA ( bool csmaEnabled,
uint8_t maxChanges = 4,
uint8_t backoffMax = 0,
uint8_t difsSlots = 2 )

Configures CSMA for LoRaWAN as per TR013, LoRa Alliance.

Parameters
csmaEnabledEnable/disable CSMA for LoRaWAN.
maxChangesMaximum number of channel hops if channel is used (default 4).
backoffMaxNum of BO slots to be decremented after DIFS phase. 0 to disable BO (default).
difsSlotsNum of CADs to estimate a clear CH (default 2).

◆ setDatarate()

int16_t LoRaWANNode::setDatarate ( uint8_t drUp)

Set uplink datarate. This should not be used when ADR is enabled.

Parameters
drUpDatarate to use for uplinks.
Returns
Status Codes

◆ setDeviceStatus()

void LoRaWANNode::setDeviceStatus ( uint8_t battLevel)

Set device status.

Parameters
battLevelBattery level to set. 0 for external power source, 1 for lowest battery, 254 for highest battery, 255 for unable to measure.

◆ setDutyCycle()

void LoRaWANNode::setDutyCycle ( bool enable = true,
RadioLibTime_t msPerHour = 0 )

Toggle adherence to dutyCycle limits to on or off.

Parameters
enableWhether to adhere to dutyCycle limits or not (default true).
msPerHourThe maximum allowed Time-on-Air per hour in milliseconds (default 0 = maximum allowed for configured band).

◆ setDwellTime()

void LoRaWANNode::setDwellTime ( bool enable,
RadioLibTime_t msPerUplink = 0 )

Set or disable uplink dwell time limitation; enabled by default if mandatory.

Parameters
enableWhether to adhere to dwellTime limits or not (default true).
msPerUplinkThe maximum allowed Time-on-Air per uplink in milliseconds (default 0 = band default value); make sure you follow regulations/law!

◆ setRx2Dr()

int16_t LoRaWANNode::setRx2Dr ( uint8_t dr)

Configure the Rx2 datarate for ABP mode. This should not be needed for LoRaWAN 1.1 as it is configured through the first downlink.

Parameters
drThe datarate to be used for listening for downlinks in Rx2.
Returns
Status Codes

◆ setTxPower()

int16_t LoRaWANNode::setTxPower ( int8_t txPower)

Configure TX power of the radio module.

Parameters
txPowerOutput power during TX mode to be set in dBm.
Returns
Status Codes

◆ startMulticastSession() [1/2]

int16_t LoRaWANNode::startMulticastSession ( uint8_t cls,
uint32_t mcAddr,
const uint8_t * mcAppSKey,
const uint8_t * mcNwkSKey,
uint32_t mcFCntMin = 0,
uint32_t mcFCntMax = 0xFFFFFFFF,
uint32_t mcFreq = 0,
uint8_t mcDr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED )

Start a Multicast session.

Parameters
clsThe LoRaWAN Class used for this session (only C is supported).
mcAddrThe Multicast address.
mcAppSKeyThe Multicast payload encryption key.
mcNwkSKeyThe Multicast payload integrity key.
mcFCntMinThe minimum expected Multicast frame counter.
mcFCntMinThe maximum allowed Multicast frame counter.
mcFreqThe frequency used for the Multicast downlinks (in Hz). Default = 0 uses Rx2 frequency.
mcDrThe datarate used for the Multicast downlinks. Default = 0 uses Rx2 datarate.
Returns
Status Codes

◆ startMulticastSession() [2/2]

int16_t LoRaWANNode::startMulticastSession ( uint8_t id,
MulticastGroup_t * mcGroup )

Start a Multicast session.

Parameters
idMulticast group ID.
mcGroupMulticast group specification structure. The user is expected to fill in all fields of this structure.
Returns
Status Codes

◆ stopMulticastSession()

bool LoRaWANNode::stopMulticastSession ( uint8_t id,
bool addRxFCnt = false )

Stop an ongoing multicast session.

Parameters
idMulticast group ID to stop. Must match the ID used to start the session.
addRxFCntWhether to add the multicast Rx frame counter to the session Rx frame counter.
Returns
true if the session was stopped successfully, false otherwise

◆ testPayloadLength()

int16_t LoRaWANNode::testPayloadLength ( uint8_t len)
virtual

Test whether a certain payload length can be transmitted. Three options: NONE (ok), MAC_ANSWERS_PENDING (send MAC-only uplink first) or PACKET_TOO_LONG.

Returns
Status Codes

◆ timeUntilUplink()

RadioLibTime_t LoRaWANNode::timeUntilUplink ( bool seconds = false)

Calculate the time until next uplink is available under dutyCycle limits.

Parameters
secondsSet to true to get time in seconds instead of milliseconds (rounded up).
Returns
Time until next uplink (default unit: milliseconds).

The documentation for this class was generated from the following files:
  • src/protocols/LoRaWAN/LoRaWAN.h
  • src/protocols/LoRaWAN/LoRaWAN.cpp