1 /*! 2 * \file LoRaMacMessageTypes.h 3 * 4 * \brief LoRa MAC layer message type definitions 5 * 6 * \copyright Revised BSD License, see section \ref LICENSE. 7 * 8 * \code 9 * ______ _ 10 * / _____) _ | | 11 * ( (____ _____ ____ _| |_ _____ ____| |__ 12 * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 * _____) ) ____| | | || |_| ____( (___| | | | 14 * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 * (C)2013 Semtech 16 * 17 * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 * embedded.connectivity.solutions=============== 22 * 23 * \endcode 24 * 25 * \author Miguel Luis ( Semtech ) 26 * 27 * \author Gregory Cristian ( Semtech ) 28 * 29 * \author Daniel Jaeckle ( STACKFORCE ) 30 * 31 * \author Johannes Bruder ( STACKFORCE ) 32 * 33 * addtogroup LORAMAC 34 * \{ 35 * 36 */ 37 #ifndef __LORAMAC_MESSAGE_TYPES_H__ 38 #define __LORAMAC_MESSAGE_TYPES_H__ 39 40 #ifdef __cplusplus 41 extern "C" 42 { 43 #endif 44 45 #include <stdint.h> 46 #include "LoRaMacHeaderTypes.h" 47 48 /*! 49 * LoRaMac type for Join-request message 50 */ 51 typedef struct sLoRaMacMessageJoinRequest 52 { 53 /*! 54 * Serialized message buffer 55 */ 56 uint8_t* Buffer; 57 /*! 58 * Size of serialized message buffer 59 */ 60 uint8_t BufSize; 61 /*! 62 * MAC header 63 */ 64 LoRaMacHeader_t MHDR; 65 /*! 66 * Join EUI 67 */ 68 uint8_t JoinEUI[LORAMAC_JOIN_EUI_FIELD_SIZE]; 69 /*! 70 * Device EUI 71 */ 72 uint8_t DevEUI[LORAMAC_DEV_EUI_FIELD_SIZE]; 73 /*! 74 * Device Nonce 75 */ 76 uint16_t DevNonce; 77 /*! 78 * Message integrity code (MIC) 79 */ 80 uint32_t MIC; 81 }LoRaMacMessageJoinRequest_t; 82 83 /*! 84 * LoRaMac type for rejoin-request type 1 message 85 */ 86 typedef struct sLoRaMacMessageReJoinType1 87 { 88 /*! 89 * Serialized message buffer 90 */ 91 uint8_t* Buffer; 92 /*! 93 * Size of serialized message buffer 94 */ 95 uint8_t BufSize; 96 /*! 97 * MAC header 98 */ 99 LoRaMacHeader_t MHDR; 100 /*! 101 * Rejoin-request type ( 1 ) 102 */ 103 uint8_t ReJoinType; 104 /*! 105 * Join EUI 106 */ 107 uint8_t JoinEUI[LORAMAC_JOIN_EUI_FIELD_SIZE]; 108 /*! 109 * Device EUI 110 */ 111 uint8_t DevEUI[LORAMAC_DEV_EUI_FIELD_SIZE]; 112 /*! 113 * ReJoin Type 1 counter 114 */ 115 uint16_t RJcount1; 116 /*! 117 * Message integrity code (MIC) 118 */ 119 uint32_t MIC; 120 }LoRaMacMessageReJoinType1_t; 121 122 /*! 123 * LoRaMac type for rejoin-request type 0 or 2 message 124 */ 125 typedef struct sLoRaMacMessageReJoinType0or2 126 { 127 /*! 128 * Serialized message buffer 129 */ 130 uint8_t* Buffer; 131 /*! 132 * Size of serialized message buffer 133 */ 134 uint8_t BufSize; 135 /*! 136 * MAC header 137 */ 138 LoRaMacHeader_t MHDR; 139 /*! 140 * Rejoin-request type ( 0 or 2 ) 141 */ 142 uint8_t ReJoinType; 143 /*! 144 * Network ID ( 3 bytes ) 145 */ 146 uint8_t NetID[LORAMAC_NET_ID_FIELD_SIZE]; 147 /*! 148 * Device EUI 149 */ 150 uint8_t DevEUI[LORAMAC_DEV_EUI_FIELD_SIZE]; 151 /*! 152 * ReJoin Type 0 and 2 frame counter 153 */ 154 uint16_t RJcount0; 155 /*! 156 * Message integrity code (MIC) 157 */ 158 uint32_t MIC; 159 }LoRaMacMessageReJoinType0or2_t; 160 161 /*! 162 * LoRaMac type for Join-accept message 163 */ 164 typedef struct sLoRaMacMessageJoinAccept 165 { 166 /*! 167 * Serialized message buffer 168 */ 169 uint8_t* Buffer; 170 /*! 171 * Size of serialized message buffer 172 */ 173 uint8_t BufSize; 174 /*! 175 * MAC header 176 */ 177 LoRaMacHeader_t MHDR; 178 /*! 179 * Server Nonce ( 3 bytes ) 180 */ 181 uint8_t JoinNonce[LORAMAC_JOIN_NONCE_FIELD_SIZE]; 182 /*! 183 * Network ID ( 3 bytes ) 184 */ 185 uint8_t NetID[LORAMAC_NET_ID_FIELD_SIZE]; 186 /*! 187 * Device address 188 */ 189 uint32_t DevAddr; 190 /*! 191 * Device address 192 */ 193 LoRaMacDLSettings_t DLSettings; 194 /*! 195 * Delay between TX and RX 196 */ 197 uint8_t RxDelay; 198 /*! 199 * List of channel frequencies (opt.) 200 */ 201 uint8_t CFList[16]; 202 /*! 203 * Message integrity code (MIC) 204 */ 205 uint32_t MIC; 206 }LoRaMacMessageJoinAccept_t; 207 208 209 /*! 210 * LoRaMac type for Data MAC messages 211 * (Unconfirmed Data Up, Confirmed Data Up, Unconfirmed Data Down, Confirmed Data Down) 212 */ 213 typedef struct sLoRaMacMessageData 214 { 215 /*! 216 * Serialized message buffer 217 */ 218 uint8_t* Buffer; 219 /*! 220 * Size of serialized message buffer 221 */ 222 uint8_t BufSize; 223 /*! 224 * MAC header 225 */ 226 LoRaMacHeader_t MHDR; 227 /*! 228 * Frame header (FHDR) 229 */ 230 LoRaMacFrameHeader_t FHDR; 231 /*! 232 * Port field (opt.) 233 */ 234 uint8_t FPort; 235 /*! 236 * Frame payload may contain MAC commands or data (opt.) 237 */ 238 uint8_t* FRMPayload; 239 /*! 240 * Size of frame payload (not included in LoRaMac messages) 241 */ 242 uint8_t FRMPayloadSize; 243 /*! 244 * Message integrity code (MIC) 245 */ 246 uint32_t MIC; 247 }LoRaMacMessageData_t; 248 249 /*! 250 * LoRaMac message type enumerator 251 */ 252 typedef enum eLoRaMacMessageType 253 { 254 /*! 255 * Join-request message 256 */ 257 LORAMAC_MSG_TYPE_JOIN_REQUEST, 258 /*! 259 * Rejoin-request type 1 message 260 */ 261 LORAMAC_MSG_TYPE_RE_JOIN_1, 262 /*! 263 * Rejoin-request type 1 message 264 */ 265 LORAMAC_MSG_TYPE_RE_JOIN_0_2, 266 /*! 267 * Join-accept message 268 */ 269 LORAMAC_MSG_TYPE_JOIN_ACCEPT, 270 /*! 271 * Data MAC messages 272 */ 273 LORAMAC_MSG_TYPE_DATA, 274 /*! 275 * Undefined message type 276 */ 277 LORAMAC_MSG_TYPE_UNDEF, 278 }LoRaMacMessageType_t; 279 280 /*! 281 * LoRaMac general message type 282 */ 283 typedef struct sLoRaMacMessage 284 { 285 LoRaMacMessageType_t Type; 286 union uMessage 287 { 288 LoRaMacMessageJoinRequest_t JoinReq; 289 LoRaMacMessageReJoinType1_t ReJoin1; 290 LoRaMacMessageReJoinType0or2_t ReJoin0or2; 291 LoRaMacMessageJoinAccept_t JoinAccept; 292 LoRaMacMessageData_t Data; 293 }Message; 294 }LoRaMacMessage_t; 295 296 /*! \} addtogroup LORAMAC */ 297 298 #ifdef __cplusplus 299 } 300 #endif 301 302 #endif // __LORAMAC_MESSAGE_TYPES_H__ 303