gapgattserver.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /**************************************************************************************************
  2. Phyplus Microelectronics Limited confidential and proprietary.
  3. All rights reserved.
  4. IMPORTANT: All rights of this software belong to Phyplus Microelectronics
  5. Limited ("Phyplus"). Your use of this Software is limited to those
  6. specific rights granted under the terms of the business contract, the
  7. confidential agreement, the non-disclosure agreement and any other forms
  8. of agreements as a customer or a partner of Phyplus. You may not use this
  9. Software unless you agree to abide by the terms of these agreements.
  10. You acknowledge that the Software may not be modified, copied,
  11. distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
  12. (BLE) integrated circuit, either as a product or is integrated into your
  13. products. Other than for the aforementioned purposes, you may not use,
  14. reproduce, copy, prepare derivative works of, modify, distribute, perform,
  15. display or sell this Software and/or its documentation for any purposes.
  16. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  17. PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  18. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  19. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  20. PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
  21. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  22. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  23. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  24. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  25. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  26. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  27. **************************************************************************************************/
  28. /**************************************************************************************************
  29. Filename: gapgattserver.h
  30. Revised:
  31. Revision:
  32. Description: This file contains GAP GATT attribute definitions
  33. and prototypes.
  34. **************************************************************************************************/
  35. #ifndef GAPGATTSERVER_H
  36. #define GAPGATTSERVER_H
  37. #ifdef __cplusplus
  38. extern "C"
  39. {
  40. #endif
  41. /*********************************************************************
  42. * INCLUDES
  43. */
  44. /*********************************************************************
  45. * CONSTANTS
  46. */
  47. #define GAP_DEVICE_NAME_LEN (20+1)
  48. // Privacy Flag States
  49. #define GAP_PRIVACY_DISABLED 0x00
  50. #define GAP_PRIVACY_ENABLED 0x01
  51. // GAP GATT Server Parameters
  52. #define GGS_DEVICE_NAME_ATT 0 // RW uint8[GAP_DEVICE_NAME_LEN]
  53. #define GGS_APPEARANCE_ATT 1 // RW uint16
  54. #define GGS_PERI_PRIVACY_FLAG_ATT 2 // RW uint8
  55. #define GGS_RECONNCT_ADDR_ATT 3 // RW uint8[B_ADDR_LEN]
  56. #define GGS_PERI_CONN_PARAM_ATT 4 // RW sizeof(gapPeriConnectParams_t)
  57. #define GGS_PERI_PRIVACY_FLAG_PROPS 5 // RW uint8
  58. #define GGS_W_PERMIT_DEVICE_NAME_ATT 6 // W uint8
  59. #define GGS_W_PERMIT_APPEARANCE_ATT 7 // W uint8
  60. #define GGS_W_PERMIT_PRIVACY_FLAG_ATT 8 // W uint8
  61. // GAP Services bit fields
  62. #define GAP_SERVICE 0x00000001
  63. // Attribute ID used with application's callback when attribute value is changed OTA
  64. #define GGS_DEVICE_NAME_ID 0
  65. #define GGS_APPEARANCE_ID 1
  66. #if defined ( TESTMODES )
  67. // GGS TestModes
  68. #define GGS_TESTMODE_OFF 0 // No Test mode
  69. #define GGS_TESTMODE_W_PERMIT_DEVICE_NAME 1 // Make Device Name attribute writable
  70. #define GGS_TESTMODE_W_PERMIT_APPEARANCE 2 // Make Appearance attribute writable
  71. #define GGS_TESTMODE_W_PERMIT_PRIVACY_FLAG 3 // Make Peripheral Privacy Flag attribute writable with authentication
  72. #endif // TESTMODES
  73. /*********************************************************************
  74. * TYPEDEFS
  75. */
  76. // Callback to notify when attribute value is changed over the air.
  77. typedef void (*ggsAttrValueChange_t)( uint8 attrId );
  78. // GAP GATT Server callback structure
  79. typedef struct
  80. {
  81. ggsAttrValueChange_t pfnAttrValueChange; // When attribute value is changed OTA
  82. } ggsAppCBs_t;
  83. /*********************************************************************
  84. * MACROS
  85. */
  86. /*********************************************************************
  87. * Profile Callbacks
  88. */
  89. /*********************************************************************
  90. * API FUNCTIONS
  91. */
  92. /**
  93. * @brief Set a GAP GATT Server parameter.
  94. *
  95. * @param param - Profile parameter ID<BR>
  96. * @param len - length of data to right
  97. * @param 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 will be cast to
  100. * uint16 pointer).<BR>
  101. *
  102. * @return bStatus_t
  103. */
  104. extern bStatus_t GGS_SetParameter( uint8 param, uint8 len, void *value );
  105. /**
  106. * @brief Get a GAP GATT Server parameter.
  107. *
  108. * @param param - Profile parameter ID<BR>
  109. * @param value - pointer to data to put. This is dependent on
  110. * the parameter ID and WILL be cast to the appropriate
  111. * data type (example: data type of uint16 will be cast to
  112. * uint16 pointer).<BR>
  113. *
  114. * @return bStatus_t
  115. */
  116. extern bStatus_t GGS_GetParameter( uint8 param, void *value );
  117. /**
  118. * @brief Add function for the GAP GATT Service.
  119. *
  120. * @param services - services to add. This is a bit map and can
  121. * contain more than one service.
  122. *
  123. * @return SUCCESS: Service added successfully.<BR>
  124. * INVALIDPARAMETER: Invalid service field.<BR>
  125. * FAILURE: Not enough attribute handles available.<BR>
  126. * bleMemAllocError: Memory allocation error occurred.<BR>
  127. */
  128. extern bStatus_t GGS_AddService( uint32 services );
  129. /**
  130. * @brief Delete function for the GAP GATT Service.
  131. *
  132. * @param services - services to delete. This is a bit map and can
  133. * contain more than one service.
  134. *
  135. * @return SUCCESS: Service deleted successfully.<BR>
  136. * FAILURE: Service not found.<BR>
  137. */
  138. extern bStatus_t GGS_DelService( uint32 services );
  139. /**
  140. * @brief Registers the application callback function.
  141. *
  142. * Note: Callback registration is needed only when the
  143. * Device Name is made writable. The application
  144. * will be notified when the Device Name is changed
  145. * over the air.
  146. *
  147. * @param appCallbacks - pointer to application callbacks.
  148. *
  149. * @return none
  150. */
  151. extern void GGS_RegisterAppCBs( ggsAppCBs_t *appCallbacks );
  152. /**
  153. * @brief Set a GGS Parameter value. Use this function to change
  154. * the default GGS parameter values.
  155. *
  156. * @param value - new GGS param value
  157. *
  158. * @return void
  159. */
  160. extern void GGS_SetParamValue( uint16 value );
  161. /**
  162. * @brief Get a GGS Parameter value.
  163. *
  164. * @param none
  165. *
  166. * @return GGS Parameter value
  167. */
  168. extern uint16 GGS_GetParamValue( void );
  169. /*********************************************************************
  170. * TASK FUNCTIONS - Don't call these. These are system functions.
  171. */
  172. /*********************************************************************
  173. *********************************************************************/
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177. #endif /* GAPGATTSERVER_H */