Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

178 lines
4.8 KiB

  1. /*!
  2. * \file LoRaMacConfirmQueue.h
  3. *
  4. * \brief LoRa MAC confirm queue implementation
  5. *
  6. * \copyright Revised BSD License, see section \ref LICENSE.
  7. *
  8. * \code
  9. * ______ _
  10. * / _____) _ | |
  11. * ( (____ _____ ____ _| |_ _____ ____| |__
  12. * \____ \| ___ | (_ _) ___ |/ ___) _ \
  13. * _____) ) ____| | | || |_| ____( (___| | | |
  14. * (______/|_____)_|_|_| \__)_____)\____)_| |_|
  15. * (C)2013 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. * \defgroup LORAMACCONFIRMQUEUE LoRa MAC confirm queue implementation
  32. * This module specifies the API implementation of the LoRaMAC confirm queue.
  33. * The confirm queue is implemented with as a ring buffer. The number of
  34. * elements can be defined with \ref LORA_MAC_MLME_CONFIRM_QUEUE_LEN. The
  35. * current implementation does not support multiple elements of the same
  36. * Mlme_t type.
  37. * \{
  38. */
  39. #ifndef __LORAMAC_CONFIRMQUEUE_H__
  40. #define __LORAMAC_CONFIRMQUEUE_H__
  41. #ifdef __cplusplus
  42. extern "C"
  43. {
  44. #endif
  45. #include <stdbool.h>
  46. #include <stdint.h>
  47. #include "LoRaMac.h"
  48. /*!
  49. * LoRaMac MLME-Confirm queue length
  50. */
  51. #define LORA_MAC_MLME_CONFIRM_QUEUE_LEN 5
  52. /*!
  53. * Structure to hold multiple MLME request confirm data
  54. */
  55. typedef struct sMlmeConfirmQueue
  56. {
  57. /*!
  58. * Holds the previously performed MLME-Request
  59. */
  60. Mlme_t Request;
  61. /*!
  62. * Status of the operation
  63. */
  64. LoRaMacEventInfoStatus_t Status;
  65. /*!
  66. * Set to true, if the request is ready to be handled
  67. */
  68. bool ReadyToHandle;
  69. /*!
  70. * Set to true, if it is not permitted to set the ReadyToHandle variable
  71. * with a function call to LoRaMacConfirmQueueSetStatusCmn.
  72. */
  73. bool RestrictCommonReadyToHandle;
  74. }MlmeConfirmQueue_t;
  75. /*!
  76. * \brief Initializes the confirm queue
  77. *
  78. * \param [IN] primitives - Pointer to the LoRaMac primitives.
  79. */
  80. void LoRaMacConfirmQueueInit( LoRaMacPrimitives_t* primitive );
  81. /*!
  82. * \brief Adds an element to the confirm queue.
  83. *
  84. * \param [IN] mlmeConfirm - Pointer to the element to add.
  85. *
  86. * \retval [true - operation was successful, false - operation failed]
  87. */
  88. bool LoRaMacConfirmQueueAdd( MlmeConfirmQueue_t* mlmeConfirm );
  89. /*!
  90. * \brief Removes the last element which was added into the queue.
  91. *
  92. * \retval [true - operation was successful, false - operation failed]
  93. */
  94. bool LoRaMacConfirmQueueRemoveLast( void );
  95. /*!
  96. * \brief Removes the first element which was added to the confirm queue.
  97. *
  98. * \retval [true - operation was successful, false - operation failed]
  99. */
  100. bool LoRaMacConfirmQueueRemoveFirst( void );
  101. /*!
  102. * \brief Sets the status of an element.
  103. *
  104. * \param [IN] status - The status to set.
  105. *
  106. * \param [IN] request - The related request to set the status.
  107. */
  108. void LoRaMacConfirmQueueSetStatus( LoRaMacEventInfoStatus_t status, Mlme_t request );
  109. /*!
  110. * \brief Gets the status of an element.
  111. *
  112. * \param [IN] request - The request to query the status.
  113. *
  114. * \retval The status of the related MlmeRequest.
  115. */
  116. LoRaMacEventInfoStatus_t LoRaMacConfirmQueueGetStatus( Mlme_t request );
  117. /*!
  118. * \brief Sets a common status for all elements in the queue.
  119. *
  120. * \param [IN] status - The status to set.
  121. */
  122. void LoRaMacConfirmQueueSetStatusCmn( LoRaMacEventInfoStatus_t status );
  123. /*!
  124. * \brief Gets the common status of all elements.
  125. *
  126. * \retval The common status of all elements.
  127. */
  128. LoRaMacEventInfoStatus_t LoRaMacConfirmQueueGetStatusCmn( void );
  129. /*!
  130. * \brief Verifies if a request is in the queue and active.
  131. *
  132. * \param [IN] request - The request to verify.
  133. *
  134. * \retval [true - element is in the queue, false - element is not in the queue].
  135. */
  136. bool LoRaMacConfirmQueueIsCmdActive( Mlme_t request );
  137. /*!
  138. * \brief Handles all callbacks of active requests
  139. *
  140. * \param [IN] mlmeConfirm - Pointer to the generic mlmeConfirm structure.
  141. */
  142. void LoRaMacConfirmQueueHandleCb( MlmeConfirm_t* mlmeConfirm );
  143. /*!
  144. * \brief Query number of elements in the queue.
  145. *
  146. * \retval Number of elements.
  147. */
  148. uint8_t LoRaMacConfirmQueueGetCnt( void );
  149. /*!
  150. * \brief Verify if the confirm queue is full.
  151. *
  152. * \retval [true - queue is full, false - queue is not full].
  153. */
  154. bool LoRaMacConfirmQueueIsFull( void );
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #endif // __LORAMAC_CONFIRMQUEUE_H__