att.h 40 KB

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