Microchip® Advanced Software Framework

lorawan_private.h File Reference

LoRaWAN private header file.

Copyright (c) 2018-2020 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "lorawan_defs.h"
#include "sal.h"

Data Structures

struct  _ClassCParams_t
 
union  _JoinAccept
 
struct  _JoinReqinfo_t
 
struct  _Lora
 
struct  _LorawanLBT
 
struct  _LorawanMcastActivationParams_t
 
union  _LorawanMcastKeys
 
struct  _LorawanMcastParams_t
 
struct  ActivationParameters_t
 
union  DeviceAddress_t
 
union  DlSettings_t
 
union  FCnt_t
 
union  FCtrl_t
 
union  GenericEui_t
 
union  Hdr_t
 
struct  LinkAdrResp_t
 
struct  LorawanCommands_t
 
union  LorawanMacKeys_t
 
union  Mhdr_t
 
struct  ProtocolParams_t
 
struct  ReceiveWindowParameters_t
 
union  Redundancy_t
 

Macros

#define ABP_TIMEOUT_MS   50
 
#define CHANNEL_MASK_ACK   0x01
 
#define DATA_RATE_ACK   0x02
 
#define DR0   0
 
#define DR1   1
 
#define DR10   10
 
#define DR11   11
 
#define DR12   12
 
#define DR13   13
 
#define DR14   14
 
#define DR15   15
 
#define DR2   2
 
#define DR3   3
 
#define DR4   4
 
#define DR5   5
 
#define DR6   6
 
#define DR7   7
 
#define DR8   8
 
#define DR9   9
 
#define FHDR_FPORT_SIZE   8
 
#define FPORT_MAX   223
 
#define FPORT_MIN   1
 
#define FREQ_VALUE_SIZE_IN_BYTES   (3)
 
#define HDRS_MIC_PORT_MIN_SIZE   13
 
#define INVALID_VALUE   0xFF
 
#define JA_JOIN_NONCE_SIZE   3
 
#define JA_NET_ID_SIZE   3
 
#define LORAWAN_FHDR_SIZE_WITHOUT_FOPTS   8
 
#define LORAWAN_MCAST_DEVADDR_DEFAULT   0xFFFFFFFF
 
#define LORAWAN_TEST_PORT   224
 
#define MAC_CMD_FREQ_IN_HZ(frequency)   (frequency * 100)
 
#define MAC_CMD_FREQ_VALUE(frequency)   (frequency & 0x00FFFFFF)
 
#define MAJOR_VERSION3   0
 
#define MAX_FOPTS_LEN   0x0F
 
#define MAX_NB_CMD_TO_PROCESS   16
 
#define MAXIMUM_BUFFER_LENGTH   271
 
#define POWER_ACK   0x04
 
#define RESERVED_FOR_FUTURE_USE   0
 
#define RESPONSE_NOT_OK   0
 
#define RESPONSE_OK   1
 
#define RX1_DR_OFFSET_ACK   0x04
 
#define UPLINK_FREQ_EXISTS_ACK   0x02
 

Typedefs

typedef struct _ClassCParams_t ClassCParams
 
typedef union _JoinAccept JoinAccept_t
 
typedef struct _JoinReqinfo_t JoinReqinfo_t
 
typedef struct _Lora LoRa_t
 
typedef struct _LorawanLBT LorawanLBT_t
 
typedef struct
_LorawanMcastActivationParams_t 
LorawanMcastActivationParams_t
 
typedef union _LorawanMcastKeys LorawanMcastKeys_t
 
typedef struct
_LorawanMcastParams_t 
LorawanMcastParams_t
 

Enumerations

enum  LoRaMacCid_t {
  LINK_CHECK_CID = 0x02,
  LINK_ADR_CID = 0x03,
  DUTY_CYCLE_CID = 0x04,
  RX2_SETUP_CID = 0x05,
  DEV_STATUS_CID = 0x06,
  NEW_CHANNEL_CID = 0x07,
  RX_TIMING_SETUP_CID = 0x08,
  TX_PARAM_SETUP_CID = 0x09,
  DL_CHANNEL_CID = 0x0A,
  DEV_TIME_CID = 0x0D
}
 
enum  LoRaMacFrameType_t {
  FRAME_TYPE_JOIN_REQ =0x00,
  FRAME_TYPE_JOIN_ACCEPT,
  FRAME_TYPE_DATA_UNCONFIRMED_UP,
  FRAME_TYPE_DATA_UNCONFIRMED_DOWN,
  FRAME_TYPE_DATA_CONFIRMED_UP,
  FRAME_TYPE_DATA_CONFIRMED_DOWN,
  FRAME_TYPE_RFU,
  FRAME_TYPE_PROPRIETARY
}
 
enum  LoRaMacState_t {
  IDLE =0,
  TRANSMISSION_OCCURRING,
  BEFORE_RX1,
  RX1_OPEN,
  BETWEEN_RX1_RX2,
  RX2_OPEN,
  RETRANSMISSION_DELAY,
  ABP_DELAY
}
 

Functions

void AckRetransmissionCallback (void)
 
void AssemblePacket (bool confirmed, uint8_t port, uint8_t *buffer, uint16_t bufferLength)
 
void AutomaticReplyCallback (void)
 
void ConfigureRadioRx (uint8_t dataRate, uint32_t freq)
 
StackRetStatus_t EncodeDeviceTimeReq (void)
 
StackRetStatus_t EncodeLinkCheckReq (void)
 
SalStatus_t EncryptFRMPayload (uint8_t *buffer, uint8_t bufferLength, uint8_t dir, uint32_t frameCounter, uint8_t *key, salItems_t key_type, uint16_t macBufferIndex, uint8_t *bufferToBeEncrypted, uint32_t devAddr)
 
uint8_t * ExecuteDevStatus (uint8_t *ptr)
 
uint8_t * ExecuteDevTimeAns (uint8_t *ptr)
 
uint8_t * ExecuteDlChannel (uint8_t *ptr)
 
uint8_t * ExecuteDutyCycle (uint8_t *ptr)
 
uint8_t * ExecuteLinkAdr (uint8_t *ptr)
 
uint8_t * ExecuteNewChannel (uint8_t *ptr)
 
uint8_t * ExecuteRxParamSetupReq (uint8_t *ptr)
 
uint8_t * ExecuteTxParamSetup (uint8_t *ptr)
 
uint32_t GetRx1Freq (void)
 
void LorawanCheckAndDoRetryOnTimeout (void)
 
void LorawanClasscNotifyAppOnReceive (uint32_t devAddr, uint8_t *pData, uint8_t dataLength, StackRetStatus_t status)
 
uint32_t LorawanClasscPause (void)
 
void LorawanClasscReceiveWindowCallback (void)
 
void LorawanClasscRxDone (Hdr_t *hdr)
 
void LorawanClasscRxTimeout (void)
 
void LorawanClasscTxDone (int8_t rxWindowOffset2)
 
void LorawanClasscUlAckTimerCallback (uint8_t param)
 
StackRetStatus_t LorawanClasscValidateSend (void)
 
void LorawanConfigureRadioForRX2 (bool doCallback)
 
void LorawanGetChAndInitiateRadioTransmit (void)
 
bool LorawanGetChannelIdStatus (uint8_t channelId)
 
uint8_t LorawanGetDataRange (uint8_t channelId)
 
uint16_t LorawanGetDutyCycle (uint8_t channelId)
 
uint32_t LorawanGetFrequency (uint8_t channelId)
 
uint8_t LorawanGetIsmBand (void)
 
void LorawanGetReceiveWindow2Parameters (ReceiveWindow2Params_t *rx2Params)
 
void LorawanGetReceiveWindowCParameters (ReceiveWindowParameters_t *rxcParams)
 
void LorawanLinkCheckCallback (void)
 
void LorawanLinkCheckConfigure (uint16_t period)
 
StackRetStatus_t LorawanProcessFcntDown (Hdr_t *hdr, bool isMulticast)
 
void LorawanReceiveWindow1Callback (void)
 
void LorawanReceiveWindow2Callback (void)
 
StackRetStatus_t LorawanSetChannelIdStatus (uint8_t channelId, bool statusNew)
 
StackRetStatus_t LorawanSetDataRange (uint8_t channelId, uint8_t dataRangeNew)
 
StackRetStatus_t LorawanSetDutyCycle (uint8_t channelId, uint16_t dutyCycleValue)
 
StackRetStatus_t LorawanSetEdClass (EdClass_t edclass)
 
StackRetStatus_t LorawanSetFrequency (uint8_t channelId, uint32_t frequencyNew)
 
StackRetStatus_t LorawanSetReceiveWindow2Parameters (uint32_t frequency, uint8_t dataRate)
 
StackRetStatus_t LorawanSetReceiveWindowCParameters (uint32_t frequency, uint8_t dataRate)
 
uint8_t PrepareJoinRequestFrame (void)
 
uint16_t Random (uint16_t max)
 
void ResetParametersForConfirmedTransmission (void)
 
void ResetParametersForUnconfirmedTransmission (void)
 
void SetJoinFailState (StackRetStatus_t status)
 
void UnconfirmedTransmissionCallback (void)
 
void UpdateCurrentDataRate (uint8_t valueNew)
 
void UpdateCurrentDataRateAfterDataRangeChanges (void)
 
void UpdateDLSettings (uint8_t dlRx2Dr, uint8_t dlRx1DrOffset)
 
void UpdateJoinInProgress (uint8_t state)
 
void UpdateJoinSuccessState (void)
 
void UpdateReceiveWindow2Parameters (uint32_t frequency, uint8_t dataRate)
 
void UpdateReceiveWindowCParameters (uint32_t frequency, uint8_t dataRate)
 
void UpdateRetransmissionAckTimeoutState (void)
 
void UpdateRxDataAvailableCbParams (uint32_t devAddr, uint8_t *pData, uint8_t dataLength, StackRetStatus_t status)
 
void UpdateTransactionCompleteCbParams (StackRetStatus_t status)
 
void UpdateTxPower (uint8_t txPowerNew)
 

Variables

AppData_t AppPayload
 

#define ABP_TIMEOUT_MS   50
#define CHANNEL_MASK_ACK   0x01
#define DATA_RATE_ACK   0x02
#define DR0   0
#define DR1   1
#define DR10   10
#define DR11   11
#define DR12   12
#define DR13   13
#define DR14   14
#define DR15   15
#define DR2   2
#define DR3   3
#define DR4   4
#define DR5   5
#define DR6   6
#define DR7   7
#define DR8   8
#define DR9   9
#define FHDR_FPORT_SIZE   8
#define FPORT_MAX   223
#define FPORT_MIN   1
#define FREQ_VALUE_SIZE_IN_BYTES   (3)
#define HDRS_MIC_PORT_MIN_SIZE   13
#define INVALID_VALUE   0xFF
#define JA_JOIN_NONCE_SIZE   3
#define JA_NET_ID_SIZE   3
#define LORAWAN_FHDR_SIZE_WITHOUT_FOPTS   8
#define LORAWAN_MCAST_DEVADDR_DEFAULT   0xFFFFFFFF
#define LORAWAN_TEST_PORT   224
#define MAC_CMD_FREQ_IN_HZ (   frequency)    (frequency * 100)
#define MAC_CMD_FREQ_VALUE (   frequency)    (frequency & 0x00FFFFFF)
#define MAJOR_VERSION3   0
#define MAX_FOPTS_LEN   0x0F
#define MAX_NB_CMD_TO_PROCESS   16
#define MAXIMUM_BUFFER_LENGTH   271
#define POWER_ACK   0x04
#define RESERVED_FOR_FUTURE_USE   0
#define RESPONSE_NOT_OK   0
#define RESPONSE_OK   1
#define RX1_DR_OFFSET_ACK   0x04
#define UPLINK_FREQ_EXISTS_ACK   0x02

typedef struct _ClassCParams_t ClassCParams
typedef union _JoinAccept JoinAccept_t
typedef struct _JoinReqinfo_t JoinReqinfo_t
typedef struct _Lora LoRa_t
typedef struct _LorawanLBT LorawanLBT_t

Enumerator
LINK_CHECK_CID 
LINK_ADR_CID 
DUTY_CYCLE_CID 
RX2_SETUP_CID 
DEV_STATUS_CID 
NEW_CHANNEL_CID 
RX_TIMING_SETUP_CID 
TX_PARAM_SETUP_CID 
DL_CHANNEL_CID 
DEV_TIME_CID 
Enumerator
FRAME_TYPE_JOIN_REQ 
FRAME_TYPE_JOIN_ACCEPT 
FRAME_TYPE_DATA_UNCONFIRMED_UP 
FRAME_TYPE_DATA_UNCONFIRMED_DOWN 
FRAME_TYPE_DATA_CONFIRMED_UP 
FRAME_TYPE_DATA_CONFIRMED_DOWN 
FRAME_TYPE_RFU 
FRAME_TYPE_PROPRIETARY 
Enumerator
IDLE 
TRANSMISSION_OCCURRING 
BEFORE_RX1 
RX1_OPEN 
BETWEEN_RX1_RX2 
RX2_OPEN 
RETRANSMISSION_DELAY 
ABP_DELAY 

void AckRetransmissionCallback ( void  )
void AssemblePacket ( bool  confirmed,
uint8_t  port,
uint8_t *  buffer,
uint16_t  bufferLength 
)
void AutomaticReplyCallback ( void  )
void ConfigureRadioRx ( uint8_t  dataRate,
uint32_t  freq 
)
StackRetStatus_t EncodeDeviceTimeReq ( void  )
StackRetStatus_t EncodeLinkCheckReq ( void  )
SalStatus_t EncryptFRMPayload ( uint8_t *  buffer,
uint8_t  bufferLength,
uint8_t  dir,
uint32_t  frameCounter,
uint8_t *  key,
salItems_t  key_type,
uint16_t  macBufferIndex,
uint8_t *  bufferToBeEncrypted,
uint32_t  devAddr 
)
uint8_t* ExecuteDevStatus ( uint8_t *  ptr)
uint8_t* ExecuteDevTimeAns ( uint8_t *  ptr)
uint8_t* ExecuteDlChannel ( uint8_t *  ptr)
uint8_t* ExecuteDutyCycle ( uint8_t *  ptr)
uint8_t* ExecuteLinkAdr ( uint8_t *  ptr)
uint8_t* ExecuteNewChannel ( uint8_t *  ptr)
uint8_t* ExecuteRxParamSetupReq ( uint8_t *  ptr)
uint8_t* ExecuteTxParamSetup ( uint8_t *  ptr)
uint32_t GetRx1Freq ( void  )
void LorawanCheckAndDoRetryOnTimeout ( void  )
void LorawanClasscNotifyAppOnReceive ( uint32_t  devAddr,
uint8_t *  pData,
uint8_t  dataLength,
StackRetStatus_t  status 
)
uint32_t LorawanClasscPause ( void  )
void LorawanClasscReceiveWindowCallback ( void  )
void LorawanClasscRxDone ( Hdr_t hdr)
void LorawanClasscRxTimeout ( void  )
void LorawanClasscTxDone ( int8_t  rxWindowOffset2)
void LorawanClasscUlAckTimerCallback ( uint8_t  param)
StackRetStatus_t LorawanClasscValidateSend ( void  )
void LorawanConfigureRadioForRX2 ( bool  doCallback)
void LorawanGetChAndInitiateRadioTransmit ( void  )
bool LorawanGetChannelIdStatus ( uint8_t  channelId)
uint8_t LorawanGetDataRange ( uint8_t  channelId)
uint16_t LorawanGetDutyCycle ( uint8_t  channelId)
uint32_t LorawanGetFrequency ( uint8_t  channelId)
uint8_t LorawanGetIsmBand ( void  )
void LorawanGetReceiveWindow2Parameters ( ReceiveWindow2Params_t rx2Params)
void LorawanGetReceiveWindowCParameters ( ReceiveWindowParameters_t rxcParams)
void LorawanLinkCheckCallback ( void  )
void LorawanLinkCheckConfigure ( uint16_t  period)
StackRetStatus_t LorawanProcessFcntDown ( Hdr_t hdr,
bool  isMulticast 
)
void LorawanReceiveWindow1Callback ( void  )
void LorawanReceiveWindow2Callback ( void  )
StackRetStatus_t LorawanSetChannelIdStatus ( uint8_t  channelId,
bool  statusNew 
)
StackRetStatus_t LorawanSetDataRange ( uint8_t  channelId,
uint8_t  dataRangeNew 
)
StackRetStatus_t LorawanSetDutyCycle ( uint8_t  channelId,
uint16_t  dutyCycleValue 
)
StackRetStatus_t LorawanSetEdClass ( EdClass_t  edclass)
StackRetStatus_t LorawanSetFrequency ( uint8_t  channelId,
uint32_t  frequencyNew 
)
StackRetStatus_t LorawanSetReceiveWindow2Parameters ( uint32_t  frequency,
uint8_t  dataRate 
)
StackRetStatus_t LorawanSetReceiveWindowCParameters ( uint32_t  frequency,
uint8_t  dataRate 
)
uint8_t PrepareJoinRequestFrame ( void  )
uint16_t Random ( uint16_t  max)
void ResetParametersForConfirmedTransmission ( void  )
void ResetParametersForUnconfirmedTransmission ( void  )
void SetJoinFailState ( StackRetStatus_t  status)
void UnconfirmedTransmissionCallback ( void  )
void UpdateCurrentDataRate ( uint8_t  valueNew)
void UpdateCurrentDataRateAfterDataRangeChanges ( void  )
void UpdateDLSettings ( uint8_t  dlRx2Dr,
uint8_t  dlRx1DrOffset 
)
void UpdateJoinInProgress ( uint8_t  state)
void UpdateJoinSuccessState ( void  )
void UpdateReceiveWindow2Parameters ( uint32_t  frequency,
uint8_t  dataRate 
)
void UpdateReceiveWindowCParameters ( uint32_t  frequency,
uint8_t  dataRate 
)
void UpdateRetransmissionAckTimeoutState ( void  )
void UpdateRxDataAvailableCbParams ( uint32_t  devAddr,
uint8_t *  pData,
uint8_t  dataLength,
StackRetStatus_t  status 
)
void UpdateTransactionCompleteCbParams ( StackRetStatus_t  status)
void UpdateTxPower ( uint8_t  txPowerNew)

AppData_t AppPayload