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:
Mon Jul 13 09:15:59 2020 -0700
Revision:
35:be452a242876
Parent:
34:9c8966cd66a2
remove old crypto

Who changed what in which revision?

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