end node on synchronous star LoRa network.

Dependencies:   SX127x sx12xx_hal TSL2561

radio chip selection

Radio chip driver is not included, allowing choice of radio device.
If you're using SX1272 or SX1276, then import sx127x driver into your program.
if you're using SX1261 or SX1262, then import sx126x driver into your program.
if you're using SX1280, then import sx1280 driver into your program.
If you're using NAmote72 or Murata discovery, then you must import only sx127x driver.

This project for use with LoRaWAN_singlechannel_gateway project.

Alternately gateway running on raspberry pi can be used as gateway.

LoRaWAN on single radio channel

Network description is at gateway project page. Synchronous star network.

Hardware Support

This project supports SX1276 and SX1272, sx126x kit, sx126x shield, and sx128x 2.4GHz. The ST board B-L072Z-LRWAN1 is also supported (TypeABZ module). When B-L072Z-LRWAN1 target is selected, TARGET_DISCO_L072CZ_LRWAN1 is defined by tools, allowing correct radio driver configuration for this platform. Alternately, any mbed board that can use LoRa radio shield board should work, but NUCLEO boards are tested.

End-node Unique ID

DevEUI is created from CPU serial number. AppEUI and AppKey are declared as software constants.

End-node Configuration

Data rate definition LORAMAC_DEFAULT_DATARATE configured in LoRaMac-definitions.h. See gateway project page for configuration of gateway.
LoRaWAN addressing is configured in Comissioning.h; only OTA mode is functional.
Header file board/lora_config.h, selects application layer options (i.e. sensors) to be compiled in.

Serial Interface

Serial port operates at 115200bps.
Application layer single_us915_main.cpp User button triggers uplink (i.e. blue button on nucleo board), or jumper enables continuously sends repeated uplink packets. The MAC layer holds each uplink request until the allocated timeslot.

commandargumentsdescription
?-print available commands
. (period)-print status (DevEUI, DevAddr, etc)
ullength integerset payload length of test uplink packets

sensor demo

Selected grove sensors may be plugged into SX1272 shield.
To enable, edit lora_config.h to define SENSORS.

Sensor connections on SX1272MB2xAS:

D8 D9: buttonRX TX: (unused)A3 A4: Rotary Angle Sensor
D6 D7: RGB LEDSCL SDA: digital light sensorA1 A2: Rotary Angle Sensor

Digital input pin, state reported via uplink: PC8
Digital output pin, controlled via downlink: PC6
PWM out: PB_10

Jumper enables auto-repeated transmit: PC10 and PC12 on NUCLEO board, located on end of morpho headers nearby JP4.

Committer:
Wayne Roberts
Date:
Fri Dec 07 17:57:41 2018 -0800
Revision:
29:ad409c68c0a6
Parent:
25:fed9d5b77183
Child:
30:1c35c4f56e50
update to latest radio HAL

Who changed what in which revision?

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