LoRaWAN MAC layer implementation

Dependents:   LoRaWAN-demo-72_tjm LoRaWAN-demo-72_jlc LoRaWAN-demo-elmo frdm_LoRa_Connect_Woodstream_Demo_tjm ... more

Embed: (wiki syntax)

« Back to documentation index

LoRaMac-api-v3.h File Reference

LoRaMac-api-v3.h File Reference

LoRa MAC wrapper layer implementation. More...

Go to the source code of this file.

Data Structures

union  LoRaMacEventFlags_t
struct  LoRaMacEventInfo_t
struct  sLoRaMacCallbacks

Typedefs

typedef struct sLoRaMacCallbacks LoRaMacCallbacks_t

Functions

void LoRaMacInit (LoRaMacCallbacks_t *callbacks)
void LoRaMacSetAdrOn (bool enable)
void LoRaMacInitNwkIds (uint32_t netID, uint32_t devAddr, uint8_t *nwkSKey, uint8_t *appSKey)
uint8_t LoRaMacJoinReq (uint8_t *devEui, uint8_t *appEui, uint8_t *appKey)
uint8_t LoRaMacLinkCheckReq (void)
uint8_t LoRaMacSendFrame (uint8_t fPort, void *fBuffer, uint16_t fBufferSize)
uint8_t LoRaMacSendConfirmedFrame (uint8_t fPort, void *fBuffer, uint16_t fBufferSize, uint8_t nbRetries)
uint8_t LoRaMacSend (LoRaMacHeader_t *macHdr, uint8_t *fOpts, uint8_t fPort, void *fBuffer, uint16_t fBufferSize)
uint8_t LoRaMacPrepareFrame (ChannelParams_t channel, LoRaMacHeader_t *macHdr, LoRaMacFrameCtrl_t *fCtrl, uint8_t *fOpts, uint8_t fPort, void *fBuffer, uint16_t fBufferSize)
uint8_t LoRaMacSendFrameOnChannel (ChannelParams_t channel)
uint8_t LoRaMacSendOnChannel (ChannelParams_t channel, LoRaMacHeader_t *macHdr, LoRaMacFrameCtrl_t *fCtrl, uint8_t *fOpts, uint8_t fPort, void *fBuffer, uint16_t fBufferSize)
void LoRaMacSetDeviceClass (DeviceClass_t deviceClass)
void LoRaMacSetChannelsTxPower (int8_t txPower)
void LoRaMacSetChannelsDatarate (int8_t datarate)
void LoRaMacTestSetDutyCycleOn (bool enable)
void LoRaMacTestRxWindowsOn (bool enable)
void LoRaMacTestSetMic (uint16_t upLinkCounter)

Detailed Description

LoRa MAC wrapper layer implementation.

Revised BSD License, see section LICENSE.

                ______                              _
               / _____)             _              | |
              ( (____  _____ ____ _| |_ _____  ____| |__
               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
               _____) ) ____| | | || |_| ____( (___| | | |
              (______/|_____)_|_|_| \__)_____)\____)_| |_|
              (C)2013 Semtech

               ___ _____ _   ___ _  _____ ___  ___  ___ ___
              / __|_   _/_\ / __| |/ / __/ _ \| _ \/ __| __|
              \__ \ | |/ _ \ (__| ' <| _| (_) |   / (__| _|
              |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
              embedded.connectivity.solutions===============
Author:
Miguel Luis ( Semtech )
Gregory Cristian ( Semtech )
Daniel Jäckle ( STACKFORCE )

Definition in file LoRaMac-api-v3.h.


Typedef Documentation

LoRaMAC events structure Used to notify upper layers of MAC events


Function Documentation

void LoRaMacInit ( LoRaMacCallbacks_t callbacks )

LoRaMAC layer initialization

Parameters:
[IN]callbacks Pointer to a structure defining the LoRaMAC callback functions.

Definition at line 137 of file LoRaMac-api-v3.cpp.

void LoRaMacInitNwkIds ( uint32_t  netID,
uint32_t  devAddr,
uint8_t *  nwkSKey,
uint8_t *  appSKey 
)

Initializes the network IDs. Device address, network session AES128 key and application session AES128 key.

Remarks:
To be only used when Over-the-Air activation isn't used.
Parameters:
[IN]netID 24 bits network identifier ( provided by network operator )
[IN]devAddr 32 bits device address on the network (must be unique to the network)
[IN]nwkSKey Pointer to the network session AES128 key array ( 16 bytes )
[IN]appSKey Pointer to the application session AES128 key array ( 16 bytes )

Definition at line 160 of file LoRaMac-api-v3.cpp.

uint8_t LoRaMacJoinReq ( uint8_t *  devEui,
uint8_t *  appEui,
uint8_t *  appKey 
)

Initiates the Over-the-Air activation

Parameters:
[IN]devEui Pointer to the device EUI array ( 8 bytes )
[IN]appEui Pointer to the application EUI array ( 8 bytes )
[IN]appKey Pointer to the application AES128 key array ( 16 bytes )
Return values:
status[0: OK, 1: Tx error, 2: Already joined a network]

Definition at line 200 of file LoRaMac-api-v3.cpp.

uint8_t LoRaMacLinkCheckReq ( void   )

Sends a LinkCheckReq MAC command on the next uplink frame

Return values:
statusFunction status [0: OK, 1: Busy]

Definition at line 253 of file LoRaMac-api-v3.cpp.

uint8_t LoRaMacPrepareFrame ( ChannelParams_t  channel,
LoRaMacHeader_t macHdr,
LoRaMacFrameCtrl_t fCtrl,
uint8_t *  fOpts,
uint8_t  fPort,
void *  fBuffer,
uint16_t  fBufferSize 
)

LoRaMAC layer frame buffer initialization.

Parameters:
[IN]channel Channel parameters
[IN]macHdr MAC header field
[IN]fCtrl MAC frame control field
[IN]fOpts MAC commands buffer
[IN]fPort MAC payload port
[IN]fBuffer MAC data buffer to be sent
[IN]fBufferSize MAC data buffer size
Return values:
status[0: OK, 1: N/A, 2: No network joined, 3: Length or port error, 4: Unknown MAC command]

Definition at line 410 of file LoRaMac-api-v3.cpp.

uint8_t LoRaMacSend ( LoRaMacHeader_t macHdr,
uint8_t *  fOpts,
uint8_t  fPort,
void *  fBuffer,
uint16_t  fBufferSize 
)

============================================================================ = LoRaMac test functions = ============================================================================

LoRaMAC layer generic send frame

Parameters:
[IN]macHdr MAC header field
[IN]fOpts MAC commands buffer
[IN]fPort MAC payload port
[IN]fBuffer MAC data buffer to be sent
[IN]fBufferSize MAC data buffer size
Return values:
status[0: OK, 1: Busy, 2: No network joined, 3: Length or port error, 4: Unknown MAC command 5: Unable to find a free channel 6: Device switched off]

Definition at line 375 of file LoRaMac-api-v3.cpp.

uint8_t LoRaMacSendConfirmedFrame ( uint8_t  fPort,
void *  fBuffer,
uint16_t  fBufferSize,
uint8_t  nbRetries 
)

LoRaMAC layer send frame

Parameters:
[IN]fPort MAC payload port (must be > 0)
[IN]fBuffer MAC data buffer to be sent
[IN]fBufferSize MAC data buffer size
[IN]fBufferSize MAC data buffer size
[IN]nbRetries Number of retries to receive the acknowledgement
Return values:
status[0: OK, 1: Busy, 2: No network joined, 3: Length or port error, 4: Unknown MAC command 5: Unable to find a free channel 6: Device switched off]

Definition at line 328 of file LoRaMac-api-v3.cpp.

uint8_t LoRaMacSendFrame ( uint8_t  fPort,
void *  fBuffer,
uint16_t  fBufferSize 
)

LoRaMAC layer send frame

Parameters:
[IN]fPort MAC payload port (must be > 0)
[IN]fBuffer MAC data buffer to be sent
[IN]fBufferSize MAC data buffer size
Return values:
status[0: OK, 1: Busy, 2: No network joined, 3: Length or port error, 4: Unknown MAC command 5: Unable to find a free channel 6: Device switched off]

Definition at line 282 of file LoRaMac-api-v3.cpp.

uint8_t LoRaMacSendFrameOnChannel ( ChannelParams_t  channel )

LoRaMAC layer prepared frame buffer transmission with channel specification

Remarks:
LoRaMacPrepareFrame must be called at least once before calling this function.
Parameters:
[IN]channel Channel parameters
Return values:
status[0: OK, 1: Busy]

Definition at line 440 of file LoRaMac-api-v3.cpp.

uint8_t LoRaMacSendOnChannel ( ChannelParams_t  channel,
LoRaMacHeader_t macHdr,
LoRaMacFrameCtrl_t fCtrl,
uint8_t *  fOpts,
uint8_t  fPort,
void *  fBuffer,
uint16_t  fBufferSize 
)

LoRaMAC layer generic send frame with channel specification

Parameters:
[IN]channel Channel parameters
[IN]macHdr MAC header field
[IN]fCtrl MAC frame control field
[IN]fOpts MAC commands buffer
[IN]fPort MAC payload port
[IN]fBuffer MAC data buffer to be sent
[IN]fBufferSize MAC data buffer size
Return values:
status[0: OK, 1: Busy, 2: No network joined, 3: Length or port error, 4: Unknown MAC command]

Definition at line 450 of file LoRaMac-api-v3.cpp.

void LoRaMacSetAdrOn ( bool  enable )

Enables/Disables the ADR (Adaptive Data Rate)

Parameters:
[IN]enable [true: ADR ON, false: ADR OFF]

Definition at line 150 of file LoRaMac-api-v3.cpp.

void LoRaMacSetChannelsDatarate ( int8_t  datarate )

Sets channels datarate

Parameters:
[IN]datarate eu868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7] us915 - [DR_0, DR_1, DR_2, DR_3, DR_4]

Definition at line 581 of file LoRaMac-api-v3.cpp.

void LoRaMacSetChannelsTxPower ( int8_t  txPower )

Sets channels tx output power

Parameters:
[IN]txPower [TX_POWER_20_DBM, TX_POWER_14_DBM, TX_POWER_11_DBM, TX_POWER_08_DBM, TX_POWER_05_DBM, TX_POWER_02_DBM]

Definition at line 591 of file LoRaMac-api-v3.cpp.

void LoRaMacSetDeviceClass ( DeviceClass_t  deviceClass )

============================================================================ = LoRaMac setup functions = ============================================================================

Definition at line 471 of file LoRaMac-api-v3.cpp.

void LoRaMacTestRxWindowsOn ( bool  enable )

Disables/Enables the reception windows opening

Parameters:
[IN]enable [true: enable, false: disable]

Definition at line 3783 of file LoRaMac.cpp.

void LoRaMacTestSetDutyCycleOn ( bool  enable )

Disables/Enables the duty cycle enforcement (EU868)

Parameters:
[IN]enable - Enabled or disables the duty cycle

Definition at line 3794 of file LoRaMac.cpp.

void LoRaMacTestSetMic ( uint16_t  upLinkCounter )

Enables the MIC field test

Parameters:
[IN]upLinkCounter Fixed Tx packet counter value

Definition at line 3788 of file LoRaMac.cpp.