mac_mlme_beacon_notify.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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_BEACON_NOTIFY_H_INCLUDED
  43. #define MAC_MLME_BEACON_NOTIFY_H_INCLUDED
  44. #include <stdint.h>
  45. #include <stdbool.h>
  46. #include "mac_common.h"
  47. #include "mac_time.h"
  48. /** @file
  49. * The MAC Beacon notify module declares the MAC beacon notification routine and necessary
  50. * types/macros according to the MAC specification.
  51. *
  52. * @defgroup mac_beacon_notify MAC MLME Beacon Notify API
  53. * @ingroup mac_15_4
  54. * @{
  55. * @brief Module to declare MAC MLME Beacon Notify API.
  56. * @details The MAC Beacon Notify module declares Beacon Notify MLME routines and necessary macros/types
  57. * according to the MAC specification. MAC MLME Beacon notify indication is declared as
  58. * mlme_beacon_notify_ind().
  59. */
  60. /**@brief This constant is defined in 7.2.2.1.7 Address List field
  61. *
  62. * @details The maximum number of addresses pending shall be limited to seven and may comprise
  63. * both short and extended addresses.
  64. */
  65. #define MAC_PENDING_ADDR_MAX 7
  66. /*@brief The maximum length of GTS fields inside beacon in octets.
  67. *
  68. * @details This definition is used to allocate memory for outgoing beacon.
  69. */
  70. #define MAC_MAX_GTS_FIELD_LEN 23
  71. /**@brief Superframe specification structure.*/
  72. typedef struct
  73. {
  74. uint16_t beacon_order : 4;
  75. uint16_t superframe_order : 4;
  76. uint16_t final_cap_slot : 4;
  77. uint16_t battery_life_extension : 1;
  78. uint16_t reserved : 1;
  79. uint16_t pan_coordinator : 1;
  80. uint16_t association_permit : 1;
  81. } mac_superframe_spec_t;
  82. /** @brief List of pending addresses
  83. * Short addresses are at the top of the table.
  84. */
  85. typedef struct
  86. {
  87. mac_addr_t addr_list[MAC_PENDING_ADDR_MAX];
  88. /**< Addresses array. */
  89. uint8_t short_addr_number; /**< Number of short addresses in the array. */
  90. uint8_t ext_addr_number; /**< Number of long addresses in the array. */
  91. } mac_pending_addr_list_t;
  92. /**@brief PAN Descriptor structure.
  93. *
  94. * @details See Table 55-Elements of PANDescriptor.
  95. */
  96. typedef struct
  97. {
  98. mac_addr_mode_t coord_addr_mode; /**< Coordinator addressing mode. */
  99. uint16_t coord_pan_id; /**< Coordinator PAN ID. */
  100. mac_addr_t coord_address; /**< Coordinator address. */
  101. uint8_t logical_channel; /**< Logical channel. */
  102. #ifdef CONFIG_SUB_GHZ
  103. uint8_t channel_page; /**< Channel page. */
  104. #endif
  105. mac_superframe_spec_t superframe_spec; /**< Superframe specification. */
  106. bool gts_permit; /**< Is GTS permitted? */
  107. uint8_t link_quality; /**< Link quality. */
  108. mac_timestamp_t timestamp; /**< Timestamp. */
  109. #if (CONFIG_SECURE == 1)
  110. uint8_t security_failure; /**< Security failure. */
  111. uint8_t security_level; /**< Security level. */
  112. uint8_t key_id_mode; /**< Key ID mode. */
  113. uint64_t key_source; /**< Key source. */
  114. uint8_t key_index; /**< Key index. */
  115. #endif
  116. } mac_pan_descriptor_t;
  117. /**@brief Pending Address Specification
  118. *
  119. * @details See Figure 51-Format of the Pending Address Specification field.
  120. */
  121. typedef struct
  122. {
  123. uint8_t pending_short : 3;
  124. uint8_t : 1;
  125. uint8_t pending_extended : 3;
  126. uint8_t : 1;
  127. } mac_pend_addr_spec_t;
  128. /**@brief MLME-BEACON-NOTIFY.indication parameters
  129. *
  130. * @details See 7.1.5.1 MLME-BEACON-NOTIFY.indication
  131. */
  132. typedef struct
  133. {
  134. uint8_t bsn; /**< Beacon sequence number. */
  135. mac_pan_descriptor_t pan_descriptor; /**< PAN descriptor. */
  136. mac_pend_addr_spec_t pend_addr_spec; /**< Pending address specification. */
  137. mac_addr_t addr_list[MAC_PENDING_ADDR_MAX];
  138. /**< Addresses array. */
  139. uint8_t sdu_length; /**< SDU length. */
  140. mac_payload_descriptor_t sdu; /**< SDU. */
  141. #if (CONFIG_SECURE == 1)
  142. uint8_t security_level; /**< Security level. */
  143. uint8_t key_id_mode; /**< Key ID mode. */
  144. uint64_t key_source; /**< Key source. */
  145. uint8_t key_index; /**< Key index. */
  146. #endif
  147. } mlme_beacon_notify_ind_t;
  148. /**@brief User implemented function, which handles MLME-BEACON-NOTIFY.indication.
  149. *
  150. * @details The MLME-BEACON-NOTIFY.indication primitive is used to send parameters contained
  151. * within a beacon frame received by the MAC sublayer to the next higher layer.
  152. * The primitive also sends a measure of the LQI and the time the beacon frame
  153. * was received. See 7.1.5.1 MLME-BEACON-NOTIFY.indication.
  154. *
  155. * @param ind MLME-BEACON-NOTIFY.indication parameters. See @ref mlme_beacon_notify_ind_t.
  156. */
  157. extern void mlme_beacon_notify_ind(mlme_beacon_notify_ind_t * ind);
  158. /** @} */
  159. #endif // MAC_MLME_BEACON_NOTIFY_H_INCLUDED