RadioLib Universal wireless communication library for Arduino

Public Member Functions | Public Attributes | List of all members
LoRaWANNode Class Reference

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

`#include <LoRaWAN.h>`

## Public Member Functions
| LoRaWANNode (PhysicalLayer *phy, const LoRaWANBand_t *band)
| Default constructor. More...
void | wipe ()
| Wipe internal persistent parameters. This will reset all counters and saved variables, so the device will have to rejoin the network.
void | setCSMA (uint8_t backoffMax, uint8_t difsSlots, bool enableCSMA=false)
| Configures CSMA for LoRaWAN as per TR-13, LoRa Alliance. More...
int16_t | restoreOTAA ()
| Restore OTAA session by loading information from persistent storage. More...
int16_t | beginOTAA (uint64_t joinEUI, uint64_t devEUI, uint8_t *nwkKey, uint8_t *appKey, bool force=false)
| Join network by performing over-the-air activation. By this procedure, the device will perform an exchange with the network server and set all necessary configuration. More...
int16_t | beginABP (uint32_t addr, uint8_t *nwkSKey, uint8_t *appSKey, uint8_t *fNwkSIntKey=NULL, uint8_t *sNwkSIntKey=NULL)
| Join network by performing activation by personalization. In this procedure, all necessary configuration must be provided by the user. More...
int16_t | uplink (const char *str, uint8_t port)
| Send a message to the server. More...
int16_t | uplink (uint8_t *data, size_t len, uint8_t port)
| Send a message to the server. More...
int16_t | downlink (uint8_t *data, size_t *len)
| Wait for downlink from the server in either RX1 or RX2 window. More...
void | setDeviceStatus (uint8_t battLevel)
| Set device status. More...

## Public Attributes
bool | FSK
| Set to true to force the node to only use FSK channels. Set to false by default.
int8_t | startChannel
| Starting channel offset. Some band plans only support a subset of available channels. Set to a positive value to set the first channel that will be used (e.g. 8 for US915 FSB2 used by TTN). By default -1 (no channel offset).
int8_t | numChannels
| Number of supported channels. Some band plans only support a subset of available channels. Set to a positive value to set the number of channels that will be used (e.g. 8 for US915 FSB2 used by TTN). By default -1 (no channel offset).
uint8_t | backoffMax
| Num of Back Off(BO) slots to be decremented after DIFS phase. 0 to disable BO. A random BO avoids collisions in the case where two or more nodes start the CSMA process at the same time.
uint8_t | difsSlots
| Num of CADs to estimate a clear CH.
bool | enableCSMA
| enable/disable CSMA for LoRaWAN.

## Detailed Description

LoRaWAN-compatible node (class A device).

## Constructor & Destructor Documentation

## ◆ LoRaWANNode()

LoRaWANNode::LoRaWANNode | ( | PhysicalLayer * | phy,
|  | const LoRaWANBand_t * | band
| ) |  |

Default constructor.

Parameters

  phy | Pointer to the PhysicalLayer radio module.
  band | Pointer to the LoRaWAN band to use.

## Member Function Documentation

## ◆ beginABP()

int16_t LoRaWANNode::beginABP | ( | uint32_t | addr,
|  | uint8_t * | nwkSKey,
|  | uint8_t * | appSKey,
|  | uint8_t * | fNwkSIntKey = `NULL`,
|  | uint8_t * | sNwkSIntKey = `NULL`
| ) |  |

Join network by performing activation by personalization. In this procedure, all necessary configuration must be provided by the user.

Parameters

  addr | Device address.
  nwkSKey | Pointer to the network session AES-128 key (LoRaWAN 1.0) or MAC command network session key (LoRaWAN 1.1).
  appSKey | Pointer to the application session AES-128 key.
  fNwkSIntKey | Pointer to the network session F key (LoRaWAN 1.1), unused for LoRaWAN 1.0.
  sNwkSIntKey | Pointer to the network session S key (LoRaWAN 1.1), unused for LoRaWAN 1.0.

Returns
  Status Codes

## ◆ beginOTAA()

int16_t LoRaWANNode::beginOTAA | ( | uint64_t | joinEUI,
|  | uint64_t | devEUI,
|  | uint8_t * | nwkKey,
|  | uint8_t * | appKey,
|  | bool | force = `false`
| ) |  |

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

Parameters

  joinEUI | 8-byte application identifier.
  devEUI | 8-byte device identifier.
  nwkKey | Pointer to the network AES-128 key.
  appKey | Pointer to the application AES-128 key.
  force | Set to true to force joining even if previously joined.

Returns
  Status Codes

## ◆ downlink()

int16_t LoRaWANNode::downlink | ( | uint8_t * | data,
|  | size_t * | len
| ) |  |

Wait for downlink from the server in either RX1 or RX2 window.

Parameters

  data | Buffer to save received data into.
  len | Pointer to variable that will be used to save the number of received bytes.

Returns
  Status Codes

## ◆ restoreOTAA()

int16_t LoRaWANNode::restoreOTAA | ( |  | ) |

Restore OTAA session by loading information from persistent storage.

Returns
  Status Codes

## ◆ setCSMA()

void LoRaWANNode::setCSMA | ( | uint8_t | backoffMax,
|  | uint8_t | difsSlots,
|  | bool | enableCSMA = `false`
| ) |  |

Configures CSMA for LoRaWAN as per TR-13, LoRa Alliance.

Parameters

  backoffMax | Num of BO slots to be decremented after DIFS phase. 0 to disable BO.
  difsSlots | Num of CADs to estimate a clear CH.
  enableCSMA | enable/disable CSMA for LoRaWAN.

## ◆ setDeviceStatus()

void LoRaWANNode::setDeviceStatus | ( | uint8_t | battLevel | ) |

Set device status.

Parameters

  battLevel | Battery level to set. 0 for external power source, 1 for lowest battery, 254 for highest battery, 255 for unable to measure.

## ◆ uplink() [1/2]

int16_t LoRaWANNode::uplink | ( | const char * | str,
|  | uint8_t | port
| ) |  |

Send a message to the server.

Parameters

  str | C-string that will be transmitted.
  port | Port number to send the message to.

Returns
  Status Codes

## ◆ uplink() [2/2]

int16_t LoRaWANNode::uplink | ( | uint8_t * | data,
|  | size_t | len,
|  | uint8_t | port
| ) |  |

Send a message to the server.

Parameters

  data | Data to send.
  len | Length of the data.
  port | Port number to send the message to.

Returns
  Status Codes

The documentation for this class was generated from the following files:

- src/protocols/LoRaWAN/LoRaWAN.h
- src/protocols/LoRaWAN/LoRaWAN.cpp