mac_mlme_scan.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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_SCAN_H_INCLUDED
  43. #define MAC_MLME_SCAN_H_INCLUDED
  44. #include <stdint.h>
  45. #include "mac_common.h"
  46. #include "mac_mlme_beacon_notify.h"
  47. #include "mac_task_scheduler.h"
  48. /** @file
  49. * The MAC MLME Scan module declares the MAC Scan primitives and necessary types
  50. * according to the MAC specification.
  51. *
  52. * @defgroup mac_scan MAC MLME Scan API
  53. * @ingroup mac_15_4
  54. * @{
  55. * @brief Module to declare MAC MLME Scan API.
  56. * @details The MAC Scan module declares MLME Scan primitives and necessary types according to
  57. * the MAC specification. More specifically, MLME Scan request aka mlme_scan_req(), and MLME
  58. * Scan confirm callback typedef aka mlme_scan_conf_cb_t primitives are declared.
  59. */
  60. /**@brief Type of scan. */
  61. typedef enum
  62. {
  63. ED_SCAN = 0, /**< Energy detection scan. */
  64. ACTIVE_SCAN, /**< Active scan. */
  65. PASSIVE_SCAN, /**< Passive scan. */
  66. ORPHAN_SCAN /**< Orphan scan. */
  67. } mac_scan_type_t;
  68. /**
  69. * @brief MLME-SCAN.confirm
  70. *
  71. * @details The MLME-SCAN.confirm reports the result of the channel scan request.
  72. *
  73. * In accordance with IEEE Std 802.15.4-2006, section 7.1.11.2
  74. */
  75. typedef struct
  76. {
  77. mac_status_t status; /**< Status of operation. */
  78. mac_scan_type_t scan_type; /**< Scan type. */
  79. #ifdef CONFIG_SUB_GHZ
  80. uint8_t channel_page; /**< Channel page. */
  81. #endif
  82. uint32_t unscanned_channels; /**< Unscanned channels. */
  83. uint8_t result_list_size; /**< Result list size. */
  84. uint8_t * energy_detect_list; /**< Energy detection list. */
  85. mac_pan_descriptor_t * pan_descriptor_list; /**< PAN descriptor list. */
  86. } mlme_scan_conf_t;
  87. /**
  88. * @brief MLME-SCAN.request
  89. *
  90. * @details The MLME-SCAN.request primitive is used to initiate a channel
  91. * scan over a given list of channels.
  92. *
  93. * In accordance with IEEE Std 802.15.4-2006, section 7.1.11.1
  94. */
  95. typedef struct
  96. {
  97. /** Do not edit this field. */
  98. mac_abstract_req_t service;
  99. /** Confirm to this request. */
  100. mlme_scan_conf_t confirm;
  101. mac_scan_type_t scan_type; /**< Scan type. */
  102. uint32_t scan_channels; /**< Scan channels. */
  103. uint8_t scan_duration; /**< Scan duration. */
  104. uint8_t pan_descriptors_buf_size; /**< PAN descriptor buffer size. */
  105. mac_pan_descriptor_t * pan_descriptors_buf; /**< PAN descriptor buffer. */
  106. uint8_t energy_detect_buf_size; /**< Energy detection buffer size. */
  107. uint8_t * energy_detect_buf; /**< Energy detection buffer. */
  108. #ifdef CONFIG_SUB_GHZ
  109. uint8_t channel_page; /**< Channel page. */
  110. #endif
  111. #if (CONFIG_SECURE == 1)
  112. uint8_t security_level; /**< Security level. */
  113. uint8_t key_id_mode; /**< Key ID mode. */
  114. uint64_t key_source; /**< Key source. */
  115. uint8_t key_index; /**< Key index. */
  116. #endif
  117. } mlme_scan_req_t;
  118. /**
  119. * @brief User callback to scan request.
  120. *
  121. * @details The MLME-SCAN.confirm primitive is generated by the MLME and issued to
  122. * its next higher layer when the channel scan initiated with
  123. * the MLME-SCAN.request primitive has completed.
  124. *
  125. * In accordance with IEEE Std 802.15.4-2006, section 7.1.11.2
  126. */
  127. typedef void (* mlme_scan_conf_cb_t)(mlme_scan_conf_t *);
  128. /**
  129. * @brief MLME-SCAN request
  130. *
  131. * @details The MLME-SCAN.request primitive is generated by the next higher layer and
  132. * issued to its MLME to initiate a channel scan to search for activity within the POS
  133. * of the device. This primitive can be used to perform an ED scan to determine channel
  134. * usage, an active or passive scan to locate beacon frames containing any PAN identifier,
  135. * or an orphan scan to locate a PAN to which the device is currently associated.
  136. *
  137. * @param[in] req MLME-SCAN request structure.
  138. * @param[in] conf_cb pointer to user callback.
  139. *
  140. * In accordance with IEEE Std 802.15.4-2006, section 7.1.11.1
  141. */
  142. void mlme_scan_req(mlme_scan_req_t * req, mlme_scan_conf_cb_t conf_cb);
  143. /** @} */
  144. #endif // MAC_MLME_SCAN_H_INCLUDED