mac_mlme_sync.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /**
  2. * Copyright (c) 2016 - 2020 Nordic Semiconductor ASA and Luxoft Global Operations Gmbh.
  3. *
  4. * All Rights Reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. *
  10. * 1. Redistributions of source code must retain the above copyright notice, this
  11. * list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form, except as embedded into a Nordic
  14. * Semiconductor ASA integrated circuit in a product or a software update for
  15. * such product, must reproduce the above copyright notice, this list of
  16. * conditions and the following disclaimer in the documentation and/or other
  17. * materials provided with the distribution.
  18. *
  19. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * 4. This software, with or without modification, must only be used with a
  24. * Nordic Semiconductor ASA integrated circuit.
  25. *
  26. * 5. Any software provided in binary form under this license must not be reverse
  27. * engineered, decompiled, modified and/or disassembled.
  28. *
  29. *
  30. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  31. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  32. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  33. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  34. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  35. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  36. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  38. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  39. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. */
  42. #ifndef MAC_MLME_SYNC_H_INCLUDED
  43. #define MAC_MLME_SYNC_H_INCLUDED
  44. #if (CONFIG_SYNC_ENABLED == 1)
  45. #include <stdint.h>
  46. #include "mac_common.h"
  47. #include "mac_task_scheduler.h"
  48. /** @file
  49. * The MAC MLME Sync module declares the MAC Sync primitives and necessary types
  50. * according to the MAC specification.
  51. *
  52. * @defgroup mac_sync MAC MLME Sync API
  53. * @ingroup mac_15_4
  54. * @{
  55. * @brief Module to declare MAC MLME Sync API.
  56. * @details The MAC Sync module declares MLME Sync and sync loss primitives and necessary types according to
  57. * the MAC specification. More specifically, MLME Sync request aka mlme_sync_req(), and MLME
  58. * Sync Loss indication aka mlme_sync_loss_ind() primitives are declared.
  59. */
  60. /**@brief Sync Loss reason enumeration. */
  61. typedef enum
  62. {
  63. MAC_SYNC_BEACON_LOST, /**< Beacon lost. */
  64. MAC_SYNC_REALIGNMENT, /**< Realignment. */
  65. MAC_SYNC_PAN_ID_CONFLICT /**< PAN ID Conflict. */
  66. } mlme_sync_loss_reason_t;
  67. /**
  68. * @brief MLME-SYNC-LOSS.indication
  69. *
  70. * @details On receipt of the MLME-SYNC-LOSS.indication primitive, the next
  71. * higher layer is notified of a loss of synchronization.
  72. *
  73. * In accordance with IEEE Std 802.15.4-2006, section 7.1.15.2
  74. */
  75. typedef struct
  76. {
  77. mlme_sync_loss_reason_t loss_reason; /**< Loss reason. */
  78. uint16_t pan_id; /**< PAN ID. */
  79. uint8_t logical_channel; /**< Logical channel. */
  80. #ifdef CONFIG_SUB_GHZ
  81. uint8_t channel_page; /**< Channel page. */
  82. #endif
  83. #if (CONFIG_SECURE == 1)
  84. uint8_t security_level; /**< Security level. */
  85. uint8_t key_id_mode; /**< Key ID mode. */
  86. uint64_t key_source; /**< Key source. */
  87. uint8_t key_index; /**< Key index. */
  88. #endif
  89. } mlme_sync_loss_ind_t;
  90. #if (CONFIG_SYNC_REQ_ENABLED == 1)
  91. /**
  92. * @brief MLME-SYNC.request
  93. *
  94. * @details The MLME-SYNC.request primitive is generated by the next higher
  95. * layer of a device on a beacon-enabled PAN and issued to its MLME to
  96. * synchronize with the coordinator.
  97. *
  98. * In accordance with IEEE Std 802.15.4-2006, section 7.1.15.1
  99. */
  100. typedef struct
  101. {
  102. /** Do not edit this field. */
  103. mac_abstract_req_t service;
  104. uint8_t logical_channel; /**< Logical channel. */
  105. #ifdef CONFIG_SUB_GHZ
  106. uint8_t channel_page; /**< Channel page. */
  107. #endif
  108. bool track_beacon; /**< Track beacon? */
  109. } mlme_sync_req_t;
  110. /**
  111. * @brief MLME-SYNC-LOSS indication.
  112. *
  113. * @details Generated by the MLME of a device and issued to its next
  114. * higher layer in the event of a loss of synchronization with the
  115. * coordinator. It is also generated by the MLME of the PAN coordinator
  116. * and issued to its next higher layer in the event of a PAN ID conflict.
  117. *
  118. * @param[in] ind MLME-SYNC-LOSS indication structure.
  119. *
  120. * In accordance with IEEE Std 802.15.4-2006, section 7.1.7.4
  121. */
  122. extern void mlme_sync_loss_ind(mlme_sync_loss_ind_t * ind);
  123. /**
  124. * @brief MLME-SYNC request.
  125. *
  126. * @details Generated by the next higher layer of a device on a
  127. * beacon-enabled PAN and issued to its MLME to synchronize with
  128. * the coordinator.
  129. *
  130. * @param[in] req MLME_SYNC request structure.
  131. *
  132. * In accordance with IEEE Std 802.15.4-2006, section 7.1.15.1
  133. */
  134. void mlme_sync_req(mlme_sync_req_t * req);
  135. #endif // (CONFIG_SYNC_REQ_ENABLED == 1)
  136. /** @} */
  137. #endif // (CONFIG_SYNC_ENABLED == 1)
  138. #endif // MAC_MLME_SYNC_H_INCLUDED