Update LoRaWAN MAC

Dependents:   LoRaWAN-SX1272-Application-crash LoRaWAN-SX1272-Application-24-31-9sec Canada-SX1272-LoRaWAN-EEPROM Training-Aug2018-SX1272-X-NUCLEO-IKS01A2_Natalia

Fork of LoRaWAN-lib by Semtech

Committer:
mluis
Date:
Tue Jul 05 13:24:54 2016 +0000
Revision:
7:c16969e0f70f
Parent:
4:37c12dbc8dc7
Synchronized with https://github.com/Lora-net/LoRaMac-node git revision 7a4aec588de628d864c364e9469ae45105fdbe26

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mluis 2:14a5d6ad92d5 1 /*!
mluis 2:14a5d6ad92d5 2 * \file LoRaMac-api-v3.h
mluis 2:14a5d6ad92d5 3 *
mluis 2:14a5d6ad92d5 4 * \brief LoRa MAC wrapper layer implementation
mluis 2:14a5d6ad92d5 5 *
mluis 2:14a5d6ad92d5 6 * \copyright Revised BSD License, see section \ref LICENSE.
mluis 2:14a5d6ad92d5 7 *
mluis 2:14a5d6ad92d5 8 * \code
mluis 2:14a5d6ad92d5 9 * ______ _
mluis 2:14a5d6ad92d5 10 * / _____) _ | |
mluis 2:14a5d6ad92d5 11 * ( (____ _____ ____ _| |_ _____ ____| |__
mluis 2:14a5d6ad92d5 12 * \____ \| ___ | (_ _) ___ |/ ___) _ \
mluis 2:14a5d6ad92d5 13 * _____) ) ____| | | || |_| ____( (___| | | |
mluis 2:14a5d6ad92d5 14 * (______/|_____)_|_|_| \__)_____)\____)_| |_|
mluis 2:14a5d6ad92d5 15 * (C)2013 Semtech
mluis 2:14a5d6ad92d5 16 *
mluis 2:14a5d6ad92d5 17 * ___ _____ _ ___ _ _____ ___ ___ ___ ___
mluis 2:14a5d6ad92d5 18 * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
mluis 2:14a5d6ad92d5 19 * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
mluis 2:14a5d6ad92d5 20 * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
mluis 2:14a5d6ad92d5 21 * embedded.connectivity.solutions===============
mluis 2:14a5d6ad92d5 22 *
mluis 2:14a5d6ad92d5 23 * \endcode
mluis 2:14a5d6ad92d5 24 *
mluis 2:14a5d6ad92d5 25 * \author Miguel Luis ( Semtech )
mluis 2:14a5d6ad92d5 26 *
mluis 2:14a5d6ad92d5 27 * \author Gregory Cristian ( Semtech )
mluis 2:14a5d6ad92d5 28 *
mluis 2:14a5d6ad92d5 29 * \author Daniel Jäckle ( STACKFORCE )
mluis 2:14a5d6ad92d5 30 */
mluis 2:14a5d6ad92d5 31 #ifndef __LORAMAC_API_V3_H__
mluis 2:14a5d6ad92d5 32 #define __LORAMAC_API_V3_H__
mluis 2:14a5d6ad92d5 33
mluis 2:14a5d6ad92d5 34 // Includes board dependent definitions such as channels frequencies
mluis 2:14a5d6ad92d5 35 #include "LoRaMac.h"
mluis 2:14a5d6ad92d5 36
mluis 2:14a5d6ad92d5 37 /*!
mluis 2:14a5d6ad92d5 38 * Beacon interval in us
mluis 2:14a5d6ad92d5 39 */
mluis 2:14a5d6ad92d5 40 #define BEACON_INTERVAL 128000000
mluis 2:14a5d6ad92d5 41
mluis 2:14a5d6ad92d5 42 /*!
mluis 4:37c12dbc8dc7 43 * Class A&B receive delay 1 in us
mluis 2:14a5d6ad92d5 44 */
mluis 2:14a5d6ad92d5 45 #define RECEIVE_DELAY1 1000000
mluis 4:37c12dbc8dc7 46
mluis 4:37c12dbc8dc7 47 /*!
mluis 4:37c12dbc8dc7 48 * Class A&B receive delay 2 in us
mluis 4:37c12dbc8dc7 49 */
mluis 2:14a5d6ad92d5 50 #define RECEIVE_DELAY2 2000000
mluis 2:14a5d6ad92d5 51
mluis 2:14a5d6ad92d5 52 /*!
mluis 4:37c12dbc8dc7 53 * Join accept receive delay 1 in us
mluis 2:14a5d6ad92d5 54 */
mluis 2:14a5d6ad92d5 55 #define JOIN_ACCEPT_DELAY1 5000000
mluis 4:37c12dbc8dc7 56
mluis 4:37c12dbc8dc7 57 /*!
mluis 4:37c12dbc8dc7 58 * Join accept receive delay 2 in us
mluis 4:37c12dbc8dc7 59 */
mluis 2:14a5d6ad92d5 60 #define JOIN_ACCEPT_DELAY2 6000000
mluis 2:14a5d6ad92d5 61
mluis 2:14a5d6ad92d5 62 /*!
mluis 2:14a5d6ad92d5 63 * Class A&B maximum receive window delay in us
mluis 2:14a5d6ad92d5 64 */
mluis 2:14a5d6ad92d5 65 #define MAX_RX_WINDOW 3000000
mluis 2:14a5d6ad92d5 66
mluis 2:14a5d6ad92d5 67 /*!
mluis 2:14a5d6ad92d5 68 * Maximum allowed gap for the FCNT field
mluis 2:14a5d6ad92d5 69 */
mluis 2:14a5d6ad92d5 70 #define MAX_FCNT_GAP 16384
mluis 2:14a5d6ad92d5 71
mluis 2:14a5d6ad92d5 72 /*!
mluis 2:14a5d6ad92d5 73 * ADR acknowledgement counter limit
mluis 2:14a5d6ad92d5 74 */
mluis 2:14a5d6ad92d5 75 #define ADR_ACK_LIMIT 64
mluis 2:14a5d6ad92d5 76
mluis 2:14a5d6ad92d5 77 /*!
mluis 2:14a5d6ad92d5 78 * Number of ADR acknowledgement requests before returning to default datarate
mluis 2:14a5d6ad92d5 79 */
mluis 2:14a5d6ad92d5 80 #define ADR_ACK_DELAY 32
mluis 2:14a5d6ad92d5 81
mluis 2:14a5d6ad92d5 82 /*!
mluis 2:14a5d6ad92d5 83 * Number of seconds after the start of the second reception window without
mluis 2:14a5d6ad92d5 84 * receiving an acknowledge.
mluis 4:37c12dbc8dc7 85 * AckTimeout = \ref ACK_TIMEOUT + Random( -\ref ACK_TIMEOUT_RND, \ref ACK_TIMEOUT_RND )
mluis 2:14a5d6ad92d5 86 */
mluis 2:14a5d6ad92d5 87 #define ACK_TIMEOUT 2000000
mluis 2:14a5d6ad92d5 88
mluis 2:14a5d6ad92d5 89 /*!
mluis 2:14a5d6ad92d5 90 * Random number of seconds after the start of the second reception window without
mluis 2:14a5d6ad92d5 91 * receiving an acknowledge
mluis 4:37c12dbc8dc7 92 * AckTimeout = \ref ACK_TIMEOUT + Random( -\ref ACK_TIMEOUT_RND, \ref ACK_TIMEOUT_RND )
mluis 2:14a5d6ad92d5 93 */
mluis 2:14a5d6ad92d5 94 #define ACK_TIMEOUT_RND 1000000
mluis 2:14a5d6ad92d5 95
mluis 2:14a5d6ad92d5 96 /*!
mluis 4:37c12dbc8dc7 97 * Check the Mac layer state every MAC_STATE_CHECK_TIMEOUT in us
mluis 2:14a5d6ad92d5 98 */
mluis 2:14a5d6ad92d5 99 #define MAC_STATE_CHECK_TIMEOUT 1000000
mluis 2:14a5d6ad92d5 100
mluis 2:14a5d6ad92d5 101 /*!
mluis 2:14a5d6ad92d5 102 * Maximum number of times the MAC layer tries to get an acknowledge.
mluis 2:14a5d6ad92d5 103 */
mluis 2:14a5d6ad92d5 104 #define MAX_ACK_RETRIES 8
mluis 2:14a5d6ad92d5 105
mluis 2:14a5d6ad92d5 106 /*!
mluis 4:37c12dbc8dc7 107 * RSSI free threshold [dBm]
mluis 2:14a5d6ad92d5 108 */
mluis 4:37c12dbc8dc7 109 #define RSSI_FREE_TH ( int8_t )( -90 )
mluis 2:14a5d6ad92d5 110
mluis 2:14a5d6ad92d5 111 /*!
mluis 4:37c12dbc8dc7 112 * Frame direction definition for up-link communications
mluis 2:14a5d6ad92d5 113 */
mluis 2:14a5d6ad92d5 114 #define UP_LINK 0
mluis 4:37c12dbc8dc7 115
mluis 4:37c12dbc8dc7 116 /*!
mluis 4:37c12dbc8dc7 117 * Frame direction definition for down-link communications
mluis 4:37c12dbc8dc7 118 */
mluis 2:14a5d6ad92d5 119 #define DOWN_LINK 1
mluis 2:14a5d6ad92d5 120
mluis 2:14a5d6ad92d5 121 /*!
mluis 2:14a5d6ad92d5 122 * Sets the length of the LoRaMAC footer field.
mluis 2:14a5d6ad92d5 123 * Mainly indicates the MIC field length
mluis 2:14a5d6ad92d5 124 */
mluis 2:14a5d6ad92d5 125 #define LORAMAC_MFR_LEN 4
mluis 2:14a5d6ad92d5 126
mluis 2:14a5d6ad92d5 127 /*!
mluis 2:14a5d6ad92d5 128 * Syncword for Private LoRa networks
mluis 2:14a5d6ad92d5 129 */
mluis 2:14a5d6ad92d5 130 #define LORA_MAC_PRIVATE_SYNCWORD 0x12
mluis 2:14a5d6ad92d5 131
mluis 2:14a5d6ad92d5 132 /*!
mluis 2:14a5d6ad92d5 133 * Syncword for Public LoRa networks
mluis 2:14a5d6ad92d5 134 */
mluis 2:14a5d6ad92d5 135 #define LORA_MAC_PUBLIC_SYNCWORD 0x34
mluis 2:14a5d6ad92d5 136
mluis 2:14a5d6ad92d5 137 /*!
mluis 2:14a5d6ad92d5 138 * LoRaMAC event flags
mluis 2:14a5d6ad92d5 139 */
mluis 2:14a5d6ad92d5 140 typedef union
mluis 2:14a5d6ad92d5 141 {
mluis 2:14a5d6ad92d5 142 uint8_t Value;
mluis 2:14a5d6ad92d5 143 struct
mluis 2:14a5d6ad92d5 144 {
mluis 2:14a5d6ad92d5 145 uint8_t Tx : 1;
mluis 2:14a5d6ad92d5 146 uint8_t Rx : 1;
mluis 2:14a5d6ad92d5 147 uint8_t RxData : 1;
mluis 2:14a5d6ad92d5 148 uint8_t Multicast : 1;
mluis 2:14a5d6ad92d5 149 uint8_t RxSlot : 2;
mluis 2:14a5d6ad92d5 150 uint8_t LinkCheck : 1;
mluis 2:14a5d6ad92d5 151 uint8_t JoinAccept : 1;
mluis 2:14a5d6ad92d5 152 }Bits;
mluis 2:14a5d6ad92d5 153 }LoRaMacEventFlags_t;
mluis 2:14a5d6ad92d5 154
mluis 2:14a5d6ad92d5 155 /*!
mluis 2:14a5d6ad92d5 156 * LoRaMAC event information
mluis 2:14a5d6ad92d5 157 */
mluis 2:14a5d6ad92d5 158 typedef struct
mluis 2:14a5d6ad92d5 159 {
mluis 2:14a5d6ad92d5 160 LoRaMacEventInfoStatus_t Status;
mluis 2:14a5d6ad92d5 161 bool TxAckReceived;
mluis 2:14a5d6ad92d5 162 uint8_t TxNbRetries;
mluis 2:14a5d6ad92d5 163 uint8_t TxDatarate;
mluis 2:14a5d6ad92d5 164 uint8_t RxPort;
mluis 2:14a5d6ad92d5 165 uint8_t *RxBuffer;
mluis 2:14a5d6ad92d5 166 uint8_t RxBufferSize;
mluis 2:14a5d6ad92d5 167 int16_t RxRssi;
mluis 2:14a5d6ad92d5 168 uint8_t RxSnr;
mluis 2:14a5d6ad92d5 169 uint16_t Energy;
mluis 2:14a5d6ad92d5 170 uint8_t DemodMargin;
mluis 2:14a5d6ad92d5 171 uint8_t NbGateways;
mluis 2:14a5d6ad92d5 172 }LoRaMacEventInfo_t;
mluis 2:14a5d6ad92d5 173
mluis 2:14a5d6ad92d5 174 /*!
mluis 2:14a5d6ad92d5 175 * LoRaMAC events structure
mluis 2:14a5d6ad92d5 176 * Used to notify upper layers of MAC events
mluis 2:14a5d6ad92d5 177 */
mluis 2:14a5d6ad92d5 178 typedef struct sLoRaMacCallbacks
mluis 2:14a5d6ad92d5 179 {
mluis 2:14a5d6ad92d5 180 /*!
mluis 2:14a5d6ad92d5 181 * MAC layer event callback prototype.
mluis 2:14a5d6ad92d5 182 *
mluis 2:14a5d6ad92d5 183 * \param [IN] flags Bit field indicating the MAC events occurred
mluis 2:14a5d6ad92d5 184 * \param [IN] info Details about MAC events occurred
mluis 2:14a5d6ad92d5 185 */
mluis 2:14a5d6ad92d5 186 void ( *MacEvent )( LoRaMacEventFlags_t *flags, LoRaMacEventInfo_t *info );
mluis 2:14a5d6ad92d5 187 /*!
mluis 2:14a5d6ad92d5 188 * Function callback to get the current battery level
mluis 2:14a5d6ad92d5 189 *
mluis 2:14a5d6ad92d5 190 * \retval batteryLevel Current battery level
mluis 2:14a5d6ad92d5 191 */
mluis 2:14a5d6ad92d5 192 uint8_t ( *GetBatteryLevel )( void );
mluis 2:14a5d6ad92d5 193 }LoRaMacCallbacks_t;
mluis 2:14a5d6ad92d5 194
mluis 2:14a5d6ad92d5 195 /*!
mluis 2:14a5d6ad92d5 196 * LoRaMAC layer initialization
mluis 2:14a5d6ad92d5 197 *
mluis 2:14a5d6ad92d5 198 * \param [IN] callbacks Pointer to a structure defining the LoRaMAC
mluis 2:14a5d6ad92d5 199 * callback functions.
mluis 2:14a5d6ad92d5 200 */
mluis 2:14a5d6ad92d5 201 void LoRaMacInit( LoRaMacCallbacks_t *callbacks );
mluis 2:14a5d6ad92d5 202
mluis 2:14a5d6ad92d5 203 /*!
mluis 2:14a5d6ad92d5 204 * Enables/Disables the ADR (Adaptive Data Rate)
mluis 2:14a5d6ad92d5 205 *
mluis 2:14a5d6ad92d5 206 * \param [IN] enable [true: ADR ON, false: ADR OFF]
mluis 2:14a5d6ad92d5 207 */
mluis 2:14a5d6ad92d5 208 void LoRaMacSetAdrOn( bool enable );
mluis 2:14a5d6ad92d5 209
mluis 2:14a5d6ad92d5 210 /*!
mluis 2:14a5d6ad92d5 211 * Initializes the network IDs. Device address,
mluis 2:14a5d6ad92d5 212 * network session AES128 key and application session AES128 key.
mluis 2:14a5d6ad92d5 213 *
mluis 2:14a5d6ad92d5 214 * \remark To be only used when Over-the-Air activation isn't used.
mluis 2:14a5d6ad92d5 215 *
mluis 2:14a5d6ad92d5 216 * \param [IN] netID 24 bits network identifier
mluis 2:14a5d6ad92d5 217 * ( provided by network operator )
mluis 2:14a5d6ad92d5 218 * \param [IN] devAddr 32 bits device address on the network
mluis 2:14a5d6ad92d5 219 * (must be unique to the network)
mluis 2:14a5d6ad92d5 220 * \param [IN] nwkSKey Pointer to the network session AES128 key array
mluis 2:14a5d6ad92d5 221 * ( 16 bytes )
mluis 2:14a5d6ad92d5 222 * \param [IN] appSKey Pointer to the application session AES128 key array
mluis 2:14a5d6ad92d5 223 * ( 16 bytes )
mluis 2:14a5d6ad92d5 224 */
mluis 2:14a5d6ad92d5 225 void LoRaMacInitNwkIds( uint32_t netID, uint32_t devAddr, uint8_t *nwkSKey, uint8_t *appSKey );
mluis 2:14a5d6ad92d5 226
mluis 2:14a5d6ad92d5 227 /*
mluis 2:14a5d6ad92d5 228 * Wrapper function which calls \ref LoRaMacMulticastChannelLink.
mluis 2:14a5d6ad92d5 229 */
mluis 2:14a5d6ad92d5 230 void LoRaMacMulticastChannelAdd( MulticastParams_t *channelParam );
mluis 2:14a5d6ad92d5 231
mluis 2:14a5d6ad92d5 232 /*
mluis 2:14a5d6ad92d5 233 * Wrapper function which calls \ref LoRaMacMulticastChannelUnlink.
mluis 2:14a5d6ad92d5 234 */
mluis 2:14a5d6ad92d5 235 void LoRaMacMulticastChannelRemove( MulticastParams_t *channelParam );
mluis 2:14a5d6ad92d5 236
mluis 2:14a5d6ad92d5 237 /*!
mluis 2:14a5d6ad92d5 238 * Initiates the Over-the-Air activation
mluis 2:14a5d6ad92d5 239 *
mluis 2:14a5d6ad92d5 240 * \param [IN] devEui Pointer to the device EUI array ( 8 bytes )
mluis 2:14a5d6ad92d5 241 * \param [IN] appEui Pointer to the application EUI array ( 8 bytes )
mluis 2:14a5d6ad92d5 242 * \param [IN] appKey Pointer to the application AES128 key array ( 16 bytes )
mluis 2:14a5d6ad92d5 243 *
mluis 2:14a5d6ad92d5 244 * \retval status [0: OK, 1: Tx error, 2: Already joined a network]
mluis 2:14a5d6ad92d5 245 */
mluis 2:14a5d6ad92d5 246 uint8_t LoRaMacJoinReq( uint8_t *devEui, uint8_t *appEui, uint8_t *appKey );
mluis 2:14a5d6ad92d5 247
mluis 2:14a5d6ad92d5 248 /*!
mluis 2:14a5d6ad92d5 249 * Sends a LinkCheckReq MAC command on the next uplink frame
mluis 2:14a5d6ad92d5 250 *
mluis 2:14a5d6ad92d5 251 * \retval status Function status [0: OK, 1: Busy]
mluis 2:14a5d6ad92d5 252 */
mluis 2:14a5d6ad92d5 253 uint8_t LoRaMacLinkCheckReq( void );
mluis 2:14a5d6ad92d5 254
mluis 2:14a5d6ad92d5 255 /*!
mluis 2:14a5d6ad92d5 256 * LoRaMAC layer send frame
mluis 2:14a5d6ad92d5 257 *
mluis 2:14a5d6ad92d5 258 * \param [IN] fPort MAC payload port (must be > 0)
mluis 2:14a5d6ad92d5 259 * \param [IN] fBuffer MAC data buffer to be sent
mluis 2:14a5d6ad92d5 260 * \param [IN] fBufferSize MAC data buffer size
mluis 2:14a5d6ad92d5 261 *
mluis 2:14a5d6ad92d5 262 * \retval status [0: OK, 1: Busy, 2: No network joined,
mluis 2:14a5d6ad92d5 263 * 3: Length or port error, 4: Unknown MAC command
mluis 2:14a5d6ad92d5 264 * 5: Unable to find a free channel
mluis 2:14a5d6ad92d5 265 * 6: Device switched off]
mluis 2:14a5d6ad92d5 266 */
mluis 2:14a5d6ad92d5 267 uint8_t LoRaMacSendFrame( uint8_t fPort, void *fBuffer, uint16_t fBufferSize );
mluis 2:14a5d6ad92d5 268
mluis 2:14a5d6ad92d5 269 /*!
mluis 2:14a5d6ad92d5 270 * LoRaMAC layer send frame
mluis 2:14a5d6ad92d5 271 *
mluis 2:14a5d6ad92d5 272 * \param [IN] fPort MAC payload port (must be > 0)
mluis 2:14a5d6ad92d5 273 * \param [IN] fBuffer MAC data buffer to be sent
mluis 2:14a5d6ad92d5 274 * \param [IN] fBufferSize MAC data buffer size
mluis 2:14a5d6ad92d5 275 * \param [IN] fBufferSize MAC data buffer size
mluis 2:14a5d6ad92d5 276 * \param [IN] nbRetries Number of retries to receive the acknowledgement
mluis 2:14a5d6ad92d5 277 *
mluis 2:14a5d6ad92d5 278 * \retval status [0: OK, 1: Busy, 2: No network joined,
mluis 2:14a5d6ad92d5 279 * 3: Length or port error, 4: Unknown MAC command
mluis 2:14a5d6ad92d5 280 * 5: Unable to find a free channel
mluis 2:14a5d6ad92d5 281 * 6: Device switched off]
mluis 2:14a5d6ad92d5 282 */
mluis 2:14a5d6ad92d5 283 uint8_t LoRaMacSendConfirmedFrame( uint8_t fPort, void *fBuffer, uint16_t fBufferSize, uint8_t nbRetries );
mluis 2:14a5d6ad92d5 284
mluis 2:14a5d6ad92d5 285 /*!
mluis 2:14a5d6ad92d5 286 * ============================================================================
mluis 2:14a5d6ad92d5 287 * = LoRaMac test functions =
mluis 2:14a5d6ad92d5 288 * ============================================================================
mluis 2:14a5d6ad92d5 289 */
mluis 2:14a5d6ad92d5 290
mluis 2:14a5d6ad92d5 291 /*!
mluis 2:14a5d6ad92d5 292 * LoRaMAC layer generic send frame
mluis 2:14a5d6ad92d5 293 *
mluis 2:14a5d6ad92d5 294 * \param [IN] macHdr MAC header field
mluis 2:14a5d6ad92d5 295 * \param [IN] fOpts MAC commands buffer
mluis 2:14a5d6ad92d5 296 * \param [IN] fPort MAC payload port
mluis 2:14a5d6ad92d5 297 * \param [IN] fBuffer MAC data buffer to be sent
mluis 2:14a5d6ad92d5 298 * \param [IN] fBufferSize MAC data buffer size
mluis 2:14a5d6ad92d5 299 * \retval status [0: OK, 1: Busy, 2: No network joined,
mluis 2:14a5d6ad92d5 300 * 3: Length or port error, 4: Unknown MAC command
mluis 2:14a5d6ad92d5 301 * 5: Unable to find a free channel
mluis 2:14a5d6ad92d5 302 * 6: Device switched off]
mluis 2:14a5d6ad92d5 303 */
mluis 2:14a5d6ad92d5 304 uint8_t LoRaMacSend( LoRaMacHeader_t *macHdr, uint8_t *fOpts, uint8_t fPort, void *fBuffer, uint16_t fBufferSize );
mluis 2:14a5d6ad92d5 305
mluis 2:14a5d6ad92d5 306 /*!
mluis 2:14a5d6ad92d5 307 * LoRaMAC layer frame buffer initialization.
mluis 2:14a5d6ad92d5 308 *
mluis 2:14a5d6ad92d5 309 * \param [IN] channel Channel parameters
mluis 2:14a5d6ad92d5 310 * \param [IN] macHdr MAC header field
mluis 2:14a5d6ad92d5 311 * \param [IN] fCtrl MAC frame control field
mluis 2:14a5d6ad92d5 312 * \param [IN] fOpts MAC commands buffer
mluis 2:14a5d6ad92d5 313 * \param [IN] fPort MAC payload port
mluis 2:14a5d6ad92d5 314 * \param [IN] fBuffer MAC data buffer to be sent
mluis 2:14a5d6ad92d5 315 * \param [IN] fBufferSize MAC data buffer size
mluis 2:14a5d6ad92d5 316 * \retval status [0: OK, 1: N/A, 2: No network joined,
mluis 2:14a5d6ad92d5 317 * 3: Length or port error, 4: Unknown MAC command]
mluis 2:14a5d6ad92d5 318 */
mluis 2:14a5d6ad92d5 319 uint8_t LoRaMacPrepareFrame( ChannelParams_t channel,LoRaMacHeader_t *macHdr, LoRaMacFrameCtrl_t *fCtrl, uint8_t *fOpts, uint8_t fPort, void *fBuffer, uint16_t fBufferSize );
mluis 2:14a5d6ad92d5 320
mluis 2:14a5d6ad92d5 321 /*!
mluis 2:14a5d6ad92d5 322 * LoRaMAC layer prepared frame buffer transmission with channel specification
mluis 2:14a5d6ad92d5 323 *
mluis 2:14a5d6ad92d5 324 * \remark LoRaMacPrepareFrame must be called at least once before calling this
mluis 2:14a5d6ad92d5 325 * function.
mluis 2:14a5d6ad92d5 326 *
mluis 2:14a5d6ad92d5 327 * \param [IN] channel Channel parameters
mluis 2:14a5d6ad92d5 328 * \retval status [0: OK, 1: Busy]
mluis 2:14a5d6ad92d5 329 */
mluis 2:14a5d6ad92d5 330 uint8_t LoRaMacSendFrameOnChannel( ChannelParams_t channel );
mluis 2:14a5d6ad92d5 331
mluis 2:14a5d6ad92d5 332 /*!
mluis 2:14a5d6ad92d5 333 * LoRaMAC layer generic send frame with channel specification
mluis 2:14a5d6ad92d5 334 *
mluis 2:14a5d6ad92d5 335 * \param [IN] channel Channel parameters
mluis 2:14a5d6ad92d5 336 * \param [IN] macHdr MAC header field
mluis 2:14a5d6ad92d5 337 * \param [IN] fCtrl MAC frame control field
mluis 2:14a5d6ad92d5 338 * \param [IN] fOpts MAC commands buffer
mluis 2:14a5d6ad92d5 339 * \param [IN] fPort MAC payload port
mluis 2:14a5d6ad92d5 340 * \param [IN] fBuffer MAC data buffer to be sent
mluis 2:14a5d6ad92d5 341 * \param [IN] fBufferSize MAC data buffer size
mluis 2:14a5d6ad92d5 342 * \retval status [0: OK, 1: Busy, 2: No network joined,
mluis 2:14a5d6ad92d5 343 * 3: Length or port error, 4: Unknown MAC command]
mluis 2:14a5d6ad92d5 344 */
mluis 2:14a5d6ad92d5 345 uint8_t LoRaMacSendOnChannel( ChannelParams_t channel, LoRaMacHeader_t *macHdr, LoRaMacFrameCtrl_t *fCtrl, uint8_t *fOpts, uint8_t fPort, void *fBuffer, uint16_t fBufferSize );
mluis 2:14a5d6ad92d5 346
mluis 2:14a5d6ad92d5 347 /*!
mluis 2:14a5d6ad92d5 348 * ============================================================================
mluis 2:14a5d6ad92d5 349 * = LoRaMac setup functions =
mluis 2:14a5d6ad92d5 350 * ============================================================================
mluis 2:14a5d6ad92d5 351 */
mluis 2:14a5d6ad92d5 352
mluis 2:14a5d6ad92d5 353 /*
mluis 2:14a5d6ad92d5 354 * Wrapper function which calls \ref LoRaMacMibSetRequestConfirm to
mluis 2:14a5d6ad92d5 355 * set the LoRaWan device class.
mluis 2:14a5d6ad92d5 356 */
mluis 2:14a5d6ad92d5 357 void LoRaMacSetDeviceClass( DeviceClass_t deviceClass );
mluis 2:14a5d6ad92d5 358
mluis 2:14a5d6ad92d5 359 /*
mluis 2:14a5d6ad92d5 360 * Wrapper function which calls \ref LoRaMacMibSetRequestConfirm to
mluis 2:14a5d6ad92d5 361 * set the network type to public or private.
mluis 2:14a5d6ad92d5 362 */
mluis 2:14a5d6ad92d5 363 void LoRaMacSetPublicNetwork( bool enable );
mluis 2:14a5d6ad92d5 364
mluis 2:14a5d6ad92d5 365 /*
mluis 2:14a5d6ad92d5 366 * Wrapper function which calls \ref LoRaMacChannelAdd.
mluis 2:14a5d6ad92d5 367 */
mluis 2:14a5d6ad92d5 368 void LoRaMacSetChannel( uint8_t id, ChannelParams_t params );
mluis 2:14a5d6ad92d5 369
mluis 2:14a5d6ad92d5 370 /*
mluis 2:14a5d6ad92d5 371 * Wrapper function which calls \ref LoRaMacMibSetRequestConfirm to
mluis 2:14a5d6ad92d5 372 * set the receive window 2 channel.
mluis 2:14a5d6ad92d5 373 */
mluis 2:14a5d6ad92d5 374 void LoRaMacSetRx2Channel( Rx2ChannelParams_t param );
mluis 2:14a5d6ad92d5 375
mluis 2:14a5d6ad92d5 376 /*!
mluis 2:14a5d6ad92d5 377 * Sets channels tx output power
mluis 2:14a5d6ad92d5 378 *
mluis 2:14a5d6ad92d5 379 * \param [IN] txPower [TX_POWER_20_DBM, TX_POWER_14_DBM,
mluis 2:14a5d6ad92d5 380 TX_POWER_11_DBM, TX_POWER_08_DBM,
mluis 2:14a5d6ad92d5 381 TX_POWER_05_DBM, TX_POWER_02_DBM]
mluis 2:14a5d6ad92d5 382 */
mluis 2:14a5d6ad92d5 383 void LoRaMacSetChannelsTxPower( int8_t txPower );
mluis 2:14a5d6ad92d5 384
mluis 2:14a5d6ad92d5 385 /*!
mluis 2:14a5d6ad92d5 386 * Sets channels datarate
mluis 2:14a5d6ad92d5 387 *
mluis 2:14a5d6ad92d5 388 * \param [IN] datarate eu868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7]
mluis 2:14a5d6ad92d5 389 * us915 - [DR_0, DR_1, DR_2, DR_3, DR_4]
mluis 2:14a5d6ad92d5 390 */
mluis 2:14a5d6ad92d5 391 void LoRaMacSetChannelsDatarate( int8_t datarate );
mluis 2:14a5d6ad92d5 392
mluis 2:14a5d6ad92d5 393 /*
mluis 2:14a5d6ad92d5 394 * Wrapper function which calls \ref LoRaMacMibSetRequestConfirm to
mluis 2:14a5d6ad92d5 395 * set the channels mask.
mluis 2:14a5d6ad92d5 396 */
mluis 2:14a5d6ad92d5 397 void LoRaMacSetChannelsMask( uint16_t *mask );
mluis 2:14a5d6ad92d5 398
mluis 2:14a5d6ad92d5 399 /*
mluis 2:14a5d6ad92d5 400 * Wrapper function which calls \ref LoRaMacMibSetRequestConfirm to
mluis 2:14a5d6ad92d5 401 * set the number of repetitions on a channel.
mluis 2:14a5d6ad92d5 402 */
mluis 2:14a5d6ad92d5 403 void LoRaMacSetChannelsNbRep( uint8_t nbRep );
mluis 2:14a5d6ad92d5 404
mluis 2:14a5d6ad92d5 405 /*
mluis 2:14a5d6ad92d5 406 * Wrapper function which calls \ref LoRaMacMibSetRequestConfirm to
mluis 2:14a5d6ad92d5 407 * set the maximum receive window duration in [us].
mluis 2:14a5d6ad92d5 408 */
mluis 2:14a5d6ad92d5 409 void LoRaMacSetMaxRxWindow( uint32_t delay );
mluis 2:14a5d6ad92d5 410
mluis 2:14a5d6ad92d5 411 /*
mluis 2:14a5d6ad92d5 412 * Wrapper function which calls \ref LoRaMacMibSetRequestConfirm to
mluis 2:14a5d6ad92d5 413 * set the receive delay 1 in [us].
mluis 2:14a5d6ad92d5 414 */
mluis 2:14a5d6ad92d5 415 void LoRaMacSetReceiveDelay1( uint32_t delay );
mluis 2:14a5d6ad92d5 416
mluis 2:14a5d6ad92d5 417 /*
mluis 2:14a5d6ad92d5 418 * Wrapper function which calls \ref LoRaMacMibSetRequestConfirm to
mluis 2:14a5d6ad92d5 419 * set the receive delay 2 in [us].
mluis 2:14a5d6ad92d5 420 */
mluis 2:14a5d6ad92d5 421 void LoRaMacSetReceiveDelay2( uint32_t delay );
mluis 2:14a5d6ad92d5 422
mluis 2:14a5d6ad92d5 423 /*
mluis 2:14a5d6ad92d5 424 * Wrapper function which calls \ref LoRaMacMibSetRequestConfirm to
mluis 2:14a5d6ad92d5 425 * set the join accept delay 1 in [us].
mluis 2:14a5d6ad92d5 426 */
mluis 2:14a5d6ad92d5 427 void LoRaMacSetJoinAcceptDelay1( uint32_t delay );
mluis 2:14a5d6ad92d5 428
mluis 2:14a5d6ad92d5 429 /*
mluis 2:14a5d6ad92d5 430 * Wrapper function which calls \ref LoRaMacMibSetRequestConfirm to
mluis 2:14a5d6ad92d5 431 * set the join accept delay 2 in [us].
mluis 2:14a5d6ad92d5 432 */
mluis 2:14a5d6ad92d5 433 void LoRaMacSetJoinAcceptDelay2( uint32_t delay );
mluis 2:14a5d6ad92d5 434
mluis 2:14a5d6ad92d5 435 /*
mluis 2:14a5d6ad92d5 436 * Wrapper function which calls \ref LoRaMacMibGetRequestConfirm to
mluis 2:14a5d6ad92d5 437 * get the up-link counter.
mluis 2:14a5d6ad92d5 438 */
mluis 2:14a5d6ad92d5 439 uint32_t LoRaMacGetUpLinkCounter( void );
mluis 2:14a5d6ad92d5 440
mluis 2:14a5d6ad92d5 441 /*
mluis 2:14a5d6ad92d5 442 * Wrapper function which calls \ref LoRaMacMibGetRequestConfirm to
mluis 2:14a5d6ad92d5 443 * get the down-link counter.
mluis 2:14a5d6ad92d5 444 */
mluis 2:14a5d6ad92d5 445 uint32_t LoRaMacGetDownLinkCounter( void );
mluis 2:14a5d6ad92d5 446
mluis 2:14a5d6ad92d5 447 /*
mluis 2:14a5d6ad92d5 448 * ============================================================================
mluis 2:14a5d6ad92d5 449 * = LoRaMac test functions =
mluis 2:14a5d6ad92d5 450 * ============================================================================
mluis 2:14a5d6ad92d5 451 */
mluis 2:14a5d6ad92d5 452
mluis 2:14a5d6ad92d5 453 /*!
mluis 2:14a5d6ad92d5 454 * Disables/Enables the duty cycle enforcement (EU868)
mluis 2:14a5d6ad92d5 455 *
mluis 2:14a5d6ad92d5 456 * \param [IN] enable - Enabled or disables the duty cycle
mluis 2:14a5d6ad92d5 457 */
mluis 2:14a5d6ad92d5 458 void LoRaMacTestSetDutyCycleOn( bool enable );
mluis 2:14a5d6ad92d5 459
mluis 2:14a5d6ad92d5 460 /*!
mluis 2:14a5d6ad92d5 461 * Disables/Enables the reception windows opening
mluis 2:14a5d6ad92d5 462 *
mluis 2:14a5d6ad92d5 463 * \param [IN] enable [true: enable, false: disable]
mluis 2:14a5d6ad92d5 464 */
mluis 2:14a5d6ad92d5 465 void LoRaMacTestRxWindowsOn( bool enable );
mluis 2:14a5d6ad92d5 466
mluis 2:14a5d6ad92d5 467 /*!
mluis 2:14a5d6ad92d5 468 * Enables the MIC field test
mluis 2:14a5d6ad92d5 469 *
mluis 2:14a5d6ad92d5 470 * \param [IN] upLinkCounter Fixed Tx packet counter value
mluis 2:14a5d6ad92d5 471 */
mluis 2:14a5d6ad92d5 472 void LoRaMacTestSetMic( uint16_t upLinkCounter );
mluis 2:14a5d6ad92d5 473
mluis 2:14a5d6ad92d5 474 #endif /* __LORAMAC_API_V3_H__ */