SX126x-Arduino  2.0.1
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
LoRaMac.h File Reference

LoRa MAC layer implementation. More...

Go to the source code of this file.

Data Structures

union  uDrRange
 
struct  uDrRange::sFields
 
struct  sBand
 
struct  sChannelParams
 
struct  sRx2ChannelParams
 
struct  sLoRaMacParams
 
struct  sMulticastParams
 
union  uLoRaMacHeader
 
struct  uLoRaMacHeader::sHdrBits
 
union  uLoRaMacFrameCtrl
 
struct  uLoRaMacFrameCtrl::sCtrlBits
 
union  eLoRaMacFlags_t
 
struct  eLoRaMacFlags_t::sMacFlagBits
 
struct  sMcpsReqUnconfirmed
 
struct  sMcpsReqConfirmed
 
struct  sMcpsReqProprietary
 
struct  sMcpsReq
 
union  sMcpsReq::uMcpsParam
 
struct  sMcpsConfirm
 
struct  sMcpsIndication
 
struct  sMlmeReqJoin
 
struct  sMlmeReqTxCw
 
struct  sMlmeReq
 
union  sMlmeReq::uMlmeParam
 
struct  sMlmeConfirm
 
union  uMibParam
 
struct  eMibRequestConfirm
 
struct  sLoRaMacTxInfo
 
struct  sLoRaMacPrimitives
 
struct  sLoRaMacCallback
 

Macros

#define MAC_STATE_CHECK_TIMEOUT   250
 
#define MAX_ACK_RETRIES   8
 
#define UP_LINK   0
 
#define DOWN_LINK   1
 
#define LORAMAC_MFR_LEN   4
 
#define LORA_MAC_FRMPAYLOAD_OVERHEAD   13
 

Typedefs

typedef enum eDeviceClass DeviceClass_t
 
typedef union uDrRange DrRange_t
 
typedef struct sBand Band_t
 
typedef struct sChannelParams ChannelParams_t
 
typedef struct sRx2ChannelParams Rx2ChannelParams_t
 
typedef struct sLoRaMacParams LoRaMacParams_t
 
typedef struct sMulticastParams MulticastParams_t
 
typedef enum eLoRaMacFrameType LoRaMacFrameType_t
 
typedef enum eLoRaMacMoteCmd LoRaMacMoteCmd_t
 
typedef enum eLoRaMacSrvCmd LoRaMacSrvCmd_t
 
typedef enum eLoRaMacBatteryLevel LoRaMacBatteryLevel_t
 
typedef union uLoRaMacHeader LoRaMacHeader_t
 
typedef union uLoRaMacFrameCtrl LoRaMacFrameCtrl_t
 
typedef enum eLoRaMacEventInfoStatus LoRaMacEventInfoStatus_t
 
typedef union eLoRaMacFlags_t LoRaMacFlags_t
 
typedef enum eMcps Mcps_t
 LoRaMAC data services. More...
 
typedef struct sMcpsReqUnconfirmed McpsReqUnconfirmed_t
 
typedef struct sMcpsReqConfirmed McpsReqConfirmed_t
 
typedef struct sMcpsReqProprietary McpsReqProprietary_t
 
typedef struct sMcpsReq McpsReq_t
 
typedef struct sMcpsConfirm McpsConfirm_t
 
typedef struct sMcpsIndication McpsIndication_t
 
typedef enum eMlme Mlme_t
 LoRaMAC management services. More...
 
typedef struct sMlmeReqJoin MlmeReqJoin_t
 
typedef struct sMlmeReqTxCw MlmeReqTxCw_t
 
typedef struct sMlmeReq MlmeReq_t
 
typedef struct sMlmeConfirm MlmeConfirm_t
 
typedef enum eMib Mib_t
 
typedef enum eJoinStatus eJoinStatus_t
 
typedef union uMibParam MibParam_t
 
typedef struct eMibRequestConfirm MibRequestConfirm_t
 
typedef struct sLoRaMacTxInfo LoRaMacTxInfo_t
 
typedef enum eLoRaMacStatus LoRaMacStatus_t
 
typedef enum eLoRaMacRegion_t LoRaMacRegion_t
 
typedef struct sLoRaMacPrimitives LoRaMacPrimitives_t
 
typedef struct sLoRaMacCallback LoRaMacCallback_t
 

Enumerations

enum  eDeviceClass { CLASS_A, CLASS_B, CLASS_C }
 
enum  eLoRaMacFrameType {
  FRAME_TYPE_JOIN_REQ = 0x00, FRAME_TYPE_JOIN_ACCEPT = 0x01, FRAME_TYPE_DATA_UNCONFIRMED_UP = 0x02, FRAME_TYPE_DATA_UNCONFIRMED_DOWN = 0x03,
  FRAME_TYPE_DATA_CONFIRMED_UP = 0x04, FRAME_TYPE_DATA_CONFIRMED_DOWN = 0x05, FRAME_TYPE_RFU = 0x06, FRAME_TYPE_PROPRIETARY = 0x07
}
 
enum  eLoRaMacMoteCmd {
  MOTE_MAC_LINK_CHECK_REQ = 0x02, MOTE_MAC_LINK_ADR_ANS = 0x03, MOTE_MAC_DUTY_CYCLE_ANS = 0x04, MOTE_MAC_RX_PARAM_SETUP_ANS = 0x05,
  MOTE_MAC_DEV_STATUS_ANS = 0x06, MOTE_MAC_NEW_CHANNEL_ANS = 0x07, MOTE_MAC_RX_TIMING_SETUP_ANS = 0x08, MOTE_MAC_TX_PARAM_SETUP_ANS = 0x09,
  MOTE_MAC_DL_CHANNEL_ANS = 0x0A
}
 
enum  eLoRaMacSrvCmd {
  SRV_MAC_LINK_CHECK_ANS = 0x02, SRV_MAC_LINK_ADR_REQ = 0x03, SRV_MAC_DUTY_CYCLE_REQ = 0x04, SRV_MAC_RX_PARAM_SETUP_REQ = 0x05,
  SRV_MAC_DEV_STATUS_REQ = 0x06, SRV_MAC_NEW_CHANNEL_REQ = 0x07, SRV_MAC_RX_TIMING_SETUP_REQ = 0x08, SRV_MAC_TX_PARAM_SETUP_REQ = 0x09,
  SRV_MAC_DL_CHANNEL_REQ = 0x0A
}
 
enum  eLoRaMacBatteryLevel { BAT_LEVEL_EXT_SRC = 0x00, BAT_LEVEL_EMPTY = 0x01, BAT_LEVEL_FULL = 0xFE, BAT_LEVEL_NO_MEASURE = 0xFF }
 
enum  eLoRaMacEventInfoStatus {
  LORAMAC_EVENT_INFO_STATUS_OK = 0, LORAMAC_EVENT_INFO_STATUS_ERROR, LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT, LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT,
  LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT, LORAMAC_EVENT_INFO_STATUS_RX1_ERROR, LORAMAC_EVENT_INFO_STATUS_RX2_ERROR, LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL,
  LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED, LORAMAC_EVENT_INFO_STATUS_TX_DR_PAYLOAD_SIZE_ERROR, LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS, LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL,
  LORAMAC_EVENT_INFO_STATUS_MIC_FAIL
}
 
enum  eMcps { MCPS_UNCONFIRMED, MCPS_CONFIRMED, MCPS_MULTICAST, MCPS_PROPRIETARY }
 LoRaMAC data services. More...
 
enum  eMlme { MLME_JOIN, MLME_LINK_CHECK, MLME_TXCW, MLME_TXCW_1 }
 LoRaMAC management services. More...
 
enum  eMib {
  MIB_DEVICE_CLASS, MIB_NETWORK_JOINED, MIB_ADR, MIB_NET_ID,
  MIB_DEV_ADDR, MIB_NWK_SKEY, MIB_APP_SKEY, MIB_PUBLIC_NETWORK,
  MIB_REPEATER_SUPPORT, MIB_CHANNELS, MIB_RX2_CHANNEL, MIB_RX2_DEFAULT_CHANNEL,
  MIB_CHANNELS_MASK, MIB_CHANNELS_DEFAULT_MASK, MIB_CHANNELS_NB_REP, MIB_MAX_RX_WINDOW_DURATION,
  MIB_RECEIVE_DELAY_1, MIB_RECEIVE_DELAY_2, MIB_JOIN_ACCEPT_DELAY_1, MIB_JOIN_ACCEPT_DELAY_2,
  MIB_CHANNELS_DEFAULT_DATARATE, MIB_CHANNELS_DATARATE, MIB_CHANNELS_TX_POWER, MIB_CHANNELS_DEFAULT_TX_POWER,
  MIB_UPLINK_COUNTER, MIB_DOWNLINK_COUNTER, MIB_MULTICAST_CHANNEL, MIB_SYSTEM_MAX_RX_ERROR,
  MIB_MIN_RX_SYMBOLS, MIB_ANTENNA_GAIN
}
 
enum  eJoinStatus { JOIN_NOT_START, JOIN_OK, JOIN_ONGOING, JOIN_FAILED }
 
enum  eLoRaMacStatus {
  LORAMAC_STATUS_OK, LORAMAC_STATUS_BUSY, LORAMAC_STATUS_SERVICE_UNKNOWN, LORAMAC_STATUS_PARAMETER_INVALID,
  LORAMAC_STATUS_FREQUENCY_INVALID, LORAMAC_STATUS_DATARATE_INVALID, LORAMAC_STATUS_FREQ_AND_DR_INVALID, LORAMAC_STATUS_NO_NETWORK_JOINED,
  LORAMAC_STATUS_LENGTH_ERROR, LORAMAC_STATUS_DEVICE_OFF, LORAMAC_STATUS_REGION_NOT_SUPPORTED
}
 
enum  eLoRaMacRegion_t {
  LORAMAC_REGION_AS923, LORAMAC_REGION_AU915, LORAMAC_REGION_CN470, LORAMAC_REGION_CN779,
  LORAMAC_REGION_EU433, LORAMAC_REGION_EU868, LORAMAC_REGION_KR920, LORAMAC_REGION_IN865,
  LORAMAC_REGION_US915, LORAMAC_REGION_AS923_2, LORAMAC_REGION_AS923_3, LORAMAC_REGION_AS923_4,
  LORAMAC_REGION_RU864
}
 

Functions

LoRaMacStatus_t LoRaMacInitialization (LoRaMacPrimitives_t *primitives, LoRaMacCallback_t *callbacks, LoRaMacRegion_t region, eDeviceClass nodeClass=CLASS_A)
 LoRaMAC layer initialization. More...
 
uint32_t LoRaMacGetOTAADevId (void)
 Returns the Device Address set by the LoRaWan server after OTAA join was successful. More...
 
LoRaMacStatus_t LoRaMacQueryTxPossible (uint8_t size, LoRaMacTxInfo_t *txInfo)
 Queries the LoRaMAC if it is possible to send the next frame with a given payload size. The LoRaMAC takes scheduled MAC commands into account and reports, when the frame can be send or not. More...
 
LoRaMacStatus_t LoRaMacChannelAdd (uint8_t id, ChannelParams_t params)
 LoRaMAC channel add service. More...
 
LoRaMacStatus_t LoRaMacChannelRemove (uint8_t id)
 LoRaMAC channel remove service. More...
 
LoRaMacStatus_t LoRaMacMulticastChannelLink (MulticastParams_t *channelParam)
 LoRaMAC multicast channel link service. More...
 
LoRaMacStatus_t LoRaMacMulticastChannelUnlink (MulticastParams_t *channelParam)
 LoRaMAC multicast channel unlink service. More...
 
LoRaMacStatus_t LoRaMacMibGetRequestConfirm (MibRequestConfirm_t *mibGet)
 LoRaMAC MIB-Get. More...
 
LoRaMacStatus_t LoRaMacMibSetRequestConfirm (MibRequestConfirm_t *mibSet)
 LoRaMAC MIB-Set. More...
 
LoRaMacStatus_t LoRaMacMlmeRequest (MlmeReq_t *mlmeRequest)
 LoRaMAC MLME-Request. More...
 
LoRaMacStatus_t LoRaMacMcpsRequest (McpsReq_t *mcpsRequest)
 LoRaMAC MCPS-Request. More...
 

Variables

LoRaMacRegion_t LoRaMacRegion
 
static const uint8_t LoRaMacMaxEirpTable [] = {8, 10, 12, 13, 14, 16, 18, 20, 21, 24, 26, 27, 29, 30, 33, 36}
 

Detailed Description

LoRa MAC layer implementation.

______ _
/ _____) _ | |
( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
(C)2013 Semtech
___ _____ _ ___ _ _____ ___ ___ ___ ___
/ __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
\__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
|___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
embedded.connectivity.solutions===============
Author
Miguel Luis ( Semtech )
Gregory Cristian ( Semtech )
Daniel Jaeckle ( STACKFORCE )