ble_racp.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * Copyright (c) 2012 - 2020, Nordic Semiconductor ASA
  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. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. /** @file
  41. *
  42. * @defgroup ble_racp Record Access Control Point
  43. * @{
  44. * @ingroup ble_sdk_lib
  45. * @brief Record Access Control Point library.
  46. */
  47. #ifndef BLE_RACP_H__
  48. #define BLE_RACP_H__
  49. #include <stdint.h>
  50. #include <stdbool.h>
  51. #include "ble.h"
  52. #include "ble_types.h"
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56. /**@brief Record Access Control Point opcodes. */
  57. #define RACP_OPCODE_RESERVED 0 /**< Record Access Control Point opcode - Reserved for future use. */
  58. #define RACP_OPCODE_REPORT_RECS 1 /**< Record Access Control Point opcode - Report stored records. */
  59. #define RACP_OPCODE_DELETE_RECS 2 /**< Record Access Control Point opcode - Delete stored records. */
  60. #define RACP_OPCODE_ABORT_OPERATION 3 /**< Record Access Control Point opcode - Abort operation. */
  61. #define RACP_OPCODE_REPORT_NUM_RECS 4 /**< Record Access Control Point opcode - Report number of stored records. */
  62. #define RACP_OPCODE_NUM_RECS_RESPONSE 5 /**< Record Access Control Point opcode - Number of stored records response. */
  63. #define RACP_OPCODE_RESPONSE_CODE 6 /**< Record Access Control Point opcode - Response code. */
  64. /**@brief Record Access Control Point operators. */
  65. #define RACP_OPERATOR_NULL 0 /**< Record Access Control Point operator - Null. */
  66. #define RACP_OPERATOR_ALL 1 /**< Record Access Control Point operator - All records. */
  67. #define RACP_OPERATOR_LESS_OR_EQUAL 2 /**< Record Access Control Point operator - Less than or equal to. */
  68. #define RACP_OPERATOR_GREATER_OR_EQUAL 3 /**< Record Access Control Point operator - Greater than or equal to. */
  69. #define RACP_OPERATOR_RANGE 4 /**< Record Access Control Point operator - Within range of (inclusive). */
  70. #define RACP_OPERATOR_FIRST 5 /**< Record Access Control Point operator - First record (i.e. oldest record). */
  71. #define RACP_OPERATOR_LAST 6 /**< Record Access Control Point operator - Last record (i.e. most recent record). */
  72. #define RACP_OPERATOR_RFU_START 7 /**< Record Access Control Point operator - Start of Reserved for Future Use area. */
  73. /**@brief Record Access Control Point Operand Filter Type Value. */
  74. #define RACP_OPERAND_FILTER_TYPE_TIME_OFFSET 1 /**< Record Access Control Point Operand Filter Type Value - Time Offset. */
  75. #define RACP_OPERAND_FILTER_TYPE_FACING_TIME 2 /**< Record Access Control Point Operand Filter Type Value - User Facing Time. */
  76. /**@brief Record Access Control Point response codes. */
  77. #define RACP_RESPONSE_RESERVED 0 /**< Record Access Control Point response code - Reserved for future use. */
  78. #define RACP_RESPONSE_SUCCESS 1 /**< Record Access Control Point response code - Successful operation. */
  79. #define RACP_RESPONSE_OPCODE_UNSUPPORTED 2 /**< Record Access Control Point response code - Unsupported op code received. */
  80. #define RACP_RESPONSE_INVALID_OPERATOR 3 /**< Record Access Control Point response code - Operator not valid for service. */
  81. #define RACP_RESPONSE_OPERATOR_UNSUPPORTED 4 /**< Record Access Control Point response code - Unsupported operator. */
  82. #define RACP_RESPONSE_INVALID_OPERAND 5 /**< Record Access Control Point response code - Operand not valid for service. */
  83. #define RACP_RESPONSE_NO_RECORDS_FOUND 6 /**< Record Access Control Point response code - No matching records found. */
  84. #define RACP_RESPONSE_ABORT_FAILED 7 /**< Record Access Control Point response code - Abort could not be completed. */
  85. #define RACP_RESPONSE_PROCEDURE_NOT_DONE 8 /**< Record Access Control Point response code - Procedure could not be completed. */
  86. #define RACP_RESPONSE_OPERAND_UNSUPPORTED 9 /**< Record Access Control Point response code - Unsupported operand. */
  87. /**@brief Record Access Control Point value structure. */
  88. typedef struct
  89. {
  90. uint8_t opcode; /**< Op Code. */
  91. uint8_t operator; /**< Operator. */
  92. uint8_t operand_len; /**< Length of the operand. */
  93. uint8_t * p_operand; /**< Pointer to the operand. */
  94. } ble_racp_value_t;
  95. /**@brief Function for decoding a Record Access Control Point write.
  96. *
  97. * @details This call decodes a write to the Record Access Control Point.
  98. *
  99. * @param[in] data_len Length of data in received write.
  100. * @param[in] p_data Pointer to received data.
  101. * @param[out] p_racp_val Pointer to decoded Record Access Control Point write.
  102. * @note This does not do a data copy. It assumes the data pointed to by
  103. * p_data is persistant until no longer needed.
  104. */
  105. void ble_racp_decode(uint8_t data_len, uint8_t const * p_data, ble_racp_value_t * p_racp_val);
  106. /**@brief Function for encoding a Record Access Control Point response.
  107. *
  108. * @details This call encodes a response from the Record Access Control Point response.
  109. *
  110. * @param[in] p_racp_val Pointer to Record Access Control Point to encode.
  111. * @param[out] p_data Pointer to where encoded data is written.
  112. * NOTE! It is calling routines respsonsibility to make sure.
  113. *
  114. * @return Length of encoded data.
  115. */
  116. uint8_t ble_racp_encode(const ble_racp_value_t * p_racp_val, uint8_t * p_data);
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif // BLE_RACP_H__
  121. /** @} */