ble_racp.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. */
  11. /** @file
  12. *
  13. * @defgroup ble_sdk_lib_racp Record Access Control Point
  14. * @{
  15. * @ingroup ble_sdk_lib
  16. * @brief Record Access Control Point library.
  17. */
  18. #ifndef BLE_RACP_H__
  19. #define BLE_RACP_H__
  20. #include <stdint.h>
  21. #include <stdbool.h>
  22. #include "ble.h"
  23. #include "ble_types.h"
  24. #include "ble.h"
  25. /**@brief Record Access Control Point opcodes. */
  26. #define RACP_OPCODE_RESERVED 0 /**< Record Access Control Point opcode - Reserved for future use. */
  27. #define RACP_OPCODE_REPORT_RECS 1 /**< Record Access Control Point opcode - Report stored records. */
  28. #define RACP_OPCODE_DELETE_RECS 2 /**< Record Access Control Point opcode - Delete stored records. */
  29. #define RACP_OPCODE_ABORT_OPERATION 3 /**< Record Access Control Point opcode - Abort operation. */
  30. #define RACP_OPCODE_REPORT_NUM_RECS 4 /**< Record Access Control Point opcode - Report number of stored records. */
  31. #define RACP_OPCODE_NUM_RECS_RESPONSE 5 /**< Record Access Control Point opcode - Number of stored records response. */
  32. #define RACP_OPCODE_RESPONSE_CODE 6 /**< Record Access Control Point opcode - Response code. */
  33. /**@brief Record Access Control Point operators. */
  34. #define RACP_OPERATOR_NULL 0 /**< Record Access Control Point operator - Null. */
  35. #define RACP_OPERATOR_ALL 1 /**< Record Access Control Point operator - All records. */
  36. #define RACP_OPERATOR_LESS_OR_EQUAL 2 /**< Record Access Control Point operator - Less than or equal to. */
  37. #define RACP_OPERATOR_GREATER_OR_EQUAL 3 /**< Record Access Control Point operator - Greater than or equal to. */
  38. #define RACP_OPERATOR_RANGE 4 /**< Record Access Control Point operator - Within range of (inclusive). */
  39. #define RACP_OPERATOR_FIRST 5 /**< Record Access Control Point operator - First record (i.e. oldest record). */
  40. #define RACP_OPERATOR_LAST 6 /**< Record Access Control Point operator - Last record (i.e. most recent record). */
  41. #define RACP_OPERATOR_RFU_START 7 /**< Record Access Control Point operator - Start of Reserved for Future Use area. */
  42. /**@brief Record Access Control Point response codes. */
  43. #define RACP_RESPONSE_RESERVED 0 /**< Record Access Control Point response code - Reserved for future use. */
  44. #define RACP_RESPONSE_SUCCESS 1 /**< Record Access Control Point response code - Successful operation. */
  45. #define RACP_RESPONSE_OPCODE_UNSUPPORTED 2 /**< Record Access Control Point response code - Unsupported op code received. */
  46. #define RACP_RESPONSE_INVALID_OPERATOR 3 /**< Record Access Control Point response code - Operator not valid for service. */
  47. #define RACP_RESPONSE_OPERATOR_UNSUPPORTED 4 /**< Record Access Control Point response code - Unsupported operator. */
  48. #define RACP_RESPONSE_INVALID_OPERAND 5 /**< Record Access Control Point response code - Operand not valid for service. */
  49. #define RACP_RESPONSE_NO_RECORDS_FOUND 6 /**< Record Access Control Point response code - No matching records found. */
  50. #define RACP_RESPONSE_ABORT_FAILED 7 /**< Record Access Control Point response code - Abort could not be completed. */
  51. #define RACP_RESPONSE_PROCEDURE_NOT_DONE 8 /**< Record Access Control Point response code - Procedure could not be completed. */
  52. #define RACP_RESPONSE_OPERAND_UNSUPPORTED 9 /**< Record Access Control Point response code - Unsupported operand. */
  53. /**@brief Record Access Control Point value structure. */
  54. typedef struct
  55. {
  56. uint8_t opcode; /**< Op Code. */
  57. uint8_t operator; /**< Operator. */
  58. uint8_t operand_len; /**< Length of the operand. */
  59. uint8_t * p_operand; /**< Pointer to the operand. */
  60. } ble_racp_value_t;
  61. /**@brief Function for decoding a Record Access Control Point write.
  62. *
  63. * @details This call decodes a write to the Record Access Control Point.
  64. *
  65. * @param[in] data_len Length of data in received write.
  66. * @param[in] p_data Pointer to received data.
  67. * @param[out] p_racp_val Pointer to decoded Record Access Control Point write.
  68. * @note This does not do a data copy. It assumes the data pointed to by
  69. * p_data is persistant until no longer needed.
  70. */
  71. void ble_racp_decode(uint8_t data_len, uint8_t * p_data, ble_racp_value_t * p_racp_val);
  72. /**@brief Function for encoding a Record Access Control Point response.
  73. *
  74. * @details This call encodes a response from the Record Access Control Point response.
  75. *
  76. * @param[in] p_racp_val Pointer to Record Access Control Point to encode.
  77. * @param[out] p_data Pointer to where encoded data is written.
  78. * NOTE! It is calling routines respsonsibility to make sure.
  79. *
  80. * @return Length of encoded data.
  81. */
  82. uint8_t ble_racp_encode(const ble_racp_value_t * p_racp_val, uint8_t * p_data);
  83. #endif // BLE_RACP_H__
  84. /** @} */