gattprofile.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 0xFEE7
  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. #if(DEBUG == DEBUG_UART_BLE)
  37. #define SIMPLEPROFILE_CHAR5_UUID 0xFFE5
  38. #endif
  39. // Simple Keys Profile Services bit fields
  40. #define SIMPLEPROFILE_SERVICE 0x00000001
  41. // Length of characteristic in bytes ( Default MTU is 23 )
  42. #define SIMPLEPROFILE_CHAR1_LEN 256
  43. #define SIMPLEPROFILE_CHAR2_LEN 256
  44. #define SIMPLEPROFILE_CHAR3_LEN 256
  45. #define SIMPLEPROFILE_CHAR4_LEN 64
  46. #if(DEBUG == DEBUG_UART_BLE)
  47. #define SIMPLEPROFILE_CHAR5_LEN 256
  48. #endif
  49. /*********************************************************************
  50. * TYPEDEFS
  51. */
  52. /*********************************************************************
  53. * MACROS
  54. */
  55. /*********************************************************************
  56. * Profile Callbacks
  57. */
  58. // Callback when a characteristic value has changed
  59. typedef void (*simpleProfileChange_t)(uint8_t paramID, uint8_t *pValue, uint16_t len);
  60. typedef struct
  61. {
  62. simpleProfileChange_t pfnSimpleProfileChange; // Called when characteristic value changes
  63. } simpleProfileCBs_t;
  64. /*********************************************************************
  65. * API FUNCTIONS
  66. */
  67. /*
  68. * SimpleProfile_AddService- Initializes the Simple GATT Profile service by registering
  69. * GATT attributes with the GATT server.
  70. *
  71. * @param services - services to add. This is a bit map and can
  72. * contain more than one service.
  73. */
  74. extern bStatus_t SimpleProfile_AddService(uint32_t services);
  75. /*
  76. * SimpleProfile_RegisterAppCBs - Registers the application callback function.
  77. * Only call this function once.
  78. *
  79. * appCallbacks - pointer to application callbacks.
  80. */
  81. extern bStatus_t SimpleProfile_RegisterAppCBs(simpleProfileCBs_t *appCallbacks);
  82. /*
  83. * SimpleProfile_SetParameter - Set a Simple GATT Profile parameter.
  84. *
  85. * param - Profile parameter ID
  86. * len - length of data to right
  87. * value - pointer to data to write. This is dependent on
  88. * the parameter ID and WILL be cast to the appropriate
  89. * data type (example: data type of uint16_t will be cast to
  90. * uint16_t pointer).
  91. */
  92. extern bStatus_t SimpleProfile_SetParameter(uint8_t param, uint16_t len, void *value);
  93. /*
  94. * SimpleProfile_GetParameter - Get a Simple GATT Profile parameter.
  95. *
  96. * param - Profile parameter ID
  97. * value - pointer to data to write. This is dependent on
  98. * the parameter ID and WILL be cast to the appropriate
  99. * data type (example: data type of uint16_t will be cast to
  100. * uint16_t pointer).
  101. */
  102. extern bStatus_t SimpleProfile_GetParameter(uint8_t param, void *value);
  103. /*
  104. * simpleProfileChar4_Notify - Send notification.
  105. *
  106. * connHandle - connect handle
  107. * pNoti - pointer to structure to notify.
  108. */
  109. extern bStatus_t simpleProfileChar4_Notify(uint16_t connHandle, attHandleValueNoti_t *pNoti);
  110. #if(DEBUG == DEBUG_UART_BLE)
  111. /*
  112. * simpleProfileChar5_Notify - Send notification.
  113. *
  114. * connHandle - connect handle
  115. * pNoti - pointer to structure to notify.
  116. */
  117. extern bStatus_t simpleProfileChar5_Notify(uint16_t connHandle, attHandleValueNoti_t *pNoti);
  118. #endif
  119. /*********************************************************************
  120. *********************************************************************/
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124. #endif