gattprofile.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name : gattprofile.h
  3. * Author : WCH
  4. * Version : V1.0
  5. * Date : 2018/12/11
  6. * Description :
  7. *********************************************************************************
  8. * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
  9. * Attention: This software (modified or not) and binary are used for
  10. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
  11. *******************************************************************************/
  12. #ifndef GATTPROFILE_H
  13. #define GATTPROFILE_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /*********************************************************************
  18. * INCLUDES
  19. */
  20. /*********************************************************************
  21. * CONSTANTS
  22. */
  23. // Profile Parameters
  24. #define SIMPLEPROFILE_CHAR1 0 // RW uint8_t - Profile Characteristic 1 value
  25. #define SIMPLEPROFILE_CHAR2 1 // RW uint8_t - Profile Characteristic 2 value
  26. #define SIMPLEPROFILE_CHAR3 2 // RW uint8_t - Profile Characteristic 3 value
  27. #define SIMPLEPROFILE_CHAR4 3 // RW uint8_t - Profile Characteristic 4 value
  28. #define SIMPLEPROFILE_CHAR5 4 // RW uint8_t - Profile Characteristic 4 value
  29. // Simple Profile Service UUID
  30. #define SIMPLEPROFILE_SERV_UUID 0xFFE0
  31. // Key Pressed UUID
  32. #define SIMPLEPROFILE_CHAR1_UUID 0xFFE1
  33. #define SIMPLEPROFILE_CHAR2_UUID 0xFFE2
  34. #define SIMPLEPROFILE_CHAR3_UUID 0xFFE3
  35. #define SIMPLEPROFILE_CHAR4_UUID 0xFFE4
  36. #define SIMPLEPROFILE_CHAR5_UUID 0xFFE5
  37. // Simple Keys Profile Services bit fields
  38. #define SIMPLEPROFILE_SERVICE 0x00000001
  39. // Length of Characteristic 5 in bytes
  40. #define SIMPLEPROFILE_CHAR4_LEN 8
  41. #define SIMPLEPROFILE_CHAR5_LEN 5
  42. /*********************************************************************
  43. * TYPEDEFS
  44. */
  45. /*********************************************************************
  46. * MACROS
  47. */
  48. /*********************************************************************
  49. * Profile Callbacks
  50. */
  51. // Callback when a characteristic value has changed
  52. typedef void (*simpleProfileChange_t)(uint8_t paramID);
  53. typedef struct
  54. {
  55. simpleProfileChange_t pfnSimpleProfileChange; // Called when characteristic value changes
  56. } simpleProfileCBs_t;
  57. /*********************************************************************
  58. * API FUNCTIONS
  59. */
  60. /*
  61. * SimpleProfile_AddService- Initializes the Simple GATT Profile service by registering
  62. * GATT attributes with the GATT server.
  63. *
  64. * @param services - services to add. This is a bit map and can
  65. * contain more than one service.
  66. */
  67. extern bStatus_t SimpleProfile_AddService(uint32_t services);
  68. /*
  69. * SimpleProfile_RegisterAppCBs - Registers the application callback function.
  70. * Only call this function once.
  71. *
  72. * appCallbacks - pointer to application callbacks.
  73. */
  74. extern bStatus_t SimpleProfile_RegisterAppCBs(simpleProfileCBs_t *appCallbacks);
  75. /*
  76. * SimpleProfile_SetParameter - Set a Simple GATT Profile parameter.
  77. *
  78. * param - Profile parameter ID
  79. * len - length of data to right
  80. * value - pointer to data to write. This is dependent on
  81. * the parameter ID and WILL be cast to the appropriate
  82. * data type (example: data type of uint16_t will be cast to
  83. * uint16_t pointer).
  84. */
  85. extern bStatus_t SimpleProfile_SetParameter(uint8_t param, uint16_t len, void *value);
  86. /*
  87. * SimpleProfile_GetParameter - Get a Simple GATT Profile parameter.
  88. *
  89. * param - Profile parameter ID
  90. * value - pointer to data to write. This is dependent on
  91. * the parameter ID and WILL be cast to the appropriate
  92. * data type (example: data type of uint16_t will be cast to
  93. * uint16_t pointer).
  94. */
  95. extern bStatus_t SimpleProfile_GetParameter(uint8_t param, void *value);
  96. /*********************************************************************
  97. *********************************************************************/
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif