mac_mlme_gts.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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_GTS_H_INCLUDED
  43. #define MAC_MLME_GTS_H_INCLUDED
  44. #if (CONFIG_GTS_ENABLED == 1)
  45. #include <stdint.h>
  46. #include "mac_common.h"
  47. #include "mac_task_scheduler.h"
  48. /** @file
  49. * The MAC MLME GTS module declares the MAC Guaranteed time slots routines and
  50. * necessary types/macros according to the MAC specification.
  51. *
  52. * @defgroup mac_gts MAC MLME GTS API
  53. * @ingroup mac_15_4
  54. * @{
  55. * @brief Module to declare MAC MLME GTS API.
  56. * @details The MAC GTS module declares MAC Guaranteed Time Slots routines and necessary types according to
  57. * the MAC specification. More specifically, MLME GTS request aka mlme_gts_req(), MLME GTS indicaton
  58. * aka mlme_gts_ind(), and MLME GTS confirm callback typedef aka mlme_gts_conf_cb_t primitives are
  59. * declared.
  60. */
  61. /**@brief GTS directions, from device side. */
  62. typedef enum
  63. {
  64. MAC_GTS_DIR_TXONLY = 0, /**< TX only direction. */
  65. MAC_GTS_DIR_RXONLY = 1 /**< RX only direction. */
  66. } mac_gts_direction_t;
  67. /**@brief GTS characteristics type. */
  68. typedef enum
  69. {
  70. MAC_GTS_DEALLOC = 0, /**< GTS Dealloc. */
  71. MAC_GTS_ALLOC = 1 /**< GTS Alloc. */
  72. } mac_gts_characteristics_type_t;
  73. /**@brief MAC GTS characteristics (not packed)
  74. *
  75. * @details See Section 7.3.9.2
  76. */
  77. typedef union
  78. {
  79. struct
  80. {
  81. uint8_t gts_length : 4;
  82. uint8_t gts_direction : 1;
  83. uint8_t characterictics_type : 1;
  84. uint8_t : 2;
  85. } bit;
  86. uint8_t all;
  87. } mac_gts_characteristics_t;
  88. /**
  89. * @brief MLME-GTS.confirm
  90. *
  91. * @details The MLME-GTS.confirm primitive reports the results of a
  92. * request to allocate a new GTS or deallocate an existing GTS.
  93. *
  94. * In accordance with IEEE Std 802.15.4-2006, section 7.1.7.2
  95. */
  96. typedef struct
  97. {
  98. mac_gts_characteristics_t gts_characteristics; /**< GTS characteristics. */
  99. mac_status_t status; /**< Status of operation. */
  100. } mlme_gts_conf_t;
  101. /**
  102. * @brief MLME-GTS.request
  103. *
  104. * @details The MLME-GTS.request primitive allows a device to send a request
  105. * to the PAN coordinator to allocate a new GTS or to deallocate an existing GTS.
  106. * This primitive is also used by the PAN coordinator to initiate a GTS deallocation.
  107. *
  108. * In accordance with IEEE Std 802.15.4-2006, section 7.1.7.1
  109. */
  110. typedef struct
  111. {
  112. /** Do not edit this field. */
  113. mac_abstract_req_t service;
  114. /** Confirm to this request. */
  115. mlme_gts_conf_t confirm;
  116. mac_gts_characteristics_t gts_characteristics; /**< GTS characteristics. */
  117. #if (CONFIG_SECURE == 1)
  118. uint8_t security_level; /**< Security level. */
  119. uint8_t key_id_mode; /**< Key ID mode. */
  120. uint64_t key_source; /**< Key source. */
  121. uint8_t key_index; /**< Key index. */
  122. #endif
  123. } mlme_gts_req_t;
  124. /**
  125. * @brief MLME-GTS.indication
  126. *
  127. * @details The MLME-GTS.indication primitive indicates that a
  128. * GTS has been allocated or that a previously allocated GTS
  129. * has been deallocated.
  130. *
  131. * In accordance with IEEE Std 802.15.4-2006, section 7.1.7.3
  132. */
  133. typedef struct
  134. {
  135. uint16_t device_address; /**< Device address. */
  136. mac_gts_characteristics_t gts_characteristics; /**< GTS characteristics. */
  137. #if (CONFIG_SECURE == 1)
  138. uint8_t security_level; /**< Security level. */
  139. uint8_t key_id_mode; /**< Key ID mode. */
  140. uint64_t key_source; /**< Key source. */
  141. uint8_t key_index; /**< Key index. */
  142. #endif
  143. } mlme_gts_ind_t;
  144. /**
  145. * @brief MLME-GTS confirm callback
  146. *
  147. * @details The MLME-GTS.confirm primitive is generated by the MLME and
  148. * issued to its next higher layer in response to a previously
  149. * issued MLME-GTS.request primitive.
  150. *
  151. * @param MLME_GTS callback structure.
  152. *
  153. * In accordance with IEEE Std 802.15.4-2006, section 7.1.7.4
  154. */
  155. typedef void (* mlme_gts_conf_cb_t)(mlme_gts_conf_t *);
  156. /**
  157. * @brief MLME-GTS request
  158. *
  159. * @details The MLME-GTS.request primitive is generated by the next higher
  160. * layer of a device and issued to its MLME to request the allocation of a
  161. * new GTS or to request the deallocation of an existing GTS. It is also
  162. * generated by the next higher layer of the PAN coordinator and issued to
  163. * its MLME to request the deallocation of an existing GTS.
  164. *
  165. * @param req MLME_GTS request structure.
  166. * @param conf_cb pointer to user callback.
  167. *
  168. * In accordance with IEEE Std 802.15.4-2006, section 7.1.7.4
  169. */
  170. void mlme_gts_req(mlme_gts_req_t * req, mlme_gts_conf_cb_t conf_cb);
  171. /**
  172. * @brief MLME-GTS indication handler
  173. *
  174. * @details The MLME-GTS.indication primitive is generated by the MLME of
  175. * the PAN coordinator to its next higher layer whenever a GTS is allocated
  176. * or deallocated following the reception of a GTS request command (see 7.3.9)
  177. * by the MLME. The MLME of the PAN coordinator also generates this primitive when a GTS
  178. * deallocation is initiated by the PAN coordinator itself.
  179. *
  180. * @param ind MLME_GTS indication structure.
  181. *
  182. * In accordance with IEEE Std 802.15.4-2006, section 7.1.7.4
  183. */
  184. extern void mlme_gts_ind(mlme_gts_ind_t * ind);
  185. /** @} */
  186. #endif // (CONFIG_GTS_ENABLED == 1)
  187. #endif // MAC_MLME_GTS_H_INCLUDED