gattservapp.h 23 KB

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