att.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260
  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: att.h
  30. <!--
  31. Revised:
  32. Revision:
  33. Description: This file contains Attribute Protocol (ATT) definitions
  34. and prototypes.
  35. -->
  36. **************************************************************************************************/
  37. #ifndef ATT_H
  38. #define ATT_H
  39. #ifdef __cplusplus
  40. extern "C"
  41. {
  42. #endif
  43. /*********************************************************************
  44. * INCLUDES
  45. */
  46. #include "bcomdef.h"
  47. #include "OSAL.h"
  48. #include "l2cap.h"
  49. /*********************************************************************
  50. * CONSTANTS
  51. */
  52. // The Exchanging MTU Size is defined as the maximum size of any packet
  53. // transmitted between a client and a server. A higher layer specification
  54. // defines the default ATT MTU value. The ATT MTU value should be within
  55. // the range 23 to 517 inclusive.
  56. #define ATT_MTU_SIZE L2CAP_MTU_SIZE //!< Minimum ATT MTU size
  57. #define ATT_MAX_MTU_SIZE 517 //!< Maximum ATT MTU size
  58. #define ATT_MTU_SIZE_MIN 23
  59. /** @defgroup ATT_METHOD_DEFINES ATT Methods
  60. * @{
  61. */
  62. #define ATT_ERROR_RSP 0x01 //!< ATT Error Response
  63. #define ATT_EXCHANGE_MTU_REQ 0x02 //!< ATT Exchange MTU Request
  64. #define ATT_EXCHANGE_MTU_RSP 0x03 //!< ATT Exchange MTU Response
  65. #define ATT_FIND_INFO_REQ 0x04 //!< ATT Find Information Request
  66. #define ATT_FIND_INFO_RSP 0x05 //!< ATT Find Information Response
  67. #define ATT_FIND_BY_TYPE_VALUE_REQ 0x06 //!< ATT Find By Type Vaue Request
  68. #define ATT_FIND_BY_TYPE_VALUE_RSP 0x07 //!< ATT Find By Type Vaue Response
  69. #define ATT_READ_BY_TYPE_REQ 0x08 //!< ATT Read By Type Request
  70. #define ATT_READ_BY_TYPE_RSP 0x09 //!< ATT Read By Type Response
  71. #define ATT_READ_REQ 0x0a //!< ATT Read Request
  72. #define ATT_READ_RSP 0x0b //!< ATT Read Response
  73. #define ATT_READ_BLOB_REQ 0x0c //!< ATT Read Blob Request
  74. #define ATT_READ_BLOB_RSP 0x0d //!< ATT Read Blob Response
  75. #define ATT_READ_MULTI_REQ 0x0e //!< ATT Read Multiple Request
  76. #define ATT_READ_MULTI_RSP 0x0f //!< ATT Read Multiple Response
  77. #define ATT_READ_BY_GRP_TYPE_REQ 0x10 //!< ATT Read By Group Type Request
  78. #define ATT_READ_BY_GRP_TYPE_RSP 0x11 //!< ATT Read By Group Type Response
  79. #define ATT_WRITE_REQ 0x12 //!< ATT Write Request
  80. #define ATT_WRITE_RSP 0x13 //!< ATT Write Response
  81. #define ATT_PREPARE_WRITE_REQ 0x16 //!< ATT Prepare Write Request
  82. #define ATT_PREPARE_WRITE_RSP 0x17 //!< ATT Prepare Write Response
  83. #define ATT_EXECUTE_WRITE_REQ 0x18 //!< ATT Execute Write Request
  84. #define ATT_EXECUTE_WRITE_RSP 0x19 //!< ATT Execute Write Response
  85. #define ATT_HANDLE_VALUE_NOTI 0x1b //!< ATT Handle Value Notification
  86. #define ATT_HANDLE_VALUE_IND 0x1d //!< ATT Handle Value Indication
  87. #define ATT_HANDLE_VALUE_CFM 0x1e //!< ATT Handle Value Confirmation
  88. #define ATT_WRITE_CMD 0x52 //!< ATT Write Command
  89. #define ATT_SIGNED_WRITE_CMD 0xD2 //!< ATT Signed Write Command
  90. /** @} End ATT_METHOD_DEFINES */
  91. /*** Opcode fields: bitmasks ***/
  92. // Method (bits 5-0)
  93. #define ATT_METHOD_BITS 0x3f
  94. // Command Flag (bit 6)
  95. #define ATT_CMD_FLAG_BIT 0x40
  96. // Authentication Signature Flag (bit 7)
  97. #define ATT_AUTHEN_SIG_FLAG_BIT 0x80
  98. // Size of 16-bit Bluetooth UUID
  99. #define ATT_BT_UUID_SIZE 2
  100. // Size of 128-bit UUID
  101. #define ATT_UUID_SIZE 16
  102. // ATT Response or Confirmation timeout
  103. #define ATT_MSG_TIMEOUT 30
  104. // Authentication Signature status for received PDU; it's TRUE or FALSE for PDU to be sent
  105. #define ATT_SIG_NOT_INCLUDED 0x00 // Signature not included
  106. #define ATT_SIG_VALID 0x01 // Included signature valid
  107. #define ATT_SIG_INVALID 0x02 // Included signature not valid
  108. /*********************************************************************
  109. * Error Response: Error Code
  110. */
  111. /** @defgroup ATT_ERR_CODE_DEFINES ATT Error Codes
  112. * @{
  113. */
  114. #define ATT_ERR_INVALID_HANDLE 0x01 //!< Attribute handle value given was not valid on this attribute server
  115. #define ATT_ERR_READ_NOT_PERMITTED 0x02 //!< Attribute cannot be read
  116. #define ATT_ERR_WRITE_NOT_PERMITTED 0x03 //!< Attribute cannot be written
  117. #define ATT_ERR_INVALID_PDU 0x04 //!< The attribute PDU was invalid
  118. #define ATT_ERR_INSUFFICIENT_AUTHEN 0x05 //!< The attribute requires authentication before it can be read or written
  119. #define ATT_ERR_UNSUPPORTED_REQ 0x06 //!< Attribute server doesn't support the request received from the attribute client
  120. #define ATT_ERR_INVALID_OFFSET 0x07 //!< Offset specified was past the end of the attribute
  121. #define ATT_ERR_INSUFFICIENT_AUTHOR 0x08 //!< The attribute requires an authorization before it can be read or written
  122. #define ATT_ERR_PREPARE_QUEUE_FULL 0x09 //!< Too many prepare writes have been queued
  123. #define ATT_ERR_ATTR_NOT_FOUND 0x0a //!< No attribute found within the given attribute handle range
  124. #define ATT_ERR_ATTR_NOT_LONG 0x0b //!< Attribute cannot be read or written using the Read Blob Request or Prepare Write Request
  125. #define ATT_ERR_INSUFFICIENT_KEY_SIZE 0x0c //!< The Encryption Key Size used for encrypting this link is insufficient
  126. #define ATT_ERR_INVALID_VALUE_SIZE 0x0d //!< The attribute value length is invalid for the operation
  127. #define ATT_ERR_UNLIKELY 0x0e //!< The attribute request that was requested has encountered an error that was very unlikely, and therefore could not be completed as requested
  128. #define ATT_ERR_INSUFFICIENT_ENCRYPT 0x0f //!< The attribute requires encryption before it can be read or written
  129. #define ATT_ERR_UNSUPPORTED_GRP_TYPE 0x10 //!< The attribute type is not a supported grouping attribute as defined by a higher layer specification
  130. #define ATT_ERR_INSUFFICIENT_RESOURCES 0x11 //!< Insufficient Resources to complete the request
  131. /*** Reserved for future use: 0x12 - 0x7F ***/
  132. /*** Application error code defined by a higher layer specification: 0x80-0x9F ***/
  133. #define ATT_ERR_INVALID_VALUE 0x80 //!< The attribute value is invalid for the operation
  134. /** @} End ATT_ERR_CODE_DEFINES */
  135. /*********************************************************************
  136. * Find Information Response: UUID Format
  137. */
  138. // Handle and 16-bit Bluetooth UUID
  139. #define ATT_HANDLE_BT_UUID_TYPE 0x01
  140. // Handle and 128-bit UUID
  141. #define ATT_HANDLE_UUID_TYPE 0x02
  142. // Maximum number of handle and 16-bit UUID pairs in a single Find Info Response
  143. #define ATT_MAX_NUM_HANDLE_BT_UUID ( ( ATT_MTU_SIZE_MIN - 2 ) / ( 2 + ATT_BT_UUID_SIZE ) )
  144. // Maximum number of handle and 128-bit UUID pairs in a single Find Info Response
  145. #define ATT_MAX_NUM_HANDLE_UUID ( ( ATT_MTU_SIZE_MIN - 2 ) / ( 2 + ATT_UUID_SIZE ) )
  146. /*********************************************************************
  147. * Find By Type Value Response: Handles Infomation (Found Attribute Handle and Group End Handle)
  148. */
  149. // Maximum number of handles info in a single Find By Type Value Response
  150. #define ATT_MAX_NUM_HANDLES_INFO ( ( ATT_MTU_SIZE_MIN - 1 ) / 4 )
  151. /*********************************************************************
  152. * Read Multiple Request: Handles
  153. */
  154. // Maximum number of handles in a single Read Multiple Request
  155. #define ATT_MAX_NUM_HANDLES ( ( ATT_MTU_SIZE_MIN - 1 ) / 2 )
  156. // Minimum number of handles in a single Read Multiple Request
  157. #define ATT_MIN_NUM_HANDLES 2
  158. /*********************************************************************
  159. * Execute Write Request: Flags
  160. */
  161. // Cancel all prepared writes
  162. #define ATT_CANCEL_PREPARED_WRITES 0x00
  163. // Immediately write all pending prepared values
  164. #define ATT_WRITE_PREPARED_VALUES 0x01
  165. #if defined ( TESTMODES )
  166. // ATT Test Modes
  167. #define ATT_TESTMODE_OFF 0 // Test mode off
  168. #define ATT_TESTMODE_UNAUTHEN_SIG 1 // Do not authenticate incoming signature
  169. #endif
  170. /*********************************************************************
  171. * Size of mandatory fields of ATT requests
  172. */
  173. // Length of Read By Type Request's fixed fields: First handle number (2) + Last handle number (2)
  174. #define READ_BY_TYPE_REQ_FIXED_SIZE 4
  175. // Length of Prepare Write Request's fixed size: Attribute Handle (2) + Value Offset (2)
  176. #define PREPARE_WRITE_REQ_FIXED_SIZE 4
  177. /*********************************************************************
  178. * VARIABLES
  179. */
  180. extern CONST uint8 btBaseUUID[ATT_UUID_SIZE];
  181. /*********************************************************************
  182. * MACROS
  183. */
  184. /*********************************************************************
  185. * TYPEDEFS
  186. */
  187. /**
  188. * Attribute Protocol PDU format.
  189. */
  190. typedef struct
  191. {
  192. uint8 sig; //!< Authentication Signature status (not included (0), valid (1), invalid (2))
  193. uint8 cmd; //!< Command Flag
  194. uint8 method; //!< Method
  195. uint16 len; //!< Length of Attribute Parameters
  196. uint8 *pParams; //!< Attribute Parameters
  197. } attPacket_t;
  198. /**
  199. * Attribute Type format (2 or 16 octet UUID).
  200. */
  201. typedef struct
  202. {
  203. uint8 len; //!< Length of UUID
  204. uint8 uuid[ATT_UUID_SIZE]; //!< 16 or 128 bit UUID
  205. } attAttrType_t;
  206. /**
  207. * Attribute Type format (2-octet Bluetooth UUID).
  208. */
  209. typedef struct
  210. {
  211. uint8 len; //!< Length of UUID
  212. uint8 uuid[ATT_BT_UUID_SIZE]; //!< 16 bit UUID
  213. } attAttrBtType_t;
  214. /**
  215. * Error Response format.
  216. */
  217. typedef struct
  218. {
  219. uint8 reqOpcode; //!< Request that generated this error response
  220. uint16 handle; //!< Attribute handle that generated error response
  221. uint8 errCode; //!< Reason why the request has generated error response
  222. } attErrorRsp_t;
  223. /**
  224. * Exchange MTU Request format.
  225. */
  226. typedef struct
  227. {
  228. uint16 clientRxMTU; //!< Client receive MTU size
  229. } attExchangeMTUReq_t;
  230. /**
  231. * Exchange MTU Response format.
  232. */
  233. typedef struct
  234. {
  235. uint16 serverRxMTU; //!< Server receive MTU size
  236. } attExchangeMTURsp_t;
  237. typedef struct
  238. {
  239. uint16 clientMTU;
  240. uint16 serverMTU;
  241. }attMTU_t;
  242. /**
  243. * Find Information Request format.
  244. */
  245. typedef struct
  246. {
  247. uint16 startHandle; //!< First requested handle number (must be first field)
  248. uint16 endHandle; //!< Last requested handle number
  249. } attFindInfoReq_t;
  250. /**
  251. * Handle and its 16-bit Bluetooth UUIDs.
  252. */
  253. typedef struct
  254. {
  255. uint16 handle; //!< Handle
  256. uint8 uuid[ATT_BT_UUID_SIZE]; //!< 2-octet Bluetooth UUID
  257. } attHandleBtUUID_t;
  258. /**
  259. * Handle and its 128-bit UUID.
  260. */
  261. typedef struct
  262. {
  263. uint16 handle; //!< Handle
  264. uint8 uuid[ATT_UUID_SIZE]; //!< 16-octect UUID
  265. } attHandleUUID_t;
  266. /**
  267. * Info data format for Find Information Response (handle-UUID pair).
  268. */
  269. typedef union
  270. {
  271. attHandleBtUUID_t btPair[ATT_MAX_NUM_HANDLE_BT_UUID]; //!< A list of 1 or more handles with their 16-bit Bluetooth UUIDs
  272. attHandleUUID_t pair[ATT_MAX_NUM_HANDLE_UUID]; //!< A list of 1 or more handles with their 128-bit UUIDs
  273. } attFindInfo_t;
  274. /**
  275. * Find Information Response format.
  276. */
  277. typedef struct
  278. {
  279. uint8 numInfo; //!< Number of attribute handle-UUID pairs found
  280. uint8 format; //!< Format of information data
  281. attFindInfo_t info; //!< Information data whose format is determined by format field
  282. } attFindInfoRsp_t;
  283. /**
  284. * Find By Type Value Request format.
  285. */
  286. typedef struct
  287. {
  288. uint16 startHandle; //!< First requested handle number (must be first field)
  289. uint16 endHandle; //!< Last requested handle number
  290. attAttrBtType_t type; //!< 2-octet UUID to find
  291. uint8 len; //!< Length of value
  292. uint8 value[ATT_MTU_SIZE-7]; //!< Attribute value to find
  293. } attFindByTypeValueReq_t;
  294. /**
  295. * Handles Infomation format.
  296. */
  297. typedef struct
  298. {
  299. uint16 handle; //!< Found attribute handle
  300. uint16 grpEndHandle; //!< Group end handle
  301. } attHandlesInfo_t;
  302. /**
  303. * Find By Type Value Response format.
  304. */
  305. typedef struct
  306. {
  307. uint8 numInfo; //!< Number of handles information found
  308. attHandlesInfo_t handlesInfo[ATT_MAX_NUM_HANDLES_INFO]; //!< List of 1 or more handles information
  309. } attFindByTypeValueRsp_t;
  310. /**
  311. * Read By Type Request format.
  312. */
  313. typedef struct
  314. {
  315. uint16 startHandle; //!< First requested handle number (must be first field)
  316. uint16 endHandle; //!< Last requested handle number
  317. attAttrType_t type; //!< Requested type (2 or 16 octet UUID)
  318. } attReadByTypeReq_t;
  319. /**
  320. * Read By Type Response format.
  321. */
  322. typedef struct
  323. {
  324. uint8 numPairs; //!< Number of attribute handle-UUID pairs found
  325. uint8 len; //!< Size of each attribute handle-value pair
  326. uint8 dataList[ATT_MTU_SIZE-2]; //!< List of 1 or more attribute handle-value pairs
  327. } attReadByTypeRsp_t;
  328. /**
  329. * Read Request format.
  330. */
  331. typedef struct
  332. {
  333. uint16 handle; //!< Handle of the attribute to be read (must be first field)
  334. } attReadReq_t;
  335. /**
  336. * Read Response format.
  337. */
  338. typedef struct
  339. {
  340. uint8 len; //!< Length of value
  341. uint8 value[ATT_MTU_SIZE-1]; //!< Value of the attribute with the handle given
  342. } attReadRsp_t;
  343. /**
  344. * Read Blob Req format.
  345. */
  346. typedef struct
  347. {
  348. uint16 handle; //!< Handle of the attribute to be read (must be first field)
  349. uint16 offset; //!< Offset of the first octet to be read
  350. } attReadBlobReq_t;
  351. /**
  352. * Read Blob Response format.
  353. */
  354. typedef struct
  355. {
  356. uint8 len; //!< Length of value
  357. uint8 value[ATT_MTU_SIZE-1]; //!< Part of the value of the attribute with the handle given
  358. } attReadBlobRsp_t;
  359. /**
  360. * Read Multiple Request format.
  361. */
  362. typedef struct
  363. {
  364. uint16 handle[ATT_MAX_NUM_HANDLES]; //!< Set of two or more attribute handles (must be first field)
  365. uint8 numHandles; //!< Number of attribute handles
  366. } attReadMultiReq_t;
  367. /**
  368. * Read Multiple Response format.
  369. */
  370. typedef struct
  371. {
  372. uint8 len; //!< Length of values
  373. uint8 values[ATT_MTU_SIZE-1]; //!< Set of two or more values
  374. } attReadMultiRsp_t;
  375. /**
  376. * Read By Group Type Request format.
  377. */
  378. typedef struct
  379. {
  380. uint16 startHandle; //!< First requested handle number (must be first field)
  381. uint16 endHandle; //!< Last requested handle number
  382. attAttrType_t type; //!< Requested group type (2 or 16 octet UUID)
  383. } attReadByGrpTypeReq_t;
  384. /**
  385. * Read By Group Type Response format.
  386. */
  387. typedef struct
  388. {
  389. uint8 numGrps; //!< Number of attribute handle, end group handle and value sets found
  390. uint8 len; //!< Length of each attribute handle, end group handle and value set
  391. uint8 dataList[ATT_MTU_SIZE-2]; //!< List of 1 or more attribute handle, end group handle and value
  392. } attReadByGrpTypeRsp_t;
  393. /**
  394. * Write Request format.
  395. */
  396. typedef struct
  397. {
  398. uint16 handle; //!< Handle of the attribute to be written (must be first field)
  399. uint8 len; //!< Length of value
  400. uint8 value[ATT_MTU_SIZE-3]; //!< Value of the attribute to be written
  401. uint8 sig; //!< Authentication Signature status (not included (0), valid (1), invalid (2))
  402. uint8 cmd; //!< Command Flag
  403. } attWriteReq_t;
  404. /**
  405. * Prepare Write Request format.
  406. */
  407. typedef struct
  408. {
  409. uint16 handle; //!< Handle of the attribute to be written (must be first field)
  410. uint16 offset; //!< Offset of the first octet to be written
  411. uint8 len; //!< Length of value
  412. uint8 value[ATT_MTU_SIZE-5]; //!< Part of the value of the attribute to be written
  413. } attPrepareWriteReq_t;
  414. /**
  415. * Prepare Write Response format.
  416. */
  417. typedef struct
  418. {
  419. uint16 handle; //!< Handle of the attribute that has been read
  420. uint16 offset; //!< Offset of the first octet to be written
  421. uint8 len; //!< Length of value
  422. uint8 value[ATT_MTU_SIZE-5]; //!< Part of the value of the attribute to be written
  423. } attPrepareWriteRsp_t;
  424. /**
  425. * Execute Write Request format.
  426. */
  427. typedef struct
  428. {
  429. uint8 flags; //!< 0x00 - cancel all prepared writes.
  430. //!< 0x01 - immediately write all pending prepared values.
  431. } attExecuteWriteReq_t;
  432. /**
  433. * Handle Value Notification format.
  434. */
  435. typedef struct
  436. {
  437. uint16 handle; //!< Handle of the attribute that has been changed (must be first field)
  438. uint8 len; //!< Length of value
  439. uint8 value[ATT_MTU_SIZE-3]; //!< New value of the attribute
  440. } attHandleValueNoti_t;
  441. /**
  442. * Handle Value Indication format.
  443. */
  444. typedef struct
  445. {
  446. uint16 handle; //!< Handle of the attribute that has been changed (must be first field)
  447. uint8 len; //!< Length of value
  448. uint8 value[ATT_MTU_SIZE-3]; //!< New value of the attribute
  449. } attHandleValueInd_t;
  450. /**
  451. * ATT Message format. It's a union of all attribute protocol messages used
  452. * between the attribute protocol and upper layer profile/application.
  453. */
  454. typedef union
  455. {
  456. // Request messages
  457. attExchangeMTUReq_t exchangeMTUReq; //!< ATT Exchange MTU Request
  458. attFindInfoReq_t findInfoReq; //!< ATT Find Information Request
  459. attFindByTypeValueReq_t findByTypeValueReq; //!< ATT Find By Type Vaue Request
  460. attReadByTypeReq_t readByTypeReq; //!< ATT Read By Type Request
  461. attReadReq_t readReq; //!< ATT Read Request
  462. attReadBlobReq_t readBlobReq; //!< ATT Read Blob Request
  463. attReadMultiReq_t readMultiReq; //!< ATT Read Multiple Request
  464. attReadByGrpTypeReq_t readByGrpTypeReq; //!< ATT Read By Group Type Request
  465. attWriteReq_t writeReq; //!< ATT Write Request
  466. attPrepareWriteReq_t prepareWriteReq; //!< ATT Prepare Write Request
  467. attExecuteWriteReq_t executeWriteReq; //!< ATT Execute Write Request
  468. // Response messages
  469. attErrorRsp_t errorRsp; //!< ATT Error Response
  470. attExchangeMTURsp_t exchangeMTURsp; //!< ATT Exchange MTU Response
  471. attFindInfoRsp_t findInfoRsp; //!< ATT Find Information Response
  472. attFindByTypeValueRsp_t findByTypeValueRsp; //!< ATT Find By Type Vaue Response
  473. attReadByTypeRsp_t readByTypeRsp; //!< ATT Read By Type Response
  474. attReadRsp_t readRsp; //!< ATT Read Response
  475. attReadBlobRsp_t readBlobRsp; //!< ATT Read Blob Response
  476. attReadMultiRsp_t readMultiRsp; //!< ATT Read Multiple Response
  477. attReadByGrpTypeRsp_t readByGrpTypeRsp; //!< ATT Read By Group Type Response
  478. attPrepareWriteRsp_t prepareWriteRsp; //!< ATT Prepare Write Response
  479. // Indication and Notification messages
  480. attHandleValueNoti_t handleValueNoti; //!< ATT Handle Value Notification
  481. attHandleValueInd_t handleValueInd; //!< ATT Handle Value Indication
  482. } attMsg_t;
  483. /*********************************************************************
  484. * VARIABLES
  485. */
  486. /*********************************************************************
  487. * API FUNCTIONS
  488. */
  489. /*-------------------------------------------------------------------
  490. * General Utility APIs
  491. */
  492. /*
  493. * Parse an attribute protocol message.
  494. */
  495. extern uint8 ATT_ParsePacket( l2capDataEvent_t *pL2capMsg, attPacket_t *pPkt );
  496. /*
  497. * Compare two UUIDs. The UUIDs are converted if necessary.
  498. */
  499. extern uint8 ATT_CompareUUID( const uint8 *pUUID1, uint16 len1,
  500. const uint8 *pUUID2, uint16 len2 );
  501. /*
  502. * Convert a 16-bit UUID to 128-bit UUID.
  503. */
  504. extern uint8 ATT_ConvertUUIDto128( const uint8 *pUUID16, uint8 *pUUID128 );
  505. /*
  506. * Convert a 128-bit UUID to 16-bit UUID.
  507. */
  508. extern uint8 ATT_ConvertUUIDto16( const uint8 *pUUID128, uint8 *pUUID16 );
  509. /*-------------------------------------------------------------------
  510. * Attribute Client Utility APIs
  511. */
  512. /*
  513. * Build Error Response.
  514. */
  515. extern uint16 ATT_BuildErrorRsp( uint8 *pBuf, uint8 *pMsg );
  516. /*
  517. * Parse Error Response.
  518. */
  519. extern bStatus_t ATT_ParseErrorRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  520. /*
  521. * Build Exchange MTU Request.
  522. */
  523. extern uint16 ATT_BuildExchangeMTUReq( uint8 *pBuf, uint8 *pMsg );
  524. /*
  525. * Build Exchange MTU Respnose.
  526. */
  527. extern uint16 ATT_BuildExchangeMTURsp( uint8 *pBuf, uint8 *pMsg );
  528. /*
  529. * Parse Exchange MTU Response.
  530. */
  531. extern bStatus_t ATT_ParseExchangeMTURsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  532. /*
  533. * Build Find Information Request.
  534. */
  535. extern uint16 ATT_BuildFindInfoReq( uint8 *pBuf, uint8 *pMsg );
  536. /*
  537. * Parse Find Information Response.
  538. */
  539. extern bStatus_t ATT_ParseFindInfoRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  540. /*
  541. * Build Find Information Response.
  542. */
  543. extern uint16 ATT_BuildFindInfoRsp( uint8 *pBuf, uint8 *pMsg );
  544. /*
  545. * Build Find By Type Value Request.
  546. */
  547. extern uint16 ATT_BuildFindByTypeValueReq( uint8 *pBuf, uint8 *pMsg );
  548. /*
  549. * Build Find By Type Value Response.
  550. */
  551. extern uint16 ATT_BuildFindByTypeValueRsp( uint8 *pBuf, uint8 *pMsg );
  552. /*
  553. * Parse Find By Type Value Response.
  554. */
  555. extern bStatus_t ATT_ParseFindByTypeValueRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  556. /*
  557. * Build Read By Type Request.
  558. */
  559. extern uint16 ATT_BuildReadByTypeReq( uint8 *pBuf, uint8 *pMsg );
  560. /*
  561. * Build Read By Type Response.
  562. */
  563. extern uint16 ATT_BuildReadByTypeRsp( uint8 *pBuf, uint8 *pMsg );
  564. /*
  565. * Parse Read By Type Response.
  566. */
  567. extern bStatus_t ATT_ParseReadByTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  568. /*
  569. * Build Read Request.
  570. */
  571. extern uint16 ATT_BuildReadReq( uint8 *pBuf, uint8 *pMsg );
  572. /*
  573. * Build Read Response.
  574. */
  575. extern uint16 ATT_BuildReadRsp( uint8 *pBuf, uint8 *pMsg );
  576. /*
  577. * Parse Read Response.
  578. */
  579. extern bStatus_t ATT_ParseReadRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  580. /*
  581. * Build Read Blob Request.
  582. */
  583. extern uint16 ATT_BuildReadBlobReq( uint8 *pBuf, uint8 *pMsg );
  584. /*
  585. * Build Read Blob Response.
  586. */
  587. extern uint16 ATT_BuildReadBlobRsp( uint8 *pBuf, uint8 *pMsg );
  588. /*
  589. * Parse Read Blob Response.
  590. */
  591. extern bStatus_t ATT_ParseReadBlobRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  592. /*
  593. * Build Read Multiple Request.
  594. */
  595. extern uint16 ATT_BuildReadMultiReq( uint8 *pBuf, uint8 *pMsg );
  596. /*
  597. * Build Read Multiple Response.
  598. */
  599. extern uint16 ATT_BuildReadMultiRsp( uint8 *pBuf, uint8 *pMsg );
  600. /*
  601. * Parse Read Multiple Response.
  602. */
  603. extern bStatus_t ATT_ParseReadMultiRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  604. /*
  605. * Build Read By Group Type Response.
  606. */
  607. extern uint16 ATT_BuildReadByGrpTypeRsp( uint8 *pBuf, uint8 *pMsg );
  608. /*
  609. * Parse Read By Group Type Response.
  610. */
  611. extern bStatus_t ATT_ParseReadByGrpTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  612. /*
  613. * Build Write Request.
  614. */
  615. extern uint16 ATT_BuildWriteReq( uint8 *pBuf, uint8 *pMsg );
  616. /*
  617. * Parse Write Response.
  618. */
  619. extern bStatus_t ATT_ParseWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  620. /*
  621. * Build Prepare Write Request.
  622. */
  623. extern uint16 ATT_BuildPrepareWriteReq( uint8 *pBuf, uint8 *pMsg );
  624. /*
  625. * Build Prepare Write Response.
  626. */
  627. extern uint16 ATT_BuildPrepareWriteRsp( uint8 *pBuf, uint8 *pMsg );
  628. /*
  629. * Parse Prepare Write Response.
  630. */
  631. extern bStatus_t ATT_ParsePrepareWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  632. /*
  633. * Build Execute Write Request.
  634. */
  635. extern uint16 ATT_BuildExecuteWriteReq( uint8 *pBuf, uint8 *pMsg );
  636. /*
  637. * Parse Execute Write Response.
  638. */
  639. extern bStatus_t ATT_ParseExecuteWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  640. /*
  641. * Build Handle Value Indication.
  642. */
  643. extern uint16 ATT_BuildHandleValueInd( uint8 *pBuf, uint8 *pMsg );
  644. /*
  645. * Parse Handle Value Indication.
  646. */
  647. extern bStatus_t ATT_ParseHandleValueInd( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  648. /*-------------------------------------------------------------------
  649. * Attribute Server Utility APIs
  650. */
  651. /*
  652. * Parse Exchange MTU Request.
  653. */
  654. extern bStatus_t ATT_ParseExchangeMTUReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  655. /*
  656. * Parse Find Information Request.
  657. */
  658. extern bStatus_t ATT_ParseFindInfoReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  659. /*
  660. * Parse Find By Type Value Request.
  661. */
  662. extern bStatus_t ATT_ParseFindByTypeValueReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  663. /*
  664. * Parse Read By Type Request.
  665. */
  666. extern bStatus_t ATT_ParseReadByTypeReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  667. /*
  668. * Parse Read Request.
  669. */
  670. extern bStatus_t ATT_ParseReadReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  671. /*
  672. * Parse Write Blob Request.
  673. */
  674. extern bStatus_t ATT_ParseReadBlobReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  675. /*
  676. * Parse Read Multiple Request.
  677. */
  678. extern bStatus_t ATT_ParseReadMultiReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  679. /*
  680. * Parse Write Request.
  681. */
  682. extern bStatus_t ATT_ParseWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  683. /*
  684. * Parse Execute Write Request.
  685. */
  686. extern bStatus_t ATT_ParseExecuteWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  687. /*
  688. * Parse Prepare Write Request.
  689. */
  690. extern bStatus_t ATT_ParsePrepareWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
  691. /*
  692. * Parse Handle Value Confirmation.
  693. */
  694. extern bStatus_t ATT_ParseHandleValueCfm( uint8 *pParams, uint16 len, attMsg_t *pMsg );
  695. /*-------------------------------------------------------------------
  696. * Attribute Client Public APIs
  697. */
  698. /**
  699. * @defgroup ATT_CLIENT_API ATT Client API Functions
  700. *
  701. * @{
  702. */
  703. /**
  704. * @brief Send Exchange MTU Request.
  705. *
  706. * @param connHandle - connection to use
  707. * @param pReq - pointer to request to be sent
  708. *
  709. * @return SUCCESS: Request was sent successfully.<BR>
  710. * INVALIDPARAMETER: Invalid request field.<BR>
  711. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  712. * bleNotConnected: Connection is down.<BR>
  713. * bleMemAllocError: Memory allocation error occurred.<BR>
  714. */
  715. extern bStatus_t ATT_ExchangeMTUReq( uint16 connHandle, attExchangeMTUReq_t *pReq );
  716. /**
  717. * @brief Send Find Information Request.
  718. *
  719. * @param connHandle - connection to use
  720. * @param pReq - pointer to request to be sent
  721. *
  722. * @return SUCCESS: Request was sent successfully.<BR>
  723. * INVALIDPARAMETER: Invalid request field.<BR>
  724. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  725. * bleNotConnected: Connection is down.<BR>
  726. * bleMemAllocError: Memory allocation error occurred.<BR>
  727. */
  728. extern bStatus_t ATT_FindInfoReq( uint16 connHandle, attFindInfoReq_t *pReq );
  729. /**
  730. * @brief Send Find By Type Value Request.
  731. *
  732. * @param connHandle - connection to use
  733. * @param pReq - pointer to request to be sent
  734. *
  735. * @return SUCCESS: Request was sent successfully.<BR>
  736. * INVALIDPARAMETER: Invalid request field.<BR>
  737. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  738. * bleNotConnected: Connection is down.<BR>
  739. * bleMemAllocError: Memory allocation error occurred.<BR>
  740. */
  741. extern bStatus_t ATT_FindByTypeValueReq( uint16 connHandle, attFindByTypeValueReq_t *pReq );
  742. /**
  743. * @brief Send Read By Type Request.
  744. *
  745. * @param connHandle - connection to use
  746. * @param pReq - pointer to request to be sent
  747. *
  748. * @return SUCCESS: Request was sent successfully.<BR>
  749. * INVALIDPARAMETER: Invalid request field.<BR>
  750. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  751. * bleNotConnected: Connection is down.<BR>
  752. * bleMemAllocError: Memory allocation error occurred.<BR>
  753. */
  754. extern bStatus_t ATT_ReadByTypeReq( uint16 connHandle, attReadByTypeReq_t *pReq );
  755. /**
  756. * @brief Send Read Request.
  757. *
  758. * @param connHandle - connection to use
  759. * @param pReq - pointer to request to be sent
  760. *
  761. * @return SUCCESS: Request was sent successfully.<BR>
  762. * INVALIDPARAMETER: Invalid request field.<BR>
  763. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  764. * bleNotConnected: Connection is down.<BR>
  765. * bleMemAllocError: Memory allocation error occurred.<BR>
  766. */
  767. extern bStatus_t ATT_ReadReq( uint16 connHandle, attReadReq_t *pReq );
  768. /**
  769. * @brief Send Read Blob Request.
  770. *
  771. * @param connHandle - connection to use
  772. * @param pReq - pointer to request to be sent
  773. *
  774. * @return SUCCESS: Request was sent successfully.<BR>
  775. * INVALIDPARAMETER: Invalid request field.<BR>
  776. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  777. * bleNotConnected: Connection is down.<BR>
  778. * bleMemAllocError: Memory allocation error occurred.<BR>
  779. */
  780. extern bStatus_t ATT_ReadBlobReq( uint16 connHandle, attReadBlobReq_t *pReq );
  781. /**
  782. * @brief Send Read Multiple Request.
  783. *
  784. * @param connHandle - connection to use
  785. * @param pReq - pointer to request to be sent
  786. *
  787. * @return SUCCESS: Request was sent successfully.<BR>
  788. * INVALIDPARAMETER: Invalid request field.<BR>
  789. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  790. * bleNotConnected: Connection is down.<BR>
  791. * bleMemAllocError: Memory allocation error occurred.<BR>
  792. */
  793. extern bStatus_t ATT_ReadMultiReq( uint16 connHandle, attReadMultiReq_t *pReq );
  794. /**
  795. * @brief Send Read By Group Type Request.
  796. *
  797. * @param connHandle - connection to use
  798. * @param pReq - pointer to request to be sent
  799. *
  800. * @return SUCCESS: Request was sent successfully.<BR>
  801. * INVALIDPARAMETER: Invalid request field.<BR>
  802. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  803. * bleNotConnected: Connection is down.<BR>
  804. * bleMemAllocError: Memory allocation error occurred.<BR>
  805. */
  806. extern bStatus_t ATT_ReadByGrpTypeReq( uint16 connHandle, attReadByGrpTypeReq_t *pReq );
  807. /**
  808. * @brief Send Write Request.
  809. *
  810. * @param connHandle - connection to use
  811. * @param pReq - pointer to request to be sent
  812. *
  813. * @return SUCCESS: Request was sent successfully.<BR>
  814. * INVALIDPARAMETER: Invalid request field.<BR>
  815. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  816. * bleNotConnected: Connection is down.<BR>
  817. * bleMemAllocError: Memory allocation error occurred.<BR>
  818. * bleLinkEncrypted: Connection is already encrypted.<BR>
  819. */
  820. extern bStatus_t ATT_WriteReq( uint16 connHandle, attWriteReq_t *pReq );
  821. /**
  822. * @brief Send Prepare Write Request.
  823. *
  824. * @param connHandle - connection to use
  825. * @param pReq - pointer to request to be sent
  826. *
  827. * @return SUCCESS: Request was sent successfully.<BR>
  828. * INVALIDPARAMETER: Invalid request field.<BR>
  829. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  830. * bleNotConnected: Connection is down.<BR>
  831. * bleMemAllocError: Memory allocation error occurred.<BR>
  832. */
  833. extern bStatus_t ATT_PrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq );
  834. /**
  835. * @brief Send Execute Write Request.
  836. *
  837. * @param connHandle - connection to use
  838. * @param pReq - pointer to request to be sent
  839. *
  840. * @return SUCCESS: Request was sent successfully.<BR>
  841. * INVALIDPARAMETER: Invalid request field.<BR>
  842. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  843. * bleNotConnected: Connection is down.<BR>
  844. * bleMemAllocError: Memory allocation error occurred.<BR>
  845. */
  846. extern bStatus_t ATT_ExecuteWriteReq( uint16 connHandle, attExecuteWriteReq_t *pReq );
  847. /**
  848. * @brief Send Handle Value Confirmation.
  849. *
  850. * @param connHandle - connection to use
  851. *
  852. * @return SUCCESS: Confirmation was sent successfully.<BR>
  853. * INVALIDPARAMETER: Invalid confirmation field.<BR>
  854. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  855. * bleNotConnected: Connection is down.<BR>
  856. * bleMemAllocError: Memory allocation error occurred.<BR>
  857. */
  858. extern bStatus_t ATT_HandleValueCfm( uint16 connHandle );
  859. /**
  860. * @}
  861. */
  862. /*-------------------------------------------------------------------
  863. * Attribute Server Public APIs
  864. */
  865. /**
  866. * @defgroup ATT_SERVER_API ATT Server API Functions
  867. *
  868. * @{
  869. */
  870. /**
  871. * @brief Send Error Response.
  872. *
  873. * @param connHandle - connection to use
  874. * @param pRsp - pointer to error response to be sent
  875. *
  876. * @return SUCCESS: Response was sent successfully.<BR>
  877. * INVALIDPARAMETER: Invalid response field.<BR>
  878. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  879. * bleNotConnected: Connection is down.<BR>
  880. * bleMemAllocError: Memory allocation error occurred.<BR>
  881. */
  882. extern bStatus_t ATT_ErrorRsp( uint16 connHandle, attErrorRsp_t *pRsp );
  883. /**
  884. * @brief Send Exchange MTU Response.
  885. *
  886. * @param connHandle - connection to use
  887. * @param pRsp - pointer to request to be sent
  888. *
  889. * @return SUCCESS: Response was sent successfully.<BR>
  890. * INVALIDPARAMETER: Invalid response field.<BR>
  891. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  892. * bleNotConnected: Connection is down.<BR>
  893. * bleMemAllocError: Memory allocation error occurred.<BR>
  894. */
  895. extern bStatus_t ATT_ExchangeMTURsp( uint16 connHandle, attExchangeMTURsp_t *pRsp );
  896. /**
  897. * @brief Send Find Information Response.
  898. *
  899. * @param connHandle - connection to use
  900. * @param pRsp - pointer to response to be sent
  901. *
  902. * @return SUCCESS: Response was sent successfully.<BR>
  903. * INVALIDPARAMETER: Invalid response field.<BR>
  904. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  905. * bleNotConnected: Connection is down.<BR>
  906. * bleMemAllocError: Memory allocation error occurred.<BR>
  907. */
  908. extern bStatus_t ATT_FindInfoRsp( uint16 connHandle, attFindInfoRsp_t *pRsp );
  909. /**
  910. * @brief Send Find By Tyep Value Response.
  911. *
  912. * @param connHandle - connection to use
  913. * @param pRsp - pointer to response to be sent
  914. *
  915. * @return SUCCESS: Response was sent successfully.<BR>
  916. * INVALIDPARAMETER: Invalid response field.<BR>
  917. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  918. * bleNotConnected: Connection is down.<BR>
  919. * bleMemAllocError: Memory allocation error occurred.<BR>
  920. */
  921. extern bStatus_t ATT_FindByTypeValueRsp( uint16 connHandle, attFindByTypeValueRsp_t *pRsp );
  922. /**
  923. * @brief Send Read By Type Respond.
  924. *
  925. * @param connHandle - connection to use
  926. * @param pRsp - pointer to response to be sent
  927. *
  928. * @return SUCCESS: Response was sent successfully.<BR>
  929. * INVALIDPARAMETER: Invalid response field.<BR>
  930. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  931. * bleNotConnected: Connection is down.<BR>
  932. * bleMemAllocError: Memory allocation error occurred.<BR>
  933. */
  934. extern bStatus_t ATT_ReadByTypeRsp( uint16 connHandle, attReadByTypeRsp_t *pRsp );
  935. /**
  936. * @brief Send Read Response.
  937. *
  938. * @param connHandle - connection to use
  939. * @param pRsp - pointer to response to be sent
  940. *
  941. * @return SUCCESS: Response was sent successfully.<BR>
  942. * INVALIDPARAMETER: Invalid response field.<BR>
  943. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  944. * bleNotConnected: Connection is down.<BR>
  945. * bleMemAllocError: Memory allocation error occurred.<BR>
  946. */
  947. extern bStatus_t ATT_ReadRsp( uint16 connHandle, attReadRsp_t *pRsp );
  948. /**
  949. * @brief Send Read Blob Response.
  950. *
  951. * @param connHandle - connection to use
  952. * @param pRsp - pointer to response to be sent
  953. *
  954. * @return SUCCESS: Response was sent successfully.<BR>
  955. * INVALIDPARAMETER: Invalid response field.<BR>
  956. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  957. * bleNotConnected: Connection is down.<BR>
  958. * bleMemAllocError: Memory allocation error occurred.<BR>
  959. */
  960. extern bStatus_t ATT_ReadBlobRsp( uint16 connHandle, attReadBlobRsp_t *pRsp );
  961. /**
  962. * @brief Send Read Multiple Response.
  963. *
  964. * @param connHandle - connection to use
  965. * @param pRsp - pointer to response to be sent
  966. *
  967. * @return SUCCESS: Response was sent successfully.<BR>
  968. * INVALIDPARAMETER: Invalid response field.<BR>
  969. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  970. * bleNotConnected: Connection is down.<BR>
  971. * bleMemAllocError: Memory allocation error occurred.<BR>
  972. */
  973. extern bStatus_t ATT_ReadMultiRsp( uint16 connHandle, attReadMultiRsp_t *pRsp ) ;
  974. /**
  975. * @brief Send Read By Group Type Respond.
  976. *
  977. * @param connHandle - connection to use
  978. * @param pRsp - pointer to response to be sent
  979. *
  980. * @return SUCCESS: Response was sent successfully.<BR>
  981. * INVALIDPARAMETER: Invalid response field.<BR>
  982. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  983. * bleNotConnected: Connection is down.<BR>
  984. * bleMemAllocError: Memory allocation error occurred.<BR>
  985. */
  986. extern bStatus_t ATT_ReadByGrpTypeRsp( uint16 connHandle, attReadByGrpTypeRsp_t *pRsp );
  987. /**
  988. * @brief Send Write Response.
  989. *
  990. * @param connHandle - connection to use
  991. *
  992. * @return SUCCESS: Response was sent successfully.<BR>
  993. * INVALIDPARAMETER: Invalid response field.<BR>
  994. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  995. * bleNotConnected: Connection is down.<BR>
  996. * bleMemAllocError: Memory allocation error occurred.<BR>
  997. */
  998. extern bStatus_t ATT_WriteRsp( uint16 connHandle );
  999. /**
  1000. * @brief Send Prepare Write Response.
  1001. *
  1002. * @param connHandle - connection to use
  1003. * @param pRsp - pointer to response to be sent
  1004. *
  1005. * @return SUCCESS: Response was sent successfully.<BR>
  1006. * INVALIDPARAMETER: Invalid response field.<BR>
  1007. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1008. * bleNotConnected: Connection is down.<BR>
  1009. * bleMemAllocError: Memory allocation error occurred.<BR>
  1010. */
  1011. extern bStatus_t ATT_PrepareWriteRsp( uint16 connHandle, attPrepareWriteRsp_t *pRsp );
  1012. /**
  1013. * @brief Send Execute Write Response.
  1014. *
  1015. * @param connHandle - connection to use
  1016. *
  1017. * @return SUCCESS: Response was sent successfully.<BR>
  1018. * INVALIDPARAMETER: Invalid response field.<BR>
  1019. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1020. * bleNotConnected: Connection is down.<BR>
  1021. * bleMemAllocError: Memory allocation error occurred.<BR>
  1022. */
  1023. extern bStatus_t ATT_ExecuteWriteRsp( uint16 connHandle );
  1024. /**
  1025. * @brief Send Handle Value Notification.
  1026. *
  1027. * @param connHandle - connection to use
  1028. * @param pNoti - pointer to notification to be sent
  1029. *
  1030. * @return SUCCESS: Notification was sent successfully.<BR>
  1031. * INVALIDPARAMETER: Invalid notification field.<BR>
  1032. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1033. * bleNotConnected: Connection is down.<BR>
  1034. * bleMemAllocError: Memory allocation error occurred.<BR>
  1035. */
  1036. extern bStatus_t ATT_HandleValueNoti( uint16 connHandle, attHandleValueNoti_t *pNoti );
  1037. /**
  1038. * @brief Send Handle Value Indication.
  1039. *
  1040. * @param connHandle - connection to use
  1041. * @param pInd - pointer to indication to be sent
  1042. *
  1043. * @return SUCCESS: Indication was sent successfully.<BR>
  1044. * INVALIDPARAMETER: Invalid indication field.<BR>
  1045. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  1046. * bleNotConnected: Connection is down.<BR>
  1047. * bleMemAllocError: Memory allocation error occurred.<BR>
  1048. */
  1049. extern bStatus_t ATT_HandleValueInd( uint16 connHandle, attHandleValueInd_t *pInd );
  1050. /**
  1051. * @}
  1052. */
  1053. /**
  1054. * @brief Set a ATT Parameter value. Use this function to change
  1055. * the default ATT parameter values.
  1056. *
  1057. * @param value - new param value
  1058. *
  1059. * @return void
  1060. */
  1061. extern void ATT_SetParamValue( uint16 value );
  1062. /**
  1063. * @brief Get a ATT Parameter value.
  1064. *
  1065. * @param none
  1066. *
  1067. * @return ATT Parameter value
  1068. */
  1069. extern uint16 ATT_GetParamValue( void );
  1070. extern uint16 ATT_GetCurrentMTUSize( void );
  1071. extern void ATT_SetMTUSizeMax(uint16 mtuSize);
  1072. extern void ATT_MTU_SIZE_UPDATE(uint8 mtuSize);
  1073. extern uint16 g_ATT_MTU_SIZE;
  1074. extern uint16 g_ATT_MTU_SIZE_MAX;
  1075. extern uint16 g_ATT_MAX_NUM_HANDLES;
  1076. extern uint16 g_ATT_MAX_NUM_HANDLES_INFO;
  1077. extern uint16 g_ATT_MAX_NUM_HANDLE_BT_UUID;
  1078. extern attMTU_t g_attMtuClientServer;
  1079. /*********************************************************************
  1080. *********************************************************************/
  1081. #ifdef __cplusplus
  1082. }
  1083. #endif
  1084. #endif /* ATT_H */