gapgattserver.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /**
  2. * @file
  3. * @author chipsea
  4. * @brief
  5. * @version 0.1
  6. * @date 2020-11-30
  7. * @copyright Copyright (c) 2020, CHIPSEA Co., Ltd.
  8. * @note
  9. */
  10. /**************************************************************************************************
  11. Filename: gapgattserver.h
  12. Revised:
  13. Revision:
  14. Description: This file contains GAP GATT attribute definitions
  15. and prototypes.
  16. **************************************************************************************************/
  17. #ifndef GAPGATTSERVER_H
  18. #define GAPGATTSERVER_H
  19. #ifdef __cplusplus
  20. extern "C"
  21. {
  22. #endif
  23. /*********************************************************************
  24. * INCLUDES
  25. */
  26. /*********************************************************************
  27. * CONSTANTS
  28. */
  29. #define GAP_DEVICE_NAME_LEN (30+1)
  30. // Privacy Flag States
  31. #define GAP_PRIVACY_DISABLED 0x00
  32. #define GAP_PRIVACY_ENABLED 0x01
  33. // GAP GATT Server Parameters
  34. #define GGS_DEVICE_NAME_ATT 0 // RW uint8[GAP_DEVICE_NAME_LEN]
  35. #define GGS_APPEARANCE_ATT 1 // RW uint16
  36. #define GGS_PERI_PRIVACY_FLAG_ATT 2 // RW uint8
  37. #define GGS_RECONNCT_ADDR_ATT 3 // RW uint8[B_ADDR_LEN]
  38. #define GGS_PERI_CONN_PARAM_ATT 4 // RW sizeof(gapPeriConnectParams_t)
  39. #define GGS_PERI_PRIVACY_FLAG_PROPS 5 // RW uint8
  40. #define GGS_W_PERMIT_DEVICE_NAME_ATT 6 // W uint8
  41. #define GGS_W_PERMIT_APPEARANCE_ATT 7 // W uint8
  42. #define GGS_W_PERMIT_PRIVACY_FLAG_ATT 8 // W uint8
  43. // GAP Services bit fields
  44. #define GAP_SERVICE 0x00000001
  45. // Attribute ID used with application's callback when attribute value is changed OTA
  46. #define GGS_DEVICE_NAME_ID 0
  47. #define GGS_APPEARANCE_ID 1
  48. #if defined ( TESTMODES )
  49. // GGS TestModes
  50. #define GGS_TESTMODE_OFF 0 // No Test mode
  51. #define GGS_TESTMODE_W_PERMIT_DEVICE_NAME 1 // Make Device Name attribute writable
  52. #define GGS_TESTMODE_W_PERMIT_APPEARANCE 2 // Make Appearance attribute writable
  53. #define GGS_TESTMODE_W_PERMIT_PRIVACY_FLAG 3 // Make Peripheral Privacy Flag attribute writable with authentication
  54. #endif // TESTMODES
  55. /*********************************************************************
  56. * TYPEDEFS
  57. */
  58. // Callback to notify when attribute value is changed over the air.
  59. typedef void (*ggsAttrValueChange_t)( uint8 attrId );
  60. // GAP GATT Server callback structure
  61. typedef struct
  62. {
  63. ggsAttrValueChange_t pfnAttrValueChange; // When attribute value is changed OTA
  64. } ggsAppCBs_t;
  65. /*********************************************************************
  66. * MACROS
  67. */
  68. /*********************************************************************
  69. * Profile Callbacks
  70. */
  71. /*********************************************************************
  72. * API FUNCTIONS
  73. */
  74. /**
  75. * @brief Set a GAP GATT Server parameter.
  76. *
  77. * @param param - Profile parameter ID<BR>
  78. * @param len - length of data to right
  79. * @param value - pointer to data to write. This is dependent on
  80. * the parameter ID and WILL be cast to the appropriate
  81. * data type (example: data type of uint16 will be cast to
  82. * uint16 pointer).<BR>
  83. *
  84. * @return bStatus_t
  85. */
  86. extern bStatus_t GGS_SetParameter( uint8 param, uint8 len, void *value );
  87. /**
  88. * @brief Get a GAP GATT Server parameter.
  89. *
  90. * @param param - Profile parameter ID<BR>
  91. * @param value - pointer to data to put. This is dependent on
  92. * the parameter ID and WILL be cast to the appropriate
  93. * data type (example: data type of uint16 will be cast to
  94. * uint16 pointer).<BR>
  95. *
  96. * @return bStatus_t
  97. */
  98. extern bStatus_t GGS_GetParameter( uint8 param, void *value );
  99. /**
  100. * @brief Add function for the GAP GATT Service.
  101. *
  102. * @param services - services to add. This is a bit map and can
  103. * contain more than one service.
  104. *
  105. * @return SUCCESS: Service added successfully.<BR>
  106. * INVALIDPARAMETER: Invalid service field.<BR>
  107. * FAILURE: Not enough attribute handles available.<BR>
  108. * bleMemAllocError: Memory allocation error occurred.<BR>
  109. */
  110. extern bStatus_t GGS_AddService( uint32 services );
  111. /**
  112. * @brief Delete function for the GAP GATT Service.
  113. *
  114. * @param services - services to delete. This is a bit map and can
  115. * contain more than one service.
  116. *
  117. * @return SUCCESS: Service deleted successfully.<BR>
  118. * FAILURE: Service not found.<BR>
  119. */
  120. extern bStatus_t GGS_DelService( uint32 services );
  121. /**
  122. * @brief Registers the application callback function.
  123. *
  124. * Note: Callback registration is needed only when the
  125. * Device Name is made writable. The application
  126. * will be notified when the Device Name is changed
  127. * over the air.
  128. *
  129. * @param appCallbacks - pointer to application callbacks.
  130. *
  131. * @return none
  132. */
  133. extern void GGS_RegisterAppCBs( ggsAppCBs_t *appCallbacks );
  134. /**
  135. * @brief Set a GGS Parameter value. Use this function to change
  136. * the default GGS parameter values.
  137. *
  138. * @param value - new GGS param value
  139. *
  140. * @return void
  141. */
  142. extern void GGS_SetParamValue( uint16 value );
  143. /**
  144. * @brief Get a GGS Parameter value.
  145. *
  146. * @param none
  147. *
  148. * @return GGS Parameter value
  149. */
  150. extern uint16 GGS_GetParamValue( void );
  151. /*********************************************************************
  152. * TASK FUNCTIONS - Don't call these. These are system functions.
  153. */
  154. /*********************************************************************
  155. *********************************************************************/
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159. #endif /* GAPGATTSERVER_H */