1 /*! 2 * \file LoRaMac.h 3 * 4 * \brief LoRa MAC layer implementation 5 * 6 * \copyright Revised BSD License, see section \ref LICENSE. 7 * 8 * \code 9 * ______ _ 10 * / _____) _ | | 11 * ( (____ _____ ____ _| |_ _____ ____| |__ 12 * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 * _____) ) ____| | | || |_| ____( (___| | | | 14 * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 * (C)2013-2017 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 * \defgroup LORAMAC LoRa MAC layer implementation 34 * This module specifies the API implementation of the LoRaMAC layer. 35 * This is a placeholder for a detailed description of the LoRaMac 36 * layer and the supported features. 37 * \{ 38 * 39 * \example periodic-uplink-lpp/B-L072Z-LRWAN1/main.c 40 * LoRaWAN class A/B/C application example for the B-L072Z-LRWAN1. 41 * 42 * \example periodic-uplink-lpp/NAMote72/main.c 43 * LoRaWAN class A/B/C application example for the NAMote72. 44 * 45 * \example periodic-uplink-lpp/NucleoL073/main.c 46 * LoRaWAN class A/B/C application example for the NucleoL073. 47 * 48 * \example periodic-uplink-lpp/NucleoL152/main.c 49 * LoRaWAN class A/B/C application example for the NucleoL152. 50 * 51 * \example periodic-uplink-lpp/NucleoL476/main.c 52 * LoRaWAN class A/B/C application example for the NucleoL476. 53 * 54 * \example periodic-uplink-lpp/SAMR34/main.c 55 * LoRaWAN class A/B/C application example for the SAMR34. 56 * 57 * \example periodic-uplink-lpp/SKiM880B/main.c 58 * LoRaWAN class A/B/C application example for the SKiM880B. 59 * 60 * \example periodic-uplink-lpp/SKiM881AXL/main.c 61 * LoRaWAN class A/B/C application example for the SKiM881AXL. 62 * 63 * \example periodic-uplink-lpp/SKiM980A/main.c 64 * LoRaWAN class A/B/C application example for the SKiM980A. 65 */ 66 #ifndef __LORAMAC_H__ 67 #define __LORAMAC_H__ 68 69 #ifdef __cplusplus 70 extern "C" 71 { 72 #endif 73 74 #include <stdint.h> 75 #include <stdbool.h> 76 77 #include "timer.h" 78 #include "systime.h" 79 #include "LoRaMacTypes.h" 80 81 #include "RegionNvm.h" 82 #include "LoRaMacCryptoNvm.h" 83 #include "secure-element-nvm.h" 84 #include "LoRaMacClassBNvm.h" 85 86 /*! 87 * LoRaWAN version definition. 88 */ 89 #define LORAMAC_VERSION 0x01010100 90 91 /*! 92 * LoRaWAN fallback version definition. 93 */ 94 #define LORAMAC_FALLBACK_VERSION 0x01000400 95 96 /*! 97 * Maximum number of times the MAC layer tries to get an acknowledge. 98 */ 99 #define MAX_ACK_RETRIES 8 100 101 /*! 102 * Frame direction definition for up-link communications 103 */ 104 #define UP_LINK 0 105 106 /*! 107 * Frame direction definition for down-link communications 108 */ 109 #define DOWN_LINK 1 110 111 /*! 112 * LoRaMac MLME-Confirm queue length 113 */ 114 #define LORA_MAC_MLME_CONFIRM_QUEUE_LEN 5 115 116 /*! 117 * Start value for multicast keys enumeration 118 */ 119 #define LORAMAC_CRYPTO_MULTICAST_KEYS 127 120 121 /*! 122 * Maximum MAC commands buffer size 123 */ 124 #define LORA_MAC_COMMAND_MAX_LENGTH 128 125 126 127 /*! 128 * Bitmap value 129 */ 130 #define LORAMAC_NVM_NOTIFY_FLAG_NONE 0x00 131 132 /*! 133 * Bitmap value for the NVM group crypto. 134 */ 135 #define LORAMAC_NVM_NOTIFY_FLAG_CRYPTO 0x01 136 137 /*! 138 * Bitmap value for the NVM group MAC 1. 139 */ 140 #define LORAMAC_NVM_NOTIFY_FLAG_MAC_GROUP1 0x02 141 142 /*! 143 * Bitmap value for the NVM group MAC 2. 144 */ 145 #define LORAMAC_NVM_NOTIFY_FLAG_MAC_GROUP2 0x04 146 147 /*! 148 * Bitmap value for the NVM group secure element. 149 */ 150 #define LORAMAC_NVM_NOTIFY_FLAG_SECURE_ELEMENT 0x08 151 152 /*! 153 * Bitmap value for the NVM group 1 region. 154 */ 155 #define LORAMAC_NVM_NOTIFY_FLAG_REGION_GROUP1 0x10 156 157 /*! 158 * Bitmap value for the NVM group 2 region. 159 */ 160 #define LORAMAC_NVM_NOTIFY_FLAG_REGION_GROUP2 0x20 161 162 /*! 163 * Bitmap value for the NVM group class b. 164 */ 165 #define LORAMAC_NVM_NOTIFY_FLAG_CLASS_B 0x40 166 167 /*! 168 * LoRaWAN compliance certification protocol port number. 169 * 170 * LoRaWAN Specification V1.x.x, chapter 4.3.2 171 */ 172 #define LORAMAC_CERT_FPORT 224 173 174 /*! 175 * End-Device activation type 176 */ 177 typedef enum eActivationType 178 { 179 /*! 180 * None 181 */ 182 ACTIVATION_TYPE_NONE = 0, 183 /*! 184 * Activation By Personalization (ACTIVATION_TYPE_ABP) 185 */ 186 ACTIVATION_TYPE_ABP = 1, 187 /*! 188 * Over-The-Air Activation (ACTIVATION_TYPE_OTAA) 189 */ 190 ACTIVATION_TYPE_OTAA = 2, 191 }ActivationType_t; 192 193 /*! 194 * LoRaMAC receive window channel parameters 195 */ 196 typedef struct sRxChannelParams 197 { 198 /*! 199 * Frequency in Hz 200 */ 201 uint32_t Frequency; 202 /*! 203 * Data rate 204 * 205 * LoRaWAN Regional Parameters V1.0.2rB 206 * 207 * The allowed ranges are region specific. Please refer to \ref DR_0 to \ref DR_15 for details. 208 */ 209 uint8_t Datarate; 210 }RxChannelParams_t; 211 212 /*! 213 * LoRaMAC receive window enumeration 214 */ 215 typedef enum eLoRaMacRxSlot 216 { 217 /*! 218 * LoRaMAC receive window 1 219 */ 220 RX_SLOT_WIN_1, 221 /*! 222 * LoRaMAC receive window 2 223 */ 224 RX_SLOT_WIN_2, 225 /*! 226 * LoRaMAC receive window 2 for class c - continuous listening 227 */ 228 RX_SLOT_WIN_CLASS_C, 229 /*! 230 * LoRaMAC class c multicast downlink 231 */ 232 RX_SLOT_WIN_CLASS_C_MULTICAST, 233 /*! 234 * LoRaMAC class b ping slot window 235 */ 236 RX_SLOT_WIN_CLASS_B_PING_SLOT, 237 /*! 238 * LoRaMAC class b multicast slot window 239 */ 240 RX_SLOT_WIN_CLASS_B_MULTICAST_SLOT, 241 /*! 242 * LoRaMAC no active receive window 243 */ 244 RX_SLOT_NONE, 245 }LoRaMacRxSlot_t; 246 247 /*! 248 * Global MAC layer parameters 249 */ 250 typedef struct sLoRaMacParams 251 { 252 /*! 253 * System overall timing error in milliseconds. 254 * [-SystemMaxRxError : +SystemMaxRxError] 255 * Default: +/-10 ms 256 */ 257 uint32_t SystemMaxRxError; 258 /*! 259 * Minimum required number of symbols to detect an Rx frame 260 * Default: 6 symbols 261 */ 262 uint8_t MinRxSymbols; 263 /*! 264 * LoRaMac maximum time a reception window stays open 265 */ 266 uint32_t MaxRxWindow; 267 /*! 268 * Receive delay 1 269 */ 270 uint32_t ReceiveDelay1; 271 /*! 272 * Receive delay 2 273 */ 274 uint32_t ReceiveDelay2; 275 /*! 276 * Join accept delay 1 277 */ 278 uint32_t JoinAcceptDelay1; 279 /*! 280 * Join accept delay 1 281 */ 282 uint32_t JoinAcceptDelay2; 283 /*! 284 * Number of uplink messages repetitions [1:15] 285 */ 286 uint8_t ChannelsNbTrans; 287 /*! 288 * Datarate offset between uplink and downlink on first window 289 */ 290 uint8_t Rx1DrOffset; 291 /*! 292 * LoRaMAC 2nd reception window settings 293 */ 294 RxChannelParams_t Rx2Channel; 295 /*! 296 * LoRaMAC continuous reception window settings 297 */ 298 RxChannelParams_t RxCChannel; 299 /*! 300 * Uplink dwell time configuration. 0: No limit, 1: 400ms 301 */ 302 uint8_t UplinkDwellTime; 303 /*! 304 * Downlink dwell time configuration. 0: No limit, 1: 400ms 305 */ 306 uint8_t DownlinkDwellTime; 307 /*! 308 * Maximum possible EIRP 309 */ 310 float MaxEirp; 311 /*! 312 * Antenna gain of the node 313 */ 314 float AntennaGain; 315 /*! 316 * Limit of uplinks without any donwlink response before the ADRACKReq bit 317 * will be set. 318 */ 319 uint16_t AdrAckLimit; 320 /*! 321 * Limit of uplinks without any donwlink response after a the first frame 322 * with set ADRACKReq bit before the trying to regain the connectivity. 323 */ 324 uint16_t AdrAckDelay; 325 }LoRaMacParams_t; 326 327 /*! 328 * LoRaMAC data structure for a PingSlotInfoReq \ref MLME_PING_SLOT_INFO 329 * 330 * LoRaWAN Specification 331 */ 332 typedef union uPingSlotInfo 333 { 334 /*! 335 * Parameter for byte access 336 */ 337 uint8_t Value; 338 /*! 339 * Structure containing the parameters for the PingSlotInfoReq 340 */ 341 struct sInfoFields 342 { 343 /*! 344 * Periodicity = 0: ping slot every second 345 * Periodicity = 7: ping slot every 128 seconds 346 */ 347 uint8_t Periodicity : 3; 348 /*! 349 * RFU 350 */ 351 uint8_t RFU : 5; 352 }Fields; 353 }PingSlotInfo_t; 354 355 /*! 356 * LoRaMAC data structure for the \ref MLME_BEACON MLME-Indication 357 * 358 * LoRaWAN Specification 359 */ 360 typedef struct sBeaconInfo 361 { 362 /*! 363 * Timestamp in seconds since 00:00:00, Sunday 6th of January 1980 364 * (start of the GPS epoch) modulo 2^32 365 */ 366 SysTime_t Time; 367 /*! 368 * Frequency 369 */ 370 uint32_t Frequency; 371 /*! 372 * Datarate 373 */ 374 uint8_t Datarate; 375 /*! 376 * RSSI 377 */ 378 int16_t Rssi; 379 /*! 380 * SNR 381 */ 382 int8_t Snr; 383 /*! 384 * Param 385 * | Bits | 7:2 | 1:0 | 386 * |-------|-----|------| 387 * | Param | RFU | Prec | 388 * 389 * Prec field is used to interpret the precision of beacon's transmit time 390 * as 10^(-6+prec) and the default value is 0. 391 * RFU will be set to Zero and Prec can take values between 0:3. 392 */ 393 uint8_t Param; 394 /*! 395 * Data structure for the gateway specific part. The 396 * content of the values may differ for each gateway 397 */ 398 struct sGwSpecific 399 { 400 /*! 401 * Info descriptor - can differ for each gateway 402 */ 403 uint8_t InfoDesc; 404 /*! 405 * Info - can differ for each gateway 406 */ 407 uint8_t Info[6]; 408 }GwSpecific; 409 }BeaconInfo_t; 410 411 /*! 412 * Enumeration containing the status of the operation of a MAC service 413 */ 414 typedef enum eLoRaMacEventInfoStatus 415 { 416 /*! 417 * Service performed successfully 418 */ 419 LORAMAC_EVENT_INFO_STATUS_OK = 0, 420 /*! 421 * An error occurred during the execution of the service 422 */ 423 LORAMAC_EVENT_INFO_STATUS_ERROR, 424 /*! 425 * A Tx timeout occurred 426 */ 427 LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT, 428 /*! 429 * An Rx timeout occurred on receive window 1 430 */ 431 LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT, 432 /*! 433 * An Rx timeout occurred on receive window 2 434 */ 435 LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT, 436 /*! 437 * An Rx error occurred on receive window 1 438 */ 439 LORAMAC_EVENT_INFO_STATUS_RX1_ERROR, 440 /*! 441 * An Rx error occurred on receive window 2 442 */ 443 LORAMAC_EVENT_INFO_STATUS_RX2_ERROR, 444 /*! 445 * An error occurred in the join procedure 446 */ 447 LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL, 448 /*! 449 * A frame with an invalid downlink counter was received. The 450 * downlink counter of the frame was equal to the local copy 451 * of the downlink counter of the node. 452 */ 453 LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED, 454 /*! 455 * The MAC could not retransmit a frame since the MAC decreased the datarate. The 456 * payload size is not applicable for the datarate. 457 */ 458 LORAMAC_EVENT_INFO_STATUS_TX_DR_PAYLOAD_SIZE_ERROR, 459 /*! 460 * An address error occurred 461 */ 462 LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL, 463 /*! 464 * Message integrity check failure 465 */ 466 LORAMAC_EVENT_INFO_STATUS_MIC_FAIL, 467 /*! 468 * ToDo 469 */ 470 LORAMAC_EVENT_INFO_STATUS_MULTICAST_FAIL, 471 /*! 472 * ToDo 473 */ 474 LORAMAC_EVENT_INFO_STATUS_BEACON_LOCKED, 475 /*! 476 * ToDo 477 */ 478 LORAMAC_EVENT_INFO_STATUS_BEACON_LOST, 479 /*! 480 * ToDo 481 */ 482 LORAMAC_EVENT_INFO_STATUS_BEACON_NOT_FOUND, 483 }LoRaMacEventInfoStatus_t; 484 485 /*! 486 * LoRaMac tx/rx operation state 487 */ 488 typedef union eLoRaMacFlags_t 489 { 490 /*! 491 * Byte-access to the bits 492 */ 493 uint8_t Value; 494 /*! 495 * Structure containing single access to bits 496 */ 497 struct sMacFlagBits 498 { 499 /*! 500 * MCPS-Req pending 501 */ 502 uint8_t McpsReq : 1; 503 /*! 504 * MCPS-Ind pending 505 */ 506 uint8_t McpsInd : 1; 507 /*! 508 * MLME-Req pending 509 */ 510 uint8_t MlmeReq : 1; 511 /*! 512 * MLME-Ind pending 513 */ 514 uint8_t MlmeInd : 1; 515 /*! 516 * MAC cycle done 517 */ 518 uint8_t MacDone : 1; 519 /*! 520 * Indicate if a NVM handling is required 521 */ 522 uint8_t NvmHandle : 1; 523 }Bits; 524 }LoRaMacFlags_t; 525 526 /*! 527 * LoRaMAC region enumeration 528 */ 529 typedef enum eLoRaMacRegion 530 { 531 /*! 532 * AS band on 923MHz 533 */ 534 LORAMAC_REGION_AS923, 535 /*! 536 * Australian band on 915MHz 537 */ 538 LORAMAC_REGION_AU915, 539 /*! 540 * Chinese band on 470MHz 541 */ 542 LORAMAC_REGION_CN470, 543 /*! 544 * Chinese band on 779MHz 545 */ 546 LORAMAC_REGION_CN779, 547 /*! 548 * European band on 433MHz 549 */ 550 LORAMAC_REGION_EU433, 551 /*! 552 * European band on 868MHz 553 */ 554 LORAMAC_REGION_EU868, 555 /*! 556 * South korean band on 920MHz 557 */ 558 LORAMAC_REGION_KR920, 559 /*! 560 * India band on 865MHz 561 */ 562 LORAMAC_REGION_IN865, 563 /*! 564 * North american band on 915MHz 565 */ 566 LORAMAC_REGION_US915, 567 /*! 568 * Russia band on 864MHz 569 */ 570 LORAMAC_REGION_RU864, 571 }LoRaMacRegion_t; 572 573 typedef struct sLoRaMacNvmDataGroup1 574 { 575 /*! 576 * Counts the number of missed ADR acknowledgements 577 */ 578 uint32_t AdrAckCounter; 579 /*! 580 * Last transmission time. 581 */ 582 TimerTime_t LastTxDoneTime; 583 /*! 584 * Aggregated time off. 585 */ 586 TimerTime_t AggregatedTimeOff; 587 /*! 588 * Last received Message integrity Code (MIC) 589 */ 590 uint32_t LastRxMic; 591 /*! 592 * Channels TX power 593 */ 594 int8_t ChannelsTxPower; 595 /*! 596 * Channels data rate 597 */ 598 int8_t ChannelsDatarate; 599 /*! 600 * If the server has sent a FRAME_TYPE_DATA_CONFIRMED_DOWN this variable indicates 601 * if the ACK bit must be set for the next transmission 602 */ 603 bool SrvAckRequested; 604 /*! 605 * Counts the number if uplinks to know when the next Rejoin request type 0 is required. 606 * ( If requested by the server through RejoinParamSetupReq MAC command ) 607 */ 608 uint32_t Rejoin0UplinksCounter; 609 /*! 610 * Counter of Rejoin Request of retries. 611 * ( If requested by the server through ForceRejoinReq MAC command ) 612 */ 613 uint8_t ForceRejoinRetriesCounter; 614 /*! 615 * Counts the number of uplinks containing a RekeyInd MAC command to know 616 * when the end device should reverted to join state because it didn't 617 * received a RekeyConf. 618 */ 619 uint16_t RekeyIndUplinksCounter; 620 /*! 621 * CRC32 value of the MacGroup1 data structure. 622 */ 623 uint32_t Crc32; 624 }LoRaMacNvmDataGroup1_t; 625 626 typedef struct sLoRaMacNvmDataGroup2 627 { 628 /* 629 * LoRaMac region. 630 */ 631 LoRaMacRegion_t Region; 632 /* 633 * LoRaMac parameters 634 */ 635 LoRaMacParams_t MacParams; 636 /* 637 * LoRaMac default parameters 638 */ 639 LoRaMacParams_t MacParamsDefaults; 640 /*! 641 * Channels TX power 642 */ 643 int8_t ChannelsTxPowerDefault; 644 /*! 645 * Channels data rate 646 */ 647 int8_t ChannelsDatarateDefault; 648 /* 649 * Network ID ( 3 bytes ) 650 */ 651 uint32_t NetID; 652 /* 653 * Mote Address 654 */ 655 uint32_t DevAddr; 656 /*! 657 * Multicast channel list 658 */ 659 MulticastCtx_t MulticastChannelList[LORAMAC_MAX_MC_CTX]; 660 /* 661 * Actual device class 662 */ 663 DeviceClass_t DeviceClass; 664 /* 665 * Indicates if the node is connected to 666 * a private or public network 667 */ 668 bool PublicNetwork; 669 /* 670 * LoRaMac ADR control status 671 */ 672 bool AdrCtrlOn; 673 /* 674 * Maximum duty cycle 675 * \remark Possibility to shutdown the device. 676 */ 677 uint8_t MaxDCycle; 678 /* 679 * Enables/Disables duty cycle management (Test only) 680 */ 681 bool DutyCycleOn; 682 /* 683 * Set to true, if the datarate was increased 684 * with a link adr request. 685 */ 686 bool ChannelsDatarateChangedLinkAdrReq; 687 /* 688 * The stack will set this variable to true, if a downlink has been received. 689 */ 690 bool DownlinkReceived; 691 /* 692 * Enables/disable FPort 224 processing (certification port) 693 */ 694 bool IsCertPortOn; 695 /* 696 * Aggregated duty cycle management 697 */ 698 uint16_t AggregatedDCycle; 699 /* 700 * Stores the time at LoRaMac initialization. 701 * 702 * \remark Used for the BACKOFF_DC computation. 703 */ 704 SysTime_t InitializationTime; 705 /* 706 * Current LoRaWAN Version 707 */ 708 Version_t Version; 709 /* 710 * End-Device network activation 711 */ 712 ActivationType_t NetworkActivation; 713 /*! 714 * Number of uplinks without Rejoin request type 0. 715 * ( If requested by the server through RejoinParamSetupReq MAC command ) 716 * When it's set to 0, Rejoin0UplinksCounter won't be incremented 717 */ 718 uint32_t Rejoin0UplinksLimit; 719 /*! 720 * The total number of times the device will retry the Rejoin Request. 721 * ( If requested by the server through ForceRejoinReq MAC command ) 722 */ 723 uint8_t ForceRejoinMaxRetries; 724 /*! 725 * Rejoin Request Type 726 * ( If requested by the server through ForceRejoinReq MAC command ) 727 */ 728 uint8_t ForceRejoinType; 729 /*! 730 * Time in seconds between cyclic transmission of Type 0 Rejoin requests. 731 */ 732 uint32_t Rejoin0CycleInSec; 733 /*! 734 * Time in seconds between cyclic transmission of Type 1 Rejoin requests. 735 */ 736 uint32_t Rejoin1CycleInSec; 737 /*! 738 * Indicates if a Rejoin request was sent and no join-accept or any downlink 739 * has been received yet. 740 */ 741 bool IsRejoinAcceptPending; 742 /*! 743 * Indicates if a reqjoin request 0 is in the queue to send. 744 */ 745 bool IsRejoin0RequestQueued; 746 /*! 747 * Indicates if a reqjoin request 1 is in the queue to send. 748 */ 749 bool IsRejoin1RequestQueued; 750 /*! 751 * Indicates if a reqjoin request 2 is in the queue to send. 752 */ 753 bool IsRejoin2RequestQueued; 754 /*! 755 * CRC32 value of the MacGroup2 data structure. 756 */ 757 uint32_t Crc32; 758 }LoRaMacNvmDataGroup2_t; 759 760 /*! 761 * LoRaMAC data structure for non-volatile memory (NVM). 762 * This structure contains data which must be stored in NVM. 763 */ 764 typedef struct sLoRaMacNvmData 765 { 766 /*! 767 * Parameters related to the crypto layer. Change with every TX/RX 768 * procedure. 769 */ 770 LoRaMacCryptoNvmData_t Crypto; 771 /*! 772 * Parameters related to the MAC which change with high probability after 773 * every TX/RX procedure. 774 */ 775 LoRaMacNvmDataGroup1_t MacGroup1; 776 /*! 777 * Parameters related to the MAC which do not change very likely with every 778 * TX/RX procedure. 779 */ 780 LoRaMacNvmDataGroup2_t MacGroup2; 781 /*! 782 * Parameters related to the secure-element. 783 */ 784 SecureElementNvmData_t SecureElement; 785 /*! 786 * Parameters related to the regional implementation which change with high 787 * probability after every TX/RX procedure. 788 */ 789 RegionNvmDataGroup1_t RegionGroup1; 790 /*! 791 * Parameters related to the regional implementation which do not change 792 * very likely with every TX/RX procedure. 793 */ 794 RegionNvmDataGroup2_t RegionGroup2; 795 /*! 796 * Parameters related to class b. 797 */ 798 LoRaMacClassBNvmData_t ClassB; 799 }LoRaMacNvmData_t; 800 801 /*! 802 * 803 * \brief LoRaMAC data services 804 * 805 * \details The following table list the primitives which are supported by the 806 * specific MAC data service: 807 * 808 * Name | Request | Indication | Response | Confirm 809 * --------------------- | :-----: | :--------: | :------: | :-----: 810 * \ref MCPS_UNCONFIRMED | YES | YES | NO | YES 811 * \ref MCPS_CONFIRMED | YES | YES | NO | YES 812 * \ref MCPS_MULTICAST | NO | YES | NO | NO 813 * \ref MCPS_PROPRIETARY | YES | YES | NO | YES 814 * 815 * The following table provides links to the function implementations of the 816 * related MCPS primitives: 817 * 818 * Primitive | Function 819 * ---------------- | :---------------------: 820 * MCPS-Request | \ref LoRaMacMlmeRequest 821 * MCPS-Confirm | MacMcpsConfirm in \ref LoRaMacPrimitives_t 822 * MCPS-Indication | MacMcpsIndication in \ref LoRaMacPrimitives_t 823 */ 824 typedef enum eMcps 825 { 826 /*! 827 * Unconfirmed LoRaMAC frame 828 */ 829 MCPS_UNCONFIRMED, 830 /*! 831 * Confirmed LoRaMAC frame 832 */ 833 MCPS_CONFIRMED, 834 /*! 835 * Multicast LoRaMAC frame 836 */ 837 MCPS_MULTICAST, 838 /*! 839 * Proprietary frame 840 */ 841 MCPS_PROPRIETARY, 842 }Mcps_t; 843 844 /*! 845 * Structure which defines return parameters for requests. 846 */ 847 typedef struct sRequestReturnParam 848 { 849 /*! 850 * This value reports the time in milliseconds which 851 * an application must wait before its possible to send 852 * the next uplink. 853 */ 854 TimerTime_t DutyCycleWaitTime; 855 }RequestReturnParam_t; 856 857 /*! 858 * LoRaMAC MCPS-Request for an unconfirmed frame 859 */ 860 typedef struct sMcpsReqUnconfirmed 861 { 862 /*! 863 * Frame port field. Must be set if the payload is not empty. Use the 864 * application specific frame port values: [1...223] 865 * 866 * LoRaWAN Specification V1.0.2, chapter 4.3.2 867 */ 868 uint8_t fPort; 869 /*! 870 * Pointer to the buffer of the frame payload 871 */ 872 void* fBuffer; 873 /*! 874 * Size of the frame payload 875 */ 876 uint16_t fBufferSize; 877 /*! 878 * Uplink datarate, if ADR is off 879 */ 880 int8_t Datarate; 881 }McpsReqUnconfirmed_t; 882 883 /*! 884 * LoRaMAC MCPS-Request for a confirmed frame 885 */ 886 typedef struct sMcpsReqConfirmed 887 { 888 /*! 889 * Frame port field. Must be set if the payload is not empty. Use the 890 * application specific frame port values: [1...223] 891 * 892 * LoRaWAN Specification V1.0.2, chapter 4.3.2 893 */ 894 uint8_t fPort; 895 /*! 896 * Pointer to the buffer of the frame payload 897 */ 898 void* fBuffer; 899 /*! 900 * Size of the frame payload 901 */ 902 uint16_t fBufferSize; 903 /*! 904 * Uplink datarate, if ADR is off 905 */ 906 int8_t Datarate; 907 }McpsReqConfirmed_t; 908 909 /*! 910 * LoRaMAC MCPS-Request for a proprietary frame 911 */ 912 typedef struct sMcpsReqProprietary 913 { 914 /*! 915 * Pointer to the buffer of the frame payload 916 */ 917 void* fBuffer; 918 /*! 919 * Size of the frame payload 920 */ 921 uint16_t fBufferSize; 922 /*! 923 * Uplink datarate, if ADR is off 924 */ 925 int8_t Datarate; 926 }McpsReqProprietary_t; 927 928 /*! 929 * LoRaMAC MCPS-Request structure 930 */ 931 typedef struct sMcpsReq 932 { 933 /*! 934 * MCPS-Request type 935 */ 936 Mcps_t Type; 937 938 /*! 939 * MCPS-Request parameters 940 */ 941 union uMcpsParam 942 { 943 /*! 944 * MCPS-Request parameters for an unconfirmed frame 945 */ 946 McpsReqUnconfirmed_t Unconfirmed; 947 /*! 948 * MCPS-Request parameters for a confirmed frame 949 */ 950 McpsReqConfirmed_t Confirmed; 951 /*! 952 * MCPS-Request parameters for a proprietary frame 953 */ 954 McpsReqProprietary_t Proprietary; 955 }Req; 956 957 /*! 958 * MCPS-Request return parameters 959 */ 960 RequestReturnParam_t ReqReturn; 961 }McpsReq_t; 962 963 /*! 964 * LoRaMAC MCPS-Confirm 965 */ 966 typedef struct sMcpsConfirm 967 { 968 /*! 969 * Holds the previously performed MCPS-Request 970 */ 971 Mcps_t McpsRequest; 972 /*! 973 * Status of the operation 974 */ 975 LoRaMacEventInfoStatus_t Status; 976 /*! 977 * Uplink datarate 978 */ 979 uint8_t Datarate; 980 /*! 981 * Transmission power 982 */ 983 int8_t TxPower; 984 /*! 985 * Set if an acknowledgement was received 986 */ 987 bool AckReceived; 988 /*! 989 * Provides the number of retransmissions 990 */ 991 uint8_t NbTrans; 992 /*! 993 * The transmission time on air of the frame 994 */ 995 TimerTime_t TxTimeOnAir; 996 /*! 997 * The uplink counter value related to the frame 998 */ 999 uint32_t UpLinkCounter; 1000 /*! 1001 * The uplink channel related to the frame 1002 */ 1003 uint32_t Channel; 1004 }McpsConfirm_t; 1005 1006 /*! 1007 * LoRaMAC MCPS-Indication primitive 1008 */ 1009 typedef struct sMcpsIndication 1010 { 1011 /*! 1012 * MCPS-Indication type 1013 */ 1014 Mcps_t McpsIndication; 1015 /*! 1016 * Status of the operation 1017 */ 1018 LoRaMacEventInfoStatus_t Status; 1019 /*! 1020 * Multicast 1021 */ 1022 uint8_t Multicast; 1023 /*! 1024 * Application port 1025 */ 1026 uint8_t Port; 1027 /*! 1028 * Downlink datarate 1029 */ 1030 uint8_t RxDatarate; 1031 /*! 1032 * Frame pending status 1033 */ 1034 uint8_t IsUplinkTxPending; 1035 /*! 1036 * Pointer to the received data stream 1037 */ 1038 uint8_t* Buffer; 1039 /*! 1040 * Size of the received data stream 1041 */ 1042 uint8_t BufferSize; 1043 /*! 1044 * Indicates, if data is available 1045 */ 1046 bool RxData; 1047 /*! 1048 * Rssi of the received packet 1049 */ 1050 int16_t Rssi; 1051 /*! 1052 * Snr of the received packet 1053 */ 1054 int8_t Snr; 1055 /*! 1056 * Receive window 1057 */ 1058 LoRaMacRxSlot_t RxSlot; 1059 /*! 1060 * Set if an acknowledgement was received 1061 */ 1062 bool AckReceived; 1063 /*! 1064 * The downlink counter value for the received frame 1065 */ 1066 uint32_t DownLinkCounter; 1067 /*! 1068 * The device address of the frame 1069 */ 1070 uint32_t DevAddress; 1071 /*! 1072 * Set if a DeviceTimeAns MAC command was received. 1073 */ 1074 bool DeviceTimeAnsReceived; 1075 /*! 1076 * Response timeout for a class b or c device when a 1077 * confirmed downlink has been received. In all other 1078 * cases this variable is 0. 1079 */ 1080 TimerTime_t ResponseTimeout; 1081 }McpsIndication_t; 1082 1083 /*! 1084 * \brief LoRaMAC management services 1085 * 1086 * \details The following table list the primitives which are supported by the 1087 * specific MAC management service: 1088 * 1089 * Name | Request | Indication | Response | Confirm 1090 * ---------------------------- | :-----: | :--------: | :------: | :-----: 1091 * \ref MLME_JOIN | YES | NO | NO | YES 1092 * \ref MLME_REJOIN_0 | YES | NO | NO | YES 1093 * \ref MLME_REJOIN_1 | YES | NO | NO | YES 1094 * \ref MLME_LINK_CHECK | YES | NO | NO | YES 1095 * \ref MLME_TXCW | YES | NO | NO | YES 1096 * \ref MLME_DERIVE_MC_KE_KEY | YES | NO | NO | YES 1097 * \ref MLME_DERIVE_MC_KEY_PAIR | YES | NO | NO | YES 1098 * \ref MLME_REVERT_JOIN | NO | YES | NO | NO 1099 * 1100 * The following table provides links to the function implementations of the 1101 * related MLME primitives. 1102 * 1103 * Primitive | Function 1104 * ---------------- | :---------------------: 1105 * MLME-Request | \ref LoRaMacMlmeRequest 1106 * MLME-Confirm | MacMlmeConfirm in \ref LoRaMacPrimitives_t 1107 * MLME-Indication | MacMlmeIndication in \ref LoRaMacPrimitives_t 1108 */ 1109 typedef enum eMlme 1110 { 1111 /*! 1112 * An unknown MLME service 1113 */ 1114 MLME_UNKNOWN, 1115 /*! 1116 * Initiates the Over-the-Air activation 1117 * 1118 * LoRaWAN Specification V1.0.2, chapter 6.2 1119 */ 1120 MLME_JOIN, 1121 /*! 1122 * Initiates sending a ReJoin-request type 0 1123 * 1124 * LoRaWAN Specification V1.1.0, chapter 6.2.4.1 1125 */ 1126 MLME_REJOIN_0, 1127 /*! 1128 * Initiates sending a ReJoin-request type 1 1129 * 1130 * LoRaWAN Specification V1.1.0, chapter 6.2.4.2 1131 */ 1132 MLME_REJOIN_1, 1133 /*! 1134 * Initiates sending a ReJoin-request type 2 1135 * 1136 * LoRaWAN Specification V1.1.0, chapter 6.2.4.2 1137 */ 1138 MLME_REJOIN_2, 1139 /*! 1140 * LinkCheckReq - Connectivity validation 1141 * 1142 * LoRaWAN Specification V1.0.2, chapter 5, table 4 1143 */ 1144 MLME_LINK_CHECK, 1145 /*! 1146 * Sets Tx continuous wave mode 1147 * 1148 * LoRaWAN end-device certification 1149 */ 1150 MLME_TXCW, 1151 /*! 1152 * Derives the McKEKey from the AppKey or NwkKey. 1153 */ 1154 MLME_DERIVE_MC_KE_KEY, 1155 /*! 1156 * Derives a Multicast group key pair ( McAppSKey, McNwkSKey ) from McKey 1157 */ 1158 MLME_DERIVE_MC_KEY_PAIR, 1159 /*! 1160 * Initiates a DeviceTimeReq 1161 * 1162 * LoRaWAN end-device certification 1163 */ 1164 MLME_DEVICE_TIME, 1165 /*! 1166 * The MAC uses this MLME primitive to indicate a beacon reception 1167 * status. 1168 * 1169 * LoRaWAN end-device certification 1170 */ 1171 MLME_BEACON, 1172 /*! 1173 * Initiate a beacon acquisition. The MAC will search for a beacon. 1174 * It will search for XX_BEACON_INTERVAL milliseconds. 1175 * 1176 * LoRaWAN end-device certification 1177 */ 1178 MLME_BEACON_ACQUISITION, 1179 /*! 1180 * Initiates a PingSlotInfoReq 1181 * 1182 * LoRaWAN end-device certification 1183 */ 1184 MLME_PING_SLOT_INFO, 1185 /*! 1186 * Initiates a BeaconTimingReq 1187 * 1188 * LoRaWAN end-device certification 1189 */ 1190 MLME_BEACON_TIMING, 1191 /*! 1192 * Primitive which indicates that the beacon has been lost 1193 * 1194 * \remark The upper layer is required to switch the device class to ClassA 1195 * 1196 * LoRaWAN end-device certification 1197 */ 1198 MLME_BEACON_LOST, 1199 /*! 1200 * 1201 * Indicates that the device hasn't received a RekeyConf and it reverts to the join state. 1202 * 1203 * \remark The upper layer is required to trigger the Join process again. 1204 */ 1205 MLME_REVERT_JOIN, 1206 }Mlme_t; 1207 1208 /*! 1209 * LoRaMAC MLME-Request for the join service 1210 */ 1211 typedef struct sMlmeReqJoin 1212 { 1213 /*! 1214 * LoRaWAN Network End-Device Activation ( ACTIVATION_TYPE_NONE, ACTIVATION_TYPE_ABP or OTTA ) 1215 * 1216 * Related MIB type: \ref MIB_NETWORK_ACTIVATION 1217 */ 1218 ActivationType_t NetworkActivation; 1219 /*! 1220 * Datarate used for join request. 1221 */ 1222 uint8_t Datarate; 1223 }MlmeReqJoin_t; 1224 1225 /*! 1226 * LoRaMAC MLME-Request for Tx continuous wave mode 1227 */ 1228 typedef struct sMlmeReqTxCw 1229 { 1230 /*! 1231 * Time in seconds while the radio is kept in continuous wave mode 1232 */ 1233 uint16_t Timeout; 1234 /*! 1235 * RF frequency to set (Only used with new way) 1236 */ 1237 uint32_t Frequency; 1238 /*! 1239 * RF output power to set (Only used with new way) 1240 */ 1241 int8_t Power; 1242 }MlmeReqTxCw_t; 1243 1244 /*! 1245 * LoRaMAC MLME-Request for the ping slot info service 1246 */ 1247 typedef struct sMlmeReqPingSlotInfo 1248 { 1249 PingSlotInfo_t PingSlot; 1250 }MlmeReqPingSlotInfo_t; 1251 1252 /*! 1253 * LoRaMAC MLME-Request to derive the McKEKey from the AppKey or NwkKey 1254 */ 1255 typedef struct sMlmeReqDeriveMcKEKey 1256 { 1257 /*! 1258 * Key identifier of the root key to use to perform the derivation ( NwkKey or AppKey ) 1259 */ 1260 KeyIdentifier_t KeyID; 1261 /*! 1262 * Nonce value ( nonce <= 15) 1263 */ 1264 uint16_t Nonce; 1265 /*! 1266 * DevEUI Value 1267 */ 1268 uint8_t* DevEUI; 1269 }MlmeReqDeriveMcKEKey_t; 1270 1271 /*! 1272 * LoRaMAC MLME-Request to derive a Multicast group key pair ( McAppSKey, McNwkSKey ) from McKey 1273 */ 1274 typedef struct sMlmeReqDeriveMcSessionKeyPair 1275 { 1276 /*! 1277 * Address identifier to select the multicast group 1278 */ 1279 AddressIdentifier_t GroupID; 1280 }MlmeReqDeriveMcSessionKeyPair_t; 1281 1282 /*! 1283 * LoRaMAC MLME-Request structure 1284 */ 1285 typedef struct sMlmeReq 1286 { 1287 /*! 1288 * MLME-Request type 1289 */ 1290 Mlme_t Type; 1291 1292 /*! 1293 * MLME-Request parameters 1294 */ 1295 union uMlmeParam 1296 { 1297 /*! 1298 * MLME-Request parameters for a join request 1299 */ 1300 MlmeReqJoin_t Join; 1301 /*! 1302 * MLME-Request parameters for Tx continuous mode request 1303 */ 1304 MlmeReqTxCw_t TxCw; 1305 /*! 1306 * MLME-Request parameters for a ping slot info request 1307 */ 1308 MlmeReqPingSlotInfo_t PingSlotInfo; 1309 /*! 1310 * MLME-Request to derive the McKEKey from the AppKey or NwkKey 1311 */ 1312 MlmeReqDeriveMcKEKey_t DeriveMcKEKey; 1313 /*! 1314 * MLME-Request to derive a Multicast group key pair ( McAppSKey, McNwkSKey ) from McKey 1315 */ 1316 MlmeReqDeriveMcSessionKeyPair_t DeriveMcSessionKeyPair; 1317 }Req; 1318 1319 /*! 1320 * MLME-Request return parameters 1321 */ 1322 RequestReturnParam_t ReqReturn; 1323 }MlmeReq_t; 1324 1325 /*! 1326 * LoRaMAC MLME-Confirm primitive 1327 */ 1328 typedef struct sMlmeConfirm 1329 { 1330 /*! 1331 * Holds the previously performed MLME-Request 1332 */ 1333 Mlme_t MlmeRequest; 1334 /*! 1335 * Status of the operation 1336 */ 1337 LoRaMacEventInfoStatus_t Status; 1338 /*! 1339 * The transmission time on air of the frame 1340 */ 1341 TimerTime_t TxTimeOnAir; 1342 /*! 1343 * Demodulation margin. Contains the link margin [dB] of the last 1344 * successfully received LinkCheckReq 1345 */ 1346 uint8_t DemodMargin; 1347 /*! 1348 * Number of gateways which received the last LinkCheckReq 1349 */ 1350 uint8_t NbGateways; 1351 /*! 1352 * Provides the number of retransmissions 1353 */ 1354 uint8_t NbRetries; 1355 /*! 1356 * The delay which we have received through the 1357 * BeaconTimingAns 1358 */ 1359 TimerTime_t BeaconTimingDelay; 1360 /*! 1361 * The channel of the next beacon 1362 */ 1363 uint8_t BeaconTimingChannel; 1364 }MlmeConfirm_t; 1365 1366 /*! 1367 * LoRaMAC MLME-Indication primitive 1368 */ 1369 typedef struct sMlmeIndication 1370 { 1371 /*! 1372 * MLME-Indication type 1373 */ 1374 Mlme_t MlmeIndication; 1375 /*! 1376 * Status of the operation 1377 */ 1378 LoRaMacEventInfoStatus_t Status; 1379 /*! 1380 * Beacon information. Only valid for \ref MLME_BEACON, 1381 * status \ref LORAMAC_EVENT_INFO_STATUS_BEACON_LOCKED 1382 */ 1383 BeaconInfo_t BeaconInfo; 1384 }MlmeIndication_t; 1385 1386 /*! 1387 * LoRa Mac Information Base (MIB) 1388 * 1389 * The following table lists the MIB parameters and the related attributes: 1390 * 1391 * Attribute | Get | Set 1392 * ----------------------------------------------| :-: | :-: 1393 * \ref MIB_DEVICE_CLASS | YES | YES 1394 * \ref MIB_NETWORK_ACTIVATION | YES | YES 1395 * \ref MIB_DEV_EUI | YES | YES 1396 * \ref MIB_JOIN_EUI | YES | YES 1397 * \ref MIB_SE_PIN | YES | YES 1398 * \ref MIB_ADR | YES | YES 1399 * \ref MIB_NET_ID | YES | YES 1400 * \ref MIB_DEV_ADDR | YES | YES 1401 * \ref MIB_APP_KEY | NO | YES 1402 * \ref MIB_NWK_KEY | NO | YES 1403 * \ref MIB_J_S_INT_KEY | NO | YES 1404 * \ref MIB_J_S_ENC_KEY | NO | YES 1405 * \ref MIB_F_NWK_S_INT_KEY | NO | YES 1406 * \ref MIB_S_NWK_S_INT_KEY | NO | YES 1407 * \ref MIB_NWK_S_ENC_KEY | NO | YES 1408 * \ref MIB_APP_S_KEY | NO | YES 1409 * \ref MIB_MC_KE_KEY | NO | YES 1410 * \ref MIB_MC_KEY_0 | NO | YES 1411 * \ref MIB_MC_APP_S_KEY_0 | NO | YES 1412 * \ref MIB_MC_NWK_S_KEY_0 | NO | YES 1413 * \ref MIB_MC_KEY_1 | NO | YES 1414 * \ref MIB_MC_APP_S_KEY_1 | NO | YES 1415 * \ref MIB_MC_NWK_S_KEY_1 | NO | YES 1416 * \ref MIB_MC_KEY_2 | NO | YES 1417 * \ref MIB_MC_APP_S_KEY_2 | NO | YES 1418 * \ref MIB_MC_NWK_S_KEY_2 | NO | YES 1419 * \ref MIB_MC_KEY_3 | NO | YES 1420 * \ref MIB_MC_APP_S_KEY_3 | NO | YES 1421 * \ref MIB_MC_NWK_S_KEY_3 | NO | YES 1422 * \ref MIB_PUBLIC_NETWORK | YES | YES 1423 * \ref MIB_CHANNELS | YES | NO 1424 * \ref MIB_RX2_CHANNEL | YES | YES 1425 * \ref MIB_RX2_DFAULT_CHANNEL | YES | YES 1426 * \ref MIB_RXC_CHANNEL | YES | YES 1427 * \ref MIB_RXC_DFAULT_CHANNEL | YES | YES 1428 * \ref MIB_CHANNELS_MASK | YES | YES 1429 * \ref MIB_CHANNELS_DEFAULT_MASK | YES | YES 1430 * \ref MIB_CHANNELS_NB_TRANS | YES | YES 1431 * \ref MIB_MAX_RX_WINDOW_DURATION | YES | YES 1432 * \ref MIB_RECEIVE_DELAY_1 | YES | YES 1433 * \ref MIB_RECEIVE_DELAY_2 | YES | YES 1434 * \ref MIB_JOIN_ACCEPT_DELAY_1 | YES | YES 1435 * \ref MIB_JOIN_ACCEPT_DELAY_2 | YES | YES 1436 * \ref MIB_CHANNELS_DATARATE | YES | YES 1437 * \ref MIB_CHANNELS_MIN_TX_DATARATE | YES | NO 1438 * \ref MIB_CHANNELS_DEFAULT_DATARATE | YES | YES 1439 * \ref MIB_CHANNELS_TX_POWER | YES | YES 1440 * \ref MIB_CHANNELS_DEFAULT_TX_POWER | YES | YES 1441 * \ref MIB_SYSTEM_MAX_RX_ERROR | YES | YES 1442 * \ref MIB_MIN_RX_SYMBOLS | YES | YES 1443 * \ref MIB_BEACON_INTERVAL | YES | YES 1444 * \ref MIB_BEACON_RESERVED | YES | YES 1445 * \ref MIB_BEACON_GUARD | YES | YES 1446 * \ref MIB_BEACON_WINDOW | YES | YES 1447 * \ref MIB_BEACON_WINDOW_SLOTS | YES | YES 1448 * \ref MIB_PING_SLOT_WINDOW | YES | YES 1449 * \ref MIB_BEACON_SYMBOL_TO_DEFAULT | YES | YES 1450 * \ref MIB_BEACON_SYMBOL_TO_EXPANSION_MAX | YES | YES 1451 * \ref MIB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX | YES | YES 1452 * \ref MIB_BEACON_SYMBOL_TO_EXPANSION_FACTOR | YES | YES 1453 * \ref MIB_PING_SLOT_SYMBOL_TO_EXPANSION_FACTOR | YES | YES 1454 * \ref MIB_MAX_BEACON_LESS_PERIOD | YES | YES 1455 * \ref MIB_ANTENNA_GAIN | YES | YES 1456 * \ref MIB_DEFAULT_ANTENNA_GAIN | YES | YES 1457 * \ref MIB_NVM_CTXS | YES | YES 1458 * \ref MIB_ABP_LORAWAN_VERSION | NO | YES 1459 * \ref MIB_LORAWAN_VERSION | YES | NO 1460 * \ref MIB_IS_CERT_FPORT_ON | YES | YES 1461 * \ref MIB_REJOIN_0_CYCLE | YES | YES 1462 * \ref MIB_REJOIN_1_CYCLE | YES | YES 1463 * \ref MIB_REJOIN_2_CYCLE | YES | NO 1464 * \ref MIB_ADR_ACK_LIMIT | YES | YES 1465 * \ref MIB_ADR_ACK_DELAY | YES | YES 1466 * \ref MIB_ADR_ACK_DEFAULT_LIMIT | YES | YES 1467 * \ref MIB_ADR_ACK_DEFAULT_DELAY | YES | YES 1468 * \ref MIB_RSSI_FREE_THRESHOLD | YES | YES 1469 * \ref MIB_CARRIER_SENSE_TIME | YES | YES 1470 * 1471 * The following table provides links to the function implementations of the 1472 * related MIB primitives: 1473 * 1474 * Primitive | Function 1475 * ---------------- | :---------------------: 1476 * MIB-Set | \ref LoRaMacMibSetRequestConfirm 1477 * MIB-Get | \ref LoRaMacMibGetRequestConfirm 1478 */ 1479 typedef enum eMib 1480 { 1481 /*! 1482 * LoRaWAN device class 1483 * 1484 * LoRaWAN Specification V1.0.2 1485 */ 1486 MIB_DEVICE_CLASS, 1487 /*! 1488 * LoRaWAN Network End-Device Activation 1489 * 1490 * LoRaWAN Specification V1.0.2 1491 */ 1492 MIB_NETWORK_ACTIVATION, 1493 /*! 1494 * LoRaWAN device EUI 1495 * 1496 * LoRaWAN Specification V1.0.2 1497 */ 1498 MIB_DEV_EUI, 1499 /*! 1500 * LoRaWAN join EUI 1501 * 1502 * LoRaWAN Specification V1.0.2 1503 */ 1504 MIB_JOIN_EUI, 1505 /*! 1506 * Secure-element pin 1507 */ 1508 MIB_SE_PIN, 1509 /*! 1510 * Adaptive data rate 1511 * 1512 * LoRaWAN Specification V1.0.2, chapter 4.3.1.1 1513 * 1514 * [true: ADR enabled, false: ADR disabled] 1515 */ 1516 MIB_ADR, 1517 /*! 1518 * Network identifier 1519 * 1520 * LoRaWAN Specification V1.0.2, chapter 6.1.1 1521 */ 1522 MIB_NET_ID, 1523 /*! 1524 * End-device address 1525 * 1526 * LoRaWAN Specification V1.0.2, chapter 6.1.1 1527 */ 1528 MIB_DEV_ADDR, 1529 /*! 1530 * Application root key 1531 * 1532 * LoRaWAN Specification V1.1.0, chapter 6.1.1.3 1533 */ 1534 MIB_APP_KEY, 1535 /*! 1536 * Network root key 1537 * 1538 * LoRaWAN Specification V1.1.0, chapter 6.1.1.3 1539 */ 1540 MIB_NWK_KEY, 1541 /*! 1542 * Join session integrity key 1543 * 1544 * LoRaWAN Specification V1.1.0, chapter 6.1.1.4 1545 */ 1546 MIB_J_S_INT_KEY, 1547 /*! 1548 * Join session encryption key 1549 * 1550 * LoRaWAN Specification V1.1.0, chapter 6.1.1.4 1551 */ 1552 MIB_J_S_ENC_KEY, 1553 /*! 1554 * Forwarding Network session integrity key 1555 * 1556 * LoRaWAN Specification V1.1.0, chapter 6.1.2.2 1557 */ 1558 MIB_F_NWK_S_INT_KEY, 1559 /*! 1560 * Serving Network session integrity key 1561 * 1562 * LoRaWAN Specification V1.1.0, chapter 6.1.2.3 1563 */ 1564 MIB_S_NWK_S_INT_KEY, 1565 /*! 1566 * Network session encryption key 1567 * 1568 * LoRaWAN Specification V1.1.0, chapter 6.1.2.4 1569 */ 1570 MIB_NWK_S_ENC_KEY, 1571 /*! 1572 * Application session key 1573 * 1574 * LoRaWAN Specification V1.1.0, chapter 6.1.1.3 1575 */ 1576 MIB_APP_S_KEY, 1577 /*! 1578 * Multicast key encryption key 1579 * 1580 * LoRaWAN - Secure element specification v1 1581 */ 1582 MIB_MC_KE_KEY, 1583 /*! 1584 * Multicast root key index 0 1585 * 1586 * LoRaWAN - Secure element specification v1 1587 */ 1588 MIB_MC_KEY_0, 1589 /*! 1590 * Multicast Application session key index 0 1591 * 1592 * LoRaWAN - Secure element specification v1 1593 */ 1594 MIB_MC_APP_S_KEY_0, 1595 /*! 1596 * Multicast Network session key index 0 1597 * 1598 * LoRaWAN - Secure element specification v1 1599 */ 1600 MIB_MC_NWK_S_KEY_0, 1601 /*! 1602 * Multicast root key index 1 1603 * 1604 * LoRaWAN - Secure element specification v1 1605 */ 1606 MIB_MC_KEY_1, 1607 /*! 1608 * Multicast Application session key index 1 1609 * 1610 * LoRaWAN - Secure element specification v1 1611 */ 1612 MIB_MC_APP_S_KEY_1, 1613 /*! 1614 * Multicast Network session key index 1 1615 * 1616 * LoRaWAN - Secure element specification v1 1617 */ 1618 MIB_MC_NWK_S_KEY_1, 1619 /*! 1620 * Multicast root key index 2 1621 * 1622 * LoRaWAN - Secure element specification v1 1623 */ 1624 MIB_MC_KEY_2, 1625 /*! 1626 * Multicast Application session key index 2 1627 * 1628 * LoRaWAN - Secure element specification v1 1629 */ 1630 MIB_MC_APP_S_KEY_2, 1631 /*! 1632 * Multicast Network session key index 2 1633 * 1634 * LoRaWAN - Secure element specification v1 1635 */ 1636 MIB_MC_NWK_S_KEY_2, 1637 /*! 1638 * Multicast root key index 3 1639 * 1640 * LoRaWAN - Secure element specification v1 1641 */ 1642 MIB_MC_KEY_3, 1643 /*! 1644 * Multicast Application session key index 3 1645 * 1646 * LoRaWAN - Secure element specification v1 1647 */ 1648 MIB_MC_APP_S_KEY_3, 1649 /*! 1650 * Multicast Network session key index 3 1651 * 1652 * LoRaWAN - Secure element specification v1 1653 */ 1654 MIB_MC_NWK_S_KEY_3, 1655 /*! 1656 * Set the network type to public or private 1657 * 1658 * LoRaWAN Regional Parameters V1.0.2rB 1659 * 1660 * [true: public network, false: private network] 1661 */ 1662 MIB_PUBLIC_NETWORK, 1663 /*! 1664 * Communication channels. A get request will return a 1665 * pointer which references the first entry of the channel list. The 1666 * list is of size LORA_MAX_NB_CHANNELS 1667 * 1668 * LoRaWAN Regional Parameters V1.0.2rB 1669 */ 1670 MIB_CHANNELS, 1671 /*! 1672 * Set receive window 2 channel 1673 * 1674 * LoRaWAN Specification V1.0.2, chapter 3.3.1 1675 */ 1676 MIB_RX2_CHANNEL, 1677 /*! 1678 * Set receive window 2 channel 1679 * 1680 * LoRaWAN Specification V1.0.2, chapter 3.3.2 1681 */ 1682 MIB_RX2_DEFAULT_CHANNEL, 1683 /*! 1684 * Set receive window C channel 1685 * 1686 * LoRaWAN Specification V1.0.2, chapter 3.3.1 1687 */ 1688 MIB_RXC_CHANNEL, 1689 /*! 1690 * Set receive window C channel 1691 * 1692 * LoRaWAN Specification V1.0.2, chapter 3.3.2 1693 */ 1694 MIB_RXC_DEFAULT_CHANNEL, 1695 /*! 1696 * LoRaWAN channels mask 1697 * 1698 * LoRaWAN Regional Parameters V1.0.2rB 1699 */ 1700 MIB_CHANNELS_MASK, 1701 /*! 1702 * LoRaWAN default channels mask 1703 * 1704 * LoRaWAN Regional Parameters V1.0.2rB 1705 */ 1706 MIB_CHANNELS_DEFAULT_MASK, 1707 /*! 1708 * Set the number of repetitions on a channel 1709 * 1710 * LoRaWAN Specification V1.0.2, chapter 5.2, V1.1.0, chapter 5.3 1711 */ 1712 MIB_CHANNELS_NB_TRANS, 1713 /*! 1714 * Maximum receive window duration in [ms] 1715 * 1716 * LoRaWAN Specification V1.0.2, chapter 3.3.3 1717 */ 1718 MIB_MAX_RX_WINDOW_DURATION, 1719 /*! 1720 * Receive delay 1 in [ms] 1721 * 1722 * LoRaWAN Regional Parameters V1.0.2rB 1723 */ 1724 MIB_RECEIVE_DELAY_1, 1725 /*! 1726 * Receive delay 2 in [ms] 1727 * 1728 * LoRaWAN Regional Parameters V1.0.2rB 1729 */ 1730 MIB_RECEIVE_DELAY_2, 1731 /*! 1732 * Join accept delay 1 in [ms] 1733 * 1734 * LoRaWAN Regional Parameters V1.0.2rB 1735 */ 1736 MIB_JOIN_ACCEPT_DELAY_1, 1737 /*! 1738 * Join accept delay 2 in [ms] 1739 * 1740 * LoRaWAN Regional Parameters V1.0.2rB 1741 */ 1742 MIB_JOIN_ACCEPT_DELAY_2, 1743 /*! 1744 * Minimum Data rate of a channel 1745 * 1746 * LoRaWAN Regional Parameters V1.0.2rB 1747 * 1748 * The possible values are region specific. Please refer to \ref DR_0 to \ref DR_15 for details. 1749 */ 1750 MIB_CHANNELS_MIN_TX_DATARATE, 1751 /*! 1752 * Default Data rate of a channel 1753 * 1754 * LoRaWAN Regional Parameters V1.0.2rB 1755 * 1756 * The allowed ranges are region specific. Please refer to \ref DR_0 to \ref DR_15 for details. 1757 */ 1758 MIB_CHANNELS_DEFAULT_DATARATE, 1759 /*! 1760 * Data rate of a channel 1761 * 1762 * LoRaWAN Regional Parameters V1.0.2rB 1763 * 1764 * The allowed ranges are region specific. Please refer to \ref DR_0 to \ref DR_15 for details. 1765 */ 1766 MIB_CHANNELS_DATARATE, 1767 /*! 1768 * Transmission power of a channel 1769 * 1770 * LoRaWAN Regional Parameters V1.0.2rB 1771 * 1772 * The allowed ranges are region specific. Please refer to \ref TX_POWER_0 to \ref TX_POWER_15 for details. 1773 */ 1774 MIB_CHANNELS_TX_POWER, 1775 /*! 1776 * Transmission power of a channel 1777 * 1778 * LoRaWAN Regional Parameters V1.0.2rB 1779 * 1780 * The allowed ranges are region specific. Please refer to \ref TX_POWER_0 to \ref TX_POWER_15 for details. 1781 */ 1782 MIB_CHANNELS_DEFAULT_TX_POWER, 1783 /*! 1784 * System overall timing error in milliseconds. 1785 * [-SystemMaxRxError : +SystemMaxRxError] 1786 * Default: +/-10 ms 1787 */ 1788 MIB_SYSTEM_MAX_RX_ERROR, 1789 /*! 1790 * Minimum required number of symbols to detect an Rx frame 1791 * Default: 6 symbols 1792 */ 1793 MIB_MIN_RX_SYMBOLS, 1794 /*! 1795 * Antenna gain of the node. Default value is region specific. 1796 * The antenna gain is used to calculate the TX power of the node. 1797 * The formula is: 1798 * radioTxPower = ( int8_t )floor( maxEirp - antennaGain ) 1799 * 1800 * \remark The antenna gain value is referenced to the isotropic antenna. 1801 * The value is in dBi. 1802 * MIB_ANTENNA_GAIN[dBi] = measuredAntennaGain[dBd] + 2.15 1803 */ 1804 MIB_ANTENNA_GAIN, 1805 /*! 1806 * Default antenna gain of the node. Default value is region specific. 1807 * The antenna gain is used to calculate the TX power of the node. 1808 * The formula is: 1809 * radioTxPower = ( int8_t )floor( maxEirp - antennaGain ) 1810 * 1811 * \remark The antenna gain value is referenced to the isotropic antenna. 1812 * The value is in dBi. 1813 * MIB_DEFAULT_ANTENNA_GAIN[dBi] = measuredAntennaGain[dBd] + 2.15 1814 */ 1815 MIB_DEFAULT_ANTENNA_GAIN, 1816 /*! 1817 * Structure holding pointers to internal contexts and its size 1818 */ 1819 MIB_NVM_CTXS, 1820 /*! 1821 * LoRaWAN MAC layer operating version when activated by ABP. 1822 */ 1823 MIB_ABP_LORAWAN_VERSION, 1824 /*! 1825 * LoRaWAN MAC and regional parameter version. 1826 */ 1827 MIB_LORAWAN_VERSION, 1828 /*! 1829 * Time between periodic transmission of a Type 0 Rejoin request. 1830 */ 1831 MIB_REJOIN_0_CYCLE, 1832 /*! 1833 * Time between periodic transmission of a Type 1 Rejoin request. 1834 */ 1835 MIB_REJOIN_1_CYCLE, 1836 /*! 1837 * Beacon interval in ms 1838 */ 1839 MIB_BEACON_INTERVAL, 1840 /*! 1841 * Beacon reserved time in ms 1842 */ 1843 MIB_BEACON_RESERVED, 1844 /*! 1845 * Beacon guard time in ms 1846 */ 1847 MIB_BEACON_GUARD, 1848 /*! 1849 * Beacon window time in ms 1850 */ 1851 MIB_BEACON_WINDOW, 1852 /*! 1853 * Beacon window time in number of slots 1854 */ 1855 MIB_BEACON_WINDOW_SLOTS, 1856 /*! 1857 * Ping slot length time in ms 1858 */ 1859 MIB_PING_SLOT_WINDOW, 1860 /*! 1861 * Default symbol timeout for beacons and ping slot windows 1862 */ 1863 MIB_BEACON_SYMBOL_TO_DEFAULT, 1864 /*! 1865 * Maximum symbol timeout for beacons 1866 */ 1867 MIB_BEACON_SYMBOL_TO_EXPANSION_MAX, 1868 /*! 1869 * Maximum symbol timeout for ping slots 1870 */ 1871 MIB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX, 1872 /*! 1873 * Symbol expansion value for beacon windows in case of beacon 1874 * loss in symbols 1875 */ 1876 MIB_BEACON_SYMBOL_TO_EXPANSION_FACTOR, 1877 /*! 1878 * Symbol expansion value for ping slot windows in case of beacon 1879 * loss in symbols 1880 */ 1881 MIB_PING_SLOT_SYMBOL_TO_EXPANSION_FACTOR, 1882 /*! 1883 * Maximum allowed beacon less time in ms 1884 */ 1885 MIB_MAX_BEACON_LESS_PERIOD, 1886 /*! 1887 * Ping slot data rate 1888 * 1889 * LoRaWAN Regional Parameters V1.0.2rB 1890 * 1891 * The allowed ranges are region specific. Please refer to \ref DR_0 to \ref DR_15 for details. 1892 */ 1893 MIB_PING_SLOT_DATARATE, 1894 /*! 1895 * LoRaWAN certification FPort handling state (ON/OFF) 1896 */ 1897 MIB_IS_CERT_FPORT_ON, 1898 /*! 1899 * ADR ack limit value 1900 */ 1901 MIB_ADR_ACK_LIMIT, 1902 /*! 1903 * ADR ack delay value 1904 */ 1905 MIB_ADR_ACK_DELAY, 1906 /*! 1907 * ADR ack default limit value 1908 */ 1909 MIB_ADR_ACK_DEFAULT_LIMIT, 1910 /*! 1911 * ADR ack default delay value 1912 */ 1913 MIB_ADR_ACK_DEFAULT_DELAY, 1914 /*! 1915 * RSSI free channel threshold value (KR920 and AS923 only) 1916 */ 1917 MIB_RSSI_FREE_THRESHOLD, 1918 /*! 1919 * Carrier sense time value (KR920 and AS923 only) 1920 */ 1921 MIB_CARRIER_SENSE_TIME 1922 }Mib_t; 1923 1924 /*! 1925 * LoRaMAC MIB parameters 1926 */ 1927 typedef union uMibParam 1928 { 1929 /*! 1930 * LoRaWAN device class 1931 * 1932 * Related MIB type: \ref MIB_DEVICE_CLASS 1933 */ 1934 DeviceClass_t Class; 1935 /*! 1936 * LoRaWAN Network End-Device Activation ( ACTIVATION_TYPE_NONE, ACTIVATION_TYPE_ABP or OTTA ) 1937 * 1938 * Related MIB type: \ref MIB_NETWORK_ACTIVATION 1939 */ 1940 ActivationType_t NetworkActivation; 1941 /*! 1942 * LoRaWAN device EUI 1943 * 1944 * Related MIB type: \ref MIB_DEV_EUI 1945 */ 1946 uint8_t* DevEui; 1947 /*! 1948 * LoRaWAN Join server EUI 1949 * 1950 * Related MIB type: \ref MIB_JOIN_EUI 1951 */ 1952 uint8_t* JoinEui; 1953 /*! 1954 * Secure-element pin 1955 * 1956 * Related MIB type: \ref MIB_SE_PIN 1957 */ 1958 uint8_t* SePin; 1959 /*! 1960 * Activation state of ADR 1961 * 1962 * Related MIB type: \ref MIB_ADR 1963 */ 1964 bool AdrEnable; 1965 /*! 1966 * Network identifier 1967 * 1968 * Related MIB type: \ref MIB_NET_ID 1969 */ 1970 uint32_t NetID; 1971 /*! 1972 * End-device address 1973 * 1974 * Related MIB type: \ref MIB_DEV_ADDR 1975 */ 1976 uint32_t DevAddr; 1977 /*! 1978 * Application root key 1979 * 1980 * Related MIB type: \ref MIB_APP_KEY 1981 */ 1982 uint8_t* AppKey; 1983 /*! 1984 * Network root key 1985 * 1986 * Related MIB type: \ref MIB_NWK_KEY 1987 */ 1988 uint8_t* NwkKey; 1989 /*! 1990 * Join session integrity key 1991 * 1992 * Related MIB type: \ref MIB_J_S_INT_KEY 1993 */ 1994 uint8_t* JSIntKey; 1995 /*! 1996 * Join session encryption key 1997 * 1998 * Related MIB type: \ref MIB_J_S_ENC_KEY 1999 */ 2000 uint8_t* JSEncKey; 2001 /*! 2002 * Forwarding Network session integrity key 2003 * 2004 * Related MIB type: \ref MIB_F_NWK_S_INT_KEY 2005 */ 2006 uint8_t* FNwkSIntKey; 2007 /*! 2008 * Serving Network session integrity key 2009 * 2010 * Related MIB type: \ref MIB_S_NWK_S_INT_KEY 2011 */ 2012 uint8_t* SNwkSIntKey; 2013 /*! 2014 * Network session encryption key 2015 * 2016 * Related MIB type: \ref MIB_NWK_S_ENC_KEY 2017 */ 2018 uint8_t* NwkSEncKey; 2019 /*! 2020 * Application session key 2021 * 2022 * Related MIB type: \ref MIB_APP_S_KEY 2023 */ 2024 uint8_t* AppSKey; 2025 /*! 2026 * Multicast key encryption key 2027 * 2028 * Related MIB type: \ref MIB_MC_KE_KEY 2029 */ 2030 uint8_t* McKEKey; 2031 /*! 2032 * Multicast root key index 0 2033 * 2034 * Related MIB type: \ref MIB_MC_KEY_0 2035 */ 2036 uint8_t* McKey0; 2037 /*! 2038 * Multicast Application session key index 0 2039 * 2040 * Related MIB type: \ref MIB_MC_APP_S_KEY_0 2041 */ 2042 uint8_t* McAppSKey0; 2043 /*! 2044 * Multicast Network session key index 0 2045 * 2046 * Related MIB type: \ref MIB_MC_NWK_S_KEY_0 2047 */ 2048 uint8_t* McNwkSKey0; 2049 /*! 2050 * Multicast root key index 0 2051 * 2052 * Related MIB type: \ref MIB_MC_KEY_0 2053 */ 2054 uint8_t* McKey1; 2055 /*! 2056 * Multicast Application session key index 1 2057 * 2058 * Related MIB type: \ref MIB_MC_APP_S_KEY_1 2059 */ 2060 uint8_t* McAppSKey1; 2061 /*! 2062 * Multicast Network session key index 1 2063 * 2064 * Related MIB type: \ref MIB_MC_NWK_S_KEY_1 2065 */ 2066 uint8_t* McNwkSKey1; 2067 /*! 2068 * Multicast root key index 2 2069 * 2070 * Related MIB type: \ref MIB_MC_KEY_2 2071 */ 2072 uint8_t* McKey2; 2073 /*! 2074 * Multicast Application session key index 2 2075 * 2076 * Related MIB type: \ref MIB_MC_APP_S_KEY_2 2077 */ 2078 uint8_t* McAppSKey2; 2079 /*! 2080 * Multicast Network session key index 2 2081 * 2082 * Related MIB type: \ref MIB_MC_NWK_S_KEY_2 2083 */ 2084 uint8_t* McNwkSKey2; 2085 /*! 2086 * Multicast root key index 2 2087 * 2088 * Related MIB type: \ref MIB_MC_KEY_2 2089 */ 2090 uint8_t* McKey3; 2091 /*! 2092 * Multicast Application session key index 2 2093 * 2094 * Related MIB type: \ref MIB_MC_APP_S_KEY_2 2095 */ 2096 uint8_t* McAppSKey3; 2097 /*! 2098 * Multicast Network session key index 2 2099 * 2100 * Related MIB type: \ref MIB_MC_NWK_S_KEY_2 2101 */ 2102 uint8_t* McNwkSKey3; 2103 /*! 2104 * Enable or disable a public network 2105 * 2106 * Related MIB type: \ref MIB_PUBLIC_NETWORK 2107 */ 2108 bool EnablePublicNetwork; 2109 /*! 2110 * LoRaWAN Channel 2111 * 2112 * Related MIB type: \ref MIB_CHANNELS 2113 */ 2114 ChannelParams_t* ChannelList; 2115 /*! 2116 * Channel for the receive window 2 2117 * 2118 * Related MIB type: \ref MIB_RX2_CHANNEL 2119 */ 2120 RxChannelParams_t Rx2Channel; 2121 /*! 2122 * Channel for the receive window 2 2123 * 2124 * Related MIB type: \ref MIB_RX2_DEFAULT_CHANNEL 2125 */ 2126 RxChannelParams_t Rx2DefaultChannel; 2127 /*! 2128 * Channel for the receive window C 2129 * 2130 * Related MIB type: \ref MIB_RXC_CHANNEL 2131 */ 2132 RxChannelParams_t RxCChannel; 2133 /*! 2134 * Channel for the receive window C 2135 * 2136 * Related MIB type: \ref MIB_RXC_DEFAULT_CHANNEL 2137 */ 2138 RxChannelParams_t RxCDefaultChannel; 2139 /*! 2140 * Channel mask 2141 * 2142 * Related MIB type: \ref MIB_CHANNELS_MASK 2143 */ 2144 uint16_t* ChannelsMask; 2145 /*! 2146 * Default channel mask 2147 * 2148 * Related MIB type: \ref MIB_CHANNELS_DEFAULT_MASK 2149 */ 2150 uint16_t* ChannelsDefaultMask; 2151 /*! 2152 * Number of frame repetitions 2153 * 2154 * Related MIB type: \ref MIB_CHANNELS_NB_TRANS 2155 */ 2156 uint8_t ChannelsNbTrans; 2157 /*! 2158 * Maximum receive window duration 2159 * 2160 * Related MIB type: \ref MIB_MAX_RX_WINDOW_DURATION 2161 */ 2162 uint32_t MaxRxWindow; 2163 /*! 2164 * Receive delay 1 2165 * 2166 * Related MIB type: \ref MIB_RECEIVE_DELAY_1 2167 */ 2168 uint32_t ReceiveDelay1; 2169 /*! 2170 * Receive delay 2 2171 * 2172 * Related MIB type: \ref MIB_RECEIVE_DELAY_2 2173 */ 2174 uint32_t ReceiveDelay2; 2175 /*! 2176 * Join accept delay 1 2177 * 2178 * Related MIB type: \ref MIB_JOIN_ACCEPT_DELAY_1 2179 */ 2180 uint32_t JoinAcceptDelay1; 2181 /*! 2182 * Join accept delay 2 2183 * 2184 * Related MIB type: \ref MIB_JOIN_ACCEPT_DELAY_2 2185 */ 2186 uint32_t JoinAcceptDelay2; 2187 /*! 2188 * Channels minimum tx data rate 2189 * 2190 * Related MIB type: \ref MIB_CHANNELS_MIN_TX_DATARATE 2191 */ 2192 int8_t ChannelsMinTxDatarate; 2193 /*! 2194 * Channels data rate 2195 * 2196 * Related MIB type: \ref MIB_CHANNELS_DEFAULT_DATARATE 2197 */ 2198 int8_t ChannelsDefaultDatarate; 2199 /*! 2200 * Channels data rate 2201 * 2202 * Related MIB type: \ref MIB_CHANNELS_DATARATE 2203 */ 2204 int8_t ChannelsDatarate; 2205 /*! 2206 * Channels TX power 2207 * 2208 * Related MIB type: \ref MIB_CHANNELS_DEFAULT_TX_POWER 2209 */ 2210 int8_t ChannelsDefaultTxPower; 2211 /*! 2212 * Channels TX power 2213 * 2214 * Related MIB type: \ref MIB_CHANNELS_TX_POWER 2215 */ 2216 int8_t ChannelsTxPower; 2217 /*! 2218 * Multicast channels 2219 * 2220 * Related MIB type: \ref MIB_MULTICAST_CHANNEL 2221 */ 2222 McChannelParams_t MulticastChannel; 2223 /*! 2224 * System overall timing error in milliseconds. 2225 * 2226 * Related MIB type: \ref MIB_SYSTEM_MAX_RX_ERROR 2227 */ 2228 uint32_t SystemMaxRxError; 2229 /*! 2230 * Minimum required number of symbols to detect an Rx frame 2231 * 2232 * Related MIB type: \ref MIB_MIN_RX_SYMBOLS 2233 */ 2234 uint8_t MinRxSymbols; 2235 /*! 2236 * Antenna gain 2237 * 2238 * Related MIB type: \ref MIB_ANTENNA_GAIN 2239 */ 2240 float AntennaGain; 2241 /*! 2242 * Default antenna gain 2243 * 2244 * Related MIB type: \ref MIB_DEFAULT_ANTENNA_GAIN 2245 */ 2246 float DefaultAntennaGain; 2247 /*! 2248 * Returns a pointer to the structure holding all data which shall be stored 2249 * in the NVM. 2250 * 2251 * Related MIB type: \ref MIB_NVM_CTXS 2252 */ 2253 LoRaMacNvmData_t* Contexts; 2254 /* 2255 * LoRaWAN MAC layer operating version when activated by ABP. 2256 * 2257 * Related MIB type: \ref MIB_ABP_LORAWAN_VERSION 2258 */ 2259 Version_t AbpLrWanVersion; 2260 /* 2261 * LoRaWAN MAC regional parameter version. 2262 * 2263 * Related MIB type: \ref MIB_LORAWAN_VERSION 2264 */ 2265 struct sLrWanVersion 2266 { 2267 Version_t LoRaWan; 2268 Version_t LoRaWanRegion; 2269 }LrWanVersion; 2270 /*! 2271 * Time in seconds between cyclic transmission of Type 0 Rejoin requests. 2272 */ 2273 uint32_t Rejoin0CycleInSec; 2274 /*! 2275 * Time in seconds between cyclic transmission of Type 1 Rejoin requests. 2276 */ 2277 uint32_t Rejoin1CycleInSec; 2278 /*! 2279 * Time in seconds between cyclic transmission of Type 2 Rejoin requests. 2280 */ 2281 uint32_t Rejoin2CycleInSec; 2282 /*! 2283 * Beacon interval in ms 2284 * 2285 * Related MIB type: \ref MIB_BEACON_INTERVAL 2286 */ 2287 uint32_t BeaconInterval; 2288 /*! 2289 * Beacon reserved time in ms 2290 * 2291 * Related MIB type: \ref MIB_BEACON_RESERVED 2292 */ 2293 uint32_t BeaconReserved; 2294 /*! 2295 * Beacon guard time in ms 2296 * 2297 * Related MIB type: \ref MIB_BEACON_GUARD 2298 */ 2299 uint32_t BeaconGuard; 2300 /*! 2301 * Beacon window time in ms 2302 * 2303 * Related MIB type: \ref MIB_BEACON_WINDOW 2304 */ 2305 uint32_t BeaconWindow; 2306 /*! 2307 * Beacon window time in number of slots 2308 * 2309 * Related MIB type: \ref MIB_BEACON_WINDOW_SLOTS 2310 */ 2311 uint32_t BeaconWindowSlots; 2312 /*! 2313 * Ping slot length time in ms 2314 * 2315 * Related MIB type: \ref MIB_PING_SLOT_WINDOW 2316 */ 2317 uint32_t PingSlotWindow; 2318 /*! 2319 * Default symbol timeout for beacons and ping slot windows 2320 * 2321 * Related MIB type: \ref MIB_BEACON_SYMBOL_TO_DEFAULT 2322 */ 2323 uint32_t BeaconSymbolToDefault; 2324 /*! 2325 * Maximum symbol timeout for beacons 2326 * 2327 * Related MIB type: \ref MIB_BEACON_SYMBOL_TO_EXPANSION_MAX 2328 */ 2329 uint32_t BeaconSymbolToExpansionMax; 2330 /*! 2331 * Maximum symbol timeout for ping slots 2332 * 2333 * Related MIB type: \ref MIB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX 2334 */ 2335 uint32_t PingSlotSymbolToExpansionMax; 2336 /*! 2337 * Symbol expansion value for beacon windows in case of beacon 2338 * loss in symbols 2339 * 2340 * Related MIB type: \ref MIB_BEACON_SYMBOL_TO_EXPANSION_FACTOR 2341 */ 2342 uint32_t BeaconSymbolToExpansionFactor; 2343 /*! 2344 * Symbol expansion value for ping slot windows in case of beacon 2345 * loss in symbols 2346 * 2347 * Related MIB type: \ref MIB_PING_SLOT_SYMBOL_TO_EXPANSION_FACTOR 2348 */ 2349 uint32_t PingSlotSymbolToExpansionFactor; 2350 /*! 2351 * Maximum allowed beacon less time in ms 2352 * 2353 * Related MIB type: \ref MIB_MAX_BEACON_LESS_PERIOD 2354 */ 2355 uint32_t MaxBeaconLessPeriod; 2356 /*! 2357 * Ping slots data rate 2358 * 2359 * Related MIB type: \ref MIB_PING_SLOT_DATARATE 2360 */ 2361 int8_t PingSlotDatarate; 2362 /*! 2363 * LoRaWAN certification FPort handling state (ON/OFF) 2364 * 2365 * Related MIB type: \ref MIB_IS_CERT_FPORT_ON 2366 */ 2367 bool IsCertPortOn; 2368 /*! 2369 * ADR ack limit value 2370 * 2371 * Related MIB types: \ref MIB_ADR_ACK_LIMIT, MIB_ADR_ACK_DEFAULT_LIMIT 2372 */ 2373 uint16_t AdrAckLimit; 2374 /*! 2375 * ADR ack delay value 2376 * 2377 * Related MIB types: \ref MIB_ADR_ACK_DELAY, MIB_ADR_ACK_DEFAULT_DELAY 2378 */ 2379 uint16_t AdrAckDelay; 2380 /*! 2381 * RSSI free channel threshold (KR920 and AS923 only) 2382 * 2383 * Related MIB type: \ref MIB_RSSI_FREE_THRESHOLD 2384 */ 2385 int16_t RssiFreeThreshold; 2386 /*! 2387 * Carrier sense time (KR920 and AS923 only) 2388 * 2389 * Related MIB type: \ref MIB_CARRIER_SENSE_TIME 2390 */ 2391 uint32_t CarrierSenseTime; 2392 }MibParam_t; 2393 2394 /*! 2395 * LoRaMAC MIB-RequestConfirm structure 2396 */ 2397 typedef struct eMibRequestConfirm 2398 { 2399 /*! 2400 * MIB-Request type 2401 */ 2402 Mib_t Type; 2403 2404 /*! 2405 * MLME-RequestConfirm parameters 2406 */ 2407 MibParam_t Param; 2408 }MibRequestConfirm_t; 2409 2410 /*! 2411 * LoRaMAC tx information 2412 */ 2413 typedef struct sLoRaMacTxInfo 2414 { 2415 /*! 2416 * Size of the application data payload which can be transmitted. 2417 */ 2418 uint8_t MaxPossibleApplicationDataSize; 2419 /*! 2420 * The current maximum possible payload size without MAC commands 2421 * which is dependent on the current datarate. 2422 */ 2423 uint8_t CurrentPossiblePayloadSize; 2424 }LoRaMacTxInfo_t; 2425 2426 /*! 2427 * LoRaMAC Status 2428 */ 2429 typedef enum eLoRaMacStatus 2430 { 2431 /*! 2432 * Service started successfully 2433 */ 2434 LORAMAC_STATUS_OK, 2435 /*! 2436 * Service not started - LoRaMAC is busy 2437 */ 2438 LORAMAC_STATUS_BUSY, 2439 /*! 2440 * Service unknown 2441 */ 2442 LORAMAC_STATUS_SERVICE_UNKNOWN, 2443 /*! 2444 * Service not started - invalid parameter 2445 */ 2446 LORAMAC_STATUS_PARAMETER_INVALID, 2447 /*! 2448 * Service not started - invalid frequency 2449 */ 2450 LORAMAC_STATUS_FREQUENCY_INVALID, 2451 /*! 2452 * Service not started - invalid datarate 2453 */ 2454 LORAMAC_STATUS_DATARATE_INVALID, 2455 /*! 2456 * Service not started - invalid frequency and datarate 2457 */ 2458 LORAMAC_STATUS_FREQ_AND_DR_INVALID, 2459 /*! 2460 * Service not started - the device is not in a LoRaWAN 2461 */ 2462 LORAMAC_STATUS_NO_NETWORK_JOINED, 2463 /*! 2464 * Service not started - payload length error 2465 */ 2466 LORAMAC_STATUS_LENGTH_ERROR, 2467 /*! 2468 * Service not started - the specified region is not supported 2469 * or not activated with preprocessor definitions. 2470 */ 2471 LORAMAC_STATUS_REGION_NOT_SUPPORTED, 2472 /*! 2473 * The application data was not transmitted 2474 * because prioritized pending MAC commands had to be sent. 2475 */ 2476 LORAMAC_STATUS_SKIPPED_APP_DATA, 2477 /*! 2478 * An MCPS or MLME request can return this status. In this case, 2479 * the MAC cannot send the frame, as the duty cycle limits all 2480 * available bands. When a request returns this value, the 2481 * variable "DutyCycleWaitTime" in "ReqReturn" of the input 2482 * parameters contains the remaining time to wait. If the 2483 * value is constant and does not change, the expected time 2484 * on air for this frame is exceeding the maximum permitted 2485 * time according to the duty cycle time period, defined 2486 * in Region.h, DUTY_CYCLE_TIME_PERIOD. By default this time 2487 * is 1 hour, and a band with 1% duty cycle is then allowed 2488 * to use an air time of 36 seconds. 2489 */ 2490 LORAMAC_STATUS_DUTYCYCLE_RESTRICTED, 2491 /*! 2492 * 2493 */ 2494 LORAMAC_STATUS_NO_CHANNEL_FOUND, 2495 /*! 2496 * 2497 */ 2498 LORAMAC_STATUS_NO_FREE_CHANNEL_FOUND, 2499 /*! 2500 * ToDo 2501 */ 2502 LORAMAC_STATUS_BUSY_BEACON_RESERVED_TIME, 2503 /*! 2504 * ToDo 2505 */ 2506 LORAMAC_STATUS_BUSY_PING_SLOT_WINDOW_TIME, 2507 /*! 2508 * ToDo 2509 */ 2510 LORAMAC_STATUS_BUSY_UPLINK_COLLISION, 2511 /*! 2512 * An error in the cryptographic module is occurred 2513 */ 2514 LORAMAC_STATUS_CRYPTO_ERROR, 2515 /*! 2516 * An error in the frame counter handler module is occurred 2517 */ 2518 LORAMAC_STATUS_FCNT_HANDLER_ERROR, 2519 /*! 2520 * An error in the MAC command module is occurred 2521 */ 2522 LORAMAC_STATUS_MAC_COMMAD_ERROR, 2523 /*! 2524 * An error in the Class B module is occurred 2525 */ 2526 LORAMAC_STATUS_CLASS_B_ERROR, 2527 /*! 2528 * An error in the Confirm Queue module is occurred 2529 */ 2530 LORAMAC_STATUS_CONFIRM_QUEUE_ERROR, 2531 /*! 2532 * The multicast group doesn't exist 2533 */ 2534 LORAMAC_STATUS_MC_GROUP_UNDEFINED, 2535 /*! 2536 * Undefined error occurred 2537 */ 2538 LORAMAC_STATUS_ERROR 2539 }LoRaMacStatus_t; 2540 2541 /*! 2542 * LoRaMAC events structure 2543 * Used to notify upper layers of MAC events 2544 */ 2545 typedef struct sLoRaMacPrimitives 2546 { 2547 /*! 2548 * \brief MCPS-Confirm primitive 2549 * 2550 * \param [OUT] MCPS-Confirm parameters 2551 */ 2552 void ( *MacMcpsConfirm )( McpsConfirm_t* McpsConfirm ); 2553 /*! 2554 * \brief MCPS-Indication primitive 2555 * 2556 * \param [OUT] MCPS-Indication parameters 2557 */ 2558 void ( *MacMcpsIndication )( McpsIndication_t* McpsIndication ); 2559 /*! 2560 * \brief MLME-Confirm primitive 2561 * 2562 * \param [OUT] MLME-Confirm parameters 2563 */ 2564 void ( *MacMlmeConfirm )( MlmeConfirm_t* MlmeConfirm ); 2565 /*! 2566 * \brief MLME-Indication primitive 2567 * 2568 * \param [OUT] MLME-Indication parameters 2569 */ 2570 void ( *MacMlmeIndication )( MlmeIndication_t* MlmeIndication ); 2571 }LoRaMacPrimitives_t; 2572 2573 /*! 2574 * LoRaMAC callback structure 2575 */ 2576 typedef struct sLoRaMacCallback 2577 { 2578 /*! 2579 * \brief Measures the battery level 2580 * 2581 * \retval Battery level [0: node is connected to an external 2582 * power source, 1..254: battery level, where 1 is the minimum 2583 * and 254 is the maximum value, 255: the node was not able 2584 * to measure the battery level] 2585 */ 2586 uint8_t ( *GetBatteryLevel )( void ); 2587 /*! 2588 * \brief Measures the temperature level 2589 * 2590 * \retval Temperature level 2591 */ 2592 float ( *GetTemperatureLevel )( void ); 2593 /*! 2594 * \brief Will be called when an attribute has changed in one of the context. 2595 * 2596 * \param notifyFlags Bitmap that contains the modules which changed. 2597 * Refer to \ref LoRaMacNvmData_t. 2598 */ 2599 void ( *NvmDataChange )( uint16_t notifyFlags ); 2600 /*! 2601 *\brief Will be called each time a Radio IRQ is handled by the MAC 2602 * layer. 2603 * 2604 *\warning Runs in a IRQ context. Should only change variables state. 2605 */ 2606 void ( *MacProcessNotify )( void ); 2607 }LoRaMacCallback_t; 2608 2609 2610 /*! 2611 * LoRaMAC Max EIRP (dBm) table 2612 */ 2613 static const uint8_t LoRaMacMaxEirpTable[] = { 8, 10, 12, 13, 14, 16, 18, 20, 21, 24, 26, 27, 29, 30, 33, 36 }; 2614 2615 /*! 2616 * \brief LoRaMAC layer initialization 2617 * 2618 * \details In addition to the initialization of the LoRaMAC layer, this 2619 * function initializes the callback primitives of the MCPS and 2620 * MLME services. Every data field of \ref LoRaMacPrimitives_t must be 2621 * set to a valid callback function. 2622 * 2623 * \param [IN] primitives - Pointer to a structure defining the LoRaMAC 2624 * event functions. Refer to \ref LoRaMacPrimitives_t. 2625 * 2626 * \param [IN] callbacks - Pointer to a structure defining the LoRaMAC 2627 * callback functions. Refer to \ref LoRaMacCallback_t. 2628 * 2629 * \param [IN] region - The region to start. 2630 * 2631 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2632 * returns are: 2633 * \ref LORAMAC_STATUS_OK, 2634 * \ref LORAMAC_STATUS_PARAMETER_INVALID, 2635 * \ref LORAMAC_STATUS_REGION_NOT_SUPPORTED. 2636 */ 2637 LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t* primitives, LoRaMacCallback_t* callbacks, LoRaMacRegion_t region ); 2638 2639 /*! 2640 * \brief Starts LoRaMAC layer 2641 * 2642 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2643 * returns are: 2644 * \ref LORAMAC_STATUS_OK, 2645 */ 2646 LoRaMacStatus_t LoRaMacStart( void ); 2647 2648 /*! 2649 * \brief Stops LoRaMAC layer 2650 * 2651 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2652 * returns are: 2653 * \ref LORAMAC_STATUS_OK, 2654 */ 2655 LoRaMacStatus_t LoRaMacStop( void ); 2656 2657 /*! 2658 * \brief Returns a value indicating if the MAC layer is busy or not. 2659 * 2660 * \retval isBusy Mac layer is busy. 2661 */ 2662 bool LoRaMacIsBusy( void ); 2663 2664 /*! 2665 * Processes the LoRaMac events. 2666 * 2667 * \remark This function must be called in the main loop. 2668 */ 2669 void LoRaMacProcess( void ); 2670 2671 /*! 2672 * \brief Queries the LoRaMAC if it is possible to send the next frame with 2673 * a given application data payload size. The LoRaMAC takes scheduled 2674 * MAC commands into account and reports, when the frame can be send or not. 2675 * 2676 * \param [IN] size - Size of application data payload to be send next 2677 * 2678 * \param [OUT] txInfo - The structure \ref LoRaMacTxInfo_t contains 2679 * information about the actual maximum payload possible 2680 * ( according to the configured datarate or the next 2681 * datarate according to ADR ), and the maximum frame 2682 * size, taking the scheduled MAC commands into account. 2683 * 2684 * \retval LoRaMacStatus_t Status of the operation. When the parameters are 2685 * not valid, the function returns \ref LORAMAC_STATUS_PARAMETER_INVALID. 2686 * In case of a length error caused by the application data payload in combination 2687 * with the MAC commands, the function returns \ref LORAMAC_STATUS_LENGTH_ERROR. 2688 * In this case its recommended to send a frame without application data to flush 2689 * the MAC commands. Otherwise the LoRaMAC will prioritize the MAC commands and 2690 * if needed it will skip the application data. Please note that if MAC commands do 2691 * not fit at all into the payload size on the related datarate, the LoRaMAC will 2692 * automatically clip the MAC commands. 2693 * In case the query is valid, and the LoRaMAC is able to send the frame, 2694 * the function returns \ref LORAMAC_STATUS_OK. 2695 */ 2696 LoRaMacStatus_t LoRaMacQueryTxPossible( uint8_t size, LoRaMacTxInfo_t* txInfo ); 2697 2698 /*! 2699 * \brief LoRaMAC channel add service 2700 * 2701 * \details Adds a new channel to the channel list and activates the id in 2702 * the channel mask. Please note that this functionality is not available 2703 * on all regions. Information about allowed ranges are available at the LoRaWAN Regional Parameters V1.0.2rB 2704 * 2705 * \param [IN] id - Id of the channel. 2706 * 2707 * \param [IN] params - Channel parameters to set. 2708 * 2709 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2710 * \ref LORAMAC_STATUS_OK, 2711 * \ref LORAMAC_STATUS_BUSY, 2712 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 2713 */ 2714 LoRaMacStatus_t LoRaMacChannelAdd( uint8_t id, ChannelParams_t params ); 2715 2716 /*! 2717 * \brief LoRaMAC channel remove service 2718 * 2719 * \details Deactivates the id in the channel mask. 2720 * 2721 * \param [IN] id - Id of the channel. 2722 * 2723 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2724 * \ref LORAMAC_STATUS_OK, 2725 * \ref LORAMAC_STATUS_BUSY, 2726 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 2727 */ 2728 LoRaMacStatus_t LoRaMacChannelRemove( uint8_t id ); 2729 2730 /*! 2731 * \brief LoRaMAC multicast channel setup service 2732 * 2733 * \details Sets up a multicast channel. 2734 * 2735 * \param [IN] channel - Multicast channel to set. 2736 * 2737 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2738 * \ref LORAMAC_STATUS_OK, 2739 * \ref LORAMAC_STATUS_BUSY, 2740 * \ref LORAMAC_STATUS_PARAMETER_INVALID, 2741 * \ref LORAMAC_STATUS_MC_GROUP_UNDEFINED. 2742 */ 2743 LoRaMacStatus_t LoRaMacMcChannelSetup( McChannelParams_t *channel ); 2744 2745 /*! 2746 * \brief LoRaMAC multicast channel removal service 2747 * 2748 * \details Removes/Disables a multicast channel. 2749 * 2750 * \param [IN] groupID - Multicast channel ID to be removed/disabled 2751 * 2752 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2753 * \ref LORAMAC_STATUS_OK, 2754 * \ref LORAMAC_STATUS_BUSY, 2755 * \ref LORAMAC_STATUS_MC_GROUP_UNDEFINED. 2756 */ 2757 LoRaMacStatus_t LoRaMacMcChannelDelete( AddressIdentifier_t groupID ); 2758 2759 /*! 2760 * \brief LoRaMAC multicast channel get groupId from MC address. 2761 * 2762 * \param [IN] mcAddress - Multicast address to be checked 2763 * 2764 * \retval groupID Multicast channel ID associated to the address. 2765 * Returns 0xFF if the address isn't found. 2766 */ 2767 uint8_t LoRaMacMcChannelGetGroupId( uint32_t mcAddress ); 2768 2769 /*! 2770 * \brief LoRaMAC multicast channel Rx parameters setup service 2771 * 2772 * \details Sets up a multicast channel reception parameters. 2773 * 2774 * \param [IN] groupID - Multicast channel ID 2775 * \param [IN] rxParams - Reception parameters 2776 * \param [OUT] status - Status mask [UNDEF_ID | FREQ_ERR | DR_ERR | GROUP_ID] 2777 * 2778 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2779 * \ref LORAMAC_STATUS_OK, 2780 * \ref LORAMAC_STATUS_BUSY, 2781 * \ref LORAMAC_STATUS_PARAMETER_INVALID, 2782 * \ref LORAMAC_STATUS_MC_GROUP_UNDEFINED. 2783 */ 2784 LoRaMacStatus_t LoRaMacMcChannelSetupRxParams( AddressIdentifier_t groupID, McRxParams_t *rxParams, uint8_t *status ); 2785 2786 /*! 2787 * \brief LoRaMAC MIB-Get 2788 * 2789 * \details The mac information base service to get attributes of the LoRaMac 2790 * layer. 2791 * 2792 * The following code-snippet shows how to use the API to get the 2793 * parameter AdrEnable, defined by the enumeration type 2794 * \ref MIB_ADR. 2795 * \code 2796 * MibRequestConfirm_t mibReq; 2797 * mibReq.Type = MIB_ADR; 2798 * 2799 * if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK ) 2800 * { 2801 * // LoRaMAC updated the parameter mibParam.AdrEnable 2802 * } 2803 * \endcode 2804 * 2805 * \param [IN] mibRequest - MIB-GET-Request to perform. Refer to \ref MibRequestConfirm_t. 2806 * 2807 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2808 * \ref LORAMAC_STATUS_OK, 2809 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN, 2810 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 2811 */ 2812 LoRaMacStatus_t LoRaMacMibGetRequestConfirm( MibRequestConfirm_t* mibGet ); 2813 2814 /*! 2815 * \brief LoRaMAC MIB-Set 2816 * 2817 * \details The mac information base service to set attributes of the LoRaMac 2818 * layer. 2819 * 2820 * The following code-snippet shows how to use the API to set the 2821 * parameter AdrEnable, defined by the enumeration type 2822 * \ref MIB_ADR. 2823 * 2824 * \code 2825 * MibRequestConfirm_t mibReq; 2826 * mibReq.Type = MIB_ADR; 2827 * mibReq.Param.AdrEnable = true; 2828 * 2829 * if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK ) 2830 * { 2831 * // LoRaMAC updated the parameter 2832 * } 2833 * \endcode 2834 * 2835 * \param [IN] mibRequest - MIB-SET-Request to perform. Refer to \ref MibRequestConfirm_t. 2836 * 2837 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2838 * \ref LORAMAC_STATUS_OK, 2839 * \ref LORAMAC_STATUS_BUSY, 2840 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN, 2841 * \ref LORAMAC_STATUS_PARAMETER_INVALID. 2842 */ 2843 LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t* mibSet ); 2844 2845 /*! 2846 * \brief LoRaMAC MLME-Request 2847 * 2848 * \details The Mac layer management entity handles management services. The 2849 * following code-snippet shows how to use the API to perform a 2850 * network join request. Please note that for a join request, the 2851 * DevEUI and the JoinEUI must be set previously via the MIB. Please 2852 * also refer to the sample implementations. 2853 * 2854 * \code 2855 * 2856 * MlmeReq_t mlmeReq; 2857 * mlmeReq.Type = MLME_JOIN; 2858 * mlmeReq.Req.Join.Datarate = LORAWAN_DEFAULT_DATARATE; 2859 * 2860 * if( LoRaMacMlmeRequest( &mlmeReq ) == LORAMAC_STATUS_OK ) 2861 * { 2862 * // Service started successfully. Waiting for the Mlme-Confirm event 2863 * } 2864 * \endcode 2865 * 2866 * \param [IN] mlmeRequest - MLME-Request to perform. Refer to \ref MlmeReq_t. 2867 * 2868 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2869 * \ref LORAMAC_STATUS_OK, 2870 * \ref LORAMAC_STATUS_BUSY, 2871 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN, 2872 * \ref LORAMAC_STATUS_PARAMETER_INVALID, 2873 * \ref LORAMAC_STATUS_NO_NETWORK_JOINED, 2874 * \ref LORAMAC_STATUS_LENGTH_ERROR, 2875 */ 2876 LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t* mlmeRequest ); 2877 2878 /*! 2879 * \brief LoRaMAC MCPS-Request 2880 * 2881 * \details The Mac Common Part Sublayer handles data services. The following 2882 * code-snippet shows how to use the API to send an unconfirmed 2883 * LoRaMAC frame. 2884 * 2885 * \code 2886 * uint8_t myBuffer[] = { 1, 2, 3 }; 2887 * 2888 * McpsReq_t mcpsReq; 2889 * mcpsReq.Type = MCPS_UNCONFIRMED; 2890 * mcpsReq.Req.Unconfirmed.fPort = 1; 2891 * mcpsReq.Req.Unconfirmed.fBuffer = myBuffer; 2892 * mcpsReq.Req.Unconfirmed.fBufferSize = sizeof( myBuffer ); 2893 * 2894 * if( LoRaMacMcpsRequest( &mcpsReq ) == LORAMAC_STATUS_OK ) 2895 * { 2896 * // Service started successfully. Waiting for the MCPS-Confirm event 2897 * } 2898 * \endcode 2899 * 2900 * \param [IN] mcpsRequest - MCPS-Request to perform. Refer to \ref McpsReq_t. 2901 * 2902 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2903 * \ref LORAMAC_STATUS_OK, 2904 * \ref LORAMAC_STATUS_BUSY, 2905 * \ref LORAMAC_STATUS_SERVICE_UNKNOWN, 2906 * \ref LORAMAC_STATUS_PARAMETER_INVALID, 2907 * \ref LORAMAC_STATUS_NO_NETWORK_JOINED, 2908 * \ref LORAMAC_STATUS_LENGTH_ERROR, 2909 */ 2910 LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t* mcpsRequest ); 2911 2912 /*! 2913 * \brief LoRaMAC deinitialization 2914 * 2915 * \details This function stops the timers, re-initializes MAC & regional parameters to default 2916 * and sets radio into sleep state. 2917 * 2918 * \retval LoRaMacStatus_t Status of the operation. Possible returns are: 2919 * \ref LORAMAC_STATUS_OK, 2920 * \ref LORAMAC_STATUS_BUSY 2921 */ 2922 LoRaMacStatus_t LoRaMacDeInitialization( void ); 2923 2924 /*! 2925 * \brief Resets the internal state machine. 2926 * 2927 * \details Resets the internal state machine to force the MAC to finalize a procedure. 2928 */ 2929 void LoRaMacReset( void ); 2930 2931 /*! \} defgroup LORAMAC */ 2932 2933 #ifdef __cplusplus 2934 } 2935 #endif 2936 2937 #endif // __LORAMAC_H__ 2938