Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LoRaWAN-lib by
LoRaMac.h
00001 /*! 00002 * \file LoRaMac.h 00003 * 00004 * \brief LoRa MAC layer implementation 00005 * 00006 * \copyright Revised BSD License, see section \ref LICENSE. 00007 * 00008 * \code 00009 * ______ _ 00010 * / _____) _ | | 00011 * ( (____ _____ ____ _| |_ _____ ____| |__ 00012 * \____ \| ___ | (_ _) ___ |/ ___) _ \ 00013 * _____) ) ____| | | || |_| ____( (___| | | | 00014 * (______/|_____)_|_|_| \__)_____)\____)_| |_| 00015 * (C)2013 Semtech 00016 * 00017 * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 00018 * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 00019 * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 00020 * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 00021 * embedded.connectivity.solutions=============== 00022 * 00023 * \endcode 00024 * 00025 * \author Miguel Luis ( Semtech ) 00026 * 00027 * \author Gregory Cristian ( Semtech ) 00028 * 00029 * \author Daniel Jäckle ( STACKFORCE ) 00030 * 00031 * \defgroup LORAMAC LoRa MAC layer implementation 00032 * This module specifies the API implementation of the LoRaMAC layer. 00033 * This is a placeholder for a detailed description of the LoRaMac 00034 * layer and the supported features. 00035 * \{ 00036 * 00037 * \example classA/LoRaMote/main.c 00038 * LoRaWAN class A application example for the LoRaMote. 00039 * 00040 * \example classB/LoRaMote/main.c 00041 * LoRaWAN class B application example for the LoRaMote. 00042 * 00043 * \example classC/LoRaMote/main.c 00044 * LoRaWAN class C application example for the LoRaMote. 00045 */ 00046 #ifndef __LORAMAC_H__ 00047 #define __LORAMAC_H__ 00048 00049 // Includes board dependent definitions such as channels frequencies 00050 #include "LoRaMac-board.h" 00051 00052 /*! 00053 * Beacon interval in us 00054 */ 00055 #define BEACON_INTERVAL 128000000 00056 00057 /*! 00058 * Class A&B receive delay 1 in us 00059 */ 00060 #define RECEIVE_DELAY1 1000000 00061 00062 /*! 00063 * Class A&B receive delay 2 in us 00064 */ 00065 #define RECEIVE_DELAY2 2000000 00066 00067 /*! 00068 * Join accept receive delay 1 in us 00069 */ 00070 #define JOIN_ACCEPT_DELAY1 5000000 00071 00072 /*! 00073 * Join accept receive delay 2 in us 00074 */ 00075 #define JOIN_ACCEPT_DELAY2 6000000 00076 00077 /*! 00078 * Class A&B maximum receive window delay in us 00079 */ 00080 #define MAX_RX_WINDOW 3000000 00081 00082 /*! 00083 * Maximum allowed gap for the FCNT field 00084 */ 00085 #define MAX_FCNT_GAP 16384 00086 00087 /*! 00088 * ADR acknowledgement counter limit 00089 */ 00090 #define ADR_ACK_LIMIT 64 00091 00092 /*! 00093 * Number of ADR acknowledgement requests before returning to default datarate 00094 */ 00095 #define ADR_ACK_DELAY 32 00096 00097 /*! 00098 * Number of seconds after the start of the second reception window without 00099 * receiving an acknowledge. 00100 * AckTimeout = \ref ACK_TIMEOUT + Random( -\ref ACK_TIMEOUT_RND, \ref ACK_TIMEOUT_RND ) 00101 */ 00102 #define ACK_TIMEOUT 2000000 00103 00104 /*! 00105 * Random number of seconds after the start of the second reception window without 00106 * receiving an acknowledge 00107 * AckTimeout = \ref ACK_TIMEOUT + Random( -\ref ACK_TIMEOUT_RND, \ref ACK_TIMEOUT_RND ) 00108 */ 00109 #define ACK_TIMEOUT_RND 1000000 00110 00111 /*! 00112 * Check the Mac layer state every MAC_STATE_CHECK_TIMEOUT in us 00113 */ 00114 #define MAC_STATE_CHECK_TIMEOUT 1000000 00115 00116 /*! 00117 * Maximum number of times the MAC layer tries to get an acknowledge. 00118 */ 00119 #define MAX_ACK_RETRIES 8 00120 00121 /*! 00122 * RSSI free threshold [dBm] 00123 */ 00124 #define RSSI_FREE_TH ( int8_t )( -90 ) 00125 00126 /*! 00127 * Frame direction definition for up-link communications 00128 */ 00129 #define UP_LINK 0 00130 00131 /*! 00132 * Frame direction definition for down-link communications 00133 */ 00134 #define DOWN_LINK 1 00135 00136 /*! 00137 * Sets the length of the LoRaMAC footer field. 00138 * Mainly indicates the MIC field length 00139 */ 00140 #define LORAMAC_MFR_LEN 4 00141 00142 /*! 00143 * Syncword for Private LoRa networks 00144 */ 00145 #define LORA_MAC_PRIVATE_SYNCWORD 0x12 00146 00147 /*! 00148 * Syncword for Public LoRa networks 00149 */ 00150 #define LORA_MAC_PUBLIC_SYNCWORD 0x34 00151 00152 /*! 00153 * LoRaMac internal state 00154 */ 00155 //uint32_t LoRaMacState; 00156 00157 /*! 00158 * LoRaWAN devices classes definition 00159 */ 00160 typedef enum eDeviceClass 00161 { 00162 /*! 00163 * LoRaWAN device class A 00164 * 00165 * LoRaWAN Specification V1.0, chapter 3ff 00166 */ 00167 CLASS_A , 00168 /*! 00169 * LoRaWAN device class B 00170 * 00171 * LoRaWAN Specification V1.0, chapter 8ff 00172 */ 00173 CLASS_B , 00174 /*! 00175 * LoRaWAN device class C 00176 * 00177 * LoRaWAN Specification V1.0, chapter 17ff 00178 */ 00179 CLASS_C , 00180 }DeviceClass_t ; 00181 00182 /*! 00183 * LoRaMAC channels parameters definition 00184 */ 00185 typedef union uDrRange 00186 { 00187 /*! 00188 * Byte-access to the bits 00189 */ 00190 int8_t Value ; 00191 /*! 00192 * Structure to store the minimum and the maximum datarate 00193 */ 00194 struct sFields 00195 { 00196 /*! 00197 * Minimum data rate 00198 * 00199 * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7] 00200 * 00201 * US915 - [DR_0, DR_1, DR_2, DR_3, DR_4] 00202 */ 00203 int8_t Min : 4; 00204 /*! 00205 * Maximum data rate 00206 * 00207 * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7] 00208 * 00209 * US915 - [DR_0, DR_1, DR_2, DR_3, DR_4] 00210 */ 00211 int8_t Max : 4; 00212 }Fields; 00213 }DrRange_t ; 00214 00215 /*! 00216 * LoRaMAC band parameters definition 00217 */ 00218 typedef struct sBand 00219 { 00220 /*! 00221 * Duty cycle 00222 */ 00223 uint16_t DCycle ; 00224 /*! 00225 * Maximum Tx power 00226 */ 00227 int8_t TxMaxPower ; 00228 /*! 00229 * Time stamp of the last Tx frame 00230 */ 00231 TimerTime_t LastTxDoneTime ; 00232 /*! 00233 * Holds the time where the device is off 00234 */ 00235 TimerTime_t TimeOff ; 00236 }Band_t ; 00237 00238 /*! 00239 * LoRaMAC channel definition 00240 */ 00241 typedef struct sChannelParams 00242 { 00243 /*! 00244 * Frequency in Hz 00245 */ 00246 uint32_t Frequency ; 00247 /*! 00248 * Data rate definition 00249 */ 00250 DrRange_t DrRange ; 00251 /*! 00252 * Band index 00253 */ 00254 uint8_t Band ; 00255 }ChannelParams_t ; 00256 00257 /*! 00258 * LoRaMAC receive window 2 channel parameters 00259 */ 00260 typedef struct sRx2ChannelParams 00261 { 00262 /*! 00263 * Frequency in Hz 00264 */ 00265 uint32_t Frequency ; 00266 /*! 00267 * Data rate 00268 * 00269 * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7] 00270 * 00271 * US915 - [DR_8, DR_9, DR_10, DR_11, DR_12, DR_13] 00272 */ 00273 uint8_t Datarate ; 00274 }Rx2ChannelParams_t ; 00275 00276 /*! 00277 * LoRaMAC multicast channel parameter 00278 */ 00279 typedef struct sMulticastParams 00280 { 00281 /*! 00282 * Address 00283 */ 00284 uint32_t Address ; 00285 /*! 00286 * Network session key 00287 */ 00288 uint8_t NwkSKey [16]; 00289 /*! 00290 * Application session key 00291 */ 00292 uint8_t AppSKey [16]; 00293 /*! 00294 * Downlink counter 00295 */ 00296 uint32_t DownLinkCounter ; 00297 /*! 00298 * Reference pointer to the next multicast channel parameters in the list 00299 */ 00300 struct sMulticastParams *Next ; 00301 }MulticastParams_t ; 00302 00303 /*! 00304 * LoRaMAC frame types 00305 * 00306 * LoRaWAN Specification V1.0, chapter 4.2.1, table 1 00307 */ 00308 typedef enum eLoRaMacFrameType 00309 { 00310 /*! 00311 * LoRaMAC join request frame 00312 */ 00313 FRAME_TYPE_JOIN_REQ = 0x00, 00314 /*! 00315 * LoRaMAC join accept frame 00316 */ 00317 FRAME_TYPE_JOIN_ACCEPT = 0x01, 00318 /*! 00319 * LoRaMAC unconfirmed up-link frame 00320 */ 00321 FRAME_TYPE_DATA_UNCONFIRMED_UP = 0x02, 00322 /*! 00323 * LoRaMAC unconfirmed down-link frame 00324 */ 00325 FRAME_TYPE_DATA_UNCONFIRMED_DOWN = 0x03, 00326 /*! 00327 * LoRaMAC confirmed up-link frame 00328 */ 00329 FRAME_TYPE_DATA_CONFIRMED_UP = 0x04, 00330 /*! 00331 * LoRaMAC confirmed down-link frame 00332 */ 00333 FRAME_TYPE_DATA_CONFIRMED_DOWN = 0x05, 00334 /*! 00335 * LoRaMAC RFU frame 00336 */ 00337 FRAME_TYPE_RFU = 0x06, 00338 /*! 00339 * LoRaMAC proprietary frame 00340 */ 00341 FRAME_TYPE_PROPRIETARY = 0x07, 00342 }LoRaMacFrameType_t ; 00343 00344 /*! 00345 * LoRaMAC mote MAC commands 00346 * 00347 * LoRaWAN Specification V1.0, chapter 5, table 4 00348 */ 00349 typedef enum eLoRaMacMoteCmd 00350 { 00351 /*! 00352 * LinkCheckReq 00353 */ 00354 MOTE_MAC_LINK_CHECK_REQ = 0x02, 00355 /*! 00356 * LinkADRAns 00357 */ 00358 MOTE_MAC_LINK_ADR_ANS = 0x03, 00359 /*! 00360 * DutyCycleAns 00361 */ 00362 MOTE_MAC_DUTY_CYCLE_ANS = 0x04, 00363 /*! 00364 * RXParamSetupAns 00365 */ 00366 MOTE_MAC_RX_PARAM_SETUP_ANS = 0x05, 00367 /*! 00368 * DevStatusAns 00369 */ 00370 MOTE_MAC_DEV_STATUS_ANS = 0x06, 00371 /*! 00372 * NewChannelAns 00373 */ 00374 MOTE_MAC_NEW_CHANNEL_ANS = 0x07, 00375 /*! 00376 * RXTimingSetupAns 00377 */ 00378 MOTE_MAC_RX_TIMING_SETUP_ANS = 0x08, 00379 }LoRaMacMoteCmd_t ; 00380 00381 /*! 00382 * LoRaMAC server MAC commands 00383 * 00384 * LoRaWAN Specification V1.0, chapter 5, table 4 00385 */ 00386 typedef enum eLoRaMacSrvCmd 00387 { 00388 /*! 00389 * LinkCheckAns 00390 */ 00391 SRV_MAC_LINK_CHECK_ANS = 0x02, 00392 /*! 00393 * LinkADRReq 00394 */ 00395 SRV_MAC_LINK_ADR_REQ = 0x03, 00396 /*! 00397 * DutyCycleReq 00398 */ 00399 SRV_MAC_DUTY_CYCLE_REQ = 0x04, 00400 /*! 00401 * RXParamSetupReq 00402 */ 00403 SRV_MAC_RX_PARAM_SETUP_REQ = 0x05, 00404 /*! 00405 * DevStatusReq 00406 */ 00407 SRV_MAC_DEV_STATUS_REQ = 0x06, 00408 /*! 00409 * NewChannelReq 00410 */ 00411 SRV_MAC_NEW_CHANNEL_REQ = 0x07, 00412 /*! 00413 * RXTimingSetupReq 00414 */ 00415 SRV_MAC_RX_TIMING_SETUP_REQ = 0x08, 00416 }LoRaMacSrvCmd_t ; 00417 00418 /*! 00419 * LoRaMAC Battery level indicator 00420 */ 00421 typedef enum eLoRaMacBatteryLevel 00422 { 00423 /*! 00424 * External power source 00425 */ 00426 BAT_LEVEL_EXT_SRC = 0x00, 00427 /*! 00428 * Battery level empty 00429 */ 00430 BAT_LEVEL_EMPTY = 0x01, 00431 /*! 00432 * Battery level full 00433 */ 00434 BAT_LEVEL_FULL = 0xFE, 00435 /*! 00436 * Battery level - no measurement available 00437 */ 00438 BAT_LEVEL_NO_MEASURE = 0xFF, 00439 }LoRaMacBatteryLevel_t ; 00440 00441 /*! 00442 * LoRaMAC header field definition (MHDR field) 00443 * 00444 * LoRaWAN Specification V1.0, chapter 4.2 00445 */ 00446 typedef union uLoRaMacHeader 00447 { 00448 /*! 00449 * Byte-access to the bits 00450 */ 00451 uint8_t Value ; 00452 /*! 00453 * Structure containing single access to header bits 00454 */ 00455 struct sHdrBits 00456 { 00457 /*! 00458 * Major version 00459 */ 00460 uint8_t Major : 2; 00461 /*! 00462 * RFU 00463 */ 00464 uint8_t RFU : 3; 00465 /*! 00466 * Message type 00467 */ 00468 uint8_t MType : 3; 00469 }Bits; 00470 }LoRaMacHeader_t ; 00471 00472 /*! 00473 * LoRaMAC frame control field definition (FCtrl) 00474 * 00475 * LoRaWAN Specification V1.0, chapter 4.3.1 00476 */ 00477 typedef union uLoRaMacFrameCtrl 00478 { 00479 /*! 00480 * Byte-access to the bits 00481 */ 00482 uint8_t Value ; 00483 struct sCtrlBits 00484 { 00485 /*! 00486 * Frame options length 00487 */ 00488 uint8_t FOptsLen : 4; 00489 /*! 00490 * Frame pending bit 00491 */ 00492 uint8_t FPending : 1; 00493 /*! 00494 * Message acknowledge bit 00495 */ 00496 uint8_t Ack : 1; 00497 /*! 00498 * ADR acknowledgment request bit 00499 */ 00500 uint8_t AdrAckReq : 1; 00501 /*! 00502 * ADR control in frame header 00503 */ 00504 uint8_t Adr : 1; 00505 }Bits; 00506 }LoRaMacFrameCtrl_t ; 00507 00508 /*! 00509 * Enumeration containing the status of the operation of a MAC service 00510 */ 00511 typedef enum eLoRaMacEventInfoStatus 00512 { 00513 /*! 00514 * Service performed successfully 00515 */ 00516 LORAMAC_EVENT_INFO_STATUS_OK = 0, 00517 /*! 00518 * An error occured during the execution of the service 00519 */ 00520 LORAMAC_EVENT_INFO_STATUS_ERROR , 00521 /*! 00522 * A Tx timeouit occured 00523 */ 00524 LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT , 00525 /*! 00526 * An Rx timeout occured on receive window 2 00527 */ 00528 LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT , 00529 /*! 00530 * An Rx error occured on receive window 2 00531 */ 00532 LORAMAC_EVENT_INFO_STATUS_RX2_ERROR , 00533 /*! 00534 * An error occured in the join procedure 00535 */ 00536 LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL , 00537 /*! 00538 * A frame with an invalid downlink counter was received. The 00539 * downlink counter of the frame was equal to the local copy 00540 * of the downlink counter of the node. 00541 */ 00542 LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED , 00543 /*! 00544 * An address error occured 00545 */ 00546 LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL , 00547 /*! 00548 * message integrity check failure 00549 */ 00550 LORAMAC_EVENT_INFO_STATUS_MIC_FAIL , 00551 }LoRaMacEventInfoStatus_t ; 00552 00553 /*! 00554 * LoRaMac tx/rx operation state 00555 */ 00556 typedef union eLoRaMacFlags_t 00557 { 00558 /*! 00559 * Byte-access to the bits 00560 */ 00561 uint8_t Value ; 00562 struct sMacFlagBits 00563 { 00564 /*! 00565 * MCPS-Req pending 00566 */ 00567 uint8_t McpsReq : 1; 00568 /*! 00569 * MCPS-Ind pending 00570 */ 00571 uint8_t McpsInd : 1; 00572 /*! 00573 * MLME-Req pending 00574 */ 00575 uint8_t MlmeReq : 1; 00576 /*! 00577 * MAC cycle done 00578 */ 00579 uint8_t MacDone : 1; 00580 }Bits; 00581 }LoRaMacFlags_t ; 00582 00583 /*! 00584 * 00585 * \brief LoRaMAC data services 00586 * 00587 * \details The following table list the primitives which are supported by the 00588 * specific MAC data service: 00589 * 00590 * Name | Request | Indication | Response | Confirm 00591 * --------------------- | :-----: | :--------: | :------: | :-----: 00592 * \ref MCPS_UNCONFIRMED | YES | YES | NO | YES 00593 * \ref MCPS_CONFIRMED | YES | YES | NO | YES 00594 * \ref MCPS_MULTICAST | NO | YES | NO | NO 00595 * \ref MCPS_PROPRIETARY | YES | YES | NO | YES 00596 * 00597 * The following table provides links to the function implementations of the 00598 * related MCPS primitives: 00599 * 00600 * Primitive | Function 00601 * ---------------- | :---------------------: 00602 * MCPS-Request | \ref LoRaMacMlmeRequest 00603 * MCPS-Confirm | MacMcpsConfirm in \ref LoRaMacPrimitives_t 00604 * MCPS-Indication | MacMcpsIndication in \ref LoRaMacPrimitives_t 00605 */ 00606 typedef enum eMcps 00607 { 00608 /*! 00609 * Unconfirmed LoRaMAC frame 00610 */ 00611 MCPS_UNCONFIRMED , 00612 /*! 00613 * Confirmed LoRaMAC frame 00614 */ 00615 MCPS_CONFIRMED , 00616 /*! 00617 * Multicast LoRaMAC frame 00618 */ 00619 MCPS_MULTICAST , 00620 /*! 00621 * Proprietary frame 00622 */ 00623 MCPS_PROPRIETARY , 00624 }Mcps_t; 00625 00626 /*! 00627 * LoRaMAC MCPS-Request for an unconfirmed frame 00628 */ 00629 typedef struct sMcpsReqUnconfirmed 00630 { 00631 /*! 00632 * Frame port field. Must be set if the payload is not empty. Use the 00633 * application specific frame port values: [1...223] 00634 * 00635 * LoRaWAN Specification V1.0, chapter 4.3.2 00636 */ 00637 uint8_t fPort ; 00638 /*! 00639 * Pointer to the buffer of the frame payload 00640 */ 00641 void *fBuffer ; 00642 /*! 00643 * Size of the frame payload 00644 */ 00645 uint16_t fBufferSize ; 00646 /*! 00647 * Uplink datarate, if ADR is off 00648 */ 00649 int8_t Datarate ; 00650 }McpsReqUnconfirmed_t ; 00651 00652 /*! 00653 * LoRaMAC MCPS-Request for a confirmed frame 00654 */ 00655 typedef struct sMcpsReqConfirmed 00656 { 00657 /*! 00658 * Frame port field. Must be set if the payload is not empty. Use the 00659 * application specific frame port values: [1...223] 00660 * 00661 * LoRaWAN Specification V1.0, chapter 4.3.2 00662 */ 00663 uint8_t fPort ; 00664 /*! 00665 * Pointer to the buffer of the frame payload 00666 */ 00667 void *fBuffer ; 00668 /*! 00669 * Size of the frame payload 00670 */ 00671 uint16_t fBufferSize ; 00672 /*! 00673 * Uplink datarate, if ADR is off 00674 */ 00675 int8_t Datarate ; 00676 /*! 00677 * Number of trials to transmit the frame, if the LoRaMAC layer did not 00678 * receive an acknowledgment. The MAC performs a datarate adaptation, 00679 * according to the LoRaWAN Specification V1.0, chapter 18.4, according 00680 * to the following table: 00681 * 00682 * Transmission nb | Data Rate 00683 * ----------------|----------- 00684 * 1 (first) | DR 00685 * 2 | DR 00686 * 3 | max(DR-1,0) 00687 * 4 | max(DR-1,0) 00688 * 5 | max(DR-2,0) 00689 * 6 | max(DR-2,0) 00690 * 7 | max(DR-3,0) 00691 * 8 | max(DR-3,0) 00692 * 00693 * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease 00694 * the datarate, in case the LoRaMAC layer did not receive an acknowledgment 00695 */ 00696 uint8_t NbTrials ; 00697 }McpsReqConfirmed_t ; 00698 00699 /*! 00700 * LoRaMAC MCPS-Request for a proprietary frame 00701 */ 00702 typedef struct sMcpsReqProprietary 00703 { 00704 /*! 00705 * Pointer to the buffer of the frame payload 00706 */ 00707 void *fBuffer ; 00708 /*! 00709 * Size of the frame payload 00710 */ 00711 uint16_t fBufferSize ; 00712 /*! 00713 * Uplink datarate, if ADR is off 00714 */ 00715 int8_t Datarate ; 00716 }McpsReqProprietary_t ; 00717 00718 /*! 00719 * LoRaMAC MCPS-Request structure 00720 */ 00721 typedef struct sMcpsReq 00722 { 00723 /*! 00724 * MCPS-Request type 00725 */ 00726 Mcps_t Type ; 00727 00728 /*! 00729 * MCPS-Request parameters 00730 */ 00731 union uMcpsParam 00732 { 00733 /*! 00734 * MCPS-Request parameters for an unconfirmed frame 00735 */ 00736 McpsReqUnconfirmed_t Unconfirmed ; 00737 /*! 00738 * MCPS-Request parameters for a confirmed frame 00739 */ 00740 McpsReqConfirmed_t Confirmed ; 00741 /*! 00742 * MCPS-Request parameters for a proprietary frame 00743 */ 00744 McpsReqProprietary_t Proprietary ; 00745 }Req; 00746 }McpsReq_t ; 00747 00748 /*! 00749 * LoRaMAC MCPS-Confirm 00750 */ 00751 typedef struct sMcpsConfirm 00752 { 00753 /*! 00754 * Holds the previously performed MCPS-Request 00755 */ 00756 Mcps_t McpsRequest ; 00757 /*! 00758 * Status of the operation 00759 */ 00760 LoRaMacEventInfoStatus_t Status ; 00761 /*! 00762 * Uplink datarate 00763 */ 00764 uint8_t Datarate ; 00765 /*! 00766 * Transmission power 00767 */ 00768 int8_t TxPower ; 00769 /*! 00770 * Set if an acknowledgement was received 00771 */ 00772 bool AckReceived ; 00773 /*! 00774 * Provides the number of retransmissions 00775 */ 00776 uint8_t NbRetries ; 00777 /*! 00778 * The transmission time on air of the frame 00779 */ 00780 TimerTime_t TxTimeOnAir ; 00781 /*! 00782 * The uplink counter value related to the frame 00783 */ 00784 uint32_t UpLinkCounter ; 00785 }McpsConfirm_t ; 00786 00787 /*! 00788 * LoRaMAC MCPS-Indication primitive 00789 */ 00790 typedef struct sMcpsIndication 00791 { 00792 /*! 00793 * MCPS-Indication type 00794 */ 00795 Mcps_t McpsIndication ; 00796 /*! 00797 * Status of the operation 00798 */ 00799 LoRaMacEventInfoStatus_t Status ; 00800 /*! 00801 * Multicast 00802 */ 00803 uint8_t Multicast ; 00804 /*! 00805 * Application port 00806 */ 00807 uint8_t Port ; 00808 /*! 00809 * Downlink datarate 00810 */ 00811 uint8_t RxDatarate ; 00812 /*! 00813 * Frame pending status 00814 */ 00815 uint8_t FramePending ; 00816 /*! 00817 * Pointer to the received data stream 00818 */ 00819 uint8_t *Buffer ; 00820 /*! 00821 * Size of the received data stream 00822 */ 00823 uint8_t BufferSize ; 00824 /*! 00825 * Indicates, if data is available 00826 */ 00827 bool RxData ; 00828 /*! 00829 * Rssi of the received packet 00830 */ 00831 int16_t Rssi ; 00832 /*! 00833 * Snr of the received packet 00834 */ 00835 uint8_t Snr ; 00836 /*! 00837 * Receive window 00838 * 00839 * [0: Rx window 1, 1: Rx window 2] 00840 */ 00841 uint8_t RxSlot ; 00842 /*! 00843 * Set if an acknowledgement was received 00844 */ 00845 bool AckReceived ; 00846 /*! 00847 * The downlink counter value for the received frame 00848 */ 00849 uint32_t DownLinkCounter ; 00850 }McpsIndication_t ; 00851 00852 /*! 00853 * \brief LoRaMAC management services 00854 * 00855 * \details The following table list the primitives which are supported by the 00856 * specific MAC management service: 00857 * 00858 * Name | Request | Indication | Response | Confirm 00859 * --------------------- | :-----: | :--------: | :------: | :-----: 00860 * \ref MLME_JOIN | YES | NO | NO | YES 00861 * \ref MLME_LINK_CHECK | YES | NO | NO | YES 00862 * 00863 * The following table provides links to the function implementations of the 00864 * related MLME primitives. 00865 * 00866 * Primitive | Function 00867 * ---------------- | :---------------------: 00868 * MLME-Request | \ref LoRaMacMlmeRequest 00869 * MLME-Confirm | MacMlmeConfirm in \ref LoRaMacPrimitives_t 00870 */ 00871 typedef enum eMlme 00872 { 00873 /*! 00874 * Initiates the Over-the-Air activation 00875 * 00876 * LoRaWAN Specification V1.0, chapter 6.2 00877 */ 00878 MLME_JOIN , 00879 /*! 00880 * LinkCheckReq - Connectivity validation 00881 * 00882 * LoRaWAN Specification V1.0, chapter 5, table 4 00883 */ 00884 MLME_LINK_CHECK , 00885 }Mlme_t; 00886 00887 /*! 00888 * LoRaMAC MLME-Request for the join service 00889 */ 00890 typedef struct sMlmeReqJoin 00891 { 00892 /*! 00893 * Globally unique end-device identifier 00894 * 00895 * LoRaWAN Specification V1.0, chapter 6.2.1 00896 */ 00897 uint8_t *DevEui ; 00898 /*! 00899 * Application identifier 00900 * 00901 * LoRaWAN Specification V1.0, chapter 6.1.2 00902 */ 00903 uint8_t *AppEui ; 00904 /*! 00905 * AES-128 application key 00906 * 00907 * LoRaWAN Specification V1.0, chapter 6.2.2 00908 */ 00909 uint8_t *AppKey ; 00910 }MlmeReqJoin_t ; 00911 00912 /*! 00913 * 00914 */ 00915 typedef struct sMlmeReq 00916 { 00917 /*! 00918 * MLME-Request type 00919 */ 00920 Mlme_t Type; 00921 00922 /*! 00923 * MLME-Request parameters 00924 */ 00925 union uMlmeParam 00926 { 00927 /*! 00928 * MLME-Request parameters for a join request 00929 */ 00930 MlmeReqJoin_t Join ; 00931 }Req; 00932 }MlmeReq_t; 00933 00934 /*! 00935 * LoRaMAC MLME-Confirm primitive 00936 */ 00937 typedef struct sMlmeConfirm 00938 { 00939 /*! 00940 * Holds the previously performed MLME-Request 00941 */ 00942 Mlme_t MlmeRequest ; 00943 /*! 00944 * Status of the operation 00945 */ 00946 LoRaMacEventInfoStatus_t Status ; 00947 /*! 00948 * The transmission time on air of the frame 00949 */ 00950 TimerTime_t TxTimeOnAir ; 00951 /*! 00952 * Demodulation margin. Contains the link margin [dB] of the last 00953 * successfully received LinkCheckReq 00954 */ 00955 uint8_t DemodMargin ; 00956 /*! 00957 * Number of gateways which received the last LinkCheckReq 00958 */ 00959 uint8_t NbGateways ; 00960 }MlmeConfirm_t ; 00961 00962 /*! 00963 * LoRa Mac Information Base (MIB) 00964 * 00965 * The following table lists the MIB parameters and the related attributes: 00966 * 00967 * Attribute | Get | Set 00968 * --------------------------------- | :-: | :-: 00969 * \ref MIB_DEVICE_CLASS | YES | YES 00970 * \ref MIB_NETWORK_JOINED | YES | YES 00971 * \ref MIB_ADR | YES | YES 00972 * \ref MIB_NET_ID | YES | YES 00973 * \ref MIB_DEV_ADDR | YES | YES 00974 * \ref MIB_NWK_SKEY | YES | YES 00975 * \ref MIB_APP_SKEY | YES | YES 00976 * \ref MIB_PUBLIC_NETWORK | YES | YES 00977 * \ref MIB_REPEATER_SUPPORT | YES | YES 00978 * \ref MIB_CHANNELS | YES | NO 00979 * \ref MIB_RX2_CHANNEL | YES | YES 00980 * \ref MIB_CHANNELS_MASK | YES | YES 00981 * \ref MIB_CHANNELS_NB_REP | YES | YES 00982 * \ref MIB_MAX_RX_WINDOW_DURATION | YES | YES 00983 * \ref MIB_RECEIVE_DELAY_1 | YES | YES 00984 * \ref MIB_RECEIVE_DELAY_2 | YES | YES 00985 * \ref MIB_JOIN_ACCEPT_DELAY_1 | YES | YES 00986 * \ref MIB_JOIN_ACCEPT_DELAY_2 | YES | YES 00987 * \ref MIB_CHANNELS_DATARATE | YES | YES 00988 * \ref MIB_CHANNELS_TX_POWER | YES | YES 00989 * \ref MIB_UPLINK_COUNTER | YES | NO 00990 * \ref MIB_DOWNLINK_COUNTER | YES | NO 00991 * \ref MIB_MULTICAST_CHANNEL | YES | NO 00992 * 00993 * The following table provides links to the function implementations of the 00994 * related MIB primitives: 00995 * 00996 * Primitive | Function 00997 * ---------------- | :---------------------: 00998 * MIB-Set | \ref LoRaMacMibSetRequestConfirm 00999 * MIB-Get | \ref LoRaMacMibGetRequestConfirm 01000 */ 01001 typedef enum eMib 01002 { 01003 /*! 01004 * LoRaWAN device class 01005 * 01006 * LoRaWAN Specification V1.0 01007 */ 01008 MIB_DEVICE_CLASS , 01009 /*! 01010 * LoRaWAN Network joined attribute 01011 * 01012 * LoRaWAN Specification V1.0 01013 */ 01014 MIB_NETWORK_JOINED , 01015 /*! 01016 * Adaptive data rate 01017 * 01018 * LoRaWAN Specification V1.0, chapter 4.3.1.1 01019 * 01020 * [true: ADR enabled, false: ADR disabled] 01021 */ 01022 MIB_ADR , 01023 /*! 01024 * Network identifier 01025 * 01026 * LoRaWAN Specification V1.0, chapter 6.2.5 01027 */ 01028 MIB_NET_ID , 01029 /*! 01030 * End-device address 01031 * 01032 * LoRaWAN Specification V1.0, chapter 6.1.2 01033 */ 01034 MIB_DEV_ADDR , 01035 /*! 01036 * Network session key 01037 * 01038 * LoRaWAN Specification V1.0, chapter 6.1.3 01039 */ 01040 MIB_NWK_SKEY , 01041 /*! 01042 * Application session key 01043 * 01044 * LoRaWAN Specification V1.0, chapter 6.1.4 01045 */ 01046 MIB_APP_SKEY , 01047 /*! 01048 * Set the network type to public or private 01049 * 01050 * LoRaWAN Specification V1.0, chapter 7 01051 * 01052 * [true: public network, false: private network] 01053 */ 01054 MIB_PUBLIC_NETWORK , 01055 /*! 01056 * Support the operation with repeaters 01057 * 01058 * LoRaWAN Specification V1.0, chapter 7 01059 * 01060 * [true: repeater support enabled, false: repeater support disabled] 01061 */ 01062 MIB_REPEATER_SUPPORT , 01063 /*! 01064 * Communication channels. A get request will return a 01065 * pointer which references the first entry of the channel list. The 01066 * list is of size LORA_MAX_NB_CHANNELS 01067 * 01068 * LoRaWAN Specification V1.0, chapter 7 01069 */ 01070 MIB_CHANNELS , 01071 /*! 01072 * Set receive window 2 channel 01073 * 01074 * LoRaWAN Specification V1.0, chapter 3.3.2 01075 */ 01076 MIB_RX2_CHANNEL , 01077 /*! 01078 * LoRaWAN channels mask 01079 * 01080 * LoRaWAN Specification V1.0, chapter 5.2 01081 */ 01082 MIB_CHANNELS_MASK , 01083 /*! 01084 * Set the number of repetitions on a channel 01085 * 01086 * LoRaWAN Specification V1.0, chapter 5.2 01087 */ 01088 MIB_CHANNELS_NB_REP , 01089 /*! 01090 * Maximum receive window duration in [us] 01091 * 01092 * LoRaWAN Specification V1.0, chapter 3.3.3 01093 */ 01094 MIB_MAX_RX_WINDOW_DURATION , 01095 /*! 01096 * Receive delay 1 in [us] 01097 * 01098 * LoRaWAN Specification V1.0, chapter 6 01099 */ 01100 MIB_RECEIVE_DELAY_1 , 01101 /*! 01102 * Receive delay 2 in [us] 01103 * 01104 * LoRaWAN Specification V1.0, chapter 6 01105 */ 01106 MIB_RECEIVE_DELAY_2 , 01107 /*! 01108 * Join accept delay 1 in [us] 01109 * 01110 * LoRaWAN Specification V1.0, chapter 6 01111 */ 01112 MIB_JOIN_ACCEPT_DELAY_1 , 01113 /*! 01114 * Join accept delay 2 in [us] 01115 * 01116 * LoRaWAN Specification V1.0, chapter 6 01117 */ 01118 MIB_JOIN_ACCEPT_DELAY_2 , 01119 /*! 01120 * Data rate of a channel 01121 * 01122 * LoRaWAN Specification V1.0, chapter 7 01123 * 01124 * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7] 01125 * 01126 * US915 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_8, DR_9, DR_10, DR_11, DR_12, DR_13] 01127 */ 01128 MIB_CHANNELS_DATARATE , 01129 /*! 01130 * Transmission power of a channel 01131 * 01132 * LoRaWAN Specification V1.0, chapter 7 01133 * 01134 * EU868 - [TX_POWER_20_DBM, TX_POWER_14_DBM, TX_POWER_11_DBM, 01135 * TX_POWER_08_DBM, TX_POWER_05_DBM, TX_POWER_02_DBM] 01136 * 01137 * US915 - [TX_POWER_30_DBM, TX_POWER_28_DBM, TX_POWER_26_DBM, 01138 * TX_POWER_24_DBM, TX_POWER_22_DBM, TX_POWER_20_DBM, 01139 * TX_POWER_18_DBM, TX_POWER_14_DBM, TX_POWER_12_DBM, 01140 * TX_POWER_10_DBM] 01141 */ 01142 MIB_CHANNELS_TX_POWER , 01143 /*! 01144 * LoRaWAN Up-link counter 01145 * 01146 * LoRaWAN Specification V1.0, chapter 4.3.1.5 01147 */ 01148 MIB_UPLINK_COUNTER , 01149 /*! 01150 * LoRaWAN Down-link counter 01151 * 01152 * LoRaWAN Specification V1.0, chapter 4.3.1.5 01153 */ 01154 MIB_DOWNLINK_COUNTER , 01155 /*! 01156 * Multicast channels. A get request will return a pointer to the first 01157 * entry of the multicast channel linked list. If the pointer is equal to 01158 * NULL, the list is empty. 01159 */ 01160 MIB_MULTICAST_CHANNEL , 01161 }Mib_t ; 01162 01163 /*! 01164 * LoRaMAC MIB parameters 01165 */ 01166 typedef union uMibParam 01167 { 01168 /*! 01169 * LoRaWAN device class 01170 * 01171 * Related MIB type: \ref MIB_DEVICE_CLASS 01172 */ 01173 DeviceClass_t Class ; 01174 /*! 01175 * LoRaWAN network joined attribute 01176 * 01177 * Related MIB type: \ref MIB_NETWORK_JOINED 01178 */ 01179 bool IsNetworkJoined ; 01180 /*! 01181 * Activation state of ADR 01182 * 01183 * Related MIB type: \ref MIB_ADR 01184 */ 01185 bool AdrEnable ; 01186 /*! 01187 * Network identifier 01188 * 01189 * Related MIB type: \ref MIB_NET_ID 01190 */ 01191 uint32_t NetID ; 01192 /*! 01193 * End-device address 01194 * 01195 * Related MIB type: \ref MIB_DEV_ADDR 01196 */ 01197 uint32_t DevAddr ; 01198 /*! 01199 * Network session key 01200 * 01201 * Related MIB type: \ref MIB_NWK_SKEY 01202 */ 01203 uint8_t *NwkSKey ; 01204 /*! 01205 * Application session key 01206 * 01207 * Related MIB type: \ref MIB_APP_SKEY 01208 */ 01209 uint8_t *AppSKey ; 01210 /*! 01211 * Enable or disable a public network 01212 * 01213 * Related MIB type: \ref MIB_PUBLIC_NETWORK 01214 */ 01215 bool EnablePublicNetwork ; 01216 /*! 01217 * Enable or disable repeater support 01218 * 01219 * Related MIB type: \ref MIB_REPEATER_SUPPORT 01220 */ 01221 bool EnableRepeaterSupport ; 01222 /*! 01223 * LoRaWAN Channel 01224 * 01225 * Related MIB type: \ref MIB_CHANNELS 01226 */ 01227 ChannelParams_t * ChannelList ; 01228 /*! 01229 * Channel for the receive window 2 01230 * 01231 * Related MIB type: \ref MIB_RX2_CHANNEL 01232 */ 01233 Rx2ChannelParams_t Rx2Channel ; 01234 /*! 01235 * Channel mask 01236 * 01237 * Related MIB type: \ref MIB_CHANNELS_MASK 01238 */ 01239 uint16_t* ChannelsMask ; 01240 /*! 01241 * Number of frame repetitions 01242 * 01243 * Related MIB type: \ref MIB_CHANNELS_NB_REP 01244 */ 01245 uint8_t ChannelNbRep ; 01246 /*! 01247 * Maximum receive window duration 01248 * 01249 * Related MIB type: \ref MIB_MAX_RX_WINDOW_DURATION 01250 */ 01251 uint32_t MaxRxWindow ; 01252 /*! 01253 * Receive delay 1 01254 * 01255 * Related MIB type: \ref MIB_RECEIVE_DELAY_1 01256 */ 01257 uint32_t ReceiveDelay1 ; 01258 /*! 01259 * Receive delay 2 01260 * 01261 * Related MIB type: \ref MIB_RECEIVE_DELAY_2 01262 */ 01263 uint32_t ReceiveDelay2 ; 01264 /*! 01265 * Join accept delay 1 01266 * 01267 * Related MIB type: \ref MIB_JOIN_ACCEPT_DELAY_1 01268 */ 01269 uint32_t JoinAcceptDelay1 ; 01270 /*! 01271 * Join accept delay 2 01272 * 01273 * Related MIB type: \ref MIB_JOIN_ACCEPT_DELAY_2 01274 */ 01275 uint32_t JoinAcceptDelay2 ; 01276 /*! 01277 * Channels data rate 01278 * 01279 * Related MIB type: \ref MIB_CHANNELS_DATARATE 01280 */ 01281 int8_t ChannelsDatarate ; 01282 /*! 01283 * Channels TX power 01284 * 01285 * Related MIB type: \ref MIB_CHANNELS_TX_POWER 01286 */ 01287 int8_t ChannelsTxPower ; 01288 /*! 01289 * LoRaWAN Up-link counter 01290 * 01291 * Related MIB type: \ref MIB_UPLINK_COUNTER 01292 */ 01293 uint32_t UpLinkCounter ; 01294 /*! 01295 * LoRaWAN Down-link counter 01296 * 01297 * Related MIB type: \ref MIB_DOWNLINK_COUNTER 01298 */ 01299 uint32_t DownLinkCounter ; 01300 /*! 01301 * Multicast channel 01302 * 01303 * Related MIB type: \ref MIB_MULTICAST_CHANNEL 01304 */ 01305 MulticastParams_t * MulticastList ; 01306 }MibParam_t ; 01307 01308 /*! 01309 * LoRaMAC MIB-RequestConfirm structure 01310 */ 01311 typedef struct eMibRequestConfirm 01312 { 01313 /*! 01314 * MIB-Request type 01315 */ 01316 Mib_t Type ; 01317 01318 /*! 01319 * MLME-RequestConfirm parameters 01320 */ 01321 MibParam_t Param ; 01322 }MibRequestConfirm_t ; 01323 01324 /*! 01325 * LoRaMAC tx information 01326 */ 01327 typedef struct sLoRaMacTxInfo 01328 { 01329 /*! 01330 * Defines the size of the applicative payload which can be processed 01331 */ 01332 uint8_t MaxPossiblePayload ; 01333 /*! 01334 * The current payload size, dependent on the current datarate 01335 */ 01336 uint8_t CurrentPayloadSize ; 01337 }LoRaMacTxInfo_t ; 01338 01339 /*! 01340 * LoRaMAC Status 01341 */ 01342 typedef enum eLoRaMacStatus 01343 { 01344 /*! 01345 * Service started successfully 01346 */ 01347 LORAMAC_STATUS_OK , 01348 /*! 01349 * Service not started - LoRaMAC is busy 01350 */ 01351 LORAMAC_STATUS_BUSY , 01352 /*! 01353 * Service unknown 01354 */ 01355 LORAMAC_STATUS_SERVICE_UNKNOWN , 01356 /*! 01357 * Service not started - invalid parameter 01358 */ 01359 LORAMAC_STATUS_PARAMETER_INVALID , 01360 /*! 01361 * Service not started - invalid frequency 01362 */ 01363 LORAMAC_STATUS_FREQUENCY_INVALID , 01364 /*! 01365 * Service not started - invalid datarate 01366 */ 01367 LORAMAC_STATUS_DATARATE_INVALID , 01368 /*! 01369 * Service not started - invalid frequency and datarate 01370 */ 01371 LORAMAC_STATUS_FREQ_AND_DR_INVALID , 01372 /*! 01373 * Service not started - the device is not in a LoRaWAN 01374 */ 01375 LORAMAC_STATUS_NO_NETWORK_JOINED , 01376 /*! 01377 * Service not started - playload lenght error 01378 */ 01379 LORAMAC_STATUS_LENGTH_ERROR , 01380 /*! 01381 * Service not started - playload lenght error 01382 */ 01383 LORAMAC_STATUS_MAC_CMD_LENGTH_ERROR , 01384 /*! 01385 * Service not started - the device is switched off 01386 */ 01387 LORAMAC_STATUS_DEVICE_OFF , 01388 }LoRaMacStatus_t ; 01389 01390 /*! 01391 * LoRaMAC events structure 01392 * Used to notify upper layers of MAC events 01393 */ 01394 typedef struct sLoRaMacPrimitives 01395 { 01396 /*! 01397 * \brief MCPS-Confirm primitive 01398 * 01399 * \param [OUT] MCPS-Confirm parameters 01400 */ 01401 void ( *MacMcpsConfirm )( McpsConfirm_t *McpsConfirm ); 01402 /*! 01403 * \brief MCPS-Indication primitive 01404 * 01405 * \param [OUT] MCPS-Indication parameters 01406 */ 01407 void ( *MacMcpsIndication )( McpsIndication_t *McpsIndication ); 01408 /*! 01409 * \brief MLME-Confirm primitive 01410 * 01411 * \param [OUT] MLME-Confirm parameters 01412 */ 01413 void ( *MacMlmeConfirm )( MlmeConfirm_t *MlmeConfirm ); 01414 }LoRaMacPrimitives_t ; 01415 01416 typedef struct sLoRaMacCallback 01417 { 01418 /*! 01419 * \brief Measures the battery level 01420 * 01421 * \retval Battery level [0: node is connected to an external 01422 * power source, 1..254: battery level, where 1 is the minimum 01423 * and 254 is the maximum value, 255: the node was not able 01424 * to measure the battery level] 01425 */ 01426 uint8_t ( *GetBatteryLevel )( void ); 01427 }LoRaMacCallback_t; 01428 01429 /*! 01430 * \brief LoRaMAC layer initialization 01431 * 01432 * \details In addition to the initialization of the LoRaMAC layer, this 01433 * function initializes the callback primitives of the MCPS and 01434 * MLME services. Every data field of \ref LoRaMacPrimitives_t must be 01435 * set to a valid callback function. 01436 * 01437 * \param [IN] events - Pointer to a structure defining the LoRaMAC 01438 * event functions. Refer to \ref LoRaMacPrimitives_t. 01439 * 01440 * \param [IN] events - Pointer to a structure defining the LoRaMAC 01441 * callback functions. Refer to \ref LoRaMacCallback_t. 01442 * 01443 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 01444 * returns are: 01445 * \ref LORAMAC_STATUS_OK, 01446 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 01447 */ 01448 LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacCallback_t *callbacks ); 01449 01450 /*! 01451 * \brief Queries the LoRaMAC if it is possible to send the next frame with 01452 * a given payload size. The LoRaMAC takes scheduled MAC commands into 01453 * account and reports, when the frame can be send or not. 01454 * 01455 * \param [IN] size - Size of applicative payload to be send next 01456 * 01457 * \param [OUT] txInfo - The structure \ref LoRaMacTxInfo_t contains 01458 * information about the actual maximum payload possible 01459 * ( according to the configured datarate or the next 01460 * datarate according to ADR ), and the maximum frame 01461 * size, taking the scheduled MAC commands into account. 01462 * 01463 * \retval LoRaMacStatus_t Status of the operation. When the parameters are 01464 * not valid, the function returns \ref LORAMAC_STATUS_PARAMETER_INVALID. 01465 * In case of a length error caused by the applicative payload size, the 01466 * function returns LORAMAC_STATUS_LENGTH_ERROR. In case of a length error 01467 * due to additional MAC commands in the queue, the function returns 01468 * LORAMAC_STATUS_MAC_CMD_LENGTH_ERROR. In case the query is valid, and 01469 * the LoRaMAC is able to send the frame, the function returns LORAMAC_STATUS_OK. * 01470 */ 01471 LoRaMacStatus_t LoRaMacQueryTxPossible( uint8_t size, LoRaMacTxInfo_t * txInfo ); 01472 01473 /*! 01474 * \brief LoRaMAC channel add service 01475 * 01476 * \details Adds a new channel to the channel list and activates the id in 01477 * the channel mask. For the US915 band, all channels are enabled 01478 * by default. It is not possible to activate less than 6 125 kHz 01479 * channels. 01480 * 01481 * \param [IN] id - Id of the channel. Possible values are: 01482 * 01483 * 0-15 for EU868 01484 * 0-72 for US915 01485 * 01486 * \param [IN] params - Channel parameters to set. 01487 * 01488 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 01489 * \ref LORAMAC_STATUS_OK, 01490 * \ref LORAMAC_STATUS_BUSY, 01491 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 01492 */ 01493 LoRaMacStatus_t LoRaMacChannelAdd( uint8_t id, ChannelParams_t params ); 01494 01495 /*! 01496 * \brief LoRaMAC channel remove service 01497 * 01498 * \details Deactivates the id in the channel mask. 01499 * 01500 * \param [IN] id - Id of the channel. 01501 * 01502 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 01503 * \ref LORAMAC_STATUS_OK, 01504 * \ref LORAMAC_STATUS_BUSY, 01505 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 01506 */ 01507 LoRaMacStatus_t LoRaMacChannelRemove( uint8_t id ); 01508 01509 /*! 01510 * \brief LoRaMAC multicast channel link service 01511 * 01512 * \details Links a multicast channel into the linked list. 01513 * 01514 * \param [IN] channelParam - Multicast channel parameters to link. 01515 * 01516 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 01517 * \ref LORAMAC_STATUS_OK, 01518 * \ref LORAMAC_STATUS_BUSY, 01519 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 01520 */ 01521 LoRaMacStatus_t LoRaMacMulticastChannelLink( MulticastParams_t *channelParam ); 01522 01523 /*! 01524 * \brief LoRaMAC multicast channel unlink service 01525 * 01526 * \details Unlinks a multicast channel from the linked list. 01527 * 01528 * \param [IN] channelParam - Multicast channel parameters to unlink. 01529 * 01530 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 01531 * \ref LORAMAC_STATUS_OK, 01532 * \ref LORAMAC_STATUS_BUSY, 01533 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 01534 */ 01535 LoRaMacStatus_t LoRaMacMulticastChannelUnlink( MulticastParams_t *channelParam ); 01536 01537 /*! 01538 * \brief LoRaMAC MIB-Get 01539 * 01540 * \details The mac information base service to get attributes of the LoRaMac 01541 * layer. 01542 * 01543 * The following code-snippet shows how to use the API to get the 01544 * parameter AdrEnable, defined by the enumeration type 01545 * \ref MIB_ADR. 01546 * \code 01547 * MibRequestConfirm_t mibReq; 01548 * mibReq.Type = MIB_ADR; 01549 * 01550 * if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK ) 01551 * { 01552 * // LoRaMAC updated the parameter mibParam.AdrEnable 01553 * } 01554 * \endcode 01555 * 01556 * \param [IN] mibRequest - MIB-GET-Request to perform. Refer to \ref MibRequestConfirm_t. 01557 * 01558 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 01559 * \ref LORAMAC_STATUS_OK, 01560 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN, 01561 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 01562 */ 01563 LoRaMacStatus_t LoRaMacMibGetRequestConfirm( MibRequestConfirm_t *mibGet ); 01564 01565 /*! 01566 * \brief LoRaMAC MIB-Set 01567 * 01568 * \details The mac information base service to set attributes of the LoRaMac 01569 * layer. 01570 * 01571 * The following code-snippet shows how to use the API to set the 01572 * parameter AdrEnable, defined by the enumeration type 01573 * \ref MIB_ADR. 01574 * 01575 * \code 01576 * MibRequestConfirm_t mibReq; 01577 * mibReq.Type = MIB_ADR; 01578 * mibReq.Param.AdrEnable = true; 01579 * 01580 * if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK ) 01581 * { 01582 * // LoRaMAC updated the parameter 01583 * } 01584 * \endcode 01585 * 01586 * \param [IN] mibRequest - MIB-SET-Request to perform. Refer to \ref MibRequestConfirm_t. 01587 * 01588 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 01589 * \ref LORAMAC_STATUS_OK, 01590 * \ref LORAMAC_STATUS_BUSY, 01591 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN, 01592 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 01593 */ 01594 LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t *mibSet ); 01595 01596 /*! 01597 * \brief LoRaMAC MLME-Request 01598 * 01599 * \details The Mac layer management entity handles management services. The 01600 * following code-snippet shows how to use the API to perform a 01601 * network join request. 01602 * 01603 * \code 01604 * static uint8_t DevEui[] = 01605 * { 01606 * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 01607 * }; 01608 * static uint8_t AppEui[] = 01609 * { 01610 * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 01611 * }; 01612 * static uint8_t AppKey[] = 01613 * { 01614 * 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 01615 * 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C 01616 * }; 01617 * 01618 * MlmeReq_t mlmeReq; 01619 * mlmeReq.Type = MLME_JOIN; 01620 * mlmeReq.Req.Join.DevEui = DevEui; 01621 * mlmeReq.Req.Join.AppEui = AppEui; 01622 * mlmeReq.Req.Join.AppKey = AppKey; 01623 * 01624 * if( LoRaMacMlmeRequest( &mlmeReq ) == LORAMAC_STATUS_OK ) 01625 * { 01626 * // Service started successfully. Waiting for the Mlme-Confirm event 01627 * } 01628 * \endcode 01629 * 01630 * \param [IN] mlmeRequest - MLME-Request to perform. Refer to \ref MlmeReq_t. 01631 * 01632 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 01633 * \ref LORAMAC_STATUS_OK, 01634 * \ref LORAMAC_STATUS_BUSY, 01635 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN, 01636 * \ref LORAMAC_STATUS_PARAMETER_INVALID, 01637 * \ref LORAMAC_STATUS_NO_NETWORK_JOINED, 01638 * \ref LORAMAC_STATUS_LENGTH_ERROR, 01639 * \ref LORAMAC_STATUS_DEVICE_OFF. 01640 */ 01641 LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t *mlmeRequest ); 01642 01643 /*! 01644 * \brief LoRaMAC MCPS-Request 01645 * 01646 * \details The Mac Common Part Sublayer handles data services. The following 01647 * code-snippet shows how to use the API to send an unconfirmed 01648 * LoRaMAC frame. 01649 * 01650 * \code 01651 * uint8_t myBuffer[] = { 1, 2, 3 }; 01652 * 01653 * McpsReq_t mcpsReq; 01654 * mcpsReq.Type = MCPS_UNCONFIRMED; 01655 * mcpsReq.Req.Unconfirmed.fPort = 1; 01656 * mcpsReq.Req.Unconfirmed.fBuffer = myBuffer; 01657 * mcpsReq.Req.Unconfirmed.fBufferSize = sizeof( myBuffer ); 01658 * 01659 * if( LoRaMacMcpsRequest( &mcpsReq ) == LORAMAC_STATUS_OK ) 01660 * { 01661 * // Service started successfully. Waiting for the MCPS-Confirm event 01662 * } 01663 * \endcode 01664 * 01665 * \param [IN] mcpsRequest - MCPS-Request to perform. Refer to \ref McpsReq_t. 01666 * 01667 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 01668 * \ref LORAMAC_STATUS_OK, 01669 * \ref LORAMAC_STATUS_BUSY, 01670 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN, 01671 * \ref LORAMAC_STATUS_PARAMETER_INVALID, 01672 * \ref LORAMAC_STATUS_NO_NETWORK_JOINED, 01673 * \ref LORAMAC_STATUS_LENGTH_ERROR, 01674 * \ref LORAMAC_STATUS_DEVICE_OFF. 01675 */ 01676 LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t *mcpsRequest ); 01677 01678 /*! \} defgroup LORAMAC */ 01679 01680 #endif // __LORAMAC_H__
Generated on Tue Jul 12 2022 21:21:12 by
1.7.2
