Fork of Semtech LoRaWAN stack

Fork of LoRaWAN-lib by canuck lehead

Committer:
Shaun Nelson
Date:
Tue Aug 08 11:21:18 2017 -0400
Branch:
SenetNetTool
Revision:
36:fc9baa35ae1a
Parent:
9:ad93de20d720
Add stack version info 4.2.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
snelson 8:4816c8449bf2 1 /*!
snelson 8:4816c8449bf2 2 * \file LoRaMac.h
snelson 8:4816c8449bf2 3 *
snelson 8:4816c8449bf2 4 * \brief LoRa MAC layer implementation
snelson 8:4816c8449bf2 5 *
snelson 8:4816c8449bf2 6 * \copyright Revised BSD License, see section \ref LICENSE.
snelson 8:4816c8449bf2 7 *
snelson 8:4816c8449bf2 8 * \code
snelson 8:4816c8449bf2 9 * ______ _
snelson 8:4816c8449bf2 10 * / _____) _ | |
snelson 8:4816c8449bf2 11 * ( (____ _____ ____ _| |_ _____ ____| |__
snelson 8:4816c8449bf2 12 * \____ \| ___ | (_ _) ___ |/ ___) _ \
snelson 8:4816c8449bf2 13 * _____) ) ____| | | || |_| ____( (___| | | |
snelson 8:4816c8449bf2 14 * (______/|_____)_|_|_| \__)_____)\____)_| |_|
snelson 8:4816c8449bf2 15 * (C)2013 Semtech
snelson 8:4816c8449bf2 16 *
snelson 8:4816c8449bf2 17 * ___ _____ _ ___ _ _____ ___ ___ ___ ___
snelson 8:4816c8449bf2 18 * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
snelson 8:4816c8449bf2 19 * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
snelson 8:4816c8449bf2 20 * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
snelson 8:4816c8449bf2 21 * embedded.connectivity.solutions===============
snelson 8:4816c8449bf2 22 *
snelson 8:4816c8449bf2 23 * \endcode
snelson 8:4816c8449bf2 24 *
snelson 8:4816c8449bf2 25 * \author Miguel Luis ( Semtech )
snelson 8:4816c8449bf2 26 *
snelson 8:4816c8449bf2 27 * \author Gregory Cristian ( Semtech )
snelson 8:4816c8449bf2 28 *
snelson 8:4816c8449bf2 29 * \author Daniel Jäckle ( STACKFORCE )
snelson 8:4816c8449bf2 30 *
snelson 8:4816c8449bf2 31 * \defgroup LORAMAC LoRa MAC layer implementation
snelson 8:4816c8449bf2 32 * This module specifies the API implementation of the LoRaMAC layer.
snelson 8:4816c8449bf2 33 * This is a placeholder for a detailed description of the LoRaMac
snelson 8:4816c8449bf2 34 * layer and the supported features.
snelson 8:4816c8449bf2 35 * \{
snelson 8:4816c8449bf2 36 *
snelson 8:4816c8449bf2 37 * \example classA/LoRaMote/main.c
snelson 8:4816c8449bf2 38 * LoRaWAN class A application example for the LoRaMote.
snelson 8:4816c8449bf2 39 *
snelson 8:4816c8449bf2 40 * \example classB/LoRaMote/main.c
snelson 8:4816c8449bf2 41 * LoRaWAN class B application example for the LoRaMote.
snelson 8:4816c8449bf2 42 *
snelson 8:4816c8449bf2 43 * \example classC/LoRaMote/main.c
snelson 8:4816c8449bf2 44 * LoRaWAN class C application example for the LoRaMote.
snelson 8:4816c8449bf2 45 */
snelson 8:4816c8449bf2 46 #ifndef __LORAMAC_H__
snelson 8:4816c8449bf2 47 #define __LORAMAC_H__
snelson 8:4816c8449bf2 48
snelson 8:4816c8449bf2 49 // Includes board dependent definitions such as channels frequencies
Shaun Nelson 36:fc9baa35ae1a 50 #include "LoRaMac-board.h"
Shaun Nelson 36:fc9baa35ae1a 51
Shaun Nelson 36:fc9baa35ae1a 52 /*!
Shaun Nelson 36:fc9baa35ae1a 53 * Stack Version Information
Shaun Nelson 36:fc9baa35ae1a 54 */
Shaun Nelson 36:fc9baa35ae1a 55 #define LORAMAC_MAJOR_VERSION 4
Shaun Nelson 36:fc9baa35ae1a 56 #define LORAMAC_MINOR_VERSION 2
Shaun Nelson 36:fc9baa35ae1a 57 #define LORAMAC_POINT_VERSION 1
snelson 8:4816c8449bf2 58
snelson 8:4816c8449bf2 59 /*!
snelson 8:4816c8449bf2 60 * Beacon interval in us
snelson 8:4816c8449bf2 61 */
snelson 8:4816c8449bf2 62 #define BEACON_INTERVAL 128000000
snelson 8:4816c8449bf2 63
snelson 8:4816c8449bf2 64 /*!
snelson 8:4816c8449bf2 65 * Class A&B receive delay 1 in us
snelson 8:4816c8449bf2 66 */
snelson 8:4816c8449bf2 67 #define RECEIVE_DELAY1 1000000
snelson 8:4816c8449bf2 68
snelson 8:4816c8449bf2 69 /*!
snelson 8:4816c8449bf2 70 * Class A&B receive delay 2 in us
snelson 8:4816c8449bf2 71 */
snelson 8:4816c8449bf2 72 #define RECEIVE_DELAY2 2000000
snelson 8:4816c8449bf2 73
snelson 8:4816c8449bf2 74 /*!
snelson 8:4816c8449bf2 75 * Join accept receive delay 1 in us
snelson 8:4816c8449bf2 76 */
snelson 8:4816c8449bf2 77 #define JOIN_ACCEPT_DELAY1 5000000
snelson 8:4816c8449bf2 78
snelson 8:4816c8449bf2 79 /*!
snelson 8:4816c8449bf2 80 * Join accept receive delay 2 in us
snelson 8:4816c8449bf2 81 */
snelson 8:4816c8449bf2 82 #define JOIN_ACCEPT_DELAY2 6000000
snelson 8:4816c8449bf2 83
snelson 8:4816c8449bf2 84 /*!
snelson 8:4816c8449bf2 85 * Class A&B maximum receive window delay in us
snelson 8:4816c8449bf2 86 */
snelson 8:4816c8449bf2 87 #define MAX_RX_WINDOW 3000000
snelson 8:4816c8449bf2 88
snelson 8:4816c8449bf2 89 /*!
snelson 8:4816c8449bf2 90 * Maximum allowed gap for the FCNT field
snelson 8:4816c8449bf2 91 */
snelson 8:4816c8449bf2 92 #define MAX_FCNT_GAP 16384
snelson 8:4816c8449bf2 93
snelson 8:4816c8449bf2 94 /*!
snelson 8:4816c8449bf2 95 * ADR acknowledgement counter limit
snelson 8:4816c8449bf2 96 */
snelson 8:4816c8449bf2 97 #define ADR_ACK_LIMIT 64
snelson 8:4816c8449bf2 98
snelson 8:4816c8449bf2 99 /*!
snelson 8:4816c8449bf2 100 * Number of ADR acknowledgement requests before returning to default datarate
snelson 8:4816c8449bf2 101 */
snelson 8:4816c8449bf2 102 #define ADR_ACK_DELAY 32
snelson 8:4816c8449bf2 103
snelson 8:4816c8449bf2 104 /*!
snelson 8:4816c8449bf2 105 * Number of seconds after the start of the second reception window without
snelson 8:4816c8449bf2 106 * receiving an acknowledge.
snelson 8:4816c8449bf2 107 * AckTimeout = \ref ACK_TIMEOUT + Random( -\ref ACK_TIMEOUT_RND, \ref ACK_TIMEOUT_RND )
snelson 8:4816c8449bf2 108 */
snelson 8:4816c8449bf2 109 #define ACK_TIMEOUT 2000000
snelson 8:4816c8449bf2 110
snelson 8:4816c8449bf2 111 /*!
snelson 8:4816c8449bf2 112 * Random number of seconds after the start of the second reception window without
snelson 8:4816c8449bf2 113 * receiving an acknowledge
snelson 8:4816c8449bf2 114 * AckTimeout = \ref ACK_TIMEOUT + Random( -\ref ACK_TIMEOUT_RND, \ref ACK_TIMEOUT_RND )
snelson 8:4816c8449bf2 115 */
snelson 8:4816c8449bf2 116 #define ACK_TIMEOUT_RND 1000000
snelson 8:4816c8449bf2 117
snelson 8:4816c8449bf2 118 /*!
snelson 8:4816c8449bf2 119 * Check the Mac layer state every MAC_STATE_CHECK_TIMEOUT in us
snelson 8:4816c8449bf2 120 */
snelson 8:4816c8449bf2 121 #define MAC_STATE_CHECK_TIMEOUT 1000000
snelson 8:4816c8449bf2 122
snelson 8:4816c8449bf2 123 /*!
snelson 8:4816c8449bf2 124 * Maximum number of times the MAC layer tries to get an acknowledge.
snelson 8:4816c8449bf2 125 */
snelson 8:4816c8449bf2 126 #define MAX_ACK_RETRIES 8
snelson 8:4816c8449bf2 127
snelson 8:4816c8449bf2 128 /*!
snelson 8:4816c8449bf2 129 * RSSI free threshold [dBm]
snelson 8:4816c8449bf2 130 */
snelson 8:4816c8449bf2 131 #define RSSI_FREE_TH ( int8_t )( -90 )
snelson 8:4816c8449bf2 132
snelson 8:4816c8449bf2 133 /*!
snelson 8:4816c8449bf2 134 * Frame direction definition for up-link communications
snelson 8:4816c8449bf2 135 */
snelson 8:4816c8449bf2 136 #define UP_LINK 0
snelson 8:4816c8449bf2 137
snelson 8:4816c8449bf2 138 /*!
snelson 8:4816c8449bf2 139 * Frame direction definition for down-link communications
snelson 8:4816c8449bf2 140 */
snelson 8:4816c8449bf2 141 #define DOWN_LINK 1
snelson 8:4816c8449bf2 142
snelson 8:4816c8449bf2 143 /*!
snelson 8:4816c8449bf2 144 * Sets the length of the LoRaMAC footer field.
snelson 8:4816c8449bf2 145 * Mainly indicates the MIC field length
snelson 8:4816c8449bf2 146 */
snelson 8:4816c8449bf2 147 #define LORAMAC_MFR_LEN 4
snelson 8:4816c8449bf2 148
snelson 8:4816c8449bf2 149 /*!
snelson 8:4816c8449bf2 150 * Syncword for Private LoRa networks
snelson 8:4816c8449bf2 151 */
snelson 8:4816c8449bf2 152 #define LORA_MAC_PRIVATE_SYNCWORD 0x12
snelson 8:4816c8449bf2 153
snelson 8:4816c8449bf2 154 /*!
snelson 8:4816c8449bf2 155 * Syncword for Public LoRa networks
snelson 8:4816c8449bf2 156 */
snelson 8:4816c8449bf2 157 #define LORA_MAC_PUBLIC_SYNCWORD 0x34
snelson 8:4816c8449bf2 158
snelson 8:4816c8449bf2 159
snelson 8:4816c8449bf2 160 /*!
snelson 8:4816c8449bf2 161 * Sets the size of the Join Retransmission duty cycle
snelson 8:4816c8449bf2 162 * table
snelson 8:4816c8449bf2 163 */
snelson 8:4816c8449bf2 164 #define JOIN_NB_RETRANSMISSION_DCYCLES 3
snelson 8:4816c8449bf2 165
snelson 9:ad93de20d720 166 /*!
snelson 9:ad93de20d720 167 * Join Aggregated duty cycle during the first hour
snelson 9:ad93de20d720 168 */
snelson 9:ad93de20d720 169 #ifndef JOIN_RETRANSMISSION_DCYCLE1
snelson 9:ad93de20d720 170 #define JOIN_RETRANSMISSION_DCYCLE1 { 3600, 36000000 }
snelson 9:ad93de20d720 171 #endif
snelson 9:ad93de20d720 172
snelson 9:ad93de20d720 173 /*!
snelson 9:ad93de20d720 174 * Join Aggregated duty cycle during the next 10 hours
snelson 9:ad93de20d720 175 */
snelson 9:ad93de20d720 176 #ifndef JOIN_RETRANSMISSION_DCYCLE2
snelson 9:ad93de20d720 177 #define JOIN_RETRANSMISSION_DCYCLE2 { 10*3600, 36000000 }
snelson 9:ad93de20d720 178 #endif
snelson 9:ad93de20d720 179
snelson 9:ad93de20d720 180 /*!
snelson 9:ad93de20d720 181 * Join Aggregated after the first 11 hours
snelson 9:ad93de20d720 182 */
snelson 9:ad93de20d720 183 #ifndef JOIN_RETRANSMISSION_DCYCLE3
snelson 9:ad93de20d720 184 #define JOIN_RETRANSMISSION_DCYCLE3 { 24*3600, 8700000 }
snelson 9:ad93de20d720 185 #endif
snelson 9:ad93de20d720 186
snelson 8:4816c8449bf2 187 /*!
snelson 8:4816c8449bf2 188 * LoRaMac internal state
snelson 8:4816c8449bf2 189 */
snelson 8:4816c8449bf2 190 //uint32_t LoRaMacState;
snelson 8:4816c8449bf2 191
snelson 8:4816c8449bf2 192 /*!
snelson 8:4816c8449bf2 193 * LoRaWAN devices classes definition
snelson 8:4816c8449bf2 194 */
snelson 8:4816c8449bf2 195 typedef enum eDeviceClass
snelson 8:4816c8449bf2 196 {
snelson 8:4816c8449bf2 197 /*!
snelson 8:4816c8449bf2 198 * LoRaWAN device class A
snelson 8:4816c8449bf2 199 *
snelson 8:4816c8449bf2 200 * LoRaWAN Specification V1.0, chapter 3ff
snelson 8:4816c8449bf2 201 */
snelson 8:4816c8449bf2 202 CLASS_A,
snelson 8:4816c8449bf2 203 /*!
snelson 8:4816c8449bf2 204 * LoRaWAN device class B
snelson 8:4816c8449bf2 205 *
snelson 8:4816c8449bf2 206 * LoRaWAN Specification V1.0, chapter 8ff
snelson 8:4816c8449bf2 207 */
snelson 8:4816c8449bf2 208 CLASS_B,
snelson 8:4816c8449bf2 209 /*!
snelson 8:4816c8449bf2 210 * LoRaWAN device class C
snelson 8:4816c8449bf2 211 *
snelson 8:4816c8449bf2 212 * LoRaWAN Specification V1.0, chapter 17ff
snelson 8:4816c8449bf2 213 */
snelson 8:4816c8449bf2 214 CLASS_C,
snelson 8:4816c8449bf2 215 }DeviceClass_t;
snelson 8:4816c8449bf2 216
snelson 8:4816c8449bf2 217 /*!
snelson 8:4816c8449bf2 218 * LoRaMAC channels parameters definition
snelson 8:4816c8449bf2 219 */
snelson 8:4816c8449bf2 220 typedef union uDrRange
snelson 8:4816c8449bf2 221 {
snelson 8:4816c8449bf2 222 /*!
snelson 8:4816c8449bf2 223 * Byte-access to the bits
snelson 8:4816c8449bf2 224 */
snelson 8:4816c8449bf2 225 int8_t Value;
snelson 8:4816c8449bf2 226 /*!
snelson 8:4816c8449bf2 227 * Structure to store the minimum and the maximum datarate
snelson 8:4816c8449bf2 228 */
snelson 8:4816c8449bf2 229 struct sFields
snelson 8:4816c8449bf2 230 {
snelson 8:4816c8449bf2 231 /*!
snelson 8:4816c8449bf2 232 * Minimum data rate
snelson 8:4816c8449bf2 233 *
snelson 8:4816c8449bf2 234 * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7]
snelson 8:4816c8449bf2 235 *
snelson 8:4816c8449bf2 236 * US915 - [DR_0, DR_1, DR_2, DR_3, DR_4]
snelson 8:4816c8449bf2 237 */
snelson 8:4816c8449bf2 238 int8_t Min : 4;
snelson 8:4816c8449bf2 239 /*!
snelson 8:4816c8449bf2 240 * Maximum data rate
snelson 8:4816c8449bf2 241 *
snelson 8:4816c8449bf2 242 * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7]
snelson 8:4816c8449bf2 243 *
snelson 8:4816c8449bf2 244 * US915 - [DR_0, DR_1, DR_2, DR_3, DR_4]
snelson 8:4816c8449bf2 245 */
snelson 8:4816c8449bf2 246 int8_t Max : 4;
snelson 8:4816c8449bf2 247 }Fields;
snelson 8:4816c8449bf2 248 }DrRange_t;
snelson 8:4816c8449bf2 249
snelson 8:4816c8449bf2 250 /*!
snelson 8:4816c8449bf2 251 * LoRaMAC band parameters definition
snelson 8:4816c8449bf2 252 */
snelson 8:4816c8449bf2 253 typedef struct sBand
snelson 8:4816c8449bf2 254 {
snelson 8:4816c8449bf2 255 /*!
snelson 8:4816c8449bf2 256 * Duty cycle
snelson 8:4816c8449bf2 257 */
snelson 8:4816c8449bf2 258 uint16_t DCycle;
snelson 8:4816c8449bf2 259 /*!
snelson 8:4816c8449bf2 260 * Maximum Tx power
snelson 8:4816c8449bf2 261 */
snelson 8:4816c8449bf2 262 int8_t TxMaxPower;
snelson 8:4816c8449bf2 263 /*!
snelson 8:4816c8449bf2 264 * Time stamp of the last Tx frame
snelson 8:4816c8449bf2 265 */
snelson 8:4816c8449bf2 266 TimerTime_t LastTxDoneTime;
snelson 8:4816c8449bf2 267 /*!
snelson 8:4816c8449bf2 268 * Holds the time where the device is off
snelson 8:4816c8449bf2 269 */
snelson 8:4816c8449bf2 270 TimerTime_t TimeOff;
snelson 8:4816c8449bf2 271 }Band_t;
snelson 8:4816c8449bf2 272
snelson 8:4816c8449bf2 273 /*!
snelson 8:4816c8449bf2 274 * LoRaMAC channel definition
snelson 8:4816c8449bf2 275 */
snelson 8:4816c8449bf2 276 typedef struct sChannelParams
snelson 8:4816c8449bf2 277 {
snelson 8:4816c8449bf2 278 /*!
snelson 8:4816c8449bf2 279 * Frequency in Hz
snelson 8:4816c8449bf2 280 */
snelson 8:4816c8449bf2 281 uint32_t Frequency;
snelson 8:4816c8449bf2 282 /*!
snelson 8:4816c8449bf2 283 * Data rate definition
snelson 8:4816c8449bf2 284 */
snelson 8:4816c8449bf2 285 DrRange_t DrRange;
snelson 8:4816c8449bf2 286 /*!
snelson 8:4816c8449bf2 287 * Band index
snelson 8:4816c8449bf2 288 */
snelson 8:4816c8449bf2 289 uint8_t Band;
snelson 8:4816c8449bf2 290 }ChannelParams_t;
snelson 8:4816c8449bf2 291
snelson 8:4816c8449bf2 292 /*!
snelson 8:4816c8449bf2 293 * LoRaMAC receive window 2 channel parameters
snelson 8:4816c8449bf2 294 */
snelson 8:4816c8449bf2 295 typedef struct sRx2ChannelParams
snelson 8:4816c8449bf2 296 {
snelson 8:4816c8449bf2 297 /*!
snelson 8:4816c8449bf2 298 * Frequency in Hz
snelson 8:4816c8449bf2 299 */
snelson 8:4816c8449bf2 300 uint32_t Frequency;
snelson 8:4816c8449bf2 301 /*!
snelson 8:4816c8449bf2 302 * Data rate
snelson 8:4816c8449bf2 303 *
snelson 8:4816c8449bf2 304 * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7]
snelson 8:4816c8449bf2 305 *
snelson 8:4816c8449bf2 306 * US915 - [DR_8, DR_9, DR_10, DR_11, DR_12, DR_13]
snelson 8:4816c8449bf2 307 */
snelson 8:4816c8449bf2 308 uint8_t Datarate;
snelson 8:4816c8449bf2 309 }Rx2ChannelParams_t;
snelson 8:4816c8449bf2 310
snelson 8:4816c8449bf2 311 /*!
snelson 8:4816c8449bf2 312 * LoRaMAC multicast channel parameter
snelson 8:4816c8449bf2 313 */
snelson 8:4816c8449bf2 314 typedef struct sMulticastParams
snelson 8:4816c8449bf2 315 {
snelson 8:4816c8449bf2 316 /*!
snelson 8:4816c8449bf2 317 * Address
snelson 8:4816c8449bf2 318 */
snelson 8:4816c8449bf2 319 uint32_t Address;
snelson 8:4816c8449bf2 320 /*!
snelson 8:4816c8449bf2 321 * Network session key
snelson 8:4816c8449bf2 322 */
snelson 8:4816c8449bf2 323 uint8_t NwkSKey[16];
snelson 8:4816c8449bf2 324 /*!
snelson 8:4816c8449bf2 325 * Application session key
snelson 8:4816c8449bf2 326 */
snelson 8:4816c8449bf2 327 uint8_t AppSKey[16];
snelson 8:4816c8449bf2 328 /*!
snelson 8:4816c8449bf2 329 * Downlink counter
snelson 8:4816c8449bf2 330 */
snelson 8:4816c8449bf2 331 uint32_t DownLinkCounter;
snelson 8:4816c8449bf2 332 /*!
snelson 8:4816c8449bf2 333 * Reference pointer to the next multicast channel parameters in the list
snelson 8:4816c8449bf2 334 */
snelson 8:4816c8449bf2 335 struct sMulticastParams *Next;
snelson 8:4816c8449bf2 336 }MulticastParams_t;
snelson 8:4816c8449bf2 337
snelson 8:4816c8449bf2 338 /*!
snelson 8:4816c8449bf2 339 * LoRaMAC frame types
snelson 8:4816c8449bf2 340 *
snelson 8:4816c8449bf2 341 * LoRaWAN Specification V1.0, chapter 4.2.1, table 1
snelson 8:4816c8449bf2 342 */
snelson 8:4816c8449bf2 343 typedef enum eLoRaMacFrameType
snelson 8:4816c8449bf2 344 {
snelson 8:4816c8449bf2 345 /*!
snelson 8:4816c8449bf2 346 * LoRaMAC join request frame
snelson 8:4816c8449bf2 347 */
snelson 8:4816c8449bf2 348 FRAME_TYPE_JOIN_REQ = 0x00,
snelson 8:4816c8449bf2 349 /*!
snelson 8:4816c8449bf2 350 * LoRaMAC join accept frame
snelson 8:4816c8449bf2 351 */
snelson 8:4816c8449bf2 352 FRAME_TYPE_JOIN_ACCEPT = 0x01,
snelson 8:4816c8449bf2 353 /*!
snelson 8:4816c8449bf2 354 * LoRaMAC unconfirmed up-link frame
snelson 8:4816c8449bf2 355 */
snelson 8:4816c8449bf2 356 FRAME_TYPE_DATA_UNCONFIRMED_UP = 0x02,
snelson 8:4816c8449bf2 357 /*!
snelson 8:4816c8449bf2 358 * LoRaMAC unconfirmed down-link frame
snelson 8:4816c8449bf2 359 */
snelson 8:4816c8449bf2 360 FRAME_TYPE_DATA_UNCONFIRMED_DOWN = 0x03,
snelson 8:4816c8449bf2 361 /*!
snelson 8:4816c8449bf2 362 * LoRaMAC confirmed up-link frame
snelson 8:4816c8449bf2 363 */
snelson 8:4816c8449bf2 364 FRAME_TYPE_DATA_CONFIRMED_UP = 0x04,
snelson 8:4816c8449bf2 365 /*!
snelson 8:4816c8449bf2 366 * LoRaMAC confirmed down-link frame
snelson 8:4816c8449bf2 367 */
snelson 8:4816c8449bf2 368 FRAME_TYPE_DATA_CONFIRMED_DOWN = 0x05,
snelson 8:4816c8449bf2 369 /*!
snelson 8:4816c8449bf2 370 * LoRaMAC RFU frame
snelson 8:4816c8449bf2 371 */
snelson 8:4816c8449bf2 372 FRAME_TYPE_RFU = 0x06,
snelson 8:4816c8449bf2 373 /*!
snelson 8:4816c8449bf2 374 * LoRaMAC proprietary frame
snelson 8:4816c8449bf2 375 */
snelson 8:4816c8449bf2 376 FRAME_TYPE_PROPRIETARY = 0x07,
snelson 8:4816c8449bf2 377 }LoRaMacFrameType_t;
snelson 8:4816c8449bf2 378
snelson 8:4816c8449bf2 379 /*!
snelson 8:4816c8449bf2 380 * LoRaMAC mote MAC commands
snelson 8:4816c8449bf2 381 *
snelson 8:4816c8449bf2 382 * LoRaWAN Specification V1.0, chapter 5, table 4
snelson 8:4816c8449bf2 383 */
snelson 8:4816c8449bf2 384 typedef enum eLoRaMacMoteCmd
snelson 8:4816c8449bf2 385 {
snelson 8:4816c8449bf2 386 /*!
snelson 8:4816c8449bf2 387 * LinkCheckReq
snelson 8:4816c8449bf2 388 */
snelson 8:4816c8449bf2 389 MOTE_MAC_LINK_CHECK_REQ = 0x02,
snelson 8:4816c8449bf2 390 /*!
snelson 8:4816c8449bf2 391 * LinkADRAns
snelson 8:4816c8449bf2 392 */
snelson 8:4816c8449bf2 393 MOTE_MAC_LINK_ADR_ANS = 0x03,
snelson 8:4816c8449bf2 394 /*!
snelson 8:4816c8449bf2 395 * DutyCycleAns
snelson 8:4816c8449bf2 396 */
snelson 8:4816c8449bf2 397 MOTE_MAC_DUTY_CYCLE_ANS = 0x04,
snelson 8:4816c8449bf2 398 /*!
snelson 8:4816c8449bf2 399 * RXParamSetupAns
snelson 8:4816c8449bf2 400 */
snelson 8:4816c8449bf2 401 MOTE_MAC_RX_PARAM_SETUP_ANS = 0x05,
snelson 8:4816c8449bf2 402 /*!
snelson 8:4816c8449bf2 403 * DevStatusAns
snelson 8:4816c8449bf2 404 */
snelson 8:4816c8449bf2 405 MOTE_MAC_DEV_STATUS_ANS = 0x06,
snelson 8:4816c8449bf2 406 /*!
snelson 8:4816c8449bf2 407 * NewChannelAns
snelson 8:4816c8449bf2 408 */
snelson 8:4816c8449bf2 409 MOTE_MAC_NEW_CHANNEL_ANS = 0x07,
snelson 8:4816c8449bf2 410 /*!
snelson 8:4816c8449bf2 411 * RXTimingSetupAns
snelson 8:4816c8449bf2 412 */
snelson 8:4816c8449bf2 413 MOTE_MAC_RX_TIMING_SETUP_ANS = 0x08,
snelson 8:4816c8449bf2 414 }LoRaMacMoteCmd_t;
snelson 8:4816c8449bf2 415
snelson 8:4816c8449bf2 416 /*!
snelson 8:4816c8449bf2 417 * LoRaMAC server MAC commands
snelson 8:4816c8449bf2 418 *
snelson 8:4816c8449bf2 419 * LoRaWAN Specification V1.0, chapter 5, table 4
snelson 8:4816c8449bf2 420 */
snelson 8:4816c8449bf2 421 typedef enum eLoRaMacSrvCmd
snelson 8:4816c8449bf2 422 {
snelson 8:4816c8449bf2 423 /*!
snelson 8:4816c8449bf2 424 * LinkCheckAns
snelson 8:4816c8449bf2 425 */
snelson 8:4816c8449bf2 426 SRV_MAC_LINK_CHECK_ANS = 0x02,
snelson 8:4816c8449bf2 427 /*!
snelson 8:4816c8449bf2 428 * LinkADRReq
snelson 8:4816c8449bf2 429 */
snelson 8:4816c8449bf2 430 SRV_MAC_LINK_ADR_REQ = 0x03,
snelson 8:4816c8449bf2 431 /*!
snelson 8:4816c8449bf2 432 * DutyCycleReq
snelson 8:4816c8449bf2 433 */
snelson 8:4816c8449bf2 434 SRV_MAC_DUTY_CYCLE_REQ = 0x04,
snelson 8:4816c8449bf2 435 /*!
snelson 8:4816c8449bf2 436 * RXParamSetupReq
snelson 8:4816c8449bf2 437 */
snelson 8:4816c8449bf2 438 SRV_MAC_RX_PARAM_SETUP_REQ = 0x05,
snelson 8:4816c8449bf2 439 /*!
snelson 8:4816c8449bf2 440 * DevStatusReq
snelson 8:4816c8449bf2 441 */
snelson 8:4816c8449bf2 442 SRV_MAC_DEV_STATUS_REQ = 0x06,
snelson 8:4816c8449bf2 443 /*!
snelson 8:4816c8449bf2 444 * NewChannelReq
snelson 8:4816c8449bf2 445 */
snelson 8:4816c8449bf2 446 SRV_MAC_NEW_CHANNEL_REQ = 0x07,
snelson 8:4816c8449bf2 447 /*!
snelson 8:4816c8449bf2 448 * RXTimingSetupReq
snelson 8:4816c8449bf2 449 */
snelson 8:4816c8449bf2 450 SRV_MAC_RX_TIMING_SETUP_REQ = 0x08,
snelson 8:4816c8449bf2 451 }LoRaMacSrvCmd_t;
snelson 8:4816c8449bf2 452
snelson 8:4816c8449bf2 453 /*!
snelson 8:4816c8449bf2 454 * LoRaMAC Battery level indicator
snelson 8:4816c8449bf2 455 */
snelson 8:4816c8449bf2 456 typedef enum eLoRaMacBatteryLevel
snelson 8:4816c8449bf2 457 {
snelson 8:4816c8449bf2 458 /*!
snelson 8:4816c8449bf2 459 * External power source
snelson 8:4816c8449bf2 460 */
snelson 8:4816c8449bf2 461 BAT_LEVEL_EXT_SRC = 0x00,
snelson 8:4816c8449bf2 462 /*!
snelson 8:4816c8449bf2 463 * Battery level empty
snelson 8:4816c8449bf2 464 */
snelson 8:4816c8449bf2 465 BAT_LEVEL_EMPTY = 0x01,
snelson 8:4816c8449bf2 466 /*!
snelson 8:4816c8449bf2 467 * Battery level full
snelson 8:4816c8449bf2 468 */
snelson 8:4816c8449bf2 469 BAT_LEVEL_FULL = 0xFE,
snelson 8:4816c8449bf2 470 /*!
snelson 8:4816c8449bf2 471 * Battery level - no measurement available
snelson 8:4816c8449bf2 472 */
snelson 8:4816c8449bf2 473 BAT_LEVEL_NO_MEASURE = 0xFF,
snelson 8:4816c8449bf2 474 }LoRaMacBatteryLevel_t;
snelson 8:4816c8449bf2 475
snelson 8:4816c8449bf2 476 /*!
snelson 8:4816c8449bf2 477 * LoRaMAC header field definition (MHDR field)
snelson 8:4816c8449bf2 478 *
snelson 8:4816c8449bf2 479 * LoRaWAN Specification V1.0, chapter 4.2
snelson 8:4816c8449bf2 480 */
snelson 8:4816c8449bf2 481 typedef union uLoRaMacHeader
snelson 8:4816c8449bf2 482 {
snelson 8:4816c8449bf2 483 /*!
snelson 8:4816c8449bf2 484 * Byte-access to the bits
snelson 8:4816c8449bf2 485 */
snelson 8:4816c8449bf2 486 uint8_t Value;
snelson 8:4816c8449bf2 487 /*!
snelson 8:4816c8449bf2 488 * Structure containing single access to header bits
snelson 8:4816c8449bf2 489 */
snelson 8:4816c8449bf2 490 struct sHdrBits
snelson 8:4816c8449bf2 491 {
snelson 8:4816c8449bf2 492 /*!
snelson 8:4816c8449bf2 493 * Major version
snelson 8:4816c8449bf2 494 */
snelson 8:4816c8449bf2 495 uint8_t Major : 2;
snelson 8:4816c8449bf2 496 /*!
snelson 8:4816c8449bf2 497 * RFU
snelson 8:4816c8449bf2 498 */
snelson 8:4816c8449bf2 499 uint8_t RFU : 3;
snelson 8:4816c8449bf2 500 /*!
snelson 8:4816c8449bf2 501 * Message type
snelson 8:4816c8449bf2 502 */
snelson 8:4816c8449bf2 503 uint8_t MType : 3;
snelson 8:4816c8449bf2 504 }Bits;
snelson 8:4816c8449bf2 505 }LoRaMacHeader_t;
snelson 8:4816c8449bf2 506
snelson 8:4816c8449bf2 507 /*!
snelson 8:4816c8449bf2 508 * LoRaMAC frame control field definition (FCtrl)
snelson 8:4816c8449bf2 509 *
snelson 8:4816c8449bf2 510 * LoRaWAN Specification V1.0, chapter 4.3.1
snelson 8:4816c8449bf2 511 */
snelson 8:4816c8449bf2 512 typedef union uLoRaMacFrameCtrl
snelson 8:4816c8449bf2 513 {
snelson 8:4816c8449bf2 514 /*!
snelson 8:4816c8449bf2 515 * Byte-access to the bits
snelson 8:4816c8449bf2 516 */
snelson 8:4816c8449bf2 517 uint8_t Value;
snelson 8:4816c8449bf2 518 /*!
snelson 8:4816c8449bf2 519 * Structure containing single access to bits
snelson 8:4816c8449bf2 520 */
snelson 8:4816c8449bf2 521 struct sCtrlBits
snelson 8:4816c8449bf2 522 {
snelson 8:4816c8449bf2 523 /*!
snelson 8:4816c8449bf2 524 * Frame options length
snelson 8:4816c8449bf2 525 */
snelson 8:4816c8449bf2 526 uint8_t FOptsLen : 4;
snelson 8:4816c8449bf2 527 /*!
snelson 8:4816c8449bf2 528 * Frame pending bit
snelson 8:4816c8449bf2 529 */
snelson 8:4816c8449bf2 530 uint8_t FPending : 1;
snelson 8:4816c8449bf2 531 /*!
snelson 8:4816c8449bf2 532 * Message acknowledge bit
snelson 8:4816c8449bf2 533 */
snelson 8:4816c8449bf2 534 uint8_t Ack : 1;
snelson 8:4816c8449bf2 535 /*!
snelson 8:4816c8449bf2 536 * ADR acknowledgment request bit
snelson 8:4816c8449bf2 537 */
snelson 8:4816c8449bf2 538 uint8_t AdrAckReq : 1;
snelson 8:4816c8449bf2 539 /*!
snelson 8:4816c8449bf2 540 * ADR control in frame header
snelson 8:4816c8449bf2 541 */
snelson 8:4816c8449bf2 542 uint8_t Adr : 1;
snelson 8:4816c8449bf2 543 }Bits;
snelson 8:4816c8449bf2 544 }LoRaMacFrameCtrl_t;
snelson 8:4816c8449bf2 545
snelson 8:4816c8449bf2 546 /*!
snelson 8:4816c8449bf2 547 * Enumeration containing the status of the operation of a MAC service
snelson 8:4816c8449bf2 548 */
snelson 8:4816c8449bf2 549 typedef enum eLoRaMacEventInfoStatus
snelson 8:4816c8449bf2 550 {
snelson 8:4816c8449bf2 551 /*!
snelson 8:4816c8449bf2 552 * Service performed successfully
snelson 8:4816c8449bf2 553 */
snelson 8:4816c8449bf2 554 LORAMAC_EVENT_INFO_STATUS_OK = 0,
snelson 8:4816c8449bf2 555 /*!
snelson 8:4816c8449bf2 556 * An error occured during the execution of the service
snelson 8:4816c8449bf2 557 */
snelson 8:4816c8449bf2 558 LORAMAC_EVENT_INFO_STATUS_ERROR,
snelson 8:4816c8449bf2 559 /*!
snelson 8:4816c8449bf2 560 * A Tx timeouit occured
snelson 8:4816c8449bf2 561 */
snelson 8:4816c8449bf2 562 LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT,
snelson 8:4816c8449bf2 563 /*!
snelson 8:4816c8449bf2 564 * An Rx timeout occured on receive window 2
snelson 8:4816c8449bf2 565 */
snelson 8:4816c8449bf2 566 LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT,
snelson 8:4816c8449bf2 567 /*!
snelson 8:4816c8449bf2 568 * An Rx error occured on receive window 2
snelson 8:4816c8449bf2 569 */
snelson 8:4816c8449bf2 570 LORAMAC_EVENT_INFO_STATUS_RX2_ERROR,
snelson 8:4816c8449bf2 571 /*!
snelson 8:4816c8449bf2 572 * An error occured in the join procedure
snelson 8:4816c8449bf2 573 */
snelson 8:4816c8449bf2 574 LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL,
snelson 8:4816c8449bf2 575 /*!
snelson 8:4816c8449bf2 576 * A frame with an invalid downlink counter was received. The
snelson 8:4816c8449bf2 577 * downlink counter of the frame was equal to the local copy
snelson 8:4816c8449bf2 578 * of the downlink counter of the node.
snelson 8:4816c8449bf2 579 */
snelson 8:4816c8449bf2 580 LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED,
snelson 8:4816c8449bf2 581 /*!
snelson 8:4816c8449bf2 582 * The node has lost MAX_FCNT_GAP or more frames.
snelson 8:4816c8449bf2 583 */
snelson 8:4816c8449bf2 584 LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS,
snelson 8:4816c8449bf2 585 /*!
snelson 8:4816c8449bf2 586 * An address error occured
snelson 8:4816c8449bf2 587 */
snelson 8:4816c8449bf2 588 LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL,
snelson 8:4816c8449bf2 589 /*!
snelson 8:4816c8449bf2 590 * message integrity check failure
snelson 8:4816c8449bf2 591 */
snelson 8:4816c8449bf2 592 LORAMAC_EVENT_INFO_STATUS_MIC_FAIL,
snelson 8:4816c8449bf2 593 }LoRaMacEventInfoStatus_t;
snelson 8:4816c8449bf2 594
snelson 8:4816c8449bf2 595 /*!
snelson 8:4816c8449bf2 596 * LoRaMac tx/rx operation state
snelson 8:4816c8449bf2 597 */
snelson 8:4816c8449bf2 598 typedef union eLoRaMacFlags_t
snelson 8:4816c8449bf2 599 {
snelson 8:4816c8449bf2 600 /*!
snelson 8:4816c8449bf2 601 * Byte-access to the bits
snelson 8:4816c8449bf2 602 */
snelson 8:4816c8449bf2 603 uint8_t Value;
snelson 8:4816c8449bf2 604 /*!
snelson 8:4816c8449bf2 605 * Structure containing single access to bits
snelson 8:4816c8449bf2 606 */
snelson 8:4816c8449bf2 607 struct sMacFlagBits
snelson 8:4816c8449bf2 608 {
snelson 8:4816c8449bf2 609 /*!
snelson 8:4816c8449bf2 610 * MCPS-Req pending
snelson 8:4816c8449bf2 611 */
snelson 8:4816c8449bf2 612 uint8_t McpsReq : 1;
snelson 8:4816c8449bf2 613 /*!
snelson 8:4816c8449bf2 614 * MCPS-Ind pending
snelson 8:4816c8449bf2 615 */
snelson 8:4816c8449bf2 616 uint8_t McpsInd : 1;
snelson 8:4816c8449bf2 617 /*!
snelson 8:4816c8449bf2 618 * MLME-Req pending
snelson 8:4816c8449bf2 619 */
snelson 8:4816c8449bf2 620 uint8_t MlmeReq : 1;
snelson 8:4816c8449bf2 621 /*!
snelson 8:4816c8449bf2 622 * MAC cycle done
snelson 8:4816c8449bf2 623 */
snelson 8:4816c8449bf2 624 uint8_t MacDone : 1;
snelson 8:4816c8449bf2 625 }Bits;
snelson 8:4816c8449bf2 626 }LoRaMacFlags_t;
snelson 8:4816c8449bf2 627
snelson 8:4816c8449bf2 628 /*!
snelson 8:4816c8449bf2 629 *
snelson 8:4816c8449bf2 630 * \brief LoRaMAC data services
snelson 8:4816c8449bf2 631 *
snelson 8:4816c8449bf2 632 * \details The following table list the primitives which are supported by the
snelson 8:4816c8449bf2 633 * specific MAC data service:
snelson 8:4816c8449bf2 634 *
snelson 8:4816c8449bf2 635 * Name | Request | Indication | Response | Confirm
snelson 8:4816c8449bf2 636 * --------------------- | :-----: | :--------: | :------: | :-----:
snelson 8:4816c8449bf2 637 * \ref MCPS_UNCONFIRMED | YES | YES | NO | YES
snelson 8:4816c8449bf2 638 * \ref MCPS_CONFIRMED | YES | YES | NO | YES
snelson 8:4816c8449bf2 639 * \ref MCPS_MULTICAST | NO | YES | NO | NO
snelson 8:4816c8449bf2 640 * \ref MCPS_PROPRIETARY | YES | YES | NO | YES
snelson 8:4816c8449bf2 641 *
snelson 8:4816c8449bf2 642 * The following table provides links to the function implementations of the
snelson 8:4816c8449bf2 643 * related MCPS primitives:
snelson 8:4816c8449bf2 644 *
snelson 8:4816c8449bf2 645 * Primitive | Function
snelson 8:4816c8449bf2 646 * ---------------- | :---------------------:
snelson 8:4816c8449bf2 647 * MCPS-Request | \ref LoRaMacMlmeRequest
snelson 8:4816c8449bf2 648 * MCPS-Confirm | MacMcpsConfirm in \ref LoRaMacPrimitives_t
snelson 8:4816c8449bf2 649 * MCPS-Indication | MacMcpsIndication in \ref LoRaMacPrimitives_t
snelson 8:4816c8449bf2 650 */
snelson 8:4816c8449bf2 651 typedef enum eMcps
snelson 8:4816c8449bf2 652 {
snelson 8:4816c8449bf2 653 /*!
snelson 8:4816c8449bf2 654 * Unconfirmed LoRaMAC frame
snelson 8:4816c8449bf2 655 */
snelson 8:4816c8449bf2 656 MCPS_UNCONFIRMED,
snelson 8:4816c8449bf2 657 /*!
snelson 8:4816c8449bf2 658 * Confirmed LoRaMAC frame
snelson 8:4816c8449bf2 659 */
snelson 8:4816c8449bf2 660 MCPS_CONFIRMED,
snelson 8:4816c8449bf2 661 /*!
snelson 8:4816c8449bf2 662 * Multicast LoRaMAC frame
snelson 8:4816c8449bf2 663 */
snelson 8:4816c8449bf2 664 MCPS_MULTICAST,
snelson 8:4816c8449bf2 665 /*!
snelson 8:4816c8449bf2 666 * Proprietary frame
snelson 8:4816c8449bf2 667 */
snelson 8:4816c8449bf2 668 MCPS_PROPRIETARY,
snelson 8:4816c8449bf2 669 }Mcps_t;
snelson 8:4816c8449bf2 670
snelson 8:4816c8449bf2 671 /*!
snelson 8:4816c8449bf2 672 * LoRaMAC MCPS-Request for an unconfirmed frame
snelson 8:4816c8449bf2 673 */
snelson 8:4816c8449bf2 674 typedef struct sMcpsReqUnconfirmed
snelson 8:4816c8449bf2 675 {
snelson 8:4816c8449bf2 676 /*!
snelson 8:4816c8449bf2 677 * Frame port field. Must be set if the payload is not empty. Use the
snelson 8:4816c8449bf2 678 * application specific frame port values: [1...223]
snelson 8:4816c8449bf2 679 *
snelson 8:4816c8449bf2 680 * LoRaWAN Specification V1.0, chapter 4.3.2
snelson 8:4816c8449bf2 681 */
snelson 8:4816c8449bf2 682 uint8_t fPort;
snelson 8:4816c8449bf2 683 /*!
snelson 8:4816c8449bf2 684 * Pointer to the buffer of the frame payload
snelson 8:4816c8449bf2 685 */
snelson 8:4816c8449bf2 686 void *fBuffer;
snelson 8:4816c8449bf2 687 /*!
snelson 8:4816c8449bf2 688 * Size of the frame payload
snelson 8:4816c8449bf2 689 */
snelson 8:4816c8449bf2 690 uint16_t fBufferSize;
snelson 8:4816c8449bf2 691 /*!
snelson 8:4816c8449bf2 692 * Uplink datarate, if ADR is off
snelson 8:4816c8449bf2 693 */
snelson 8:4816c8449bf2 694 int8_t Datarate;
snelson 8:4816c8449bf2 695 }McpsReqUnconfirmed_t;
snelson 8:4816c8449bf2 696
snelson 8:4816c8449bf2 697 /*!
snelson 8:4816c8449bf2 698 * LoRaMAC MCPS-Request for a confirmed frame
snelson 8:4816c8449bf2 699 */
snelson 8:4816c8449bf2 700 typedef struct sMcpsReqConfirmed
snelson 8:4816c8449bf2 701 {
snelson 8:4816c8449bf2 702 /*!
snelson 8:4816c8449bf2 703 * Frame port field. Must be set if the payload is not empty. Use the
snelson 8:4816c8449bf2 704 * application specific frame port values: [1...223]
snelson 8:4816c8449bf2 705 *
snelson 8:4816c8449bf2 706 * LoRaWAN Specification V1.0, chapter 4.3.2
snelson 8:4816c8449bf2 707 */
snelson 8:4816c8449bf2 708 uint8_t fPort;
snelson 8:4816c8449bf2 709 /*!
snelson 8:4816c8449bf2 710 * Pointer to the buffer of the frame payload
snelson 8:4816c8449bf2 711 */
snelson 8:4816c8449bf2 712 void *fBuffer;
snelson 8:4816c8449bf2 713 /*!
snelson 8:4816c8449bf2 714 * Size of the frame payload
snelson 8:4816c8449bf2 715 */
snelson 8:4816c8449bf2 716 uint16_t fBufferSize;
snelson 8:4816c8449bf2 717 /*!
snelson 8:4816c8449bf2 718 * Uplink datarate, if ADR is off
snelson 8:4816c8449bf2 719 */
snelson 8:4816c8449bf2 720 int8_t Datarate;
snelson 8:4816c8449bf2 721 /*!
snelson 8:4816c8449bf2 722 * Number of trials to transmit the frame, if the LoRaMAC layer did not
snelson 8:4816c8449bf2 723 * receive an acknowledgment. The MAC performs a datarate adaptation,
snelson 8:4816c8449bf2 724 * according to the LoRaWAN Specification V1.0, chapter 18.4, according
snelson 8:4816c8449bf2 725 * to the following table:
snelson 8:4816c8449bf2 726 *
snelson 8:4816c8449bf2 727 * Transmission nb | Data Rate
snelson 8:4816c8449bf2 728 * ----------------|-----------
snelson 8:4816c8449bf2 729 * 1 (first) | DR
snelson 8:4816c8449bf2 730 * 2 | DR
snelson 8:4816c8449bf2 731 * 3 | max(DR-1,0)
snelson 8:4816c8449bf2 732 * 4 | max(DR-1,0)
snelson 8:4816c8449bf2 733 * 5 | max(DR-2,0)
snelson 8:4816c8449bf2 734 * 6 | max(DR-2,0)
snelson 8:4816c8449bf2 735 * 7 | max(DR-3,0)
snelson 8:4816c8449bf2 736 * 8 | max(DR-3,0)
snelson 8:4816c8449bf2 737 *
snelson 8:4816c8449bf2 738 * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease
snelson 8:4816c8449bf2 739 * the datarate, in case the LoRaMAC layer did not receive an acknowledgment
snelson 8:4816c8449bf2 740 */
snelson 8:4816c8449bf2 741 uint8_t NbTrials;
snelson 8:4816c8449bf2 742 }McpsReqConfirmed_t;
snelson 8:4816c8449bf2 743
snelson 8:4816c8449bf2 744 /*!
snelson 8:4816c8449bf2 745 * LoRaMAC MCPS-Request for a proprietary frame
snelson 8:4816c8449bf2 746 */
snelson 8:4816c8449bf2 747 typedef struct sMcpsReqProprietary
snelson 8:4816c8449bf2 748 {
snelson 8:4816c8449bf2 749 /*!
snelson 8:4816c8449bf2 750 * Pointer to the buffer of the frame payload
snelson 8:4816c8449bf2 751 */
snelson 8:4816c8449bf2 752 void *fBuffer;
snelson 8:4816c8449bf2 753 /*!
snelson 8:4816c8449bf2 754 * Size of the frame payload
snelson 8:4816c8449bf2 755 */
snelson 8:4816c8449bf2 756 uint16_t fBufferSize;
snelson 8:4816c8449bf2 757 /*!
snelson 8:4816c8449bf2 758 * Uplink datarate, if ADR is off
snelson 8:4816c8449bf2 759 */
snelson 8:4816c8449bf2 760 int8_t Datarate;
snelson 8:4816c8449bf2 761 }McpsReqProprietary_t;
snelson 8:4816c8449bf2 762
snelson 8:4816c8449bf2 763 /*!
snelson 8:4816c8449bf2 764 * LoRaMAC MCPS-Request structure
snelson 8:4816c8449bf2 765 */
snelson 8:4816c8449bf2 766 typedef struct sMcpsReq
snelson 8:4816c8449bf2 767 {
snelson 8:4816c8449bf2 768 /*!
snelson 8:4816c8449bf2 769 * MCPS-Request type
snelson 8:4816c8449bf2 770 */
snelson 8:4816c8449bf2 771 Mcps_t Type;
snelson 8:4816c8449bf2 772
snelson 8:4816c8449bf2 773 /*!
snelson 8:4816c8449bf2 774 * MCPS-Request parameters
snelson 8:4816c8449bf2 775 */
snelson 8:4816c8449bf2 776 union uMcpsParam
snelson 8:4816c8449bf2 777 {
snelson 8:4816c8449bf2 778 /*!
snelson 8:4816c8449bf2 779 * MCPS-Request parameters for an unconfirmed frame
snelson 8:4816c8449bf2 780 */
snelson 8:4816c8449bf2 781 McpsReqUnconfirmed_t Unconfirmed;
snelson 8:4816c8449bf2 782 /*!
snelson 8:4816c8449bf2 783 * MCPS-Request parameters for a confirmed frame
snelson 8:4816c8449bf2 784 */
snelson 8:4816c8449bf2 785 McpsReqConfirmed_t Confirmed;
snelson 8:4816c8449bf2 786 /*!
snelson 8:4816c8449bf2 787 * MCPS-Request parameters for a proprietary frame
snelson 8:4816c8449bf2 788 */
snelson 8:4816c8449bf2 789 McpsReqProprietary_t Proprietary;
snelson 8:4816c8449bf2 790 }Req;
snelson 8:4816c8449bf2 791 }McpsReq_t;
snelson 8:4816c8449bf2 792
snelson 8:4816c8449bf2 793 /*!
snelson 8:4816c8449bf2 794 * LoRaMAC MCPS-Confirm
snelson 8:4816c8449bf2 795 */
snelson 8:4816c8449bf2 796 typedef struct sMcpsConfirm
snelson 8:4816c8449bf2 797 {
snelson 8:4816c8449bf2 798 /*!
snelson 8:4816c8449bf2 799 * Holds the previously performed MCPS-Request
snelson 8:4816c8449bf2 800 */
snelson 8:4816c8449bf2 801 Mcps_t McpsRequest;
snelson 8:4816c8449bf2 802 /*!
snelson 8:4816c8449bf2 803 * Status of the operation
snelson 8:4816c8449bf2 804 */
snelson 8:4816c8449bf2 805 LoRaMacEventInfoStatus_t Status;
snelson 8:4816c8449bf2 806 /*!
snelson 8:4816c8449bf2 807 * Uplink datarate
snelson 8:4816c8449bf2 808 */
snelson 8:4816c8449bf2 809 uint8_t Datarate;
snelson 8:4816c8449bf2 810 /*!
snelson 8:4816c8449bf2 811 * Transmission power
snelson 8:4816c8449bf2 812 */
snelson 8:4816c8449bf2 813 int8_t TxPower;
snelson 8:4816c8449bf2 814 /*!
snelson 8:4816c8449bf2 815 * Set if an acknowledgement was received
snelson 8:4816c8449bf2 816 */
snelson 8:4816c8449bf2 817 bool AckReceived;
snelson 8:4816c8449bf2 818 /*!
snelson 8:4816c8449bf2 819 * Provides the number of retransmissions
snelson 8:4816c8449bf2 820 */
snelson 8:4816c8449bf2 821 uint8_t NbRetries;
snelson 8:4816c8449bf2 822 /*!
snelson 8:4816c8449bf2 823 * The transmission time on air of the frame
snelson 8:4816c8449bf2 824 */
snelson 8:4816c8449bf2 825 TimerTime_t TxTimeOnAir;
snelson 8:4816c8449bf2 826 /*!
snelson 8:4816c8449bf2 827 * The uplink counter value related to the frame
snelson 8:4816c8449bf2 828 */
snelson 8:4816c8449bf2 829 uint32_t UpLinkCounter;
snelson 8:4816c8449bf2 830 }McpsConfirm_t;
snelson 8:4816c8449bf2 831
snelson 8:4816c8449bf2 832 /*!
snelson 8:4816c8449bf2 833 * LoRaMAC MCPS-Indication primitive
snelson 8:4816c8449bf2 834 */
snelson 8:4816c8449bf2 835 typedef struct sMcpsIndication
snelson 8:4816c8449bf2 836 {
snelson 8:4816c8449bf2 837 /*!
snelson 8:4816c8449bf2 838 * MCPS-Indication type
snelson 8:4816c8449bf2 839 */
snelson 8:4816c8449bf2 840 Mcps_t McpsIndication;
snelson 8:4816c8449bf2 841 /*!
snelson 8:4816c8449bf2 842 * Status of the operation
snelson 8:4816c8449bf2 843 */
snelson 8:4816c8449bf2 844 LoRaMacEventInfoStatus_t Status;
snelson 8:4816c8449bf2 845 /*!
snelson 8:4816c8449bf2 846 * Multicast
snelson 8:4816c8449bf2 847 */
snelson 8:4816c8449bf2 848 uint8_t Multicast;
snelson 8:4816c8449bf2 849 /*!
snelson 8:4816c8449bf2 850 * Application port
snelson 8:4816c8449bf2 851 */
snelson 8:4816c8449bf2 852 uint8_t Port;
snelson 8:4816c8449bf2 853 /*!
snelson 8:4816c8449bf2 854 * Downlink datarate
snelson 8:4816c8449bf2 855 */
snelson 8:4816c8449bf2 856 uint8_t RxDatarate;
snelson 8:4816c8449bf2 857 /*!
snelson 8:4816c8449bf2 858 * Frame pending status
snelson 8:4816c8449bf2 859 */
snelson 8:4816c8449bf2 860 uint8_t FramePending;
snelson 8:4816c8449bf2 861 /*!
snelson 8:4816c8449bf2 862 * Pointer to the received data stream
snelson 8:4816c8449bf2 863 */
snelson 8:4816c8449bf2 864 uint8_t *Buffer;
snelson 8:4816c8449bf2 865 /*!
snelson 8:4816c8449bf2 866 * Size of the received data stream
snelson 8:4816c8449bf2 867 */
snelson 8:4816c8449bf2 868 uint8_t BufferSize;
snelson 8:4816c8449bf2 869 /*!
snelson 8:4816c8449bf2 870 * Indicates, if data is available
snelson 8:4816c8449bf2 871 */
snelson 8:4816c8449bf2 872 bool RxData;
snelson 8:4816c8449bf2 873 /*!
snelson 8:4816c8449bf2 874 * Rssi of the received packet
snelson 8:4816c8449bf2 875 */
snelson 8:4816c8449bf2 876 int16_t Rssi;
snelson 8:4816c8449bf2 877 /*!
snelson 8:4816c8449bf2 878 * Snr of the received packet
snelson 8:4816c8449bf2 879 */
snelson 8:4816c8449bf2 880 uint8_t Snr;
snelson 8:4816c8449bf2 881 /*!
snelson 8:4816c8449bf2 882 * Receive window
snelson 8:4816c8449bf2 883 *
snelson 8:4816c8449bf2 884 * [0: Rx window 1, 1: Rx window 2]
snelson 8:4816c8449bf2 885 */
snelson 8:4816c8449bf2 886 uint8_t RxSlot;
snelson 8:4816c8449bf2 887 /*!
snelson 8:4816c8449bf2 888 * Set if an acknowledgement was received
snelson 8:4816c8449bf2 889 */
snelson 8:4816c8449bf2 890 bool AckReceived;
snelson 8:4816c8449bf2 891 /*!
snelson 8:4816c8449bf2 892 * The downlink counter value for the received frame
snelson 8:4816c8449bf2 893 */
snelson 8:4816c8449bf2 894 uint32_t DownLinkCounter;
snelson 8:4816c8449bf2 895 }McpsIndication_t;
snelson 8:4816c8449bf2 896
snelson 8:4816c8449bf2 897 /*!
snelson 8:4816c8449bf2 898 * \brief LoRaMAC management services
snelson 8:4816c8449bf2 899 *
snelson 8:4816c8449bf2 900 * \details The following table list the primitives which are supported by the
snelson 8:4816c8449bf2 901 * specific MAC management service:
snelson 8:4816c8449bf2 902 *
snelson 8:4816c8449bf2 903 * Name | Request | Indication | Response | Confirm
snelson 8:4816c8449bf2 904 * --------------------- | :-----: | :--------: | :------: | :-----:
snelson 8:4816c8449bf2 905 * \ref MLME_JOIN | YES | NO | NO | YES
snelson 8:4816c8449bf2 906 * \ref MLME_LINK_CHECK | YES | NO | NO | YES
snelson 8:4816c8449bf2 907 *
snelson 8:4816c8449bf2 908 * The following table provides links to the function implementations of the
snelson 8:4816c8449bf2 909 * related MLME primitives.
snelson 8:4816c8449bf2 910 *
snelson 8:4816c8449bf2 911 * Primitive | Function
snelson 8:4816c8449bf2 912 * ---------------- | :---------------------:
snelson 8:4816c8449bf2 913 * MLME-Request | \ref LoRaMacMlmeRequest
snelson 8:4816c8449bf2 914 * MLME-Confirm | MacMlmeConfirm in \ref LoRaMacPrimitives_t
snelson 8:4816c8449bf2 915 */
snelson 8:4816c8449bf2 916 typedef enum eMlme
snelson 8:4816c8449bf2 917 {
snelson 8:4816c8449bf2 918 /*!
snelson 8:4816c8449bf2 919 * Initiates the Over-the-Air activation
snelson 8:4816c8449bf2 920 *
snelson 8:4816c8449bf2 921 * LoRaWAN Specification V1.0, chapter 6.2
snelson 8:4816c8449bf2 922 */
snelson 8:4816c8449bf2 923 MLME_JOIN,
snelson 8:4816c8449bf2 924 /*!
snelson 8:4816c8449bf2 925 * LinkCheckReq - Connectivity validation
snelson 8:4816c8449bf2 926 *
snelson 8:4816c8449bf2 927 * LoRaWAN Specification V1.0, chapter 5, table 4
snelson 8:4816c8449bf2 928 */
snelson 8:4816c8449bf2 929 MLME_LINK_CHECK,
snelson 8:4816c8449bf2 930 }Mlme_t;
snelson 8:4816c8449bf2 931
snelson 8:4816c8449bf2 932 /*!
snelson 8:4816c8449bf2 933 * LoRaMAC MLME-Request for the join service
snelson 8:4816c8449bf2 934 */
snelson 8:4816c8449bf2 935 typedef struct sMlmeReqJoin
snelson 8:4816c8449bf2 936 {
snelson 8:4816c8449bf2 937 /*!
snelson 8:4816c8449bf2 938 * Globally unique end-device identifier
snelson 8:4816c8449bf2 939 *
snelson 8:4816c8449bf2 940 * LoRaWAN Specification V1.0, chapter 6.2.1
snelson 8:4816c8449bf2 941 */
snelson 8:4816c8449bf2 942 uint8_t *DevEui;
snelson 8:4816c8449bf2 943 /*!
snelson 8:4816c8449bf2 944 * Application identifier
snelson 8:4816c8449bf2 945 *
snelson 8:4816c8449bf2 946 * LoRaWAN Specification V1.0, chapter 6.1.2
snelson 8:4816c8449bf2 947 */
snelson 8:4816c8449bf2 948 uint8_t *AppEui;
snelson 8:4816c8449bf2 949 /*!
snelson 8:4816c8449bf2 950 * AES-128 application key
snelson 8:4816c8449bf2 951 *
snelson 8:4816c8449bf2 952 * LoRaWAN Specification V1.0, chapter 6.2.2
snelson 8:4816c8449bf2 953 */
snelson 8:4816c8449bf2 954 uint8_t *AppKey;
snelson 8:4816c8449bf2 955 }MlmeReqJoin_t;
snelson 8:4816c8449bf2 956
snelson 8:4816c8449bf2 957 /*!
snelson 8:4816c8449bf2 958 * LoRaMAC MLME-Request structure
snelson 8:4816c8449bf2 959 */
snelson 8:4816c8449bf2 960 typedef struct sMlmeReq
snelson 8:4816c8449bf2 961 {
snelson 8:4816c8449bf2 962 /*!
snelson 8:4816c8449bf2 963 * MLME-Request type
snelson 8:4816c8449bf2 964 */
snelson 8:4816c8449bf2 965 Mlme_t Type;
snelson 8:4816c8449bf2 966
snelson 8:4816c8449bf2 967 /*!
snelson 8:4816c8449bf2 968 * MLME-Request parameters
snelson 8:4816c8449bf2 969 */
snelson 8:4816c8449bf2 970 union uMlmeParam
snelson 8:4816c8449bf2 971 {
snelson 8:4816c8449bf2 972 /*!
snelson 8:4816c8449bf2 973 * MLME-Request parameters for a join request
snelson 8:4816c8449bf2 974 */
snelson 8:4816c8449bf2 975 MlmeReqJoin_t Join;
snelson 8:4816c8449bf2 976 }Req;
snelson 8:4816c8449bf2 977 }MlmeReq_t;
snelson 8:4816c8449bf2 978
snelson 8:4816c8449bf2 979 /*!
snelson 8:4816c8449bf2 980 * LoRaMAC MLME-Confirm primitive
snelson 8:4816c8449bf2 981 */
snelson 8:4816c8449bf2 982 typedef struct sMlmeConfirm
snelson 8:4816c8449bf2 983 {
snelson 8:4816c8449bf2 984 /*!
snelson 8:4816c8449bf2 985 * Holds the previously performed MLME-Request
snelson 8:4816c8449bf2 986 */
snelson 8:4816c8449bf2 987 Mlme_t MlmeRequest;
snelson 8:4816c8449bf2 988 /*!
snelson 8:4816c8449bf2 989 * Status of the operation
snelson 8:4816c8449bf2 990 */
snelson 8:4816c8449bf2 991 LoRaMacEventInfoStatus_t Status;
snelson 8:4816c8449bf2 992 /*!
snelson 8:4816c8449bf2 993 * The transmission time on air of the frame
snelson 8:4816c8449bf2 994 */
snelson 8:4816c8449bf2 995 TimerTime_t TxTimeOnAir;
snelson 8:4816c8449bf2 996 /*!
snelson 8:4816c8449bf2 997 * Demodulation margin. Contains the link margin [dB] of the last
snelson 8:4816c8449bf2 998 * successfully received LinkCheckReq
snelson 8:4816c8449bf2 999 */
snelson 8:4816c8449bf2 1000 uint8_t DemodMargin;
snelson 8:4816c8449bf2 1001 /*!
snelson 8:4816c8449bf2 1002 * Number of gateways which received the last LinkCheckReq
snelson 8:4816c8449bf2 1003 */
snelson 8:4816c8449bf2 1004 uint8_t NbGateways;
snelson 8:4816c8449bf2 1005 }MlmeConfirm_t;
snelson 8:4816c8449bf2 1006
snelson 8:4816c8449bf2 1007 /*!
snelson 8:4816c8449bf2 1008 * LoRa Mac Information Base (MIB)
snelson 8:4816c8449bf2 1009 *
snelson 8:4816c8449bf2 1010 * The following table lists the MIB parameters and the related attributes:
snelson 8:4816c8449bf2 1011 *
snelson 8:4816c8449bf2 1012 * Attribute | Get | Set
snelson 8:4816c8449bf2 1013 * --------------------------------- | :-: | :-:
snelson 8:4816c8449bf2 1014 * \ref MIB_DEVICE_CLASS | YES | YES
snelson 8:4816c8449bf2 1015 * \ref MIB_NETWORK_JOINED | YES | YES
snelson 8:4816c8449bf2 1016 * \ref MIB_ADR | YES | YES
snelson 8:4816c8449bf2 1017 * \ref MIB_NET_ID | YES | YES
snelson 8:4816c8449bf2 1018 * \ref MIB_DEV_ADDR | YES | YES
snelson 8:4816c8449bf2 1019 * \ref MIB_NWK_SKEY | YES | YES
snelson 8:4816c8449bf2 1020 * \ref MIB_APP_SKEY | YES | YES
snelson 8:4816c8449bf2 1021 * \ref MIB_PUBLIC_NETWORK | YES | YES
snelson 8:4816c8449bf2 1022 * \ref MIB_REPEATER_SUPPORT | YES | YES
snelson 8:4816c8449bf2 1023 * \ref MIB_CHANNELS | YES | NO
snelson 8:4816c8449bf2 1024 * \ref MIB_RX2_CHANNEL | YES | YES
snelson 8:4816c8449bf2 1025 * \ref MIB_CHANNELS_MASK | YES | YES
snelson 8:4816c8449bf2 1026 * \ref MIB_CHANNELS_NB_REP | YES | YES
snelson 8:4816c8449bf2 1027 * \ref MIB_MAX_RX_WINDOW_DURATION | YES | YES
snelson 8:4816c8449bf2 1028 * \ref MIB_RECEIVE_DELAY_1 | YES | YES
snelson 8:4816c8449bf2 1029 * \ref MIB_RECEIVE_DELAY_2 | YES | YES
snelson 8:4816c8449bf2 1030 * \ref MIB_JOIN_ACCEPT_DELAY_1 | YES | YES
snelson 8:4816c8449bf2 1031 * \ref MIB_JOIN_ACCEPT_DELAY_2 | YES | YES
snelson 8:4816c8449bf2 1032 * \ref MIB_CHANNELS_DATARATE | YES | YES
snelson 8:4816c8449bf2 1033 * \ref MIB_CHANNELS_DEFAULT_DATARATE| YES | YES
snelson 8:4816c8449bf2 1034 * \ref MIB_CHANNELS_TX_POWER | YES | YES
snelson 8:4816c8449bf2 1035 * \ref MIB_UPLINK_COUNTER | YES | YES
snelson 8:4816c8449bf2 1036 * \ref MIB_DOWNLINK_COUNTER | YES | YES
snelson 8:4816c8449bf2 1037 * \ref MIB_MULTICAST_CHANNEL | YES | NO
snelson 8:4816c8449bf2 1038 *
snelson 8:4816c8449bf2 1039 * The following table provides links to the function implementations of the
snelson 8:4816c8449bf2 1040 * related MIB primitives:
snelson 8:4816c8449bf2 1041 *
snelson 8:4816c8449bf2 1042 * Primitive | Function
snelson 8:4816c8449bf2 1043 * ---------------- | :---------------------:
snelson 8:4816c8449bf2 1044 * MIB-Set | \ref LoRaMacMibSetRequestConfirm
snelson 8:4816c8449bf2 1045 * MIB-Get | \ref LoRaMacMibGetRequestConfirm
snelson 8:4816c8449bf2 1046 */
snelson 8:4816c8449bf2 1047 typedef enum eMib
snelson 8:4816c8449bf2 1048 {
snelson 8:4816c8449bf2 1049 /*!
snelson 8:4816c8449bf2 1050 * LoRaWAN device class
snelson 8:4816c8449bf2 1051 *
snelson 8:4816c8449bf2 1052 * LoRaWAN Specification V1.0
snelson 8:4816c8449bf2 1053 */
snelson 8:4816c8449bf2 1054 MIB_DEVICE_CLASS,
snelson 8:4816c8449bf2 1055 /*!
snelson 8:4816c8449bf2 1056 * LoRaWAN Network joined attribute
snelson 8:4816c8449bf2 1057 *
snelson 8:4816c8449bf2 1058 * LoRaWAN Specification V1.0
snelson 8:4816c8449bf2 1059 */
snelson 8:4816c8449bf2 1060 MIB_NETWORK_JOINED,
snelson 8:4816c8449bf2 1061 /*!
snelson 8:4816c8449bf2 1062 * Adaptive data rate
snelson 8:4816c8449bf2 1063 *
snelson 8:4816c8449bf2 1064 * LoRaWAN Specification V1.0, chapter 4.3.1.1
snelson 8:4816c8449bf2 1065 *
snelson 8:4816c8449bf2 1066 * [true: ADR enabled, false: ADR disabled]
snelson 8:4816c8449bf2 1067 */
snelson 8:4816c8449bf2 1068 MIB_ADR,
snelson 8:4816c8449bf2 1069 /*!
snelson 8:4816c8449bf2 1070 * Network identifier
snelson 8:4816c8449bf2 1071 *
snelson 8:4816c8449bf2 1072 * LoRaWAN Specification V1.0, chapter 6.2.5
snelson 8:4816c8449bf2 1073 */
snelson 8:4816c8449bf2 1074 MIB_NET_ID,
snelson 8:4816c8449bf2 1075 /*!
snelson 8:4816c8449bf2 1076 * End-device address
snelson 8:4816c8449bf2 1077 *
snelson 8:4816c8449bf2 1078 * LoRaWAN Specification V1.0, chapter 6.1.2
snelson 8:4816c8449bf2 1079 */
snelson 8:4816c8449bf2 1080 MIB_DEV_ADDR,
snelson 8:4816c8449bf2 1081 /*!
snelson 8:4816c8449bf2 1082 * Network session key
snelson 8:4816c8449bf2 1083 *
snelson 8:4816c8449bf2 1084 * LoRaWAN Specification V1.0, chapter 6.1.3
snelson 8:4816c8449bf2 1085 */
snelson 8:4816c8449bf2 1086 MIB_NWK_SKEY,
snelson 8:4816c8449bf2 1087 /*!
snelson 8:4816c8449bf2 1088 * Application session key
snelson 8:4816c8449bf2 1089 *
snelson 8:4816c8449bf2 1090 * LoRaWAN Specification V1.0, chapter 6.1.4
snelson 8:4816c8449bf2 1091 */
snelson 8:4816c8449bf2 1092 MIB_APP_SKEY,
snelson 8:4816c8449bf2 1093 /*!
snelson 8:4816c8449bf2 1094 * Set the network type to public or private
snelson 8:4816c8449bf2 1095 *
snelson 8:4816c8449bf2 1096 * LoRaWAN Specification V1.0, chapter 7
snelson 8:4816c8449bf2 1097 *
snelson 8:4816c8449bf2 1098 * [true: public network, false: private network]
snelson 8:4816c8449bf2 1099 */
snelson 8:4816c8449bf2 1100 MIB_PUBLIC_NETWORK,
snelson 8:4816c8449bf2 1101 /*!
snelson 8:4816c8449bf2 1102 * Support the operation with repeaters
snelson 8:4816c8449bf2 1103 *
snelson 8:4816c8449bf2 1104 * LoRaWAN Specification V1.0, chapter 7
snelson 8:4816c8449bf2 1105 *
snelson 8:4816c8449bf2 1106 * [true: repeater support enabled, false: repeater support disabled]
snelson 8:4816c8449bf2 1107 */
snelson 8:4816c8449bf2 1108 MIB_REPEATER_SUPPORT,
snelson 8:4816c8449bf2 1109 /*!
snelson 8:4816c8449bf2 1110 * Communication channels. A get request will return a
snelson 8:4816c8449bf2 1111 * pointer which references the first entry of the channel list. The
snelson 8:4816c8449bf2 1112 * list is of size LORA_MAX_NB_CHANNELS
snelson 8:4816c8449bf2 1113 *
snelson 8:4816c8449bf2 1114 * LoRaWAN Specification V1.0, chapter 7
snelson 8:4816c8449bf2 1115 */
snelson 8:4816c8449bf2 1116 MIB_CHANNELS,
snelson 8:4816c8449bf2 1117 /*!
snelson 8:4816c8449bf2 1118 * Set receive window 2 channel
snelson 8:4816c8449bf2 1119 *
snelson 8:4816c8449bf2 1120 * LoRaWAN Specification V1.0, chapter 3.3.2
snelson 8:4816c8449bf2 1121 */
snelson 8:4816c8449bf2 1122 MIB_RX2_CHANNEL,
snelson 8:4816c8449bf2 1123 /*!
snelson 8:4816c8449bf2 1124 * LoRaWAN channels mask
snelson 8:4816c8449bf2 1125 *
snelson 8:4816c8449bf2 1126 * LoRaWAN Specification V1.0, chapter 5.2
snelson 8:4816c8449bf2 1127 */
snelson 8:4816c8449bf2 1128 MIB_CHANNELS_MASK,
snelson 8:4816c8449bf2 1129 /*!
snelson 8:4816c8449bf2 1130 * Set the number of repetitions on a channel
snelson 8:4816c8449bf2 1131 *
snelson 8:4816c8449bf2 1132 * LoRaWAN Specification V1.0, chapter 5.2
snelson 8:4816c8449bf2 1133 */
snelson 8:4816c8449bf2 1134 MIB_CHANNELS_NB_REP,
snelson 8:4816c8449bf2 1135 /*!
snelson 8:4816c8449bf2 1136 * Maximum receive window duration in [us]
snelson 8:4816c8449bf2 1137 *
snelson 8:4816c8449bf2 1138 * LoRaWAN Specification V1.0, chapter 3.3.3
snelson 8:4816c8449bf2 1139 */
snelson 8:4816c8449bf2 1140 MIB_MAX_RX_WINDOW_DURATION,
snelson 8:4816c8449bf2 1141 /*!
snelson 8:4816c8449bf2 1142 * Receive delay 1 in [us]
snelson 8:4816c8449bf2 1143 *
snelson 8:4816c8449bf2 1144 * LoRaWAN Specification V1.0, chapter 6
snelson 8:4816c8449bf2 1145 */
snelson 8:4816c8449bf2 1146 MIB_RECEIVE_DELAY_1,
snelson 8:4816c8449bf2 1147 /*!
snelson 8:4816c8449bf2 1148 * Receive delay 2 in [us]
snelson 8:4816c8449bf2 1149 *
snelson 8:4816c8449bf2 1150 * LoRaWAN Specification V1.0, chapter 6
snelson 8:4816c8449bf2 1151 */
snelson 8:4816c8449bf2 1152 MIB_RECEIVE_DELAY_2,
snelson 8:4816c8449bf2 1153 /*!
snelson 8:4816c8449bf2 1154 * Join accept delay 1 in [us]
snelson 8:4816c8449bf2 1155 *
snelson 8:4816c8449bf2 1156 * LoRaWAN Specification V1.0, chapter 6
snelson 8:4816c8449bf2 1157 */
snelson 8:4816c8449bf2 1158 MIB_JOIN_ACCEPT_DELAY_1,
snelson 8:4816c8449bf2 1159 /*!
snelson 8:4816c8449bf2 1160 * Join accept delay 2 in [us]
snelson 8:4816c8449bf2 1161 *
snelson 8:4816c8449bf2 1162 * LoRaWAN Specification V1.0, chapter 6
snelson 8:4816c8449bf2 1163 */
snelson 8:4816c8449bf2 1164 MIB_JOIN_ACCEPT_DELAY_2,
snelson 8:4816c8449bf2 1165 /*!
snelson 8:4816c8449bf2 1166 * Default Data rate of a channel
snelson 8:4816c8449bf2 1167 *
snelson 8:4816c8449bf2 1168 * LoRaWAN Specification V1.0, chapter 7
snelson 8:4816c8449bf2 1169 *
snelson 8:4816c8449bf2 1170 * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7]
snelson 8:4816c8449bf2 1171 *
snelson 8:4816c8449bf2 1172 * US915 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_8, DR_9, DR_10, DR_11, DR_12, DR_13]
snelson 8:4816c8449bf2 1173 */
snelson 8:4816c8449bf2 1174 MIB_CHANNELS_DEFAULT_DATARATE,
snelson 8:4816c8449bf2 1175 /*!
snelson 8:4816c8449bf2 1176 * Data rate of a channel
snelson 8:4816c8449bf2 1177 *
snelson 8:4816c8449bf2 1178 * LoRaWAN Specification V1.0, chapter 7
snelson 8:4816c8449bf2 1179 *
snelson 8:4816c8449bf2 1180 * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7]
snelson 8:4816c8449bf2 1181 *
snelson 8:4816c8449bf2 1182 * US915 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_8, DR_9, DR_10, DR_11, DR_12, DR_13]
snelson 8:4816c8449bf2 1183 */
snelson 8:4816c8449bf2 1184 MIB_CHANNELS_DATARATE,
snelson 8:4816c8449bf2 1185 /*!
snelson 8:4816c8449bf2 1186 * Transmission power of a channel
snelson 8:4816c8449bf2 1187 *
snelson 8:4816c8449bf2 1188 * LoRaWAN Specification V1.0, chapter 7
snelson 8:4816c8449bf2 1189 *
snelson 8:4816c8449bf2 1190 * EU868 - [TX_POWER_20_DBM, TX_POWER_14_DBM, TX_POWER_11_DBM,
snelson 8:4816c8449bf2 1191 * TX_POWER_08_DBM, TX_POWER_05_DBM, TX_POWER_02_DBM]
snelson 8:4816c8449bf2 1192 *
snelson 8:4816c8449bf2 1193 * US915 - [TX_POWER_30_DBM, TX_POWER_28_DBM, TX_POWER_26_DBM,
snelson 8:4816c8449bf2 1194 * TX_POWER_24_DBM, TX_POWER_22_DBM, TX_POWER_20_DBM,
snelson 8:4816c8449bf2 1195 * TX_POWER_18_DBM, TX_POWER_14_DBM, TX_POWER_12_DBM,
snelson 8:4816c8449bf2 1196 * TX_POWER_10_DBM]
snelson 8:4816c8449bf2 1197 */
snelson 8:4816c8449bf2 1198 MIB_CHANNELS_TX_POWER,
snelson 8:4816c8449bf2 1199 /*!
snelson 8:4816c8449bf2 1200 * LoRaWAN Up-link counter
snelson 8:4816c8449bf2 1201 *
snelson 8:4816c8449bf2 1202 * LoRaWAN Specification V1.0, chapter 4.3.1.5
snelson 8:4816c8449bf2 1203 */
snelson 8:4816c8449bf2 1204 MIB_UPLINK_COUNTER,
snelson 8:4816c8449bf2 1205 /*!
snelson 8:4816c8449bf2 1206 * LoRaWAN Down-link counter
snelson 8:4816c8449bf2 1207 *
snelson 8:4816c8449bf2 1208 * LoRaWAN Specification V1.0, chapter 4.3.1.5
snelson 8:4816c8449bf2 1209 */
snelson 8:4816c8449bf2 1210 MIB_DOWNLINK_COUNTER,
snelson 8:4816c8449bf2 1211 /*!
snelson 8:4816c8449bf2 1212 * Multicast channels. A get request will return a pointer to the first
snelson 8:4816c8449bf2 1213 * entry of the multicast channel linked list. If the pointer is equal to
snelson 8:4816c8449bf2 1214 * NULL, the list is empty.
snelson 8:4816c8449bf2 1215 */
snelson 8:4816c8449bf2 1216 MIB_MULTICAST_CHANNEL,
snelson 8:4816c8449bf2 1217 }Mib_t;
snelson 8:4816c8449bf2 1218
snelson 8:4816c8449bf2 1219 /*!
snelson 8:4816c8449bf2 1220 * LoRaMAC MIB parameters
snelson 8:4816c8449bf2 1221 */
snelson 8:4816c8449bf2 1222 typedef union uMibParam
snelson 8:4816c8449bf2 1223 {
snelson 8:4816c8449bf2 1224 /*!
snelson 8:4816c8449bf2 1225 * LoRaWAN device class
snelson 8:4816c8449bf2 1226 *
snelson 8:4816c8449bf2 1227 * Related MIB type: \ref MIB_DEVICE_CLASS
snelson 8:4816c8449bf2 1228 */
snelson 8:4816c8449bf2 1229 DeviceClass_t Class;
snelson 8:4816c8449bf2 1230 /*!
snelson 8:4816c8449bf2 1231 * LoRaWAN network joined attribute
snelson 8:4816c8449bf2 1232 *
snelson 8:4816c8449bf2 1233 * Related MIB type: \ref MIB_NETWORK_JOINED
snelson 8:4816c8449bf2 1234 */
snelson 8:4816c8449bf2 1235 bool IsNetworkJoined;
snelson 8:4816c8449bf2 1236 /*!
snelson 8:4816c8449bf2 1237 * Activation state of ADR
snelson 8:4816c8449bf2 1238 *
snelson 8:4816c8449bf2 1239 * Related MIB type: \ref MIB_ADR
snelson 8:4816c8449bf2 1240 */
snelson 8:4816c8449bf2 1241 bool AdrEnable;
snelson 8:4816c8449bf2 1242 /*!
snelson 8:4816c8449bf2 1243 * Network identifier
snelson 8:4816c8449bf2 1244 *
snelson 8:4816c8449bf2 1245 * Related MIB type: \ref MIB_NET_ID
snelson 8:4816c8449bf2 1246 */
snelson 8:4816c8449bf2 1247 uint32_t NetID;
snelson 8:4816c8449bf2 1248 /*!
snelson 8:4816c8449bf2 1249 * End-device address
snelson 8:4816c8449bf2 1250 *
snelson 8:4816c8449bf2 1251 * Related MIB type: \ref MIB_DEV_ADDR
snelson 8:4816c8449bf2 1252 */
snelson 8:4816c8449bf2 1253 uint32_t DevAddr;
snelson 8:4816c8449bf2 1254 /*!
snelson 8:4816c8449bf2 1255 * Network session key
snelson 8:4816c8449bf2 1256 *
snelson 8:4816c8449bf2 1257 * Related MIB type: \ref MIB_NWK_SKEY
snelson 8:4816c8449bf2 1258 */
snelson 8:4816c8449bf2 1259 uint8_t *NwkSKey;
snelson 8:4816c8449bf2 1260 /*!
snelson 8:4816c8449bf2 1261 * Application session key
snelson 8:4816c8449bf2 1262 *
snelson 8:4816c8449bf2 1263 * Related MIB type: \ref MIB_APP_SKEY
snelson 8:4816c8449bf2 1264 */
snelson 8:4816c8449bf2 1265 uint8_t *AppSKey;
snelson 8:4816c8449bf2 1266 /*!
snelson 8:4816c8449bf2 1267 * Enable or disable a public network
snelson 8:4816c8449bf2 1268 *
snelson 8:4816c8449bf2 1269 * Related MIB type: \ref MIB_PUBLIC_NETWORK
snelson 8:4816c8449bf2 1270 */
snelson 8:4816c8449bf2 1271 bool EnablePublicNetwork;
snelson 8:4816c8449bf2 1272 /*!
snelson 8:4816c8449bf2 1273 * Enable or disable repeater support
snelson 8:4816c8449bf2 1274 *
snelson 8:4816c8449bf2 1275 * Related MIB type: \ref MIB_REPEATER_SUPPORT
snelson 8:4816c8449bf2 1276 */
snelson 8:4816c8449bf2 1277 bool EnableRepeaterSupport;
snelson 8:4816c8449bf2 1278 /*!
snelson 8:4816c8449bf2 1279 * LoRaWAN Channel
snelson 8:4816c8449bf2 1280 *
snelson 8:4816c8449bf2 1281 * Related MIB type: \ref MIB_CHANNELS
snelson 8:4816c8449bf2 1282 */
snelson 8:4816c8449bf2 1283 ChannelParams_t* ChannelList;
snelson 8:4816c8449bf2 1284 /*!
snelson 8:4816c8449bf2 1285 * Channel for the receive window 2
snelson 8:4816c8449bf2 1286 *
snelson 8:4816c8449bf2 1287 * Related MIB type: \ref MIB_RX2_CHANNEL
snelson 8:4816c8449bf2 1288 */
snelson 8:4816c8449bf2 1289 Rx2ChannelParams_t Rx2Channel;
snelson 8:4816c8449bf2 1290 /*!
snelson 8:4816c8449bf2 1291 * Channel mask
snelson 8:4816c8449bf2 1292 *
snelson 8:4816c8449bf2 1293 * Related MIB type: \ref MIB_CHANNELS_MASK
snelson 8:4816c8449bf2 1294 */
snelson 8:4816c8449bf2 1295 uint16_t* ChannelsMask;
snelson 8:4816c8449bf2 1296 /*!
snelson 8:4816c8449bf2 1297 * Number of frame repetitions
snelson 8:4816c8449bf2 1298 *
snelson 8:4816c8449bf2 1299 * Related MIB type: \ref MIB_CHANNELS_NB_REP
snelson 8:4816c8449bf2 1300 */
snelson 8:4816c8449bf2 1301 uint8_t ChannelNbRep;
snelson 8:4816c8449bf2 1302 /*!
snelson 8:4816c8449bf2 1303 * Maximum receive window duration
snelson 8:4816c8449bf2 1304 *
snelson 8:4816c8449bf2 1305 * Related MIB type: \ref MIB_MAX_RX_WINDOW_DURATION
snelson 8:4816c8449bf2 1306 */
snelson 8:4816c8449bf2 1307 uint32_t MaxRxWindow;
snelson 8:4816c8449bf2 1308 /*!
snelson 8:4816c8449bf2 1309 * Receive delay 1
snelson 8:4816c8449bf2 1310 *
snelson 8:4816c8449bf2 1311 * Related MIB type: \ref MIB_RECEIVE_DELAY_1
snelson 8:4816c8449bf2 1312 */
snelson 8:4816c8449bf2 1313 uint32_t ReceiveDelay1;
snelson 8:4816c8449bf2 1314 /*!
snelson 8:4816c8449bf2 1315 * Receive delay 2
snelson 8:4816c8449bf2 1316 *
snelson 8:4816c8449bf2 1317 * Related MIB type: \ref MIB_RECEIVE_DELAY_2
snelson 8:4816c8449bf2 1318 */
snelson 8:4816c8449bf2 1319 uint32_t ReceiveDelay2;
snelson 8:4816c8449bf2 1320 /*!
snelson 8:4816c8449bf2 1321 * Join accept delay 1
snelson 8:4816c8449bf2 1322 *
snelson 8:4816c8449bf2 1323 * Related MIB type: \ref MIB_JOIN_ACCEPT_DELAY_1
snelson 8:4816c8449bf2 1324 */
snelson 8:4816c8449bf2 1325 uint32_t JoinAcceptDelay1;
snelson 8:4816c8449bf2 1326 /*!
snelson 8:4816c8449bf2 1327 * Join accept delay 2
snelson 8:4816c8449bf2 1328 *
snelson 8:4816c8449bf2 1329 * Related MIB type: \ref MIB_JOIN_ACCEPT_DELAY_2
snelson 8:4816c8449bf2 1330 */
snelson 8:4816c8449bf2 1331 uint32_t JoinAcceptDelay2;
snelson 8:4816c8449bf2 1332 /*!
snelson 8:4816c8449bf2 1333 * Channels data rate
snelson 8:4816c8449bf2 1334 *
snelson 8:4816c8449bf2 1335 * Related MIB type: \ref MIB_CHANNELS_DEFAULT_DATARATE
snelson 8:4816c8449bf2 1336 */
snelson 8:4816c8449bf2 1337 int8_t ChannelsDefaultDatarate;
snelson 8:4816c8449bf2 1338 /*!
snelson 8:4816c8449bf2 1339 * Channels data rate
snelson 8:4816c8449bf2 1340 *
snelson 8:4816c8449bf2 1341 * Related MIB type: \ref MIB_CHANNELS_DATARATE
snelson 8:4816c8449bf2 1342 */
snelson 8:4816c8449bf2 1343 int8_t ChannelsDatarate;
snelson 8:4816c8449bf2 1344 /*!
snelson 8:4816c8449bf2 1345 * Channels TX power
snelson 8:4816c8449bf2 1346 *
snelson 8:4816c8449bf2 1347 * Related MIB type: \ref MIB_CHANNELS_TX_POWER
snelson 8:4816c8449bf2 1348 */
snelson 8:4816c8449bf2 1349 int8_t ChannelsTxPower;
snelson 8:4816c8449bf2 1350 /*!
snelson 8:4816c8449bf2 1351 * LoRaWAN Up-link counter
snelson 8:4816c8449bf2 1352 *
snelson 8:4816c8449bf2 1353 * Related MIB type: \ref MIB_UPLINK_COUNTER
snelson 8:4816c8449bf2 1354 */
snelson 8:4816c8449bf2 1355 uint32_t UpLinkCounter;
snelson 8:4816c8449bf2 1356 /*!
snelson 8:4816c8449bf2 1357 * LoRaWAN Down-link counter
snelson 8:4816c8449bf2 1358 *
snelson 8:4816c8449bf2 1359 * Related MIB type: \ref MIB_DOWNLINK_COUNTER
snelson 8:4816c8449bf2 1360 */
snelson 8:4816c8449bf2 1361 uint32_t DownLinkCounter;
snelson 8:4816c8449bf2 1362 /*!
snelson 8:4816c8449bf2 1363 * Multicast channel
snelson 8:4816c8449bf2 1364 *
snelson 8:4816c8449bf2 1365 * Related MIB type: \ref MIB_MULTICAST_CHANNEL
snelson 8:4816c8449bf2 1366 */
snelson 8:4816c8449bf2 1367 MulticastParams_t* MulticastList;
snelson 8:4816c8449bf2 1368 }MibParam_t;
snelson 8:4816c8449bf2 1369
snelson 8:4816c8449bf2 1370 /*!
snelson 8:4816c8449bf2 1371 * LoRaMAC MIB-RequestConfirm structure
snelson 8:4816c8449bf2 1372 */
snelson 8:4816c8449bf2 1373 typedef struct eMibRequestConfirm
snelson 8:4816c8449bf2 1374 {
snelson 8:4816c8449bf2 1375 /*!
snelson 8:4816c8449bf2 1376 * MIB-Request type
snelson 8:4816c8449bf2 1377 */
snelson 8:4816c8449bf2 1378 Mib_t Type;
snelson 8:4816c8449bf2 1379
snelson 8:4816c8449bf2 1380 /*!
snelson 8:4816c8449bf2 1381 * MLME-RequestConfirm parameters
snelson 8:4816c8449bf2 1382 */
snelson 8:4816c8449bf2 1383 MibParam_t Param;
snelson 8:4816c8449bf2 1384 }MibRequestConfirm_t;
snelson 8:4816c8449bf2 1385
snelson 8:4816c8449bf2 1386 /*!
snelson 8:4816c8449bf2 1387 * LoRaMAC tx information
snelson 8:4816c8449bf2 1388 */
snelson 8:4816c8449bf2 1389 typedef struct sLoRaMacTxInfo
snelson 8:4816c8449bf2 1390 {
snelson 8:4816c8449bf2 1391 /*!
snelson 8:4816c8449bf2 1392 * Defines the size of the applicative payload which can be processed
snelson 8:4816c8449bf2 1393 */
snelson 8:4816c8449bf2 1394 uint8_t MaxPossiblePayload;
snelson 8:4816c8449bf2 1395 /*!
snelson 8:4816c8449bf2 1396 * The current payload size, dependent on the current datarate
snelson 8:4816c8449bf2 1397 */
snelson 8:4816c8449bf2 1398 uint8_t CurrentPayloadSize;
snelson 8:4816c8449bf2 1399 }LoRaMacTxInfo_t;
snelson 8:4816c8449bf2 1400
snelson 8:4816c8449bf2 1401 /*!
snelson 8:4816c8449bf2 1402 * LoRaMAC Status
snelson 8:4816c8449bf2 1403 */
snelson 8:4816c8449bf2 1404 typedef enum eLoRaMacStatus
snelson 8:4816c8449bf2 1405 {
snelson 8:4816c8449bf2 1406 /*!
snelson 8:4816c8449bf2 1407 * Service started successfully
snelson 8:4816c8449bf2 1408 */
snelson 8:4816c8449bf2 1409 LORAMAC_STATUS_OK,
snelson 8:4816c8449bf2 1410 /*!
snelson 8:4816c8449bf2 1411 * Service not started - LoRaMAC is busy
snelson 8:4816c8449bf2 1412 */
snelson 8:4816c8449bf2 1413 LORAMAC_STATUS_BUSY,
snelson 8:4816c8449bf2 1414 /*!
snelson 8:4816c8449bf2 1415 * Service unknown
snelson 8:4816c8449bf2 1416 */
snelson 8:4816c8449bf2 1417 LORAMAC_STATUS_SERVICE_UNKNOWN,
snelson 8:4816c8449bf2 1418 /*!
snelson 8:4816c8449bf2 1419 * Service not started - invalid parameter
snelson 8:4816c8449bf2 1420 */
snelson 8:4816c8449bf2 1421 LORAMAC_STATUS_PARAMETER_INVALID,
snelson 8:4816c8449bf2 1422 /*!
snelson 8:4816c8449bf2 1423 * Service not started - invalid frequency
snelson 8:4816c8449bf2 1424 */
snelson 8:4816c8449bf2 1425 LORAMAC_STATUS_FREQUENCY_INVALID,
snelson 8:4816c8449bf2 1426 /*!
snelson 8:4816c8449bf2 1427 * Service not started - invalid datarate
snelson 8:4816c8449bf2 1428 */
snelson 8:4816c8449bf2 1429 LORAMAC_STATUS_DATARATE_INVALID,
snelson 8:4816c8449bf2 1430 /*!
snelson 8:4816c8449bf2 1431 * Service not started - invalid frequency and datarate
snelson 8:4816c8449bf2 1432 */
snelson 8:4816c8449bf2 1433 LORAMAC_STATUS_FREQ_AND_DR_INVALID,
snelson 8:4816c8449bf2 1434 /*!
snelson 8:4816c8449bf2 1435 * Service not started - the device is not in a LoRaWAN
snelson 8:4816c8449bf2 1436 */
snelson 8:4816c8449bf2 1437 LORAMAC_STATUS_NO_NETWORK_JOINED,
snelson 8:4816c8449bf2 1438 /*!
snelson 8:4816c8449bf2 1439 * Service not started - playload lenght error
snelson 8:4816c8449bf2 1440 */
snelson 8:4816c8449bf2 1441 LORAMAC_STATUS_LENGTH_ERROR,
snelson 8:4816c8449bf2 1442 /*!
snelson 8:4816c8449bf2 1443 * Service not started - playload lenght error
snelson 8:4816c8449bf2 1444 */
snelson 8:4816c8449bf2 1445 LORAMAC_STATUS_MAC_CMD_LENGTH_ERROR,
snelson 8:4816c8449bf2 1446 /*!
snelson 8:4816c8449bf2 1447 * Service not started - the device is switched off
snelson 8:4816c8449bf2 1448 */
snelson 8:4816c8449bf2 1449 LORAMAC_STATUS_DEVICE_OFF,
snelson 8:4816c8449bf2 1450 /*!
snelson 8:4816c8449bf2 1451 * Service not started - transmit duty cycle exceeded
snelson 8:4816c8449bf2 1452 */
snelson 8:4816c8449bf2 1453 LORAMAC_STATUS_TX_DCYCLE_EXCEEDED,
snelson 8:4816c8449bf2 1454 }LoRaMacStatus_t;
snelson 8:4816c8449bf2 1455
snelson 8:4816c8449bf2 1456 /*!
snelson 8:4816c8449bf2 1457 * LoRaMAC events structure
snelson 8:4816c8449bf2 1458 * Used to notify upper layers of MAC events
snelson 8:4816c8449bf2 1459 */
snelson 8:4816c8449bf2 1460 typedef struct sLoRaMacPrimitives
snelson 8:4816c8449bf2 1461 {
snelson 8:4816c8449bf2 1462 /*!
snelson 8:4816c8449bf2 1463 * \brief MCPS-Confirm primitive
snelson 8:4816c8449bf2 1464 *
snelson 8:4816c8449bf2 1465 * \param [OUT] MCPS-Confirm parameters
snelson 8:4816c8449bf2 1466 */
snelson 8:4816c8449bf2 1467 void ( *MacMcpsConfirm )( McpsConfirm_t *McpsConfirm );
snelson 8:4816c8449bf2 1468 /*!
snelson 8:4816c8449bf2 1469 * \brief MCPS-Indication primitive
snelson 8:4816c8449bf2 1470 *
snelson 8:4816c8449bf2 1471 * \param [OUT] MCPS-Indication parameters
snelson 8:4816c8449bf2 1472 */
snelson 8:4816c8449bf2 1473 void ( *MacMcpsIndication )( McpsIndication_t *McpsIndication );
snelson 8:4816c8449bf2 1474 /*!
snelson 8:4816c8449bf2 1475 * \brief MLME-Confirm primitive
snelson 8:4816c8449bf2 1476 *
snelson 8:4816c8449bf2 1477 * \param [OUT] MLME-Confirm parameters
snelson 8:4816c8449bf2 1478 */
snelson 8:4816c8449bf2 1479 void ( *MacMlmeConfirm )( MlmeConfirm_t *MlmeConfirm );
snelson 8:4816c8449bf2 1480 }LoRaMacPrimitives_t;
snelson 8:4816c8449bf2 1481
snelson 8:4816c8449bf2 1482 typedef struct sLoRaMacCallback
snelson 8:4816c8449bf2 1483 {
snelson 8:4816c8449bf2 1484 /*!
snelson 8:4816c8449bf2 1485 * \brief Measures the battery level
snelson 8:4816c8449bf2 1486 *
snelson 8:4816c8449bf2 1487 * \retval Battery level [0: node is connected to an external
snelson 8:4816c8449bf2 1488 * power source, 1..254: battery level, where 1 is the minimum
snelson 8:4816c8449bf2 1489 * and 254 is the maximum value, 255: the node was not able
snelson 8:4816c8449bf2 1490 * to measure the battery level]
snelson 8:4816c8449bf2 1491 */
snelson 8:4816c8449bf2 1492 uint8_t ( *GetBatteryLevel )( void );
snelson 8:4816c8449bf2 1493 }LoRaMacCallback_t;
snelson 8:4816c8449bf2 1494
snelson 8:4816c8449bf2 1495
snelson 8:4816c8449bf2 1496 /*!
snelson 9:ad93de20d720 1497 * LoRaMAC Join Retransmission duty cycle structure
snelson 8:4816c8449bf2 1498 */
snelson 8:4816c8449bf2 1499 typedef struct sLoRaMacRetransmissionDCycle
snelson 8:4816c8449bf2 1500 {
snelson 8:4816c8449bf2 1501 TimerTime_t period; // Retransmission period in seconds
snelson 9:ad93de20d720 1502 TimerTime_t onAirTimeMax; // Max on air time in units returned by Radio.TimeOnAir()
snelson 8:4816c8449bf2 1503 } LoRaMacRetransmissionDCycle_t;
snelson 8:4816c8449bf2 1504
snelson 8:4816c8449bf2 1505
snelson 8:4816c8449bf2 1506 /*!
snelson 8:4816c8449bf2 1507 * \brief LoRaMAC layer initialization
snelson 8:4816c8449bf2 1508 *
snelson 8:4816c8449bf2 1509 * \details In addition to the initialization of the LoRaMAC layer, this
snelson 8:4816c8449bf2 1510 * function initializes the callback primitives of the MCPS and
snelson 8:4816c8449bf2 1511 * MLME services. Every data field of \ref LoRaMacPrimitives_t must be
snelson 8:4816c8449bf2 1512 * set to a valid callback function.
snelson 8:4816c8449bf2 1513 *
snelson 8:4816c8449bf2 1514 * \param [IN] events - Pointer to a structure defining the LoRaMAC
snelson 8:4816c8449bf2 1515 * event functions. Refer to \ref LoRaMacPrimitives_t.
snelson 8:4816c8449bf2 1516 *
snelson 8:4816c8449bf2 1517 * \param [IN] events - Pointer to a structure defining the LoRaMAC
snelson 8:4816c8449bf2 1518 * callback functions. Refer to \ref LoRaMacCallback_t.
snelson 8:4816c8449bf2 1519 *
snelson 8:4816c8449bf2 1520 * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
snelson 8:4816c8449bf2 1521 * returns are:
snelson 8:4816c8449bf2 1522 * \ref LORAMAC_STATUS_OK,
snelson 8:4816c8449bf2 1523 * \ref LORAMAC_STATUS_PARAMETER_INVALID.
snelson 8:4816c8449bf2 1524 */
snelson 8:4816c8449bf2 1525 LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacCallback_t *callbacks );
snelson 8:4816c8449bf2 1526
snelson 8:4816c8449bf2 1527 /*!
snelson 8:4816c8449bf2 1528 * \brief Queries the LoRaMAC if it is possible to send the next frame with
snelson 8:4816c8449bf2 1529 * a given payload size. The LoRaMAC takes scheduled MAC commands into
snelson 8:4816c8449bf2 1530 * account and reports, when the frame can be send or not.
snelson 8:4816c8449bf2 1531 *
snelson 8:4816c8449bf2 1532 * \param [IN] size - Size of applicative payload to be send next
snelson 8:4816c8449bf2 1533 *
snelson 8:4816c8449bf2 1534 * \param [OUT] txInfo - The structure \ref LoRaMacTxInfo_t contains
snelson 8:4816c8449bf2 1535 * information about the actual maximum payload possible
snelson 8:4816c8449bf2 1536 * ( according to the configured datarate or the next
snelson 8:4816c8449bf2 1537 * datarate according to ADR ), and the maximum frame
snelson 8:4816c8449bf2 1538 * size, taking the scheduled MAC commands into account.
snelson 8:4816c8449bf2 1539 *
snelson 8:4816c8449bf2 1540 * \retval LoRaMacStatus_t Status of the operation. When the parameters are
snelson 8:4816c8449bf2 1541 * not valid, the function returns \ref LORAMAC_STATUS_PARAMETER_INVALID.
snelson 8:4816c8449bf2 1542 * In case of a length error caused by the applicative payload size, the
snelson 8:4816c8449bf2 1543 * function returns LORAMAC_STATUS_LENGTH_ERROR. In case of a length error
snelson 8:4816c8449bf2 1544 * due to additional MAC commands in the queue, the function returns
snelson 8:4816c8449bf2 1545 * LORAMAC_STATUS_MAC_CMD_LENGTH_ERROR. In case the query is valid, and
snelson 8:4816c8449bf2 1546 * the LoRaMAC is able to send the frame, the function returns LORAMAC_STATUS_OK. *
snelson 8:4816c8449bf2 1547 */
snelson 8:4816c8449bf2 1548 LoRaMacStatus_t LoRaMacQueryTxPossible( uint8_t size, LoRaMacTxInfo_t* txInfo );
snelson 8:4816c8449bf2 1549
snelson 8:4816c8449bf2 1550 /*!
snelson 8:4816c8449bf2 1551 * \brief LoRaMAC channel add service
snelson 8:4816c8449bf2 1552 *
snelson 8:4816c8449bf2 1553 * \details Adds a new channel to the channel list and activates the id in
snelson 8:4816c8449bf2 1554 * the channel mask. For the US915 band, all channels are enabled
snelson 8:4816c8449bf2 1555 * by default. It is not possible to activate less than 6 125 kHz
snelson 8:4816c8449bf2 1556 * channels.
snelson 8:4816c8449bf2 1557 *
snelson 8:4816c8449bf2 1558 * \param [IN] id - Id of the channel. Possible values are:
snelson 8:4816c8449bf2 1559 *
snelson 8:4816c8449bf2 1560 * 0-15 for EU868
snelson 8:4816c8449bf2 1561 * 0-72 for US915
snelson 8:4816c8449bf2 1562 *
snelson 8:4816c8449bf2 1563 * \param [IN] params - Channel parameters to set.
snelson 8:4816c8449bf2 1564 *
snelson 8:4816c8449bf2 1565 * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
snelson 8:4816c8449bf2 1566 * \ref LORAMAC_STATUS_OK,
snelson 8:4816c8449bf2 1567 * \ref LORAMAC_STATUS_BUSY,
snelson 8:4816c8449bf2 1568 * \ref LORAMAC_STATUS_PARAMETER_INVALID.
snelson 8:4816c8449bf2 1569 */
snelson 8:4816c8449bf2 1570 LoRaMacStatus_t LoRaMacChannelAdd( uint8_t id, ChannelParams_t params );
snelson 8:4816c8449bf2 1571
snelson 8:4816c8449bf2 1572 /*!
snelson 8:4816c8449bf2 1573 * \brief LoRaMAC channel remove service
snelson 8:4816c8449bf2 1574 *
snelson 8:4816c8449bf2 1575 * \details Deactivates the id in the channel mask.
snelson 8:4816c8449bf2 1576 *
snelson 8:4816c8449bf2 1577 * \param [IN] id - Id of the channel.
snelson 8:4816c8449bf2 1578 *
snelson 8:4816c8449bf2 1579 * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
snelson 8:4816c8449bf2 1580 * \ref LORAMAC_STATUS_OK,
snelson 8:4816c8449bf2 1581 * \ref LORAMAC_STATUS_BUSY,
snelson 8:4816c8449bf2 1582 * \ref LORAMAC_STATUS_PARAMETER_INVALID.
snelson 8:4816c8449bf2 1583 */
snelson 8:4816c8449bf2 1584 LoRaMacStatus_t LoRaMacChannelRemove( uint8_t id );
snelson 8:4816c8449bf2 1585
snelson 8:4816c8449bf2 1586 /*!
snelson 8:4816c8449bf2 1587 * \brief LoRaMAC multicast channel link service
snelson 8:4816c8449bf2 1588 *
snelson 8:4816c8449bf2 1589 * \details Links a multicast channel into the linked list.
snelson 8:4816c8449bf2 1590 *
snelson 8:4816c8449bf2 1591 * \param [IN] channelParam - Multicast channel parameters to link.
snelson 8:4816c8449bf2 1592 *
snelson 8:4816c8449bf2 1593 * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
snelson 8:4816c8449bf2 1594 * \ref LORAMAC_STATUS_OK,
snelson 8:4816c8449bf2 1595 * \ref LORAMAC_STATUS_BUSY,
snelson 8:4816c8449bf2 1596 * \ref LORAMAC_STATUS_PARAMETER_INVALID.
snelson 8:4816c8449bf2 1597 */
snelson 8:4816c8449bf2 1598 LoRaMacStatus_t LoRaMacMulticastChannelLink( MulticastParams_t *channelParam );
snelson 8:4816c8449bf2 1599
snelson 8:4816c8449bf2 1600 /*!
snelson 8:4816c8449bf2 1601 * \brief LoRaMAC multicast channel unlink service
snelson 8:4816c8449bf2 1602 *
snelson 8:4816c8449bf2 1603 * \details Unlinks a multicast channel from the linked list.
snelson 8:4816c8449bf2 1604 *
snelson 8:4816c8449bf2 1605 * \param [IN] channelParam - Multicast channel parameters to unlink.
snelson 8:4816c8449bf2 1606 *
snelson 8:4816c8449bf2 1607 * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
snelson 8:4816c8449bf2 1608 * \ref LORAMAC_STATUS_OK,
snelson 8:4816c8449bf2 1609 * \ref LORAMAC_STATUS_BUSY,
snelson 8:4816c8449bf2 1610 * \ref LORAMAC_STATUS_PARAMETER_INVALID.
snelson 8:4816c8449bf2 1611 */
snelson 8:4816c8449bf2 1612 LoRaMacStatus_t LoRaMacMulticastChannelUnlink( MulticastParams_t *channelParam );
snelson 8:4816c8449bf2 1613
snelson 8:4816c8449bf2 1614 /*!
snelson 8:4816c8449bf2 1615 * \brief LoRaMAC MIB-Get
snelson 8:4816c8449bf2 1616 *
snelson 8:4816c8449bf2 1617 * \details The mac information base service to get attributes of the LoRaMac
snelson 8:4816c8449bf2 1618 * layer.
snelson 8:4816c8449bf2 1619 *
snelson 8:4816c8449bf2 1620 * The following code-snippet shows how to use the API to get the
snelson 8:4816c8449bf2 1621 * parameter AdrEnable, defined by the enumeration type
snelson 8:4816c8449bf2 1622 * \ref MIB_ADR.
snelson 8:4816c8449bf2 1623 * \code
snelson 8:4816c8449bf2 1624 * MibRequestConfirm_t mibReq;
snelson 8:4816c8449bf2 1625 * mibReq.Type = MIB_ADR;
snelson 8:4816c8449bf2 1626 *
snelson 8:4816c8449bf2 1627 * if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK )
snelson 8:4816c8449bf2 1628 * {
snelson 8:4816c8449bf2 1629 * // LoRaMAC updated the parameter mibParam.AdrEnable
snelson 8:4816c8449bf2 1630 * }
snelson 8:4816c8449bf2 1631 * \endcode
snelson 8:4816c8449bf2 1632 *
snelson 8:4816c8449bf2 1633 * \param [IN] mibRequest - MIB-GET-Request to perform. Refer to \ref MibRequestConfirm_t.
snelson 8:4816c8449bf2 1634 *
snelson 8:4816c8449bf2 1635 * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
snelson 8:4816c8449bf2 1636 * \ref LORAMAC_STATUS_OK,
snelson 8:4816c8449bf2 1637 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN,
snelson 8:4816c8449bf2 1638 * \ref LORAMAC_STATUS_PARAMETER_INVALID.
snelson 8:4816c8449bf2 1639 */
snelson 8:4816c8449bf2 1640 LoRaMacStatus_t LoRaMacMibGetRequestConfirm( MibRequestConfirm_t *mibGet );
snelson 8:4816c8449bf2 1641
snelson 8:4816c8449bf2 1642 /*!
snelson 8:4816c8449bf2 1643 * \brief LoRaMAC MIB-Set
snelson 8:4816c8449bf2 1644 *
snelson 8:4816c8449bf2 1645 * \details The mac information base service to set attributes of the LoRaMac
snelson 8:4816c8449bf2 1646 * layer.
snelson 8:4816c8449bf2 1647 *
snelson 8:4816c8449bf2 1648 * The following code-snippet shows how to use the API to set the
snelson 8:4816c8449bf2 1649 * parameter AdrEnable, defined by the enumeration type
snelson 8:4816c8449bf2 1650 * \ref MIB_ADR.
snelson 8:4816c8449bf2 1651 *
snelson 8:4816c8449bf2 1652 * \code
snelson 8:4816c8449bf2 1653 * MibRequestConfirm_t mibReq;
snelson 8:4816c8449bf2 1654 * mibReq.Type = MIB_ADR;
snelson 8:4816c8449bf2 1655 * mibReq.Param.AdrEnable = true;
snelson 8:4816c8449bf2 1656 *
snelson 8:4816c8449bf2 1657 * if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK )
snelson 8:4816c8449bf2 1658 * {
snelson 8:4816c8449bf2 1659 * // LoRaMAC updated the parameter
snelson 8:4816c8449bf2 1660 * }
snelson 8:4816c8449bf2 1661 * \endcode
snelson 8:4816c8449bf2 1662 *
snelson 8:4816c8449bf2 1663 * \param [IN] mibRequest - MIB-SET-Request to perform. Refer to \ref MibRequestConfirm_t.
snelson 8:4816c8449bf2 1664 *
snelson 8:4816c8449bf2 1665 * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
snelson 8:4816c8449bf2 1666 * \ref LORAMAC_STATUS_OK,
snelson 8:4816c8449bf2 1667 * \ref LORAMAC_STATUS_BUSY,
snelson 8:4816c8449bf2 1668 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN,
snelson 8:4816c8449bf2 1669 * \ref LORAMAC_STATUS_PARAMETER_INVALID.
snelson 8:4816c8449bf2 1670 */
snelson 8:4816c8449bf2 1671 LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t *mibSet );
snelson 8:4816c8449bf2 1672
snelson 8:4816c8449bf2 1673 /*!
snelson 8:4816c8449bf2 1674 * \brief LoRaMAC MLME-Request
snelson 8:4816c8449bf2 1675 *
snelson 8:4816c8449bf2 1676 * \details The Mac layer management entity handles management services. The
snelson 8:4816c8449bf2 1677 * following code-snippet shows how to use the API to perform a
snelson 8:4816c8449bf2 1678 * network join request.
snelson 8:4816c8449bf2 1679 *
snelson 8:4816c8449bf2 1680 * \code
snelson 8:4816c8449bf2 1681 * static uint8_t DevEui[] =
snelson 8:4816c8449bf2 1682 * {
snelson 8:4816c8449bf2 1683 * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
snelson 8:4816c8449bf2 1684 * };
snelson 8:4816c8449bf2 1685 * static uint8_t AppEui[] =
snelson 8:4816c8449bf2 1686 * {
snelson 8:4816c8449bf2 1687 * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
snelson 8:4816c8449bf2 1688 * };
snelson 8:4816c8449bf2 1689 * static uint8_t AppKey[] =
snelson 8:4816c8449bf2 1690 * {
snelson 8:4816c8449bf2 1691 * 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
snelson 8:4816c8449bf2 1692 * 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
snelson 8:4816c8449bf2 1693 * };
snelson 8:4816c8449bf2 1694 *
snelson 8:4816c8449bf2 1695 * MlmeReq_t mlmeReq;
snelson 8:4816c8449bf2 1696 * mlmeReq.Type = MLME_JOIN;
snelson 8:4816c8449bf2 1697 * mlmeReq.Req.Join.DevEui = DevEui;
snelson 8:4816c8449bf2 1698 * mlmeReq.Req.Join.AppEui = AppEui;
snelson 8:4816c8449bf2 1699 * mlmeReq.Req.Join.AppKey = AppKey;
snelson 8:4816c8449bf2 1700 *
snelson 8:4816c8449bf2 1701 * if( LoRaMacMlmeRequest( &mlmeReq ) == LORAMAC_STATUS_OK )
snelson 8:4816c8449bf2 1702 * {
snelson 8:4816c8449bf2 1703 * // Service started successfully. Waiting for the Mlme-Confirm event
snelson 8:4816c8449bf2 1704 * }
snelson 8:4816c8449bf2 1705 * \endcode
snelson 8:4816c8449bf2 1706 *
snelson 8:4816c8449bf2 1707 * \param [IN] mlmeRequest - MLME-Request to perform. Refer to \ref MlmeReq_t.
snelson 8:4816c8449bf2 1708 *
snelson 8:4816c8449bf2 1709 * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
snelson 8:4816c8449bf2 1710 * \ref LORAMAC_STATUS_OK,
snelson 8:4816c8449bf2 1711 * \ref LORAMAC_STATUS_BUSY,
snelson 8:4816c8449bf2 1712 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN,
snelson 8:4816c8449bf2 1713 * \ref LORAMAC_STATUS_PARAMETER_INVALID,
snelson 8:4816c8449bf2 1714 * \ref LORAMAC_STATUS_NO_NETWORK_JOINED,
snelson 8:4816c8449bf2 1715 * \ref LORAMAC_STATUS_LENGTH_ERROR,
snelson 8:4816c8449bf2 1716 * \ref LORAMAC_STATUS_DEVICE_OFF.
snelson 8:4816c8449bf2 1717 */
snelson 8:4816c8449bf2 1718 LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t *mlmeRequest );
snelson 8:4816c8449bf2 1719
snelson 8:4816c8449bf2 1720 /*!
snelson 8:4816c8449bf2 1721 * \brief LoRaMAC MCPS-Request
snelson 8:4816c8449bf2 1722 *
snelson 8:4816c8449bf2 1723 * \details The Mac Common Part Sublayer handles data services. The following
snelson 8:4816c8449bf2 1724 * code-snippet shows how to use the API to send an unconfirmed
snelson 8:4816c8449bf2 1725 * LoRaMAC frame.
snelson 8:4816c8449bf2 1726 *
snelson 8:4816c8449bf2 1727 * \code
snelson 8:4816c8449bf2 1728 * uint8_t myBuffer[] = { 1, 2, 3 };
snelson 8:4816c8449bf2 1729 *
snelson 8:4816c8449bf2 1730 * McpsReq_t mcpsReq;
snelson 8:4816c8449bf2 1731 * mcpsReq.Type = MCPS_UNCONFIRMED;
snelson 8:4816c8449bf2 1732 * mcpsReq.Req.Unconfirmed.fPort = 1;
snelson 8:4816c8449bf2 1733 * mcpsReq.Req.Unconfirmed.fBuffer = myBuffer;
snelson 8:4816c8449bf2 1734 * mcpsReq.Req.Unconfirmed.fBufferSize = sizeof( myBuffer );
snelson 8:4816c8449bf2 1735 *
snelson 8:4816c8449bf2 1736 * if( LoRaMacMcpsRequest( &mcpsReq ) == LORAMAC_STATUS_OK )
snelson 8:4816c8449bf2 1737 * {
snelson 8:4816c8449bf2 1738 * // Service started successfully. Waiting for the MCPS-Confirm event
snelson 8:4816c8449bf2 1739 * }
snelson 8:4816c8449bf2 1740 * \endcode
snelson 8:4816c8449bf2 1741 *
snelson 8:4816c8449bf2 1742 * \param [IN] mcpsRequest - MCPS-Request to perform. Refer to \ref McpsReq_t.
snelson 8:4816c8449bf2 1743 *
snelson 8:4816c8449bf2 1744 * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
snelson 8:4816c8449bf2 1745 * \ref LORAMAC_STATUS_OK,
snelson 8:4816c8449bf2 1746 * \ref LORAMAC_STATUS_BUSY,
snelson 8:4816c8449bf2 1747 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN,
snelson 8:4816c8449bf2 1748 * \ref LORAMAC_STATUS_PARAMETER_INVALID,
snelson 8:4816c8449bf2 1749 * \ref LORAMAC_STATUS_NO_NETWORK_JOINED,
snelson 8:4816c8449bf2 1750 * \ref LORAMAC_STATUS_LENGTH_ERROR,
snelson 8:4816c8449bf2 1751 * \ref LORAMAC_STATUS_DEVICE_OFF.
snelson 8:4816c8449bf2 1752 */
snelson 8:4816c8449bf2 1753 LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t *mcpsRequest );
snelson 8:4816c8449bf2 1754
snelson 8:4816c8449bf2 1755 /*!
snelson 8:4816c8449bf2 1756 * \brief Get LoRaMAC Join Request Retransmission Backoff time
snelson 8:4816c8449bf2 1757 *
snelson 8:4816c8449bf2 1758 * \retval Retransmission backoff time remaining until next
snelson 8:4816c8449bf2 1759 * join request can be sent
snelson 8:4816c8449bf2 1760 */
snelson 8:4816c8449bf2 1761 TimerTime_t LoRaMacCalcJoinBackOff( );
snelson 8:4816c8449bf2 1762
snelson 9:ad93de20d720 1763
snelson 8:4816c8449bf2 1764
snelson 8:4816c8449bf2 1765
snelson 8:4816c8449bf2 1766 /*! \} defgroup LORAMAC */
snelson 8:4816c8449bf2 1767
snelson 8:4816c8449bf2 1768 #endif // __LORAMAC_H__