gatt.h 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  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: gatt.h
  30. $Date:
  31. $Revision:
  32. @mainpage BLE GATT API
  33. Description: This file contains Generic Attribute Profile (GATT)
  34. definitions and prototypes.<BR><BR>
  35. */
  36. #ifndef GATT_H
  37. #define GATT_H
  38. #ifdef __cplusplus
  39. extern "C"
  40. {
  41. #endif
  42. /*********************************************************************
  43. * INCLUDES
  44. */
  45. #include "bcomdef.h"
  46. #include "OSAL.h"
  47. #include "att.h"
  48. /*********************************************************************
  49. * CONSTANTS
  50. */
  51. /** @defgroup GATT_PERMIT_BITMAPS_DEFINES GATT Attribute Access Permissions Bit Fields
  52. * @{
  53. */
  54. #define GATT_PERMIT_READ 0x01 //!< Attribute is Readable
  55. #define GATT_PERMIT_WRITE 0x02 //!< Attribute is Writable
  56. #define GATT_PERMIT_AUTHEN_READ 0x04 //!< Read requires Authentication
  57. #define GATT_PERMIT_AUTHEN_WRITE 0x08 //!< Write requires Authentication
  58. #define GATT_PERMIT_AUTHOR_READ 0x10 //!< Read requires Authorization
  59. #define GATT_PERMIT_AUTHOR_WRITE 0x20 //!< Write requires Authorization
  60. #define GATT_PERMIT_ENCRYPT_READ 0x40 //!< Read requires Encryption
  61. #define GATT_PERMIT_ENCRYPT_WRITE 0x80 //!< Write requires Encryption
  62. /** @} End GATT_PERMIT_BITMAPS_DEFINES */
  63. /** @defgroup GATT_NUM_PREPARE_WRITES_DEFINES GATT Maximum Number of Prepare Writes
  64. * @{
  65. */
  66. #define PREPARE_QUEUE_STATIC
  67. #if !defined( GATT_MAX_NUM_PREPARE_WRITES )
  68. #define GATT_MAX_NUM_PREPARE_WRITES 1 //!< GATT Maximum number of attributes that Attribute Server can prepare for writing per Attribute Client
  69. #endif
  70. /** @} End GATT_NUM_PREPARE_WRITES_DEFINES */
  71. /** @defgroup GATT_ENCRYPT_KEY_SIZE_DEFINES GATT Encryption Key Size
  72. * @{
  73. */
  74. #define GATT_ENCRYPT_KEY_SIZE 16 //!< GATT Encryption Key Size used for encrypting a link
  75. /** @} End GATT_ENCRYPT_KEY_SIZE_DEFINES */
  76. /** @defgroup GATT_MAX_ATTR_SIZE_DEFINES GATT Maximum Attribute Value Length
  77. * @{
  78. */
  79. #define GATT_MAX_ATTR_SIZE 512 //!< GATT Maximum length of an attribute value
  80. /** @} End GATT_MAX_ATTR_SIZE_DEFINES */
  81. // GATT Maximum number of connections (including loopback)
  82. #define GATT_MAX_NUM_CONN ( MAX_NUM_LL_CONN + 1 )
  83. // GATT Base Method
  84. #define GATT_BASE_METHOD 0x40
  85. // Attribute handle defintions
  86. #define GATT_INVALID_HANDLE 0x0000 // Invalid attribute handle
  87. #define GATT_MIN_HANDLE 0x0001 // Minimum attribute handle
  88. #define GATT_MAX_HANDLE 0xFFFF // Maximum attribute handle
  89. /*********************************************************************
  90. * VARIABLES
  91. */
  92. /*********************************************************************
  93. * MACROS
  94. */
  95. // Attribute Access Permissions
  96. #define gattPermitRead( a ) ( (a) & GATT_PERMIT_READ )
  97. #define gattPermitWrite( a ) ( (a) & GATT_PERMIT_WRITE )
  98. #define gattPermitAuthenRead( a ) ( (a) & GATT_PERMIT_AUTHEN_READ )
  99. #define gattPermitAuthenWrite( a ) ( (a) & GATT_PERMIT_AUTHEN_WRITE )
  100. #define gattPermitAuthorRead( a ) ( (a) & GATT_PERMIT_AUTHOR_READ )
  101. #define gattPermitAuthorWrite( a ) ( (a) & GATT_PERMIT_AUTHOR_WRITE )
  102. #define gattPermitEncryptRead( a ) ( (a) & GATT_PERMIT_ENCRYPT_READ )
  103. #define gattPermitEncryptWrite( a ) ( (a) & GATT_PERMIT_ENCRYPT_WRITE )
  104. // Check for different UUID types
  105. #define gattPrimaryServiceType( t ) ( ATT_CompareUUID( primaryServiceUUID, ATT_BT_UUID_SIZE, \
  106. (t).uuid, (t).len ) )
  107. #define gattSecondaryServiceType( t ) ( ATT_CompareUUID( secondaryServiceUUID, ATT_BT_UUID_SIZE, \
  108. (t).uuid, (t).len ) )
  109. #define gattCharacterType( t ) ( ATT_CompareUUID( characterUUID, ATT_BT_UUID_SIZE, \
  110. (t).uuid, (t).len ) )
  111. #define gattIncludeType( t ) ( ATT_CompareUUID( includeUUID, ATT_BT_UUID_SIZE, \
  112. (t).uuid, (t).len ) )
  113. #define gattServiceType( t ) ( gattPrimaryServiceType( (t) ) || \
  114. gattSecondaryServiceType( (t) ) )
  115. /*********************************************************************
  116. * TYPEDEFS
  117. */
  118. /**
  119. * GATT Read By Type Request format.
  120. */
  121. typedef struct
  122. {
  123. uint8 discCharsByUUID; //!< Whether this is a GATT Discover Characteristics by UUID sub-procedure
  124. attReadByTypeReq_t req; //!< Read By Type Request
  125. } gattReadByTypeReq_t;
  126. /**
  127. * GATT Prepare Write Request format.
  128. */
  129. typedef struct
  130. {
  131. uint16 handle; //!< Handle of the attribute to be written (must be first field)
  132. uint16 offset; //!< Offset of the first octet to be written
  133. uint8 len; //!< Length of value
  134. uint8 *pValue; //!< Part of the value of the attribute to be written (must be allocated)
  135. } gattPrepareWriteReq_t;
  136. /**
  137. * GATT Write Long Request format. Do not change the order of the members.
  138. */
  139. typedef struct
  140. {
  141. uint8 reliable; //!< Whether reliable writes requested (always FALSE for Write Long)
  142. gattPrepareWriteReq_t req; //!< GATT Prepare Write Request
  143. uint16 lastOffset; //!< Offset of last Prepare Write Request sent
  144. } gattWriteLongReq_t;
  145. /**
  146. * GATT Reliable Writes Request format. Do not change the order of the members.
  147. */
  148. typedef struct
  149. {
  150. uint8 reliable; //!< Whether reliable writes requested (always TRUE for Reliable Writes)
  151. attPrepareWriteReq_t *pReqs; //!< Arrary of Prepare Write Requests (must be allocated)
  152. uint8 numReqs; //!< Number of Prepare Write Requests
  153. uint8 index; //!< Index of last Prepare Write Request sent
  154. uint8 flags; //!< 0x00 - cancel all prepared writes.
  155. //!< 0x01 - immediately write all pending prepared values.
  156. } gattReliableWritesReq_t;
  157. /**
  158. * GATT Message format. It's a union of all attribute protocol/profile messages
  159. * used between the attribute protocol/profile and upper layer application.
  160. */
  161. typedef union
  162. {
  163. // Request messages
  164. attExchangeMTUReq_t exchangeMTUReq; //!< ATT Exchange MTU Request
  165. attFindInfoReq_t findInfoReq; //!< ATT Find Information Request
  166. attFindByTypeValueReq_t findByTypeValueReq; //!< ATT Find By Type Vaue Request
  167. attReadByTypeReq_t readByTypeReq; //!< ATT Read By Type Request
  168. attReadReq_t readReq; //!< ATT Read Request
  169. attReadBlobReq_t readBlobReq; //!< ATT Read Blob Request
  170. attReadMultiReq_t readMultiReq; //!< ATT Read Multiple Request
  171. attReadByGrpTypeReq_t readByGrpTypeReq; //!< ATT Read By Group Type Request
  172. attWriteReq_t writeReq; //!< ATT Write Request
  173. attPrepareWriteReq_t prepareWriteReq; //!< ATT Prepare Write Request
  174. attExecuteWriteReq_t executeWriteReq; //!< ATT Execute Write Request
  175. gattReadByTypeReq_t gattReadByTypeReq; //!< GATT Read By Type Request
  176. gattWriteLongReq_t gattWriteLongReq; //!< GATT Long Write Request
  177. gattReliableWritesReq_t gattReliableWritesReq; //!< GATT Reliable Writes Request
  178. // Response messages
  179. attErrorRsp_t errorRsp; //!< ATT Error Response
  180. attExchangeMTURsp_t exchangeMTURsp; //!< ATT Exchange MTU Response
  181. attFindInfoRsp_t findInfoRsp; //!< ATT Find Information Response
  182. attFindByTypeValueRsp_t findByTypeValueRsp; //!< ATT Find By Type Vaue Response
  183. attReadByTypeRsp_t readByTypeRsp; //!< ATT Read By Type Response
  184. attReadRsp_t readRsp; //!< ATT Read Response
  185. attReadBlobRsp_t readBlobRsp; //!< ATT Read Blob Response
  186. attReadMultiRsp_t readMultiRsp; //!< ATT Read Multiple Response
  187. attReadByGrpTypeRsp_t readByGrpTypeRsp; //!< ATT Read By Group Type Response
  188. attPrepareWriteRsp_t prepareWriteRsp; //!< ATT Prepare Write Response
  189. // Indication and Notification messages
  190. attHandleValueNoti_t handleValueNoti; //!< ATT Handle Value Notification
  191. attHandleValueInd_t handleValueInd; //!< ATT Handle Value Indication
  192. } gattMsg_t;
  193. /**
  194. * GATT OSAL GATT_MSG_EVENT message format. This message is used to forward an
  195. * incoming attribute protocol/profile message up to upper layer application.
  196. */
  197. typedef struct
  198. {
  199. osal_event_hdr_t hdr; //!< GATT_MSG_EVENT and status
  200. uint16 connHandle; //!< Connection message was received on
  201. uint8 method; //!< Type of message
  202. gattMsg_t msg; //!< Attribute protocol/profile message
  203. } gattMsgEvent_t;
  204. /**
  205. * GATT Attribute Type format.
  206. */
  207. typedef struct
  208. {
  209. uint8 len; //!< Length of UUID
  210. const uint8 *uuid; //!< Pointer to UUID
  211. } gattAttrType_t;
  212. /**
  213. * GATT Attribute format.
  214. */
  215. typedef struct attAttribute_t
  216. {
  217. gattAttrType_t type; //!< Attribute type (2 or 16 octet UUIDs)
  218. uint8 permissions; //!< Attribute permissions
  219. uint16 handle; //!< Attribute handle - assigned internally by attribute server
  220. uint8* const pValue; //!< Attribute value - encoding of the octet array is defined in
  221. //!< the applicable profile. The maximum length of an attribute
  222. //!< value shall be 512 octets.
  223. } gattAttribute_t;
  224. /**
  225. * GATT Service format.
  226. */
  227. typedef struct
  228. {
  229. uint16 numAttrs; //!< Number of attributes in attrs
  230. /** Array of attribute records.
  231. * NOTE: The list must start with a Service attribute followed by
  232. * all attributes associated with this Service attribute.
  233. */
  234. gattAttribute_t *attrs;
  235. } gattService_t;
  236. /*********************************************************************
  237. * VARIABLES
  238. */
  239. /*********************************************************************
  240. * API FUNCTIONS
  241. */
  242. /*-------------------------------------------------------------------
  243. * GATT Client Public APIs
  244. */
  245. /**
  246. * @defgroup GATT_CLIENT_API GATT Client API Functions
  247. *
  248. * @{
  249. */
  250. /**
  251. * @brief Initialize the Generic Attribute Profile Client.
  252. *
  253. * @return SUCCESS
  254. */
  255. extern bStatus_t GATT_InitClient( void );
  256. /**
  257. * @brief Register to receive incoming ATT Indications or Notifications
  258. * of attribute values.
  259. *
  260. * @param taskId – task to forward indications or notifications to
  261. *
  262. * @return void
  263. */
  264. extern void GATT_RegisterForInd( uint8 taskId );
  265. /**
  266. * @brief The Prepare Write Request is used to request the server to
  267. * prepare to write the value of an attribute.
  268. *
  269. * Note: This function is needed only for GATT testing.
  270. *
  271. * @param connHandle - connection to use
  272. * @param pReq - pointer to request to be sent
  273. * @param taskId - task to be notified of response
  274. *
  275. * @return SUCCESS: Request was sent successfully.<BR>
  276. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  277. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  278. * bleNotConnected: Connection is down.<BR>
  279. * blePending: A response is pending with this server.<BR>
  280. * bleMemAllocError: Memory allocation error occurred.<BR>
  281. * bleTimeout: Previous transaction timed out.<BR>
  282. */
  283. extern bStatus_t GATT_PrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq, uint8 taskId );
  284. /**
  285. * @brief The Execute Write Request is used to request the server to
  286. * write or cancel the write of all the prepared values currently
  287. * held in the prepare queue from this client.
  288. *
  289. * Note: This function is needed only for GATT testing.
  290. *
  291. * @param connHandle - connection to use
  292. * @param pReq - pointer to request to be sent
  293. * @param taskId - task to be notified of response
  294. *
  295. * @return SUCCESS: Request was sent successfully.<BR>
  296. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  297. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  298. * bleNotConnected: Connection is down.<BR>
  299. * blePending: A response is pending with this server.<BR>
  300. * bleMemAllocError: Memory allocation error occurred.<BR>
  301. * bleTimeout: Previous transaction timed out.<BR>
  302. */
  303. extern bStatus_t GATT_ExecuteWriteReq( uint16 connHandle, attExecuteWriteReq_t *pReq, uint8 taskId );
  304. /**
  305. * @}
  306. */
  307. /*-------------------------------------------------------------------
  308. * GATT Server Public APIs
  309. */
  310. /**
  311. * @defgroup GATT_SERVER_API GATT Server API Functions
  312. *
  313. * @{
  314. */
  315. /**
  316. * @brief Initialize the Generic Attribute Profile Server.
  317. *
  318. * @return SUCCESS
  319. */
  320. extern bStatus_t GATT_InitServer( void );
  321. /**
  322. * @brief Register a service attribute list with the GATT Server. A service
  323. * is composed of characteristics or references to other services.
  324. * Each characteristic contains a value and may contain optional
  325. * information about the value. There are two types of services:
  326. * primary service and secondary service.
  327. *
  328. * A service definition begins with a service declaration and ends
  329. * before the next service declaration or the maximum Attribute Handle.
  330. *
  331. * A characteristic definition begins with a characteristic declaration
  332. * and ends before the next characteristic or service declaration or
  333. * maximum Attribute Handle.
  334. *
  335. * The attribute server will only keep a pointer to the attribute
  336. * list, so the calling application will have to maintain the code
  337. * and RAM associated with this list.
  338. *
  339. * @param pService - pointer to service attribute list to be registered
  340. *
  341. * @return SUCCESS: Service registered successfully.<BR>
  342. * INVALIDPARAMETER: Invalid service field.<BR>
  343. * FAILURE: Not enough attribute handles available.<BR>
  344. * bleMemAllocError: Memory allocation error occurred.<BR>
  345. */
  346. extern bStatus_t GATT_RegisterService( gattService_t *pService );
  347. /**
  348. * @brief Deregister a service attribute list with the GATT Server.
  349. *
  350. * NOTE: It's the caller's responsibility to free the service attribute
  351. * list returned from this API.
  352. *
  353. * @param handle - handle of service to be deregistered
  354. * @param pService - pointer to deregistered service (to be returned)
  355. *
  356. * @return SUCCESS: Service deregistered successfully.<BR>
  357. * FAILURE: Service not found.<BR>
  358. */
  359. extern bStatus_t GATT_DeregisterService( uint16 handle, gattService_t *pService );
  360. /**
  361. * @brief Register to receive incoming ATT Requests.
  362. *
  363. * @param taskId – task to forward requests to
  364. *
  365. * @return void
  366. */
  367. extern void GATT_RegisterForReq( uint8 taskId );
  368. /**
  369. * @brief Verify the permissions of an attribute for reading.
  370. *
  371. * @param connHandle - connection to use
  372. * @param permissions - attribute permissions
  373. *
  374. * @return SUCCESS: Attribute can be read.<BR>
  375. * ATT_ERR_READ_NOT_PERMITTED: Attribute cannot be read.<BR>
  376. * ATT_ERR_INSUFFICIENT_AUTHEN: Attribute requires authentication.<BR>
  377. * ATT_ERR_INSUFFICIENT_KEY_SIZE: Key Size used for encrypting is insufficient.<BR>
  378. * ATT_ERR_INSUFFICIENT_ENCRYPT: Attribute requires encryption.<BR>
  379. */
  380. extern bStatus_t GATT_VerifyReadPermissions( uint16 connHandle, uint8 permissions );
  381. /**
  382. * @brief Verify the permissions of an attribute for writing.
  383. *
  384. * @param connHandle - connection to use
  385. * @param permissions - attribute permissions
  386. * @param pReq - pointer to write request
  387. *
  388. * @return SUCCESS: Attribute can be written.<BR>
  389. * ATT_ERR_READ_NOT_PERMITTED: Attribute cannot be written.<BR>
  390. * ATT_ERR_INSUFFICIENT_AUTHEN: Attribute requires authentication.<BR>
  391. * ATT_ERR_INSUFFICIENT_KEY_SIZE: Key Size used for encrypting is insufficient.<BR>
  392. * ATT_ERR_INSUFFICIENT_ENCRYPT: Attribute requires encryption.<BR>
  393. */
  394. extern bStatus_t GATT_VerifyWritePermissions( uint16 connHandle, uint8 permissions, attWriteReq_t *pReq );
  395. /**
  396. * @brief Send out a Service Changed Indication.
  397. *
  398. * @param connHandle - connection to use
  399. * @param taskId - task to be notified of confirmation
  400. *
  401. * @return SUCCESS: Indication was sent successfully.<BR>
  402. * FAILURE: Service Changed attribute not found.<BR>
  403. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  404. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  405. * bleNotConnected: Connection is down.<BR>
  406. * blePending: A confirmation is pending with this client.<BR>
  407. */
  408. extern uint8 GATT_ServiceChangedInd( uint16 connHandle, uint8 taskId );
  409. /**
  410. * @brief Find the attribute record for a given handle and UUID.
  411. *
  412. * @param startHandle - first handle to look for
  413. * @param endHandle - last handle to look for
  414. * @param pUUID - pointer to UUID to look for
  415. * @param len - length of UUID
  416. * @param pHandle - handle of owner of attribute (to be returned)
  417. *
  418. * @return Pointer to attribute record. NULL, otherwise.
  419. */
  420. extern gattAttribute_t *GATT_FindHandleUUID( uint16 startHandle, uint16 endHandle, const uint8 *pUUID,
  421. uint16 len, uint16 *pHandle );
  422. /**
  423. * @brief Find the attribute record for a given handle
  424. *
  425. * @param handle - handle to look for
  426. * @param pHandle - handle of owner of attribute (to be returned)
  427. *
  428. * @return Pointer to attribute record. NULL, otherwise.
  429. */
  430. extern gattAttribute_t *GATT_FindHandle( uint16 handle, uint16 *pHandle );
  431. /**
  432. * @brief Find the next attribute of the same type for a given attribute.
  433. *
  434. * @param pAttr - pointer to attribute to find a next for
  435. * @param endHandle - last handle to look for
  436. * @param service - handle of owner service
  437. * @param pLastHandle - handle of last attribute (to be returned)
  438. *
  439. * @return Pointer to next attribute record. NULL, otherwise.
  440. */
  441. extern gattAttribute_t *GATT_FindNextAttr( gattAttribute_t *pAttr, uint16 endHandle,
  442. uint16 service, uint16 *pLastHandle );
  443. /**
  444. * @brief Get the number of attributes for a given service
  445. *
  446. * @param handle - service handle to look for
  447. *
  448. * @return Number of attributes. 0, otherwise.
  449. */
  450. extern uint16 GATT_ServiceNumAttrs( uint16 handle );
  451. /**
  452. * @}
  453. */
  454. /*-------------------------------------------------------------------
  455. * GATT Server Sub-Procedure APIs
  456. */
  457. /**
  458. * @defgroup GATT_SERVER_SUB_PROCEDURE_API GATT Server Sub-Procedure API Functions
  459. *
  460. * @{
  461. */
  462. /**
  463. * @brief This sub-procedure is used when a server is configured to
  464. * indicate a characteristic value to a client and expects an
  465. * attribute protocol layer acknowledgement that the indication
  466. * was successfully received.
  467. *
  468. * The ATT Handle Value Indication is used in this sub-procedure.
  469. *
  470. * If the return status from this function is SUCCESS, the calling
  471. * application task will receive an OSAL GATT_MSG_EVENT message.
  472. * The type of the message will be ATT_HANDLE_VALUE_CFM.
  473. *
  474. * Note: This sub-procedure is complete when ATT_HANDLE_VALUE_CFM
  475. * (with SUCCESS or bleTimeout status) is received by the
  476. * calling application task.
  477. *
  478. * @param connHandle - connection to use
  479. * @param pInd - pointer to indication to be sent
  480. * @param authenticated - whether an authenticated link is required
  481. * @param taskId - task to be notified of response
  482. *
  483. * @return SUCCESS: Indication was sent successfully.<BR>
  484. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  485. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  486. * bleNotConnected: Connection is down.<BR>
  487. * blePending: A confirmation is pending with this client.<BR>
  488. * bleMemAllocError: Memory allocation error occurred.<BR>
  489. * bleTimeout: Previous transaction timed out.<BR>
  490. */
  491. extern bStatus_t GATT_Indication( uint16 connHandle, attHandleValueInd_t *pInd,
  492. uint8 authenticated, uint8 taskId );
  493. /**
  494. * @brief This sub-procedure is used when a server is configured to
  495. * notify a characteristic value to a client without expecting
  496. * any attribute protocol layer acknowledgement that the
  497. * notification was successfully received.
  498. *
  499. * The ATT Handle Value Notification is used in this sub-procedure.
  500. *
  501. * Note: A notification may be sent at any time and does not
  502. * invoke a confirmation.
  503. *
  504. * No confirmation will be sent to the calling application task for
  505. * this sub-procedure.
  506. *
  507. * @param connHandle - connection to use
  508. * @param pNoti - pointer to notification to be sent
  509. * @param authenticated - whether an authenticated link is required
  510. *
  511. * @return SUCCESS: Notification was sent successfully.<BR>
  512. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  513. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  514. * bleNotConnected: Connection is down.<BR>
  515. * bleMemAllocError: Memory allocation error occurred.<BR>
  516. * bleTimeout: Previous transaction timed out.<BR>
  517. */
  518. extern bStatus_t GATT_Notification( uint16 connHandle, attHandleValueNoti_t *pNoti,
  519. uint8 authenticated );
  520. /**
  521. * @}
  522. */
  523. /*-------------------------------------------------------------------
  524. * GATT Client Sub-Procedure APIs
  525. */
  526. /**
  527. * @defgroup GATT_CLIENT_SUB_PROCEDURE_API GATT Client Sub-Procedure API Functions
  528. *
  529. * @{
  530. */
  531. /**
  532. * @brief This sub-procedure is used by the client to set the ATT_MTU
  533. * to the maximum possible value that can be supported by both
  534. * devices when the client supports a value greater than the
  535. * default ATT_MTU for the Attribute Protocol. This sub-procedure
  536. * shall only be initiated once during a connection.
  537. *
  538. * The ATT Exchange MTU Request is used by this sub-procedure.
  539. *
  540. * If the return status from this function is SUCCESS, the calling
  541. * application task will receive an OSAL GATT_MSG_EVENT message.
  542. * The type of the message will be either ATT_EXCHANGE_MTU_RSP or
  543. * ATT_ERROR_RSP (if an error occurred on the server).
  544. *
  545. * Note: This sub-procedure is complete when either ATT_EXCHANGE_MTU_RSP
  546. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
  547. * SUCCESS status) is received by the calling application task.
  548. *
  549. * @param connHandle - connection to use
  550. * @param pReq - pointer to request to be sent
  551. * @param taskId - task to be notified of response
  552. *
  553. * @return SUCCESS: Request was sent successfully.<BR>
  554. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  555. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  556. * bleNotConnected: Connection is down.<BR>
  557. * blePending: A response is pending with this server.<BR>
  558. * bleMemAllocError: Memory allocation error occurred.<BR>
  559. * bleTimeout: Previous transaction timed out.<BR>
  560. */
  561. extern bStatus_t GATT_ExchangeMTU( uint16 connHandle, attExchangeMTUReq_t *pReq, uint8 taskId );
  562. /**
  563. * @brief This sub-procedure is used by a client to discover all
  564. * the primary services on a server.
  565. *
  566. * The ATT Read By Group Type Request is used with the Attribute
  567. * Type parameter set to the UUID for "Primary Service". The
  568. * Starting Handle is set to 0x0001 and the Ending Handle is
  569. * set to 0xFFFF.
  570. *
  571. * If the return status from this function is SUCCESS, the calling
  572. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  573. * The type of the messages will be either ATT_READ_BY_GRP_TYPE_RSP
  574. * or ATT_ERROR_RSP (if an error occurred on the server).
  575. *
  576. * Note: This sub-procedure is complete when either ATT_READ_BY_GRP_TYPE_RSP
  577. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  578. * (with SUCCESS status) is received by the calling application
  579. * task.
  580. *
  581. * @param connHandle - connection to use
  582. * @param taskId - task to be notified of response
  583. *
  584. * @return SUCCESS: Request was sent successfully.<BR>
  585. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  586. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  587. * bleNotConnected: Connection is down.<BR>
  588. * blePending: A response is pending with this server.<BR>
  589. * bleMemAllocError: Memory allocation error occurred.<BR>
  590. * bleTimeout: Previous transaction timed out.<BR>
  591. */
  592. extern bStatus_t GATT_DiscAllPrimaryServices( uint16 connHandle, uint8 taskId );
  593. /**
  594. * @brief This sub-procedure is used by a client to discover a specific
  595. * primary service on a server when only the Service UUID is
  596. * known. The primary specific service may exist multiple times
  597. * on a server. The primary service being discovered is identified
  598. * by the service UUID.
  599. *
  600. * The ATT Find By Type Value Request is used with the Attribute
  601. * Type parameter set to the UUID for "Primary Service" and the
  602. * Attribute Value set to the 16-bit Bluetooth UUID or 128-bit
  603. * UUID for the specific primary service. The Starting Handle shall
  604. * be set to 0x0001 and the Ending Handle shall be set to 0xFFFF.
  605. *
  606. * If the return status from this function is SUCCESS, the calling
  607. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  608. * The type of the messages will be either ATT_FIND_BY_TYPE_VALUE_RSP
  609. * or ATT_ERROR_RSP (if an error occurred on the server).
  610. *
  611. * Note: This sub-procedure is complete when either ATT_FIND_BY_TYPE_VALUE_RSP
  612. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  613. * (with SUCCESS status) is received by the calling application task.
  614. *
  615. * @param connHandle - connection to use
  616. * @param pValue - pointer to value to look for
  617. * @param len - length of value
  618. * @param taskId - task to be notified of response
  619. *
  620. * @return SUCCESS: Request was sent successfully.<BR>
  621. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  622. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  623. * bleNotConnected: Connection is down.<BR>
  624. * blePending: A response is pending with this server.<BR>
  625. * bleMemAllocError: Memory allocation error occurred.<BR>
  626. * bleTimeout: Previous transaction timed out.<BR>
  627. */
  628. extern bStatus_t GATT_DiscPrimaryServiceByUUID( uint16 connHandle, uint8 *pValue,
  629. uint8 len, uint8 taskId );
  630. /**
  631. * @brief This sub-procedure is used by a client to find include
  632. * service declarations within a service definition on a
  633. * server. The service specified is identified by the service
  634. * handle range.
  635. *
  636. * The ATT Read By Type Request is used with the Attribute
  637. * Type parameter set to the UUID for "Included Service". The
  638. * Starting Handle is set to starting handle of the specified
  639. * service and the Ending Handle is set to the ending handle
  640. * of the specified service.
  641. *
  642. * If the return status from this function is SUCCESS, the calling
  643. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  644. * The type of the messages will be either ATT_READ_BY_TYPE_RSP
  645. * or ATT_ERROR_RSP (if an error occurred on the server).
  646. *
  647. * Note: This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
  648. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  649. * (with SUCCESS status) is received by the calling application task.
  650. *
  651. * @param connHandle - connection to use
  652. * @param startHandle - starting handle
  653. * @param endHandle - end handle
  654. * @param taskId - task to be notified of response
  655. *
  656. * @return SUCCESS: Request was sent successfully.<BR>
  657. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  658. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  659. * bleNotConnected: Connection is down.<BR>
  660. * blePending: A response is pending with this server.<BR>
  661. * bleMemAllocError: Memory allocation error occurred.<BR>
  662. * bleTimeout: Previous transaction timed out.<BR>
  663. */
  664. extern bStatus_t GATT_FindIncludedServices( uint16 connHandle, uint16 startHandle,
  665. uint16 endHandle, uint8 taskId );
  666. /**
  667. * @brief This sub-procedure is used by a client to find all the
  668. * characteristic declarations within a service definition on
  669. * a server when only the service handle range is known. The
  670. * service specified is identified by the service handle range.
  671. *
  672. * The ATT Read By Type Request is used with the Attribute Type
  673. * parameter set to the UUID for "Characteristic". The Starting
  674. * Handle is set to starting handle of the specified service and
  675. * the Ending Handle is set to the ending handle of the specified
  676. * service.
  677. *
  678. * If the return status from this function is SUCCESS, the calling
  679. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  680. * The type of the messages will be either ATT_READ_BY_TYPE_RSP
  681. * or ATT_ERROR_RSP (if an error occurred on the server).
  682. *
  683. * Note: This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
  684. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  685. * (with SUCCESS status) is received by the calling application task.
  686. *
  687. * @param connHandle - connection to use
  688. * @param startHandle - starting handle
  689. * @param endHandle - end handle
  690. * @param taskId - task to be notified of response
  691. *
  692. * @return SUCCESS: Request was sent successfully.<BR>
  693. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  694. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  695. * bleNotConnected: Connection is down.<BR>
  696. * blePending: A response is pending with this server.<BR>
  697. * bleMemAllocError: Memory allocation error occurred.<BR>
  698. * bleTimeout: Previous transaction timed out.<BR>
  699. */
  700. extern bStatus_t GATT_DiscAllChars( uint16 connHandle, uint16 startHandle,
  701. uint16 endHandle, uint8 taskId );
  702. /**
  703. * @brief This sub-procedure is used by a client to discover service
  704. * characteristics on a server when only the service handle
  705. * ranges are known and the characteristic UUID is known.
  706. * The specific service may exist multiple times on a server.
  707. * The characteristic being discovered is identified by the
  708. * characteristic UUID.
  709. *
  710. * The ATT Read By Type Request is used with the Attribute Type
  711. * is set to the UUID for "Characteristic" and the Starting
  712. * Handle and Ending Handle parameters is set to the service
  713. * handle range.
  714. *
  715. * If the return status from this function is SUCCESS, the calling
  716. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  717. * The type of the messages will be either ATT_READ_BY_TYPE_RSP
  718. * or ATT_ERROR_RSP (if an error occurred on the server).
  719. *
  720. * Note: This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
  721. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  722. * (with SUCCESS status) is received by the calling application task.
  723. *
  724. * @param connHandle - connection to use
  725. * @param pReq - pointer to request to be sent
  726. * @param taskId - task to be notified of response
  727. *
  728. * @return SUCCESS: Request was sent successfully.<BR>
  729. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  730. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  731. * bleNotConnected: Connection is down.<BR>
  732. * blePending: A response is pending with this server.<BR>
  733. * bleMemAllocError: Memory allocation error occurred.<BR>
  734. * bleTimeout: Previous transaction timed out.<BR>
  735. */
  736. extern bStatus_t GATT_DiscCharsByUUID( uint16 connHandle, attReadByTypeReq_t *pReq, uint8 taskId );
  737. /**
  738. * @brief This sub-procedure is used by a client to find all the
  739. * characteristic descriptor’s Attribute Handles and Attribute
  740. * Types within a characteristic definition when only the
  741. * characteristic handle range is known. The characteristic
  742. * specified is identified by the characteristic handle range.
  743. *
  744. * The ATT Find Information Request is used with the Starting
  745. * Handle set to starting handle of the specified characteristic
  746. * and the Ending Handle set to the ending handle of the specified
  747. * characteristic. The UUID Filter parameter is NULL (zero length).
  748. *
  749. * If the return status from this function is SUCCESS, the calling
  750. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  751. * The type of the messages will be either ATT_FIND_INFO_RSP or
  752. * ATT_ERROR_RSP (if an error occurred on the server).
  753. *
  754. * Note: This sub-procedure is complete when either ATT_FIND_INFO_RSP
  755. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  756. * (with SUCCESS status) is received by the calling application task.
  757. *
  758. * @param connHandle - connection to use
  759. * @param startHandle - starting handle
  760. * @param endHandle - end handle
  761. * @param taskId - task to be notified of response
  762. *
  763. * @return SUCCESS: Request was sent successfully.<BR>
  764. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  765. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  766. * bleNotConnected: Connection is down.<BR>
  767. * blePending: A response is pending with this server.<BR>
  768. * bleMemAllocError: Memory allocation error occurred.<BR>
  769. * bleTimeout: Previous transaction timed out.<BR>
  770. */
  771. extern bStatus_t GATT_DiscAllCharDescs( uint16 connHandle, uint16 startHandle,
  772. uint16 endHandle, uint8 taskId );
  773. /**
  774. * @brief This sub-procedure is used to read a Characteristic Value
  775. * from a server when the client knows the Characteristic Value
  776. * Handle. The ATT Read Request is used with the Attribute Handle
  777. * parameter set to the Characteristic Value Handle. The Read
  778. * Response returns the Characteristic Value in the Attribute
  779. * Value parameter.
  780. *
  781. * The Read Response only contains a Characteristic Value that
  782. * is less than or equal to (ATT_MTU – 1) octets in length. If
  783. * the Characteristic Value is greater than (ATT_MTU – 1) octets
  784. * in length, the Read Long Characteristic Value procedure may
  785. * be used if the rest of the Characteristic Value is required.
  786. *
  787. * If the return status from this function is SUCCESS, the calling
  788. * application task will receive an OSAL GATT_MSG_EVENT message.
  789. * The type of the message will be either ATT_READ_RSP or
  790. * ATT_ERROR_RSP (if an error occurred on the server).
  791. *
  792. * Note: This sub-procedure is complete when either ATT_READ_RSP
  793. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
  794. * SUCCESS status) is received by the calling application task.
  795. *
  796. * @param connHandle - connection to use
  797. * @param pReq - pointer to request to be sent
  798. * @param taskId - task to be notified of response
  799. *
  800. * @return SUCCESS: Request was sent successfully.<BR>
  801. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  802. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  803. * bleNotConnected: Connection is down.<BR>
  804. * blePending: A response is pending with this server.<BR>
  805. * bleMemAllocError: Memory allocation error occurred.<BR>
  806. * bleTimeout: Previous transaction timed out.<BR>
  807. */
  808. extern bStatus_t GATT_ReadCharValue( uint16 connHandle, attReadReq_t *pReq, uint8 taskId );
  809. /**
  810. * @brief This sub-procedure is used to read a Characteristic Value
  811. * from a server when the client only knows the characteristic
  812. * UUID and does not know the handle of the characteristic.
  813. *
  814. * The ATT Read By Type Request is used to perform the sub-procedure.
  815. * The Attribute Type is set to the known characteristic UUID and
  816. * the Starting Handle and Ending Handle parameters shall be set
  817. * to the range over which this read is to be performed. This is
  818. * typically the handle range for the service in which the
  819. * characteristic belongs.
  820. *
  821. * If the return status from this function is SUCCESS, the calling
  822. * application task will receive an OSAL GATT_MSG_EVENT messages.
  823. * The type of the message will be either ATT_READ_BY_TYPE_RSP
  824. * or ATT_ERROR_RSP (if an error occurred on the server).
  825. *
  826. * Note: This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
  827. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
  828. * SUCCESS status) is received by the calling application task.
  829. *
  830. * @param connHandle - connection to use
  831. * @param pReq - pointer to request to be sent
  832. * @param taskId - task to be notified of response
  833. *
  834. * @return SUCCESS: Request was sent successfully.<BR>
  835. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  836. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  837. * bleNotConnected: Connection is down.<BR>
  838. * blePending: A response is pending with this server.<BR>
  839. * bleMemAllocError: Memory allocation error occurred.<BR>
  840. * bleTimeout: Previous transaction timed out.<BR>
  841. */
  842. extern bStatus_t GATT_ReadUsingCharUUID( uint16 connHandle, attReadByTypeReq_t *pReq, uint8 taskId );
  843. /**
  844. * @brief This sub-procedure is used to read a Characteristic Value from
  845. * a server when the client knows the Characteristic Value Handle
  846. * and the length of the Characteristic Value is longer than can
  847. * be sent in a single Read Response Attribute Protocol message.
  848. *
  849. * The ATT Read Blob Request is used in this sub-procedure.
  850. *
  851. * If the return status from this function is SUCCESS, the calling
  852. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  853. * The type of the messages will be either ATT_READ_BLOB_RSP or
  854. * ATT_ERROR_RSP (if an error occurred on the server).
  855. *
  856. * Note: This sub-procedure is complete when either ATT_READ_BLOB_RSP
  857. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  858. * (with SUCCESS status) is received by the calling application task.
  859. *
  860. * @param connHandle - connection to use
  861. * @param pReq - pointer to request to be sent
  862. * @param taskId - task to be notified of response
  863. *
  864. * @return SUCCESS: Request was sent successfully.<BR>
  865. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  866. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  867. * bleNotConnected: Connection is down.<BR>
  868. * blePending: A response is pending with this server.<BR>
  869. * bleMemAllocError: Memory allocation error occurred.<BR>
  870. * bleTimeout: Previous transaction timed out.<BR>
  871. */
  872. extern bStatus_t GATT_ReadLongCharValue( uint16 connHandle, attReadBlobReq_t *pReq, uint8 taskId );
  873. /**
  874. * @brief This sub-procedure is used to read multiple Characteristic Values
  875. * from a server when the client knows the Characteristic Value
  876. * Handles. The Attribute Protocol Read Multiple Requests is used
  877. * with the Set Of Handles parameter set to the Characteristic Value
  878. * Handles. The Read Multiple Response returns the Characteristic
  879. * Values in the Set Of Values parameter.
  880. *
  881. * The ATT Read Multiple Request is used in this sub-procedure.
  882. *
  883. * If the return status from this function is SUCCESS, the calling
  884. * application task will receive an OSAL GATT_MSG_EVENT message.
  885. * The type of the message will be either ATT_READ_MULTI_RSP
  886. * or ATT_ERROR_RSP (if an error occurred on the server).
  887. *
  888. * Note: This sub-procedure is complete when either ATT_READ_MULTI_RSP
  889. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
  890. * SUCCESS status) is received by the calling application task.
  891. *
  892. * @param connHandle - connection to use
  893. * @param pReq - pointer to request to be sent
  894. * @param taskId - task to be notified of response
  895. *
  896. * @return SUCCESS: Request was sent successfully.<BR>
  897. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  898. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  899. * bleNotConnected: Connection is down.<BR>
  900. * blePending: A response is pending with this server.<BR>
  901. * bleMemAllocError: Memory allocation error occurred.<BR>
  902. * bleTimeout: Previous transaction timed out.<BR>
  903. */
  904. extern bStatus_t GATT_ReadMultiCharValues( uint16 connHandle, attReadMultiReq_t *pReq, uint8 taskId );
  905. /**
  906. * @brief This sub-procedure is used to write a Characteristic Value
  907. * to a server when the client knows the Characteristic Value
  908. * Handle and the client does not need an acknowledgement that
  909. * the write was successfully performed. This sub-procedure
  910. * only writes the first (ATT_MTU – 3) octets of a Characteristic
  911. * Value. This sub-procedure can not be used to write a long
  912. * characteristic; instead the Write Long Characteristic Values
  913. * sub-procedure should be used.
  914. *
  915. * The ATT Write Command is used for this sub-procedure. The
  916. * Attribute Handle parameter shall be set to the Characteristic
  917. * Value Handle. The Attribute Value parameter shall be set to
  918. * the new Characteristic Value.
  919. *
  920. * No response will be sent to the calling application task for this
  921. * sub-procedure. If the Characteristic Value write request is the
  922. * wrong size, or has an invalid value as defined by the profile,
  923. * then the write will not succeed and no error will be generated
  924. * by the server.
  925. *
  926. * @param connHandle - connection to use
  927. * @param pReq - pointer to command to be sent
  928. *
  929. * @return SUCCESS: Request was sent successfully.<BR>
  930. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  931. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  932. * bleNotConnected: Connection is down.<BR>
  933. * bleMemAllocError: Memory allocation error occurred.<BR>
  934. * bleTimeout: Previous transaction timed out.<BR>
  935. */
  936. extern bStatus_t GATT_WriteNoRsp( uint16 connHandle, attWriteReq_t *pReq );
  937. /**
  938. * @brief This sub-procedure is used to write a Characteristic Value
  939. * to a server when the client knows the Characteristic Value
  940. * Handle and the ATT Bearer is not encrypted. This sub-procedure
  941. * shall only be used if the Characteristic Properties authenticated
  942. * bit is enabled and the client and server device share a bond as
  943. * defined in the GAP.
  944. *
  945. * This sub-procedure only writes the first (ATT_MTU – 15) octets
  946. * of an Attribute Value. This sub-procedure cannot be used to
  947. * write a long Attribute.
  948. *
  949. * The ATT Write Command is used for this sub-procedure. The
  950. * Attribute Handle parameter shall be set to the Characteristic
  951. * Value Handle. The Attribute Value parameter shall be set to
  952. * the new Characteristic Value authenticated by signing the
  953. * value, as defined in the Security Manager.
  954. *
  955. * No response will be sent to the calling application task for this
  956. * sub-procedure. If the authenticated Characteristic Value that is
  957. * written is the wrong size, or has an invalid value as defined by
  958. * the profile, or the signed value does not authenticate the client,
  959. * then the write will not succeed and no error will be generated by
  960. * the server.
  961. *
  962. * @param connHandle - connection to use
  963. * @param pReq - pointer to command to be sent
  964. *
  965. * @return SUCCESS: Request was sent successfully.<BR>
  966. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  967. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  968. * bleNotConnected: Connection is down.<BR>
  969. * bleMemAllocError: Memory allocation error occurred.<BR>
  970. * bleLinkEncrypted: Connection is already encrypted.<BR>
  971. * bleTimeout: Previous transaction timed out.<BR>
  972. */
  973. extern bStatus_t GATT_SignedWriteNoRsp( uint16 connHandle, attWriteReq_t *pReq );
  974. /**
  975. * @brief This sub-procedure is used to write a characteristic value
  976. * to a server when the client knows the characteristic value
  977. * handle. This sub-procedure only writes the first (ATT_MTU-3)
  978. * octets of a characteristic value. This sub-procedure can not
  979. * be used to write a long attribute; instead the Write Long
  980. * Characteristic Values sub-procedure should be used.
  981. *
  982. * The ATT Write Request is used in this sub-procedure. The
  983. * Attribute Handle parameter shall be set to the Characteristic
  984. * Value Handle. The Attribute Value parameter shall be set to
  985. * the new characteristic.
  986. *
  987. * If the return status from this function is SUCCESS, the calling
  988. * application task will receive an OSAL GATT_MSG_EVENT message.
  989. * The type of the message will be either ATT_WRITE_RSP
  990. * or ATT_ERROR_RSP (if an error occurred on the server).
  991. *
  992. * Note: This sub-procedure is complete when either ATT_WRITE_RSP
  993. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
  994. * SUCCESS status) is received by the calling application task.
  995. *
  996. * @param connHandle - connection to use
  997. * @param pReq - pointer to request to be sent
  998. * @param taskId - task to be notified of response
  999. *
  1000. * @return SUCCESS: Request was sent successfully.<BR>
  1001. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  1002. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1003. * bleNotConnected: Connection is down.<BR>
  1004. * blePending: A response is pending with this server.<BR>
  1005. * bleMemAllocError: Memory allocation error occurred.<BR>
  1006. * bleTimeout: Previous transaction timed out.<BR>
  1007. */
  1008. extern bStatus_t GATT_WriteCharValue( uint16 connHandle, attWriteReq_t *pReq, uint8 taskId );
  1009. /**
  1010. * @brief This sub-procedure is used to write a Characteristic Value to
  1011. * a server when the client knows the Characteristic Value Handle
  1012. * but the length of the Characteristic Value is longer than can
  1013. * be sent in a single Write Request Attribute Protocol message.
  1014. *
  1015. * The ATT Prepare Write Request and Execute Write Request are
  1016. * used to perform this sub-procedure.
  1017. *
  1018. * If the return status from this function is SUCCESS, the calling
  1019. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  1020. * The type of the messages will be either ATT_PREPARE_WRITE_RSP,
  1021. * ATT_EXECUTE_WRITE_RSP or ATT_ERROR_RSP (if an error occurred on
  1022. * the server).
  1023. *
  1024. * Note: This sub-procedure is complete when either ATT_PREPARE_WRITE_RSP
  1025. * (with bleTimeout status), ATT_EXECUTE_WRITE_RSP (with SUCCESS
  1026. * or bleTimeout status), or ATT_ERROR_RSP (with SUCCESS status)
  1027. * is received by the calling application task.
  1028. *
  1029. * Note: The 'pReq->pValue' pointer will be freed when the sub-procedure
  1030. * is complete.
  1031. *
  1032. * @param connHandle - connection to use
  1033. * @param pReq - pointer to request to be sent
  1034. * @param taskId - task to be notified of response
  1035. *
  1036. * @return SUCCESS: Request was sent successfully.<BR>
  1037. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  1038. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1039. * bleNotConnected: Connection is down.<BR>
  1040. * blePending: A response is pending with this server.<BR>
  1041. * bleMemAllocError: Memory allocation error occurred.<BR>
  1042. * bleTimeout: Previous transaction timed out.<BR>
  1043. */
  1044. extern bStatus_t GATT_WriteLongCharValue( uint16 connHandle, gattPrepareWriteReq_t *pReq, uint8 taskId );
  1045. /**
  1046. * @brief This sub-procedure is used to write a Characteristic Value to
  1047. * a server when the client knows the Characteristic Value Handle,
  1048. * and assurance is required that the correct Characteristic Value
  1049. * is going to be written by transferring the Characteristic Value
  1050. * to be written in both directions before the write is performed.
  1051. * This sub-procedure can also be used when multiple values must
  1052. * be written, in order, in a single operation.
  1053. *
  1054. * The sub-procedure has two phases, the first phase prepares the
  1055. * characteristic values to be written. Once this is complete,
  1056. * the second phase performs the execution of all of the prepared
  1057. * characteristic value writes on the server from this client.
  1058. *
  1059. * In the first phase, the ATT Prepare Write Request is used.
  1060. * In the second phase, the attribute protocol Execute Write
  1061. * Request is used.
  1062. *
  1063. * If the return status from this function is SUCCESS, the calling
  1064. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  1065. * The type of the messages will be either ATT_PREPARE_WRITE_RSP,
  1066. * ATT_EXECUTE_WRITE_RSP or ATT_ERROR_RSP (if an error occurred on
  1067. * the server).
  1068. *
  1069. * Note: This sub-procedure is complete when either ATT_PREPARE_WRITE_RSP
  1070. * (with bleTimeout status), ATT_EXECUTE_WRITE_RSP (with SUCCESS
  1071. * or bleTimeout status), or ATT_ERROR_RSP (with SUCCESS status)
  1072. * is received by the calling application task.
  1073. *
  1074. * Note: The 'pReqs' pointer will be freed when the sub-procedure is
  1075. * complete.
  1076. *
  1077. * @param connHandle - connection to use
  1078. * @param pReqs - pointer to requests to be sent (must be allocated)
  1079. * @param numReqs - number of requests in pReq
  1080. * @param flags - execute write request flags
  1081. * @param taskId - task to be notified of response
  1082. *
  1083. * @return SUCCESS: Request was sent successfully.<BR>
  1084. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  1085. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1086. * bleNotConnected: Connection is down.<BR>
  1087. * blePending: A response is pending with this server.<BR>
  1088. * bleMemAllocError: Memory allocation error occurred.<BR>
  1089. * bleTimeout: Previous transaction timed out.<BR>
  1090. */
  1091. extern bStatus_t GATT_ReliableWrites( uint16 connHandle, attPrepareWriteReq_t *pReqs,
  1092. uint8 numReqs, uint8 flags, uint8 taskId );
  1093. /**
  1094. * @brief This sub-procedure is used to read a characteristic descriptor
  1095. * from a server when the client knows the characteristic descriptor
  1096. * declaration’s Attribute handle.
  1097. *
  1098. * The ATT Read Request is used for this sub-procedure. The Read
  1099. * Request is used with the Attribute Handle parameter set to the
  1100. * characteristic descriptor handle. The Read Response returns the
  1101. * characteristic descriptor value in the Attribute Value parameter.
  1102. *
  1103. * If the return status from this function is SUCCESS, the calling
  1104. * application task will receive an OSAL GATT_MSG_EVENT message.
  1105. * The type of the message will be either ATT_READ_RSP or
  1106. * ATT_ERROR_RSP (if an error occurred on the server).
  1107. *
  1108. * Note: This sub-procedure is complete when either ATT_READ_RSP
  1109. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
  1110. * SUCCESS status) is received by the calling application task.
  1111. *
  1112. * @param connHandle - connection to use
  1113. * @param pReq - pointer to request to be sent
  1114. * @param taskId - task to be notified of response
  1115. *
  1116. * @return SUCCESS: Request was sent successfully.<BR>
  1117. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  1118. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1119. * bleNotConnected: Connection is down.<BR>
  1120. * blePending: A response is pending with this server.<BR>
  1121. * bleMemAllocError: Memory allocation error occurred.<BR>
  1122. * bleTimeout: Previous transaction timed out.<BR>
  1123. */
  1124. extern bStatus_t GATT_ReadCharDesc( uint16 connHandle, attReadReq_t *pReq, uint8 taskId );
  1125. /**
  1126. * @brief This sub-procedure is used to read a characteristic descriptor
  1127. * from a server when the client knows the characteristic descriptor
  1128. * declaration’s Attribute handle and the length of the characteristic
  1129. * descriptor declaration is longer than can be sent in a single Read
  1130. * Response attribute protocol message.
  1131. *
  1132. * The ATT Read Blob Request is used to perform this sub-procedure.
  1133. * The Attribute Handle parameter shall be set to the characteristic
  1134. * descriptor handle. The Value Offset parameter shall be the offset
  1135. * within the characteristic descriptor to be read.
  1136. *
  1137. * If the return status from this function is SUCCESS, the calling
  1138. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  1139. * The type of the messages will be either ATT_READ_BLOB_RSP or
  1140. * ATT_ERROR_RSP (if an error occurred on the server).
  1141. *
  1142. * Note: This sub-procedure is complete when either ATT_READ_BLOB_RSP
  1143. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  1144. * (with SUCCESS status) is received by the calling application task.
  1145. *
  1146. * @param connHandle - connection to use
  1147. * @param pReq - pointer to request to be sent
  1148. * @param taskId - task to be notified of response
  1149. *
  1150. * @return SUCCESS: Request was sent successfully.<BR>
  1151. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  1152. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1153. * bleNotConnected: Connection is down.<BR>
  1154. * blePending: A response is pending with this server.<BR>
  1155. * bleMemAllocError: Memory allocation error occurred.<BR>
  1156. * bleTimeout: Previous transaction timed out.<BR>
  1157. */
  1158. extern bStatus_t GATT_ReadLongCharDesc( uint16 connHandle, attReadBlobReq_t *pReq, uint8 taskId );
  1159. /**
  1160. * @brief This sub-procedure is used to write a characteristic
  1161. * descriptor value to a server when the client knows the
  1162. * characteristic descriptor handle.
  1163. *
  1164. * The ATT Write Request is used for this sub-procedure. The
  1165. * Attribute Handle parameter shall be set to the characteristic
  1166. * descriptor handle. The Attribute Value parameter shall be
  1167. * set to the new characteristic descriptor value.
  1168. *
  1169. * If the return status from this function is SUCCESS, the calling
  1170. * application task will receive an OSAL GATT_MSG_EVENT message.
  1171. * The type of the message will be either ATT_WRITE_RSP
  1172. * or ATT_ERROR_RSP (if an error occurred on the server).
  1173. *
  1174. * Note: This sub-procedure is complete when either ATT_WRITE_RSP
  1175. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
  1176. * SUCCESS status) is received by the calling application task.
  1177. *
  1178. * @param connHandle - connection to use
  1179. * @param pReq - pointer to request to be sent
  1180. * @param taskId - task to be notified of response
  1181. *
  1182. * @return SUCCESS: Request was sent successfully.<BR>
  1183. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  1184. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1185. * bleNotConnected: Connection is down.<BR>
  1186. * blePending: A response is pending with this server.<BR>
  1187. * bleMemAllocError: Memory allocation error occurred.<BR>
  1188. * bleTimeout: Previous transaction timed out.<BR>
  1189. */
  1190. extern bStatus_t GATT_WriteCharDesc( uint16 connHandle, attWriteReq_t *pReq, uint8 taskId );
  1191. /**
  1192. * @brief This sub-procedure is used to write a Characteristic Value to
  1193. * a server when the client knows the Characteristic Value Handle
  1194. * but the length of the Characteristic Value is longer than can
  1195. * be sent in a single Write Request Attribute Protocol message.
  1196. *
  1197. * The ATT Prepare Write Request and Execute Write Request are
  1198. * used to perform this sub-procedure.
  1199. *
  1200. * If the return status from this function is SUCCESS, the calling
  1201. * application task will receive multiple OSAL GATT_MSG_EVENT messages.
  1202. * The type of the messages will be either ATT_PREPARE_WRITE_RSP,
  1203. * ATT_EXECUTE_WRITE_RSP or ATT_ERROR_RSP (if an error occurred on
  1204. * the server).
  1205. *
  1206. * Note: This sub-procedure is complete when either ATT_PREPARE_WRITE_RSP
  1207. * (with bleTimeout status), ATT_EXECUTE_WRITE_RSP (with SUCCESS
  1208. * or bleTimeout status), or ATT_ERROR_RSP (with SUCCESS status)
  1209. * is received by the calling application task.
  1210. *
  1211. * Note: The 'pReq->pValue' pointer will be freed when the sub-procedure
  1212. * is complete.
  1213. *
  1214. * @param connHandle - connection to use
  1215. * @param pReq - pointer to request to be sent
  1216. * @param taskId - task to be notified of response
  1217. *
  1218. * @return SUCCESS: Request was sent successfully.<BR>
  1219. * INVALIDPARAMETER: Invalid connection handle or request field.v
  1220. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1221. * bleNotConnected: Connection is down.<BR>
  1222. * blePending: A response is pending with this server.<BR>
  1223. * bleMemAllocError: Memory allocation error occurred.<BR>
  1224. * bleTimeout: Previous transaction timed out.<BR>
  1225. */
  1226. extern bStatus_t GATT_WriteLongCharDesc( uint16 connHandle, gattPrepareWriteReq_t *pReq, uint8 taskId );
  1227. /**
  1228. * @}
  1229. */
  1230. /*-------------------------------------------------------------------
  1231. * GATT Flow Control APIs
  1232. */
  1233. /**
  1234. * @defgroup GATT_FLOW_CTRL_API GATT Flow Control API Functions
  1235. *
  1236. * @{
  1237. */
  1238. /**
  1239. * @brief This API is used by the Application to turn flow control on
  1240. * or off for GATT messages sent from the Host to the Application.
  1241. *
  1242. * Note: If the flow control is enabled then the Application must
  1243. * call the GATT_AppCompletedMsg() API when it completes
  1244. * processing an incoming GATT message.
  1245. *
  1246. * @param flowCtrlMode – flow control mode: TRUE or FALSE
  1247. *
  1248. * @return void
  1249. */
  1250. extern void GATT_SetHostToAppFlowCtrl( uint8 flowCtrlMode );
  1251. /**
  1252. * @brief This API is used by the Application to notify GATT that
  1253. * the processing of a message has been completed.
  1254. *
  1255. * @param pMsg – pointer to the processed GATT message
  1256. *
  1257. * @return void
  1258. */
  1259. extern void GATT_AppCompletedMsg( gattMsgEvent_t *pMsg );
  1260. /**
  1261. * @}
  1262. */
  1263. /*-------------------------------------------------------------------
  1264. * Internal API - This function is only called from GATT Qualification modules.
  1265. */
  1266. /**
  1267. * @internal
  1268. *
  1269. * @brief Set the next available attribute handle.
  1270. *
  1271. * @param handle - next attribute handle.
  1272. *
  1273. * @return none
  1274. */
  1275. extern void GATT_SetNextHandle( uint16 handle );
  1276. /*-------------------------------------------------------------------
  1277. * TASK API - These functions must only be called by OSAL.
  1278. */
  1279. /**
  1280. * @internal
  1281. *
  1282. * @brief GATT Task initialization function.
  1283. *
  1284. * @param taskId - GATT task ID.
  1285. *
  1286. * @return void
  1287. */
  1288. extern void GATT_Init( uint8 taskId );
  1289. /**
  1290. * @internal
  1291. *
  1292. * @brief GATT Task event processing function.
  1293. *
  1294. * @param taskId - GATT task ID
  1295. * @param events - GATT events.
  1296. *
  1297. * @return events not processed
  1298. */
  1299. extern uint16 GATT_ProcessEvent( uint8 taskId, uint16 events );
  1300. /*********************************************************************
  1301. *********************************************************************/
  1302. #ifdef __cplusplus
  1303. }
  1304. #endif
  1305. #endif /* GATT_H */