| SX126x-Arduino 2.0.1

Data Structures | Macros | Typedefs | Enumerations | Functions
LoRaMacHelper.h File Reference
`#include "stdint.h"`
`#include "mac/Commissioning.h"`
`#include "boards/mcu/board.h"`
`#include "mac/LoRaMac.h"`
`#include "mac/region/Region.h"`
`#include "mac/region/RegionAS923.h"`

Go to the source code of this file.

## Data Structures
struct | lmh_param_s
struct | lmh_app_data_t
| Application Data structure. More...
struct | lmh_callback_s
| LoRaMac Helper Callbacks. More...
struct | LoraMacHelper_ComplianceTest_s
| LoRaWAN compliance tests support data. More...

## Macros
#define | LORAWAN_CONFIRMED_MSG_ON 0
#define | LORAWAN_CERTIF_PORT 224
#define | LORAWAN_APP_PORT 2
#define | LORAWAN_APP_DATA_MAX_SIZE 242
#define | LORAWAN_DEFAULT_DATARATE DR_0
#define | LORAWAN_DEFAULT_TX_POWER TX_POWER_0

## Typedefs
typedef struct lmh_param_s | lmh_param_t
typedef struct lmh_callback_s | lmh_callback_t
| LoRaMac Helper Callbacks. More...
typedef struct LoraMacHelper_ComplianceTest_s | lmh_compliance_test_t
| LoRaWAN compliance tests support data. More...

## Enumerations
enum | lmh_join_status { LMH_RESET = 0, LMH_SET, LMH_ONGOING, LMH_FAILED }
enum | lmh_error_status { LMH_ERROR = -1, LMH_SUCCESS = 0 }
enum | lmh_confirm { LMH_UNCONFIRMED_MSG = 0, LMH_CONFIRMED_MSG = !LMH_UNCONFIRMED_MSG }

## Functions
lmh_error_status | lmh_init (lmh_callback_t *callbacks, lmh_param_t lora_param, bool otaa, eDeviceClass nodeClass=CLASS_A, LoRaMacRegion_t region=LORAMAC_REGION_EU868)
| Lora Initialisation. More...
lmh_error_status | lmh_send (lmh_app_data_t *app_data, lmh_confirm is_txconfirmed)
| Send data. More...
lmh_error_status | lmh_send_blocking (lmh_app_data_t *app_data, lmh_confirm is_tx_confirmed, uint32_t time_out)
| Send data and wait for RX2 window closed or timeout occurs. More...
void | lmh_join (void)
| Join a Lora Network in class A. More...
lmh_join_status | lmh_join_status_get (void)
| Check whether the Device is joined to the network. More...
uint32_t | lmh_getDevAddr (void)
| Returns the Device address set by the LoRaWan server after OTAA join success. More...
lmh_error_status | lmh_class_request (DeviceClass_t newClass)
| change Lora Class More...
void | lmh_class_get (DeviceClass_t *currentClass)
| get the current Lora Class More...
void | lmh_datarate_set (uint8_t data_rate, uint8_t enable_adr)
| Configure data rate. More...
void | lmh_tx_power_set (uint8_t tx_power)
| Configure tx power. More...
void | lmh_setDevEui (uint8_t *userDevEui)
| Set Device IEEE EUI (big endian) More...
void | lmh_setAppEui (uint8_t *userAppEui)
| Set Application IEEE EUI. More...
void | lmh_setAppKey (uint8_t *userAppKey)
| Set Application Key AES encryption/decryption cipher application key. More...
void | lmh_setNwkSKey (uint8_t *userNwkSKey)
| Set Network Session Key AES encryption/decryption cipher network session key. More...
void | lmh_setAppSKey (uint8_t *userAppSKey)
| Set Application Session Key AES encryption/decryption cipher application session key. More...
void | lmh_setDevAddr (uint32_t userDevAddr)
| Set Device address on the network (big endian) More...
bool | lmh_setSubBandChannels (uint8_t subBand)
| Set custom channel mask. More...
void | lmh_setSingleChannelGateway (uint8_t userSingleChannel, int8_t userDatarate)
| Disable channel hoping for connnection to single channel gateways Check the file CHANNELS.MD to find out which channel corresponds to which frequency in a specific region Check the file Region.h to find out which datarate corresponds to which SF and bandwidth in a specific region. More...
bool | lmh_setAS923Version (uint8_t version)
| Adjust frequency band to AS923-1, AS923-2, AS923-3. More...

## Macro Definition Documentation

## ◆ LORAWAN_CONFIRMED_MSG_ON

#define LORAWAN_CONFIRMED_MSG_ON 0

LoRaWAN confirmed messages

## ◆ LORAWAN_CERTIF_PORT

#define LORAWAN_CERTIF_PORT 224

LoRaWAN certification port

## ◆ LORAWAN_APP_PORT

#define LORAWAN_APP_PORT 2

LoRaWAN application port, do not use 224. It is reserved for certification

Examples
  LoRaWanPio\src\main.cpp.

## ◆ LORAWAN_APP_DATA_MAX_SIZE

#define LORAWAN_APP_DATA_MAX_SIZE 242

LoRaWAN User application data buffer size

## ◆ LORAWAN_DEFAULT_DATARATE

#define LORAWAN_DEFAULT_DATARATE DR_0

LoRaWAN Default datarate

Examples
  LoRaWanPio\src\main.cpp.

## ◆ LORAWAN_DEFAULT_TX_POWER

#define LORAWAN_DEFAULT_TX_POWER TX_POWER_0

LoRaWAN Default tx power

Examples
  LoRaWanPio\src\main.cpp.

## Typedef Documentation

## ◆ lmh_param_t

typedef struct lmh_param_s lmh_param_t

## ◆ lmh_callback_t

typedef struct lmh_callback_s lmh_callback_t

LoRaMac Helper Callbacks.

## ◆ lmh_compliance_test_t

typedef struct LoraMacHelper_ComplianceTest_s lmh_compliance_test_t

LoRaWAN compliance tests support data.

## Enumeration Type Documentation

## ◆ lmh_join_status

enum lmh_join_status

Enumerator
LMH_RESET |
LMH_SET |
LMH_ONGOING |
LMH_FAILED |

## ◆ lmh_error_status

enum lmh_error_status

Enumerator
LMH_ERROR |
LMH_SUCCESS |

## ◆ lmh_confirm

enum lmh_confirm

Enumerator
LMH_UNCONFIRMED_MSG |
LMH_CONFIRMED_MSG |

## Function Documentation

## ◆ lmh_init()

lmh_error_status lmh_init | ( | lmh_callback_t * | callbacks,
|  | lmh_param_t | lora_param,
|  | bool | otaa,
|  | eDeviceClass | nodeClass = `CLASS_A`,
|  | LoRaMacRegion_t | region = `LORAMAC_REGION_EU868`
| ) |  |

Lora Initialisation.

Parameters

  callbacks | Pointer to structure containing the callback functions
  lora_param | Pointer to structure containing the parameters
  otaa | Choose OTAA (true) or ABP (false) activation
  nodeClass | Choose node class CLASS_A, CLASS_B or CLASS_C, default to CLASS_A
  region | Choose LoRaWAN region to set correct region parameters, default to EU868

Return values

  error | status

## ◆ lmh_send()

lmh_error_status lmh_send | ( | lmh_app_data_t * | app_data,
|  | lmh_confirm | is_txconfirmed
| ) |  |

Send data.

Parameters

  app_data | Pointer to data structure to be sent
  is_txconfirmed | do we need confirmation?

Return values

  error | status

## ◆ lmh_send_blocking()

lmh_error_status lmh_send_blocking | ( | lmh_app_data_t * | app_data,
|  | lmh_confirm | is_tx_confirmed,
|  | uint32_t | time_out
| ) |  |

Send data and wait for RX2 window closed or timeout occurs.

Parameters

  app_data | Pointer to data structure to be sent
  is_txconfirmed | do we need confirmation?
  time_out | time to wait in milliseconds

Return values

  error | status

## ◆ lmh_join()

void lmh_join | ( | void |  | ) |

Join a Lora Network in class A.

## ◆ lmh_join_status_get()

lmh_join_status lmh_join_status_get | ( | void |  | ) |

Check whether the Device is joined to the network.

Return values

  returns | LORAMACHELPER_SET if joined

## ◆ lmh_getDevAddr()

uint32_t lmh_getDevAddr | ( | void |  | ) |

Returns the Device address set by the LoRaWan server after OTAA join success.

Return values

  returns | Device Address

## ◆ lmh_class_request()

lmh_error_status lmh_class_request | ( | DeviceClass_t | newClass | ) |

change Lora Class

Note
  callback LORA_ConfirmClass informs upper layer that the change has occured
  Only switch from class A to class B/C OR from class B/C to class A is allowed

Attention
  can be called only in LORA_ClassSwitchSlot or LORA_RxData callbacks

Parameters

  newClass | DeviceClass_t NewClass

Return values

  LoraErrorStatus |

## ◆ lmh_class_get()

void lmh_class_get | ( | DeviceClass_t * | currentClass | ) |

get the current Lora Class

Parameters

  currentClass | DeviceClass_t NewClass

## ◆ lmh_datarate_set()

void lmh_datarate_set | ( | uint8_t | data_rate,
|  | uint8_t | enable_adr
| ) |  |

Configure data rate.

Parameters

  data_rate | data rate
  enable_adr | enable adaptative data rate

## ◆ lmh_tx_power_set()

void lmh_tx_power_set | ( | uint8_t | tx_power | ) |

Configure tx power.

Parameters

  tx_power | tx power

## ◆ lmh_setDevEui()

void lmh_setDevEui | ( | uint8_t * | userDevEui | ) |

Set Device IEEE EUI (big endian)

Parameters

  userDevEui | Device EUI as uint8_t[] *

## ◆ lmh_setAppEui()

void lmh_setAppEui | ( | uint8_t * | userAppEui | ) |

Set Application IEEE EUI.

Parameters

  userAppEui | Application IEEE EUI as uint8_t[] *

## ◆ lmh_setAppKey()

void lmh_setAppKey | ( | uint8_t * | userAppKey | ) |

Set Application Key AES encryption/decryption cipher application key.

Parameters

  userAppKey | Application Key as uint8_t[] *

## ◆ lmh_setNwkSKey()

void lmh_setNwkSKey | ( | uint8_t * | userNwkSKey | ) |

Set Network Session Key AES encryption/decryption cipher network session key.

Parameters

  userNwkSKey | Network Session Key as uint8_t[] *

## ◆ lmh_setAppSKey()

void lmh_setAppSKey | ( | uint8_t * | userAppSKey | ) |

Set Application Session Key AES encryption/decryption cipher application session key.

Parameters

  userAppSKey | Application Session Key as uint8_t[] *

## ◆ lmh_setDevAddr()

void lmh_setDevAddr | ( | uint32_t | userDevAddr | ) |

Set Device address on the network (big endian)

Parameters

  userDevAddr | Device address as uint8_t[] *

## ◆ lmh_setSubBandChannels()

bool lmh_setSubBandChannels | ( | uint8_t | subBand | ) |

Set custom channel mask.

Parameters

  subBand | Sub channel number 1 to 8

## ◆ lmh_setSingleChannelGateway()

void lmh_setSingleChannelGateway | ( | uint8_t | userSingleChannel,
|  | int8_t | userDatarate
| ) |  |

Disable channel hoping for connnection to single channel gateways Check the file CHANNELS.MD to find out which channel corresponds to which frequency in a specific region Check the file Region.h to find out which datarate corresponds to which SF and bandwidth in a specific region.

Parameters

  userSingleChannel | Channel to be used
  userDatarate | Datarate to be used

## ◆ lmh_setAS923Version()

bool lmh_setAS923Version | ( | uint8_t | version | ) |

Adjust frequency band to AS923-1, AS923-2, AS923-3.

Parameters

  version | 1 => use default frequencies (AS923-1) 2 => adjust frequencies by substracting 1.8MHz (AS923-2) 3 => adjust frequencies by substracting 6.6MHz (AS923-3) 4 => adjust frequencies by substracting 5.9MHz (AS923-4), only lower 8 channels supported

Return values

  true | if success