gattservapp.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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. @headerfile: gattservapp.h
  30. $Date:
  31. $Revision:
  32. @mainpage BLE GATT Server Application API
  33. Description: This file contains the GATT Server Application (GATTServApp)
  34. definitions and prototypes.<BR><BR>
  35. **************************************************************************************************/
  36. #ifndef GATTSERVAPP_H
  37. #define GATTSERVAPP_H
  38. #ifdef __cplusplus
  39. extern "C"
  40. {
  41. #endif
  42. /*********************************************************************
  43. * INCLUDES
  44. */
  45. #include "bcomdef.h"
  46. #include "OSAL.h"
  47. /*********************************************************************
  48. * CONSTANTS
  49. */
  50. /** @defgroup GATT_SERV_MSG_EVENT_DEFINES GATT Server Message IDs
  51. * @{
  52. */
  53. #define GATT_CLIENT_CHAR_CFG_UPDATED_EVENT 0x00 //!< Sent when a Client Characteristic Configuration is updated. This event is sent as an OSAL message defined as gattCharCfgUpdatedEvent_t.
  54. /** @} End GATT_SERV_MSG_EVENT_DEFINES */
  55. /** @defgroup GATT_PROP_BITMAPS_DEFINES GATT Characteristic Properties Bit Fields
  56. * @{
  57. */
  58. #define GATT_PROP_BCAST 0x01 //!< Permits broadcasts of the Characteristic Value
  59. #define GATT_PROP_READ 0x02 //!< Permits reads of the Characteristic Value
  60. #define GATT_PROP_WRITE_NO_RSP 0x04 //!< Permits writes of the Characteristic Value without response
  61. #define GATT_PROP_WRITE 0x08 //!< Permits writes of the Characteristic Value with response
  62. #define GATT_PROP_NOTIFY 0x10 //!< Permits notifications of a Characteristic Value without acknowledgement
  63. #define GATT_PROP_INDICATE 0x20 //!< Permits indications of a Characteristic Value with acknowledgement
  64. #define GATT_PROP_AUTHEN 0x40 //!< Permits signed writes to the Characteristic Value
  65. #define GATT_PROP_EXTENDED 0x80 //!< Additional characteristic properties are defined in the Characteristic Extended Properties Descriptor
  66. /** @} End GATT_PROP_BITMAPS_DEFINES */
  67. /** @defgroup GATT_EXT_PROP_BITMAPS_DEFINES GATT Characteristic Extended Properties Bit Fields
  68. * @{
  69. */
  70. #define GATT_EXT_PROP_RELIABLE_WRITE 0x0001 //!< Permits reliable writes of the Characteristic Value
  71. #define GATT_EXT_PROP_WRITABLE_AUX 0x0002 //!< Permits writes to the characteristic descriptor
  72. /** @} End GATT_EXT_PROP_BITMAPS_DEFINES */
  73. /** @defgroup GATT_CLIENT_CFG_BITMAPS_DEFINES GATT Client Characteristic Configuration Bit Fields
  74. * @{
  75. */
  76. #define GATT_CLIENT_CFG_NOTIFY 0x0001 //!< The Characteristic Value shall be notified
  77. #define GATT_CLIENT_CFG_INDICATE 0x0002 //!< The Characteristic Value shall be indicated
  78. /** @} End GATT_CLIENT_CFG_BITMAPS_DEFINES */
  79. /** @defgroup GATT_SERV_CFG_BITMAPS_DEFINES GATT Server Characteristic Configuration Bit Fields
  80. * @{
  81. */
  82. #define GATT_SERV_CFG_BCAST 0x0001 //!< The Characteristic Value shall be broadcast when the server is in the broadcast procedure if advertising data resources are available
  83. /** @} End GATT_SERV_CFG_BITMAPS_DEFINES */
  84. #define GATT_CFG_NO_OPERATION 0x0000 // No operation
  85. /** @defgroup GATT_FORMAT_TYPES_DEFINES GATT Characteristic Format Types
  86. * @{
  87. */
  88. #define GATT_FORMAT_BOOL 0x01 //!< Unsigned 1 bit; 0 = false, 1 = true
  89. #define GATT_FORMAT_2BIT 0x02 //!< Unsigned 2 bit integer
  90. #define GATT_FORMAT_NIBBLE 0x03 //!< Unsigned 4 bit integer
  91. #define GATT_FORMAT_UINT8 0x04 //!< Unsigned 8 bit integer
  92. #define GATT_FORMAT_UINT12 0x05 //!< Unsigned 12 bit integer
  93. #define GATT_FORMAT_UINT16 0x06 //!< Unsigned 16 bit integer
  94. #define GATT_FORMAT_UINT24 0x07 //!< Unsigned 24 bit integer
  95. #define GATT_FORMAT_UINT32 0x08 //!< Unsigned 32 bit integer
  96. #define GATT_FORMAT_UINT48 0x09 //!< Unsigned 48 bit integer
  97. #define GATT_FORMAT_UINT64 0x0a //!< Unsigned 64 bit integer
  98. #define GATT_FORMAT_UINT128 0x0b //!< Unsigned 128 bit integer
  99. #define GATT_FORMAT_SINT8 0x0c //!< Signed 8 bit integer
  100. #define GATT_FORMAT_SINT12 0x0d //!< Signed 12 bit integer
  101. #define GATT_FORMAT_SINT16 0x0e //!< Signed 16 bit integer
  102. #define GATT_FORMAT_SINT24 0x0f //!< Signed 24 bit integer
  103. #define GATT_FORMAT_SINT32 0x10 //!< Signed 32 bit integer
  104. #define GATT_FORMAT_SINT48 0x11 //!< Signed 48 bit integer
  105. #define GATT_FORMAT_SINT64 0x12 //!< Signed 64 bit integer
  106. #define GATT_FORMAT_SINT128 0x13 //!< Signed 128 bit integer
  107. #define GATT_FORMAT_FLOAT32 0x14 //!< IEEE-754 32 bit floating point
  108. #define GATT_FORMAT_FLOAT64 0x15 //!< IEEE-754 64 bit floating point
  109. #define GATT_FORMAT_SFLOAT 0x16 //!< IEEE-11073 16 bit SFLOAT
  110. #define GATT_FORMAT_FLOAT 0x17 //!< IEEE-11073 32 bit FLOAT
  111. #define GATT_FORMAT_DUINT16 0x18 //!< IEEE-20601 format
  112. #define GATT_FORMAT_UTF8S 0x19 //!< UTF-8 string
  113. #define GATT_FORMAT_UTF16S 0x1a //!< UTF-16 string
  114. #define GATT_FORMAT_STRUCT 0x1b //!< Opaque structure
  115. /** @} End GATT_FORMAT_TYPES_DEFINES */
  116. /** @defgroup GATT_NS_TYPES_DEFINES GATT Namespace Types
  117. * @{
  118. */
  119. #define GATT_NS_NONE 0x00 //!< No namespace
  120. #define GATT_NS_BT_SIG 0x01 //!< Bluetooth SIG namespace
  121. /** @} End GATT_NS_TYPES_DEFINES */
  122. /** @defgroup GATT_NS_BT_DESC_DEFINES GATT Bluetooth Namespace Descriptions
  123. * @{
  124. */
  125. #define GATT_NS_BT_DESC_UNKNOWN 0x0000 //!< The description is unknown
  126. /** @} End GATT_NS_BT_DESC_DEFINES */
  127. // All profile services bit fields
  128. #define GATT_ALL_SERVICES 0xFFFFFFFF
  129. // GATT Services bit fields
  130. #define GATT_SERVICE 0x00000001
  131. #if defined ( TESTMODES )
  132. // GATT Test Modes
  133. #define GATT_TESTMODE_OFF 0 // Test mode off
  134. #define GATT_TESTMODE_NO_RSP 1 // Ignore incoming request
  135. #define GATT_TESTMODE_PREPARE_WRITE 2 // Forward Prepare Write Request right away
  136. #define GATT_TESTMODE_MAX_MTU_SIZE 3 // Use Max ATT MTU size with Exchange MTU Rsp
  137. #define GATT_TESTMODE_CORRUPT_PW_DATA 4 // Corrupt incoming Prepare Write Request data
  138. #endif
  139. // GATT Server Parameters
  140. #define GATT_PARAM_NUM_PREPARE_WRITES 0 // RW uint8
  141. /*********************************************************************
  142. * VARIABLES
  143. */
  144. /*********************************************************************
  145. * MACROS
  146. */
  147. // The number of attribute records in a given attribute table
  148. #define GATT_NUM_ATTRS( attrs ) ( sizeof( attrs ) / sizeof( gattAttribute_t ) )
  149. // The handle of a service is the handle of the first attribute
  150. #define GATT_SERVICE_HANDLE( attrs ) ( (attrs)[0].handle )
  151. // The handle of the first included service (i = 1) is the value of the second attribute
  152. #define GATT_INCLUDED_HANDLE( attrs, i ) ( *((uint16 *)((attrs)[(i)].pValue)) )
  153. /*********************************************************************
  154. * TYPEDEFS
  155. */
  156. /**
  157. * @defgroup GATT_SERV_APP_CB_API GATT Server App Callback API Functions
  158. *
  159. * @{
  160. */
  161. /**
  162. * @brief Callback function prototype to read an attribute value.
  163. *
  164. * @param connHandle - connection request was received on
  165. * @param pAttr - pointer to attribute
  166. * @param pValue - pointer to data to be read (to be returned)
  167. * @param pLen - length of data (to be returned)
  168. * @param offset - offset of the first octet to be read
  169. * @param maxLen - maximum length of data to be read
  170. *
  171. * @return SUCCESS: Read was successfully.<BR>
  172. * Error, otherwise: ref ATT_ERR_CODE_DEFINES.<BR>
  173. */
  174. typedef bStatus_t (*pfnGATTReadAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
  175. uint8 *pValue, uint16 *pLen, uint16 offset,
  176. uint8 maxLen );
  177. /**
  178. * @brief Callback function prototype to write an attribute value.
  179. *
  180. * @param connHandle - connection request was received on
  181. * @param pAttr - pointer to attribute
  182. * @param pValue - pointer to data to be written
  183. * @param pLen - length of data
  184. * @param offset - offset of the first octet to be written
  185. *
  186. * @return SUCCESS: Write was successfully.<BR>
  187. * Error, otherwise: ref ATT_ERR_CODE_DEFINES.<BR>
  188. */
  189. typedef bStatus_t (*pfnGATTWriteAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
  190. uint8 *pValue, uint16 len, uint16 offset );
  191. /**
  192. * @brief Callback function prototype to authorize a Read or Write operation
  193. * on a given attribute.
  194. *
  195. * @param connHandle - connection request was received on
  196. * @param pAttr - pointer to attribute
  197. * @param opcode - request opcode (ATT_READ_REQ or ATT_WRITE_REQ)
  198. *
  199. * @return SUCCESS: Operation authorized.<BR>
  200. * ATT_ERR_INSUFFICIENT_AUTHOR: Authorization required.<BR>
  201. */
  202. typedef bStatus_t (*pfnGATTAuthorizeAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
  203. uint8 opcode );
  204. /**
  205. * @}
  206. */
  207. /**
  208. * GATT Structure for Characteristic Presentation Format Value.
  209. */
  210. typedef struct
  211. {
  212. uint8 format; //!< Format of the value of this characteristic
  213. int8 exponent; //!< A sign integer which represents the exponent of an integer
  214. uint16 unit; //!< Unit of this attribute as defined in the data dictionary
  215. uint8 nameSpace; //!< Name space of the description
  216. uint16 desc; //!< Description of this attribute as defined in a higher layer profile
  217. } gattCharFormat_t;
  218. /**
  219. * GATT Structure for Client Characteristic Configuration.
  220. */
  221. typedef struct
  222. {
  223. uint16 connHandle; //!< Client connection handle
  224. uint8 value; //!< Characteristic configuration value for this client
  225. } gattCharCfg_t;
  226. /**
  227. * GATT Structure for service callback functions - must be setup by the application
  228. * and used when GATTServApp_RegisterService() is called.
  229. */
  230. typedef struct
  231. {
  232. pfnGATTReadAttrCB_t pfnReadAttrCB; //!< Read callback function pointer
  233. pfnGATTWriteAttrCB_t pfnWriteAttrCB; //!< Write callback function pointer
  234. pfnGATTAuthorizeAttrCB_t pfnAuthorizeAttrCB; //!< Authorization callback function pointer
  235. } gattServiceCBs_t;
  236. /**
  237. * GATT Server App event header format.
  238. */
  239. typedef struct
  240. {
  241. osal_event_hdr_t hdr; //!< GATT_SERV_MSG_EVENT and status
  242. uint16 connHandle; //!< Connection message was received on
  243. uint8 method; //!< GATT type of command. Ref: @ref GATT_SERV_MSG_EVENT_DEFINES
  244. } gattEventHdr_t;
  245. /**
  246. * GATT_CLIENT_CHAR_CFG_UPDATED_EVENT message format. This message is sent to
  247. * the app when a Client Characteristic Configuration is updated.
  248. */
  249. typedef struct
  250. {
  251. osal_event_hdr_t hdr; //!< GATT_SERV_MSG_EVENT and status
  252. uint16 connHandle; //!< Connection message was received on
  253. uint8 method; //!< GATT_CLIENT_CHAR_CFG_UPDATED_EVENT
  254. uint16 attrHandle; //!< attribute handle
  255. uint16 value; //!< attribute new value
  256. } gattClientCharCfgUpdatedEvent_t;
  257. typedef void (*gattServMsgCB_t)( gattMsgEvent_t*pMsg);
  258. /*********************************************************************
  259. * VARIABLES
  260. */
  261. /*********************************************************************
  262. * API FUNCTIONS
  263. */
  264. /**
  265. * @defgroup GATT_SERV_APP_API GATT Server App API Functions
  266. *
  267. * @{
  268. */
  269. /**
  270. * @brief Register your task ID to receive event messages
  271. * from the GATT Server Application.
  272. *
  273. * @param taskID - Default task ID to send events.
  274. *
  275. * @return none
  276. */
  277. extern void GATTServApp_RegisterForMsg( uint8 taskID );
  278. /**
  279. * @brief Register a service's attribute list and callback functions with
  280. * the GATT Server Application.
  281. *
  282. * @param pAttrs - Array of attribute records to be registered
  283. * @param numAttrs - Number of attributes in array
  284. * @param pServiceCBs - Service callback function pointers
  285. *
  286. * @return SUCCESS: Service registered successfully.<BR>
  287. * INVALIDPARAMETER: Invalid service field.<BR>
  288. * FAILURE: Not enough attribute handles available.<BR>
  289. * bleMemAllocError: Memory allocation error occurred.<BR>
  290. */
  291. extern bStatus_t GATTServApp_RegisterService( gattAttribute_t *pAttrs, uint16 numAttrs,
  292. CONST gattServiceCBs_t *pServiceCBs );
  293. /**
  294. * @brief Deregister a service's attribute list and callback functions from
  295. * the GATT Server Application.
  296. *
  297. * NOTE: It's the caller's responsibility to free the service attribute
  298. * list returned from this API.
  299. *
  300. * @param handle - handle of service to be deregistered
  301. * @param p2pAttrs - pointer to array of attribute records (to be returned)
  302. *
  303. * @return SUCCESS: Service deregistered successfully.
  304. * FAILURE: Service not found.
  305. */
  306. bStatus_t GATTServApp_DeregisterService( uint16 handle, gattAttribute_t **p2pAttrs );
  307. /**
  308. * @brief Find the attribute record within a service attribute
  309. * table for a given attribute value pointer.
  310. *
  311. * @param pAttrTbl - pointer to attribute table
  312. * @param numAttrs - number of attributes in attribute table
  313. * @param pValue - pointer to attribute value
  314. *
  315. * @return Pointer to attribute record. NULL, if not found.
  316. */
  317. extern gattAttribute_t *GATTServApp_FindAttr( gattAttribute_t *pAttrTbl,
  318. uint16 numAttrs, uint8 *pValue );
  319. /**
  320. * @brief Add function for the GATT Service.
  321. *
  322. * @param services - services to add. This is a bit map and can
  323. * contain more than one service.
  324. *
  325. * @return SUCCESS: Service added successfully.<BR>
  326. * INVALIDPARAMETER: Invalid service field.<BR>
  327. * FAILURE: Not enough attribute handles available.<BR>
  328. * bleMemAllocError: Memory allocation error occurred.<BR>
  329. */
  330. extern bStatus_t GATTServApp_AddService( uint32 services );
  331. /**
  332. * @brief Delete function for the GATT Service.
  333. *
  334. * @param services - services to delete. This is a bit map and can
  335. * contain more than one service.
  336. *
  337. * @return SUCCESS: Service deleted successfully.<BR>
  338. * FAILURE: Service not found.<BR>
  339. */
  340. extern bStatus_t GATTServApp_DelService( uint32 services );
  341. /**
  342. * @brief Set a GATT Server parameter.
  343. *
  344. * @param param - Profile parameter ID
  345. * @param len - length of data to right
  346. * @param pValue - pointer to data to write. This is dependent on the
  347. * parameter ID and WILL be cast to the appropriate
  348. * data type (example: data type of uint16 will be cast
  349. * to uint16 pointer).
  350. *
  351. * @return SUCCESS: Parameter set successful
  352. * FAILURE: Parameter in use
  353. * INVALIDPARAMETER: Invalid parameter
  354. * bleInvalidRange: Invalid value
  355. * bleMemAllocError: Memory allocation failed
  356. */
  357. extern bStatus_t GATTServApp_SetParameter( uint8 param, uint8 len, void *pValue );
  358. /**
  359. * @brief Get a GATT Server parameter.
  360. *
  361. * @param param - Profile parameter ID
  362. * @param pValue - pointer to data to put. This is dependent on the
  363. * parameter ID and WILL be cast to the appropriate
  364. * data type (example: data type of uint16 will be
  365. * cast to uint16 pointer).
  366. *
  367. * @return SUCCESS: Parameter get successful
  368. * INVALIDPARAMETER: Invalid parameter
  369. */
  370. extern bStatus_t GATTServApp_GetParameter( uint8 param, void *pValue );
  371. /**
  372. * @brief Update the Client Characteristic Configuration for a given
  373. * Client.
  374. *
  375. * Note: This API should only be called from the Bond Manager.
  376. *
  377. * @param connHandle - connection handle.
  378. * @param attrHandle - attribute handle.
  379. * @param value - characteristic configuration value.
  380. *
  381. * @return SUCCESS: Parameter get successful
  382. * INVALIDPARAMETER: Invalid parameter
  383. */
  384. extern bStatus_t GATTServApp_UpdateCharCfg( uint16 connHandle, uint16 attrHandle, uint16 value );
  385. /**
  386. * @brief Initialize the client characteristic configuration table.
  387. *
  388. * Note: Each client has its own instantiation of the Client
  389. * Characteristic Configuration. Reads/Writes of the Client
  390. * Characteristic Configuration only only affect the
  391. * configuration of that client.
  392. *
  393. * @param connHandle - connection handle (0xFFFF for all connections).
  394. * @param charCfgTbl - client characteristic configuration table.
  395. *
  396. * @return none
  397. */
  398. extern void GATTServApp_InitCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl );
  399. /**
  400. * @brief Read the client characteristic configuration for a given
  401. * client.
  402. *
  403. * Note: Each client has its own instantiation of the Client
  404. * Characteristic Configuration. Reads of the Client
  405. * Characteristic Configuration only shows the configuration
  406. * for that client.
  407. *
  408. * @param connHandle - connection handle.
  409. * @param charCfgTbl - client characteristic configuration table.
  410. *
  411. * @return attribute value
  412. */
  413. extern uint16 GATTServApp_ReadCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl );
  414. /**
  415. * @brief Write the client characteristic configuration for a given
  416. * client.
  417. *
  418. * Note: Each client has its own instantiation of the Client
  419. * Characteristic Configuration. Writes of the Client
  420. * Characteristic Configuration only only affect the
  421. * configuration of that client.
  422. *
  423. * @param connHandle - connection handle.
  424. * @param charCfgTbl - client characteristic configuration table.
  425. * @param value - attribute new value.
  426. *
  427. * @return Success or Failure
  428. */
  429. extern uint8 GATTServApp_WriteCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl, uint16 value );
  430. /**
  431. * @brief Process the client characteristic configuration
  432. * write request for a given client.
  433. *
  434. * @param connHandle - connection message was received on.
  435. * @param pAttr - pointer to attribute.
  436. * @param pValue - pointer to data to be written.
  437. * @param len - length of data.
  438. * @param offset - offset of the first octet to be written.
  439. * @param validCfg - valid configuration.
  440. *
  441. * @return Success or Failure
  442. */
  443. extern bStatus_t GATTServApp_ProcessCCCWriteReq( uint16 connHandle, gattAttribute_t *pAttr,
  444. uint8 *pValue, uint8 len, uint16 offset,
  445. uint16 validCfg );
  446. /**
  447. * @brief Process Client Charateristic Configuration change.
  448. *
  449. * @param charCfgTbl - characteristic configuration table.
  450. * @param pValue - pointer to attribute value.
  451. * @param authenticated - whether an authenticated link is required.
  452. * @param attrTbl - attribute table.
  453. * @param numAttrs - number of attributes in attribute table.
  454. * @param taskId - task to be notified of confirmation.
  455. *
  456. * @return Success or Failure
  457. */
  458. extern bStatus_t GATTServApp_ProcessCharCfg( gattCharCfg_t *charCfgTbl, uint8 *pValue,
  459. uint8 authenticated, gattAttribute_t *attrTbl,
  460. uint16 numAttrs, uint8 taskId );
  461. /**
  462. * @brief Build and send the GATT_CLIENT_CHAR_CFG_UPDATED_EVENT to
  463. * the application.
  464. *
  465. * @param connHandle - connection handle
  466. * @param attrHandle - attribute handle
  467. * @param value - attribute new value
  468. *
  469. * @return none
  470. */
  471. extern void GATTServApp_SendCCCUpdatedEvent( uint16 connHandle, uint16 attrHandle, uint16 value );
  472. /**
  473. * @brief Send out a Service Changed Indication.
  474. *
  475. * @param connHandle - connection to use
  476. * @param taskId - task to be notified of confirmation
  477. *
  478. * @return SUCCESS: Indication was sent successfully.<BR>
  479. * FAILURE: Service Changed attribute not found.<BR>
  480. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  481. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  482. * bleNotConnected: Connection is down.<BR>
  483. * blePending: A confirmation is pending with this client.<BR>
  484. */
  485. extern bStatus_t GATTServApp_SendServiceChangedInd( uint16 connHandle, uint8 taskId );
  486. /**
  487. * @brief Read an attribute. If the format of the attribute value
  488. * is unknown to GATT Server, use the callback function
  489. * provided by the Service.
  490. *
  491. * @param connHandle - connection message was received on
  492. * @param pAttr - pointer to attribute
  493. * @param service - handle of owner service
  494. * @param pValue - pointer to data to be read
  495. * @param pLen - length of data to be read
  496. * @param offset - offset of the first octet to be read
  497. * @param maxLen - maximum length of data to be read
  498. *
  499. * @return Success or Failure
  500. */
  501. extern uint8 GATTServApp_ReadAttr( uint16 connHandle, gattAttribute_t *pAttr,
  502. uint16 service, uint8 *pValue, uint16 *pLen,
  503. uint16 offset, uint8 maxLen );
  504. /**
  505. * @brief Write attribute data
  506. *
  507. * @param connHandle - connection message was received on
  508. * @param handle - attribute handle
  509. * @param pValue - pointer to data to be written
  510. * @param len - length of data
  511. * @param offset - offset of the first octet to be written
  512. *
  513. * @return Success or Failure
  514. */
  515. extern uint8 GATTServApp_WriteAttr( uint16 connHandle, uint16 handle,
  516. uint8 *pValue, uint16 len, uint16 offset );
  517. /**
  518. * @}
  519. */
  520. /**
  521. * @brief Set a GATT Server Application Parameter value. Use this
  522. * function to change the default GATT parameter values.
  523. *
  524. * @param value - new param value
  525. *
  526. * @return void
  527. */
  528. extern void GATTServApp_SetParamValue( uint16 value );
  529. /**
  530. * @brief Get a GATT Server Application Parameter value.
  531. *
  532. * @param none
  533. *
  534. * @return GATT Parameter value
  535. */
  536. extern uint16 GATTServApp_GetParamValue( void );
  537. /*-------------------------------------------------------------------
  538. * TASK API - These functions must only be called by OSAL.
  539. */
  540. /**
  541. * @internal
  542. *
  543. * @brief Initialize the GATT Server Test Application.
  544. *
  545. * @param taskId - Task identifier for the desired task
  546. *
  547. * @return void
  548. *
  549. */
  550. extern void GATTServApp_Init( uint8 taskId );
  551. /**
  552. * @internal
  553. *
  554. * @brief GATT Server Application Task event processor. This function
  555. * is called to process all events for the task. Events include
  556. * timers, messages and any other user defined events.
  557. *
  558. * @param task_id - The OSAL assigned task ID.
  559. * @param events - events to process. This is a bit map and can
  560. * contain more than one event.
  561. *
  562. * @return none
  563. */
  564. extern uint16 GATTServApp_ProcessEvent( uint8 taskId, uint16 events );
  565. bStatus_t gattServApp_RegisterCB(gattServMsgCB_t cb);
  566. /*********************************************************************
  567. *********************************************************************/
  568. #ifdef __cplusplus
  569. }
  570. #endif
  571. #endif /* GATTSERVAPP_H */