ble_gatt_aci.h 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  1. /*****************************************************************************
  2. * @file ble_gatt_aci.h
  3. * @brief STM32WB BLE API (gatt_aci)
  4. * Auto-generated file: do not edit!
  5. *****************************************************************************
  6. * @attention
  7. *
  8. * Copyright (c) 2018-2024 STMicroelectronics.
  9. * All rights reserved.
  10. *
  11. * This software is licensed under terms that can be found in the LICENSE file
  12. * in the root directory of this software component.
  13. * If no LICENSE file comes with this software, it is provided AS-IS.
  14. *
  15. *****************************************************************************
  16. */
  17. #ifndef BLE_GATT_ACI_H__
  18. #define BLE_GATT_ACI_H__
  19. //#include "ble_types.h"
  20. #include <ble/core/auto/ble_types.h>
  21. /**
  22. * @brief ACI_GATT_INIT
  23. * Initializes the GATT layer for server and client roles. It also adds the
  24. * GATT service with Service Changed Characteristic.
  25. * Until this command is issued the GATT channel does not process any commands
  26. * even if the connection is opened. This command has to be given before using
  27. * any of the GAP features.
  28. *
  29. * @return Value indicating success or error code.
  30. */
  31. tBleStatus aci_gatt_init(void);
  32. /**
  33. * @brief ACI_GATT_ADD_SERVICE
  34. * Add a service to GATT Server. When a service is created in the server, the
  35. * host needs to reserve the handle ranges for this service using
  36. * Max_Attribute_Records parameter. This parameter specifies the maximum number
  37. * of attribute records that can be added to this service (including the
  38. * service attribute, include attribute, characteristic attribute,
  39. * characteristic value attribute and characteristic descriptor attribute).
  40. * Handle of the created service is returned in command complete event. Service
  41. * declaration is taken from the service pool.
  42. * The attributes for characteristics and descriptors are allocated from the
  43. * attribute pool.
  44. *
  45. * @param Service_UUID_Type UUID type: 0x01 = 16 bits UUID while 0x02 = 128
  46. * bits UUID
  47. * @param Service_UUID See @ref Service_UUID_t
  48. * @param Service_Type Service type.
  49. * Values:
  50. * - 0x01: Primary Service
  51. * - 0x02: Secondary Service
  52. * @param Max_Attribute_Records Maximum number of attribute records that can be
  53. * added to this service
  54. * @param[out] Service_Handle Handle of the Service.
  55. * When this service is added, a handle is allocated by the server for
  56. * this service.
  57. * Server also allocates a range of handles for this service from
  58. * serviceHandle to <serviceHandle + max_attr_records - 1>
  59. * @return Value indicating success or error code.
  60. */
  61. tBleStatus aci_gatt_add_service(
  62. uint8_t Service_UUID_Type,
  63. const Service_UUID_t* Service_UUID,
  64. uint8_t Service_Type,
  65. uint8_t Max_Attribute_Records,
  66. uint16_t* Service_Handle);
  67. /**
  68. * @brief ACI_GATT_INCLUDE_SERVICE
  69. * Include a service given by Include_Start_Handle and Include_End_Handle to
  70. * another service given by Service_Handle. Attribute server creates an INCLUDE
  71. * definition attribute and return the handle of this attribute in
  72. * Included_handle.
  73. *
  74. * @param Service_Handle Handle of the Service to which another service has to
  75. * be included.
  76. * @param Include_Start_Handle Start Handle of the Service which has to be
  77. * included in service
  78. * @param Include_End_Handle End Handle of the Service which has to be included
  79. * in service
  80. * @param Include_UUID_Type UUID type: 0x01 = 16 bits UUID while 0x02 = 128
  81. * bits UUID
  82. * @param Include_UUID See @ref Include_UUID_t
  83. * @param[out] Include_Handle Handle of the include declaration
  84. * @return Value indicating success or error code.
  85. */
  86. tBleStatus aci_gatt_include_service(
  87. uint16_t Service_Handle,
  88. uint16_t Include_Start_Handle,
  89. uint16_t Include_End_Handle,
  90. uint8_t Include_UUID_Type,
  91. const Include_UUID_t* Include_UUID,
  92. uint16_t* Include_Handle);
  93. /**
  94. * @brief ACI_GATT_ADD_CHAR
  95. * Adds a characteristic to a service.
  96. * The command returns the handle of the declaration attribute. The attribute
  97. * that holds the Characteristic Value is always allocated at the next handle
  98. * (Char_Handle + 1). The Characteristic Value is immediately followed, in
  99. * order, by:
  100. * - the Server Characteristic Configuration descriptor if CHAR_PROP_BROADCAST
  101. * is selected;
  102. * - the Client Characteristic Configuration descriptor if CHAR_PROP_NOTIFY or
  103. * CHAR_PROP_INDICATE properties is selected;
  104. * - the Characteristic Extended Properties descriptor if CHAR_PROP_EXT is
  105. * selected.
  106. * For instance, if CHAR_PROP_NOTIFY is selected but not CHAR_PROP_BROADCAST
  107. * nor CHAR_PROP_EXT, then the Client Characteristic Configuration attribute
  108. * handle is Char_Handle + 2.
  109. * Additional descriptors can be added to the characteristic by calling the
  110. * ACI_GATT_ADD_CHAR_DESC command immediately after calling this command.
  111. *
  112. * @param Service_Handle Handle of the Service to which the characteristic will
  113. * be added
  114. * @param Char_UUID_Type UUID type: 0x01 = 16 bits UUID while 0x02 = 128 bits
  115. * UUID
  116. * @param Char_UUID See @ref Char_UUID_t
  117. * @param Char_Value_Length Maximum length of the characteristic value.
  118. * @param Char_Properties Characteristic Properties (Volume 3, Part G, section
  119. * 3.3.1.1 of Bluetooth Core Specification)
  120. * Flags:
  121. * - 0x00: CHAR_PROP_NONE
  122. * - 0x01: CHAR_PROP_BROADCAST (Broadcast)
  123. * - 0x02: CHAR_PROP_READ (Read)
  124. * - 0x04: CHAR_PROP_WRITE_WITHOUT_RESP (Write w/o resp)
  125. * - 0x08: CHAR_PROP_WRITE (Write)
  126. * - 0x10: CHAR_PROP_NOTIFY (Notify)
  127. * - 0x20: CHAR_PROP_INDICATE (Indicate)
  128. * - 0x40: CHAR_PROP_SIGNED_WRITE (Authenticated Signed Writes)
  129. * - 0x80: CHAR_PROP_EXT (Extended Properties)
  130. * @param Security_Permissions Security permission flags.
  131. * Flags:
  132. * - 0x00: None
  133. * - 0x01: AUTHEN_READ (Need authentication to read)
  134. * - 0x02: AUTHOR_READ (Need authorization to read)
  135. * - 0x04: ENCRY_READ (Need encryption to read)
  136. * - 0x08: AUTHEN_WRITE (need authentication to write)
  137. * - 0x10: AUTHOR_WRITE (need authorization to write)
  138. * - 0x20: ENCRY_WRITE (need encryption to write)
  139. * @param GATT_Evt_Mask GATT event mask.
  140. * Flags:
  141. * - 0x00: GATT_DONT_NOTIFY_EVENTS
  142. * - 0x01: GATT_NOTIFY_ATTRIBUTE_WRITE
  143. * - 0x02: GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP
  144. * - 0x04: GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP
  145. * - 0x08: GATT_NOTIFY_NOTIFICATION_COMPLETION
  146. * @param Enc_Key_Size Minimum encryption key size required to read the
  147. * characteristic.
  148. * Values:
  149. * - 0x07 ... 0x10
  150. * @param Is_Variable Specify if the characteristic value has a fixed length or
  151. * a variable length.
  152. * Values:
  153. * - 0x00: Fixed length
  154. * - 0x01: Variable length
  155. * @param[out] Char_Handle Handle of the characteristic that has been added (it
  156. * is the handle of the characteristic declaration).
  157. * @return Value indicating success or error code.
  158. */
  159. tBleStatus aci_gatt_add_char(
  160. uint16_t Service_Handle,
  161. uint8_t Char_UUID_Type,
  162. const Char_UUID_t* Char_UUID,
  163. uint16_t Char_Value_Length,
  164. uint8_t Char_Properties,
  165. uint8_t Security_Permissions,
  166. uint8_t GATT_Evt_Mask,
  167. uint8_t Enc_Key_Size,
  168. uint8_t Is_Variable,
  169. uint16_t* Char_Handle);
  170. /**
  171. * @brief ACI_GATT_ADD_CHAR_DESC
  172. * Adds a characteristic descriptor to a service.
  173. * Note that this command allocates the new handle for the descriptor after the
  174. * currently allocated handles. It is therefore advisable to call this command
  175. * following the call of the command ACI_GATT_ADD_CHAR which created the
  176. * characteristic containing this descriptor.
  177. *
  178. * @param Service_Handle Handle of service to which the characteristic belongs
  179. * @param Char_Handle Handle of the characteristic to which description has to
  180. * be added
  181. * @param Char_Desc_Uuid_Type UUID type: 0x01 = 16 bits UUID while 0x02 = 128
  182. * bits UUID
  183. * @param Char_Desc_Uuid See @ref Char_Desc_Uuid_t
  184. * @param Char_Desc_Value_Max_Len The maximum length of the descriptor value
  185. * @param Char_Desc_Value_Length Current Length of the characteristic
  186. * descriptor value
  187. * @param Char_Desc_Value Value of the characteristic description
  188. * @param Security_Permissions Security permission flags.
  189. * Flags:
  190. * - 0x00: None
  191. * - 0x01: AUTHEN_READ (Need authentication to read)
  192. * - 0x02: AUTHOR_READ (Need authorization to read)
  193. * - 0x04: ENCRY_READ (Need encryption to read)
  194. * - 0x08: AUTHEN_WRITE (need authentication to write)
  195. * - 0x10: AUTHOR_WRITE (need authorization to write)
  196. * - 0x20: ENCRY_WRITE (need encryption to write)
  197. * @param Access_Permissions Access permission
  198. * Flags:
  199. * - 0x00: None
  200. * - 0x01: READ
  201. * - 0x02: WRITE
  202. * - 0x04: WRITE_WO_RESP
  203. * - 0x08: SIGNED_WRITE
  204. * @param GATT_Evt_Mask GATT event mask.
  205. * Flags:
  206. * - 0x00: GATT_DONT_NOTIFY_EVENTS
  207. * - 0x01: GATT_NOTIFY_ATTRIBUTE_WRITE
  208. * - 0x02: GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP
  209. * - 0x04: GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP
  210. * @param Enc_Key_Size Minimum encryption key size required to read the
  211. * characteristic.
  212. * Values:
  213. * - 0x07 ... 0x10
  214. * @param Is_Variable Specify if the characteristic value has a fixed length or
  215. * a variable length.
  216. * Values:
  217. * - 0x00: Fixed length
  218. * - 0x01: Variable length
  219. * @param[out] Char_Desc_Handle Handle of the characteristic descriptor
  220. * @return Value indicating success or error code.
  221. */
  222. tBleStatus aci_gatt_add_char_desc(
  223. uint16_t Service_Handle,
  224. uint16_t Char_Handle,
  225. uint8_t Char_Desc_Uuid_Type,
  226. const Char_Desc_Uuid_t* Char_Desc_Uuid,
  227. uint8_t Char_Desc_Value_Max_Len,
  228. uint8_t Char_Desc_Value_Length,
  229. const uint8_t* Char_Desc_Value,
  230. uint8_t Security_Permissions,
  231. uint8_t Access_Permissions,
  232. uint8_t GATT_Evt_Mask,
  233. uint8_t Enc_Key_Size,
  234. uint8_t Is_Variable,
  235. uint16_t* Char_Desc_Handle);
  236. /**
  237. * @brief ACI_GATT_UPDATE_CHAR_VALUE
  238. * Updates a characteristic value in a service. If notifications (or
  239. * indications) are enabled on that characteristic, a notification (or
  240. * indication) is sent to any client that has registered for notifications (or
  241. * indications) via the Client Characteristic Configuration.
  242. * Notes:
  243. * - The command is disallowed if it would cause the generation of an
  244. * indication on a bearer which is still awaiting confirmation of a previous
  245. * indication.
  246. * - The command does not execute and returns BLE_STATUS_BUSY if notifications
  247. * from a previous call are not completed. The application can enable and wait
  248. * for the event ACI_GATT_NOTIFICATION_COMPLETE_EVENT to avoid this case.
  249. * - The command does not execute and returns BLE_STATUS_INSUFFICIENT_RESOURCES
  250. * if there is no more room in the TX pool to allocate notification (or
  251. * indication) packets. This happens if notifications (or indications) are
  252. * enabled and the application calls this command at an higher rate than what
  253. * is allowed by the link. Throughput on BLE link depends on connection
  254. * interval and connection length parameters (decided by the Central, see
  255. * ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ for more information on how to
  256. * suggest new connection parameters from a Peripheral). The application can
  257. * wait for the event ACI_GATT_TX_POOL_AVAILABLE_EVENT before retrying a call
  258. * to this command. It can also retry the call until it does not return
  259. * BLE_STATUS_INSUFFICIENT_RESOURCES anymore.
  260. * - When calling this command, the characteristic value is updated only if the
  261. * command returns BLE_STATUS_SUCCESS or BLE_STATUS_SEC_PERMISSION_ERROR. The
  262. * security permission error means that at least one client has not been
  263. * notified due to security requirements not met.
  264. *
  265. * @param Service_Handle Handle of service to which the characteristic belongs
  266. * @param Char_Handle Handle of the characteristic declaration
  267. * @param Val_Offset The offset from which the attribute value has to be
  268. * updated.
  269. * If this is set to 0 and the attribute value is of variable length,
  270. * then the length of the attribute will be set to the
  271. * Char_Value_Length.
  272. * If the Val_Offset is set to a value greater than 0, then the length
  273. * of the attribute will be set to the maximum length as specified for
  274. * the attribute while adding the characteristic.
  275. * @param Char_Value_Length Length of the Char_Value parameter in octets.
  276. * On STM32WB, this value must not exceed (BLE_CMD_MAX_PARAM_LEN - 6)
  277. * i.e. 249 for BLE_CMD_MAX_PARAM_LEN default value.
  278. * @param Char_Value Characteristic value
  279. * @return Value indicating success or error code.
  280. */
  281. tBleStatus aci_gatt_update_char_value(
  282. uint16_t Service_Handle,
  283. uint16_t Char_Handle,
  284. uint8_t Val_Offset,
  285. uint8_t Char_Value_Length,
  286. const uint8_t* Char_Value);
  287. /**
  288. * @brief ACI_GATT_DEL_CHAR
  289. * Deletes the specified characteristic from the service.
  290. *
  291. * @param Serv_Handle Handle of service to which the characteristic belongs
  292. * @param Char_Handle Handle of the characteristic which has to be deleted
  293. * @return Value indicating success or error code.
  294. */
  295. tBleStatus aci_gatt_del_char(uint16_t Serv_Handle, uint16_t Char_Handle);
  296. /**
  297. * @brief ACI_GATT_DEL_SERVICE
  298. * Deletes the specified service from the GATT server database.
  299. *
  300. * @param Serv_Handle Handle of the service to be deleted
  301. * @return Value indicating success or error code.
  302. */
  303. tBleStatus aci_gatt_del_service(uint16_t Serv_Handle);
  304. /**
  305. * @brief ACI_GATT_DEL_INCLUDE_SERVICE
  306. * Deletes the Include definition from the service.
  307. *
  308. * @param Serv_Handle Handle of the service to which the include service
  309. * belongs
  310. * @param Include_Handle Handle of the included service which has to be deleted
  311. * @return Value indicating success or error code.
  312. */
  313. tBleStatus aci_gatt_del_include_service(uint16_t Serv_Handle, uint16_t Include_Handle);
  314. /**
  315. * @brief ACI_GATT_SET_EVENT_MASK
  316. * Masks events from the GATT. If the bit in the GATT_Evt_Mask is set to a one,
  317. * then the event associated with that bit will be enabled.
  318. * The default configuration is all the events masked.
  319. *
  320. * @param GATT_Evt_Mask GATT/ATT event mask.
  321. * Values:
  322. * - 0x00000001: ACI_GATT_ATTRIBUTE_MODIFIED_EVENT
  323. * - 0x00000002: ACI_GATT_PROC_TIMEOUT_EVENT
  324. * - 0x00000004: ACI_ATT_EXCHANGE_MTU_RESP_EVENT
  325. * - 0x00000008: ACI_ATT_FIND_INFO_RESP_EVENT
  326. * - 0x00000010: ACI_ATT_FIND_BY_TYPE_VALUE_RESP_EVENT
  327. * - 0x00000020: ACI_ATT_READ_BY_TYPE_RESP_EVENT
  328. * - 0x00000040: ACI_ATT_READ_RESP_EVENT
  329. * - 0x00000080: ACI_ATT_READ_BLOB_RESP_EVENT
  330. * - 0x00000100: ACI_ATT_READ_MULTIPLE_RESP_EVENT
  331. * - 0x00000200: ACI_ATT_READ_BY_GROUP_TYPE_RESP_EVENT
  332. * - 0x00000800: ACI_ATT_PREPARE_WRITE_RESP_EVENT
  333. * - 0x00001000: ACI_ATT_EXEC_WRITE_RESP_EVENT
  334. * - 0x00002000: ACI_GATT_INDICATION_EVENT
  335. * - 0x00004000: ACI_GATT_NOTIFICATION_EVENT
  336. * - 0x00008000: ACI_GATT_ERROR_RESP_EVENT
  337. * - 0x00010000: ACI_GATT_PROC_COMPLETE_EVENT
  338. * - 0x00020000: ACI_GATT_DISC_READ_CHAR_BY_UUID_RESP_EVENT
  339. * - 0x00040000: ACI_GATT_TX_POOL_AVAILABLE_EVENT
  340. * - 0x00100000: ACI_GATT_READ_EXT_EVENT
  341. * - 0x00200000: ACI_GATT_INDICATION_EXT_EVENT
  342. * - 0x00400000: ACI_GATT_NOTIFICATION_EXT_EVENT
  343. * @return Value indicating success or error code.
  344. */
  345. tBleStatus aci_gatt_set_event_mask(uint32_t GATT_Evt_Mask);
  346. /**
  347. * @brief ACI_GATT_EXCHANGE_CONFIG
  348. * Performs an ATT MTU exchange procedure.
  349. * When the ATT MTU exchange procedure is completed, a
  350. * ACI_ATT_EXCHANGE_MTU_RESP_EVENT event is generated. A
  351. * ACI_GATT_PROC_COMPLETE_EVENT event is also generated to indicate the end of
  352. * the procedure.
  353. *
  354. * @param Connection_Handle Connection handle for which the command applies.
  355. * Values:
  356. * - 0x0000 ... 0x0EFF
  357. * @return Value indicating success or error code.
  358. */
  359. tBleStatus aci_gatt_exchange_config(uint16_t Connection_Handle);
  360. /**
  361. * @brief ACI_ATT_FIND_INFO_REQ
  362. * Sends a Find Information Request.
  363. * This command is used to obtain the mapping of attribute handles with their
  364. * associated types. The responses of the procedure are given through the
  365. * ACI_ATT_FIND_INFO_RESP_EVENT event. The end of the procedure is indicated by
  366. * a ACI_GATT_PROC_COMPLETE_EVENT event.
  367. *
  368. * @param Connection_Handle Connection handle for which the command applies.
  369. * Values:
  370. * - 0x0000 ... 0x0EFF
  371. * @param Start_Handle First requested handle number
  372. * @param End_Handle Last requested handle number
  373. * @return Value indicating success or error code.
  374. */
  375. tBleStatus
  376. aci_att_find_info_req(uint16_t Connection_Handle, uint16_t Start_Handle, uint16_t End_Handle);
  377. /**
  378. * @brief ACI_ATT_FIND_BY_TYPE_VALUE_REQ
  379. * Sends a Find By Type Value Request
  380. * The Find By Type Value Request is used to obtain the handles of attributes
  381. * that have a given 16-bit UUID attribute type and a given attribute value.
  382. * The responses of the procedure are given through the
  383. * ACI_ATT_FIND_BY_TYPE_VALUE_RESP_EVENT event.
  384. * The end of the procedure is indicated by a ACI_GATT_PROC_COMPLETE_EVENT
  385. * event.
  386. *
  387. * @param Connection_Handle Connection handle for which the command applies.
  388. * Values:
  389. * - 0x0000 ... 0x0EFF
  390. * @param Start_Handle First requested handle number
  391. * @param End_Handle Last requested handle number
  392. * @param UUID 2 octet UUID to find (little-endian)
  393. * @param Attribute_Val_Length Length of attribute value (maximum value is
  394. * ATT_MTU - 7).
  395. * @param Attribute_Val Attribute value to find
  396. * @return Value indicating success or error code.
  397. */
  398. tBleStatus aci_att_find_by_type_value_req(
  399. uint16_t Connection_Handle,
  400. uint16_t Start_Handle,
  401. uint16_t End_Handle,
  402. uint16_t UUID,
  403. uint8_t Attribute_Val_Length,
  404. const uint8_t* Attribute_Val);
  405. /**
  406. * @brief ACI_ATT_READ_BY_TYPE_REQ
  407. * Sends a Read By Type Request.
  408. * The Read By Type Request is used to obtain the values of attributes where
  409. * the attribute type is known but the handle is not known.
  410. * The responses are given through the ACI_ATT_READ_BY_TYPE_RESP_EVENT event.
  411. *
  412. * @param Connection_Handle Connection handle for which the command applies.
  413. * Values:
  414. * - 0x0000 ... 0x0EFF
  415. * @param Start_Handle First requested handle number
  416. * @param End_Handle Last requested handle number
  417. * @param UUID_Type UUID type: 0x01 = 16 bits UUID while 0x02 = 128 bits UUID
  418. * @param UUID See @ref UUID_t
  419. * @return Value indicating success or error code.
  420. */
  421. tBleStatus aci_att_read_by_type_req(
  422. uint16_t Connection_Handle,
  423. uint16_t Start_Handle,
  424. uint16_t End_Handle,
  425. uint8_t UUID_Type,
  426. const UUID_t* UUID);
  427. /**
  428. * @brief ACI_ATT_READ_BY_GROUP_TYPE_REQ
  429. * Sends a Read By Group Type Request.
  430. * The Read By Group Type Request is used to obtain the values of grouping
  431. * attributes where the attribute type is known but the handle is not known.
  432. * Grouping attributes are defined at GATT layer. The grouping attribute types
  433. * are: "Primary Service", "Secondary Service" and "Characteristic".
  434. * The responses of the procedure are given through the
  435. * ACI_ATT_READ_BY_GROUP_TYPE_RESP_EVENT event.
  436. * The end of the procedure is indicated by a ACI_GATT_PROC_COMPLETE_EVENT.
  437. *
  438. * @param Connection_Handle Connection handle for which the command applies.
  439. * Values:
  440. * - 0x0000 ... 0x0EFF
  441. * @param Start_Handle First requested handle number
  442. * @param End_Handle Last requested handle number
  443. * @param UUID_Type UUID type: 0x01 = 16 bits UUID while 0x02 = 128 bits UUID
  444. * @param UUID See @ref UUID_t
  445. * @return Value indicating success or error code.
  446. */
  447. tBleStatus aci_att_read_by_group_type_req(
  448. uint16_t Connection_Handle,
  449. uint16_t Start_Handle,
  450. uint16_t End_Handle,
  451. uint8_t UUID_Type,
  452. const UUID_t* UUID);
  453. /**
  454. * @brief ACI_ATT_PREPARE_WRITE_REQ
  455. * Sends a Prepare Write Request.
  456. * The Prepare Write Request is used to request the server to prepare to write
  457. * the value of an attribute.
  458. * The responses of the procedure are given through the
  459. * ACI_ATT_PREPARE_WRITE_RESP_EVENT event.
  460. * The end of the procedure is indicated by a ACI_GATT_PROC_COMPLETE_EVENT.
  461. *
  462. * @param Connection_Handle Connection handle for which the command applies.
  463. * Values:
  464. * - 0x0000 ... 0x0EFF
  465. * @param Attr_Handle Handle of the attribute to be written
  466. * @param Val_Offset The offset of the first octet to be written
  467. * @param Attribute_Val_Length Length of attribute value (maximum value is
  468. * ATT_MTU - 5).
  469. * @param Attribute_Val The value of the attribute to be written
  470. * @return Value indicating success or error code.
  471. */
  472. tBleStatus aci_att_prepare_write_req(
  473. uint16_t Connection_Handle,
  474. uint16_t Attr_Handle,
  475. uint16_t Val_Offset,
  476. uint8_t Attribute_Val_Length,
  477. const uint8_t* Attribute_Val);
  478. /**
  479. * @brief ACI_ATT_EXECUTE_WRITE_REQ
  480. * Sends an Execute Write Request.
  481. * The Execute Write Request is used to request the server to write or cancel
  482. * the write of all the prepared values currently held in the prepare queue
  483. * from this client.
  484. * The result of the procedure is given through the
  485. * ACI_ATT_EXEC_WRITE_RESP_EVENT event.
  486. * The end of the procedure is indicated by a ACI_GATT_PROC_COMPLETE_EVENT
  487. * event.
  488. *
  489. * @param Connection_Handle Connection handle for which the command applies.
  490. * Values:
  491. * - 0x0000 ... 0x0EFF
  492. * @param Execute Execute or cancel writes.
  493. * Values:
  494. * - 0x00: Cancel all prepared writes
  495. * - 0x01: Immediately write all pending prepared values
  496. * @return Value indicating success or error code.
  497. */
  498. tBleStatus aci_att_execute_write_req(uint16_t Connection_Handle, uint8_t Execute);
  499. /**
  500. * @brief ACI_GATT_DISC_ALL_PRIMARY_SERVICES
  501. * Starts the GATT client procedure to discover all primary services on the
  502. * server.
  503. * The responses of the procedure are given through the
  504. * ACI_ATT_READ_BY_GROUP_TYPE_RESP_EVENT event.
  505. *
  506. * @param Connection_Handle Specifies the ATT bearer for which the command
  507. * applies.
  508. * Values:
  509. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  510. * connection handle)
  511. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  512. * parameter is the connection-oriented channel index)
  513. * @return Value indicating success or error code.
  514. */
  515. tBleStatus aci_gatt_disc_all_primary_services(uint16_t Connection_Handle);
  516. /**
  517. * @brief ACI_GATT_DISC_PRIMARY_SERVICE_BY_UUID
  518. * Starts the procedure to discover the primary services of the specified UUID
  519. * on the server.
  520. * The responses of the procedure are given through the
  521. * ACI_ATT_FIND_BY_TYPE_VALUE_RESP_EVENT event.
  522. * The end of the procedure is indicated by a ACI_GATT_PROC_COMPLETE_EVENT
  523. * event.
  524. *
  525. * @param Connection_Handle Specifies the ATT bearer for which the command
  526. * applies.
  527. * Values:
  528. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  529. * connection handle)
  530. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  531. * parameter is the connection-oriented channel index)
  532. * @param UUID_Type UUID type: 0x01 = 16 bits UUID while 0x02 = 128 bits UUID
  533. * @param UUID See @ref UUID_t
  534. * @return Value indicating success or error code.
  535. */
  536. tBleStatus aci_gatt_disc_primary_service_by_uuid(
  537. uint16_t Connection_Handle,
  538. uint8_t UUID_Type,
  539. const UUID_t* UUID);
  540. /**
  541. * @brief ACI_GATT_FIND_INCLUDED_SERVICES
  542. * Starts the procedure to find all included services.
  543. * The responses of the procedure are given through the
  544. * ACI_ATT_READ_BY_TYPE_RESP_EVENT event.
  545. * The end of the procedure is indicated by a ACI_GATT_PROC_COMPLETE_EVENT
  546. * event.
  547. *
  548. * @param Connection_Handle Specifies the ATT bearer for which the command
  549. * applies.
  550. * Values:
  551. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  552. * connection handle)
  553. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  554. * parameter is the connection-oriented channel index)
  555. * @param Start_Handle Start attribute handle of the service
  556. * @param End_Handle End attribute handle of the service
  557. * @return Value indicating success or error code.
  558. */
  559. tBleStatus aci_gatt_find_included_services(
  560. uint16_t Connection_Handle,
  561. uint16_t Start_Handle,
  562. uint16_t End_Handle);
  563. /**
  564. * @brief ACI_GATT_DISC_ALL_CHAR_OF_SERVICE
  565. * Starts the procedure to discover all the characteristics of a given service.
  566. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  567. * generated. Before procedure completion the response packets are given
  568. * through ACI_ATT_READ_BY_TYPE_RESP_EVENT event.
  569. *
  570. * @param Connection_Handle Specifies the ATT bearer for which the command
  571. * applies.
  572. * Values:
  573. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  574. * connection handle)
  575. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  576. * parameter is the connection-oriented channel index)
  577. * @param Start_Handle Start attribute handle of the service
  578. * @param End_Handle End attribute handle of the service
  579. * @return Value indicating success or error code.
  580. */
  581. tBleStatus aci_gatt_disc_all_char_of_service(
  582. uint16_t Connection_Handle,
  583. uint16_t Start_Handle,
  584. uint16_t End_Handle);
  585. /**
  586. * @brief ACI_GATT_DISC_CHAR_BY_UUID
  587. * Starts the procedure to discover all the characteristics specified by a
  588. * UUID.
  589. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  590. * generated. Before procedure completion the response packets are given
  591. * through ACI_GATT_DISC_READ_CHAR_BY_UUID_RESP_EVENT event.
  592. *
  593. * @param Connection_Handle Specifies the ATT bearer for which the command
  594. * applies.
  595. * Values:
  596. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  597. * connection handle)
  598. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  599. * parameter is the connection-oriented channel index)
  600. * @param Start_Handle Start attribute handle of the service
  601. * @param End_Handle End attribute handle of the service
  602. * @param UUID_Type UUID type: 0x01 = 16 bits UUID while 0x02 = 128 bits UUID
  603. * @param UUID See @ref UUID_t
  604. * @return Value indicating success or error code.
  605. */
  606. tBleStatus aci_gatt_disc_char_by_uuid(
  607. uint16_t Connection_Handle,
  608. uint16_t Start_Handle,
  609. uint16_t End_Handle,
  610. uint8_t UUID_Type,
  611. const UUID_t* UUID);
  612. /**
  613. * @brief ACI_GATT_DISC_ALL_CHAR_DESC
  614. * Starts the procedure to discover all characteristic descriptors on the
  615. * server.
  616. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  617. * generated. Before procedure completion the response packets are given
  618. * through ACI_ATT_FIND_INFO_RESP_EVENT event.
  619. *
  620. * @param Connection_Handle Specifies the ATT bearer for which the command
  621. * applies.
  622. * Values:
  623. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  624. * connection handle)
  625. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  626. * parameter is the connection-oriented channel index)
  627. * @param Char_Handle Handle of the characteristic value
  628. * @param End_Handle End handle of the characteristic
  629. * @return Value indicating success or error code.
  630. */
  631. tBleStatus aci_gatt_disc_all_char_desc(
  632. uint16_t Connection_Handle,
  633. uint16_t Char_Handle,
  634. uint16_t End_Handle);
  635. /**
  636. * @brief ACI_GATT_READ_CHAR_VALUE
  637. * Starts the procedure to read the attribute value.
  638. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  639. * generated. Before procedure completion the response packet is given through
  640. * ACI_ATT_READ_RESP_EVENT event.
  641. *
  642. * @param Connection_Handle Specifies the ATT bearer for which the command
  643. * applies.
  644. * Values:
  645. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  646. * connection handle)
  647. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  648. * parameter is the connection-oriented channel index)
  649. * @param Attr_Handle Handle of the characteristic value to be read
  650. * @return Value indicating success or error code.
  651. */
  652. tBleStatus aci_gatt_read_char_value(uint16_t Connection_Handle, uint16_t Attr_Handle);
  653. /**
  654. * @brief ACI_GATT_READ_USING_CHAR_UUID
  655. * This command sends a Read By Type Request packet to the server in order to
  656. * read the value attribute of the characteristics specified by the UUID.
  657. * When the procedure is completed, an ACI_GATT_PROC_COMPLETE_EVENT event is
  658. * generated. Before procedure completion, the response packet is given through
  659. * one ACI_GATT_DISC_READ_CHAR_BY_UUID_RESP_EVENT event per reported attribute.
  660. * Note: the number of bytes of a value reported by
  661. * ACI_GATT_DISC_READ_CHAR_BY_UUID_RESP_EVENT event cannot exceed
  662. * BLE_EVT_MAX_PARAM_LEN - 7 i.e. 248 bytes for default value of
  663. * BLE_EVT_MAX_PARAM_LEN.
  664. *
  665. * @param Connection_Handle Specifies the ATT bearer for which the command
  666. * applies.
  667. * Values:
  668. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  669. * connection handle)
  670. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  671. * parameter is the connection-oriented channel index)
  672. * @param Start_Handle Starting handle of the range to be searched
  673. * @param End_Handle End handle of the range to be searched
  674. * @param UUID_Type UUID type: 0x01 = 16 bits UUID while 0x02 = 128 bits UUID
  675. * @param UUID See @ref UUID_t
  676. * @return Value indicating success or error code.
  677. */
  678. tBleStatus aci_gatt_read_using_char_uuid(
  679. uint16_t Connection_Handle,
  680. uint16_t Start_Handle,
  681. uint16_t End_Handle,
  682. uint8_t UUID_Type,
  683. const UUID_t* UUID);
  684. /**
  685. * @brief ACI_GATT_READ_LONG_CHAR_VALUE
  686. * Starts the procedure to read a long characteristic value.
  687. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  688. * generated. Before procedure completion the response packets are given
  689. * through ACI_ATT_READ_BLOB_RESP_EVENT event.
  690. *
  691. * @param Connection_Handle Specifies the ATT bearer for which the command
  692. * applies.
  693. * Values:
  694. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  695. * connection handle)
  696. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  697. * parameter is the connection-oriented channel index)
  698. * @param Attr_Handle Handle of the characteristic value to be read
  699. * @param Val_Offset Offset from which the value needs to be read
  700. * @return Value indicating success or error code.
  701. */
  702. tBleStatus aci_gatt_read_long_char_value(
  703. uint16_t Connection_Handle,
  704. uint16_t Attr_Handle,
  705. uint16_t Val_Offset);
  706. /**
  707. * @brief ACI_GATT_READ_MULTIPLE_CHAR_VALUE
  708. * Starts a procedure to read multiple characteristic values from a server.
  709. * The command must specify the handles of the characteristic values to be
  710. * read.
  711. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  712. * generated. Before procedure completion the response packets are given
  713. * through ACI_ATT_READ_MULTIPLE_RESP_EVENT event.
  714. *
  715. * @param Connection_Handle Specifies the ATT bearer for which the command
  716. * applies.
  717. * Values:
  718. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  719. * connection handle)
  720. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  721. * parameter is the connection-oriented channel index)
  722. * @param Number_of_Handles Number of handles in the following table
  723. * Values:
  724. * - 0x02 ... 0x7E
  725. * @param Handle_Entry See @ref Handle_Entry_t
  726. * @return Value indicating success or error code.
  727. */
  728. tBleStatus aci_gatt_read_multiple_char_value(
  729. uint16_t Connection_Handle,
  730. uint8_t Number_of_Handles,
  731. const Handle_Entry_t* Handle_Entry);
  732. /**
  733. * @brief ACI_GATT_WRITE_CHAR_VALUE
  734. * Starts the procedure to write a characteristic value.
  735. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  736. * generated.
  737. * The length of the value to be written must not exceed (ATT_MTU - 3). On
  738. * STM32WB, it must also not exceed (BLE_CMD_MAX_PARAM_LEN - 5) i.e. 250 for
  739. * BLE_CMD_MAX_PARAM_LEN default value.
  740. *
  741. * @param Connection_Handle Specifies the ATT bearer for which the command
  742. * applies.
  743. * Values:
  744. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  745. * connection handle)
  746. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  747. * parameter is the connection-oriented channel index)
  748. * @param Attr_Handle Handle of the characteristic value to be written
  749. * @param Attribute_Val_Length Length of the value to be written
  750. * @param Attribute_Val Value to be written
  751. * @return Value indicating success or error code.
  752. */
  753. tBleStatus aci_gatt_write_char_value(
  754. uint16_t Connection_Handle,
  755. uint16_t Attr_Handle,
  756. uint8_t Attribute_Val_Length,
  757. const uint8_t* Attribute_Val);
  758. /**
  759. * @brief ACI_GATT_WRITE_LONG_CHAR_VALUE
  760. * Starts the procedure to write a long characteristic value.
  761. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  762. * generated. During the procedure, ACI_ATT_PREPARE_WRITE_RESP_EVENT and
  763. * ACI_ATT_EXEC_WRITE_RESP_EVENT events are raised.
  764. *
  765. * @param Connection_Handle Specifies the ATT bearer for which the command
  766. * applies.
  767. * Values:
  768. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  769. * connection handle)
  770. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  771. * parameter is the connection-oriented channel index)
  772. * @param Attr_Handle Handle of the characteristic value to be written
  773. * @param Val_Offset Offset at which the attribute has to be written
  774. * @param Attribute_Val_Length Length of the value to be written.
  775. * On STM32WB, this value must not exceed (BLE_CMD_MAX_PARAM_LEN - 7)
  776. * i.e. 248 for BLE_CMD_MAX_PARAM_LEN default value.
  777. * @param Attribute_Val Value to be written
  778. * @return Value indicating success or error code.
  779. */
  780. tBleStatus aci_gatt_write_long_char_value(
  781. uint16_t Connection_Handle,
  782. uint16_t Attr_Handle,
  783. uint16_t Val_Offset,
  784. uint8_t Attribute_Val_Length,
  785. const uint8_t* Attribute_Val);
  786. /**
  787. * @brief ACI_GATT_WRITE_CHAR_RELIABLE
  788. * Starts the procedure to write a characteristic reliably.
  789. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  790. * generated. During the procedure, ACI_ATT_PREPARE_WRITE_RESP_EVENT and
  791. * ACI_ATT_EXEC_WRITE_RESP_EVENT events are raised.
  792. *
  793. * @param Connection_Handle Specifies the ATT bearer for which the command
  794. * applies.
  795. * Values:
  796. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  797. * connection handle)
  798. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  799. * parameter is the connection-oriented channel index)
  800. * @param Attr_Handle Handle of the attribute to be written
  801. * @param Val_Offset Offset at which the attribute has to be written
  802. * @param Attribute_Val_Length Length of the value to be written.
  803. * On STM32WB, this value must not exceed (BLE_CMD_MAX_PARAM_LEN - 7)
  804. * i.e. 248 for BLE_CMD_MAX_PARAM_LEN default value.
  805. * @param Attribute_Val Value to be written
  806. * @return Value indicating success or error code.
  807. */
  808. tBleStatus aci_gatt_write_char_reliable(
  809. uint16_t Connection_Handle,
  810. uint16_t Attr_Handle,
  811. uint16_t Val_Offset,
  812. uint8_t Attribute_Val_Length,
  813. const uint8_t* Attribute_Val);
  814. /**
  815. * @brief ACI_GATT_WRITE_LONG_CHAR_DESC
  816. * Starts the procedure to write a long characteristic descriptor.
  817. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  818. * generated. During the procedure, ACI_ATT_PREPARE_WRITE_RESP_EVENT and
  819. * ACI_ATT_EXEC_WRITE_RESP_EVENT events are raised.
  820. *
  821. * @param Connection_Handle Specifies the ATT bearer for which the command
  822. * applies.
  823. * Values:
  824. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  825. * connection handle)
  826. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  827. * parameter is the connection-oriented channel index)
  828. * @param Attr_Handle Handle of the attribute to be written
  829. * @param Val_Offset Offset at which the attribute has to be written
  830. * @param Attribute_Val_Length Length of the value to be written.
  831. * On STM32WB, this value must not exceed (BLE_CMD_MAX_PARAM_LEN - 7)
  832. * i.e. 248 for BLE_CMD_MAX_PARAM_LEN default value.
  833. * @param Attribute_Val Value to be written
  834. * @return Value indicating success or error code.
  835. */
  836. tBleStatus aci_gatt_write_long_char_desc(
  837. uint16_t Connection_Handle,
  838. uint16_t Attr_Handle,
  839. uint16_t Val_Offset,
  840. uint8_t Attribute_Val_Length,
  841. const uint8_t* Attribute_Val);
  842. /**
  843. * @brief ACI_GATT_READ_LONG_CHAR_DESC
  844. * Starts the procedure to read a long characteristic value.
  845. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  846. * generated. Before procedure completion the response packets are given
  847. * through ACI_ATT_READ_BLOB_RESP_EVENT event.
  848. *
  849. * @param Connection_Handle Specifies the ATT bearer for which the command
  850. * applies.
  851. * Values:
  852. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  853. * connection handle)
  854. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  855. * parameter is the connection-oriented channel index)
  856. * @param Attr_Handle Handle of the characteristic descriptor
  857. * @param Val_Offset Offset from which the value needs to be read
  858. * @return Value indicating success or error code.
  859. */
  860. tBleStatus aci_gatt_read_long_char_desc(
  861. uint16_t Connection_Handle,
  862. uint16_t Attr_Handle,
  863. uint16_t Val_Offset);
  864. /**
  865. * @brief ACI_GATT_WRITE_CHAR_DESC
  866. * Starts the procedure to write a characteristic descriptor.
  867. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  868. * generated.
  869. * The length of the value to be written must not exceed (ATT_MTU - 3). On
  870. * STM32WB, it must also not exceed (BLE_CMD_MAX_PARAM_LEN - 5) i.e. 250 for
  871. * BLE_CMD_MAX_PARAM_LEN default value.
  872. *
  873. * @param Connection_Handle Specifies the ATT bearer for which the command
  874. * applies.
  875. * Values:
  876. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  877. * connection handle)
  878. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  879. * parameter is the connection-oriented channel index)
  880. * @param Attr_Handle Handle of the attribute to be written
  881. * @param Attribute_Val_Length Length of the value to be written
  882. * @param Attribute_Val Value to be written
  883. * @return Value indicating success or error code.
  884. */
  885. tBleStatus aci_gatt_write_char_desc(
  886. uint16_t Connection_Handle,
  887. uint16_t Attr_Handle,
  888. uint8_t Attribute_Val_Length,
  889. const uint8_t* Attribute_Val);
  890. /**
  891. * @brief ACI_GATT_READ_CHAR_DESC
  892. * Starts the procedure to read the descriptor specified.
  893. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  894. * generated.
  895. * Before procedure completion the response packet is given through
  896. * ACI_ATT_READ_RESP_EVENT event.
  897. *
  898. * @param Connection_Handle Specifies the ATT bearer for which the command
  899. * applies.
  900. * Values:
  901. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  902. * connection handle)
  903. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  904. * parameter is the connection-oriented channel index)
  905. * @param Attr_Handle Handle of the descriptor to be read
  906. * @return Value indicating success or error code.
  907. */
  908. tBleStatus aci_gatt_read_char_desc(uint16_t Connection_Handle, uint16_t Attr_Handle);
  909. /**
  910. * @brief ACI_GATT_WRITE_WITHOUT_RESP
  911. * Starts the procedure to write a characteristic value without waiting for any
  912. * response from the server. No events are generated after this command is
  913. * executed.
  914. * The length of the value to be written must not exceed (ATT_MTU - 3). On
  915. * STM32WB, it must also not exceed (BLE_CMD_MAX_PARAM_LEN - 5) i.e. 250 for
  916. * BLE_CMD_MAX_PARAM_LEN default value.
  917. *
  918. * @param Connection_Handle Specifies the ATT bearer for which the command
  919. * applies.
  920. * Values:
  921. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  922. * connection handle)
  923. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  924. * parameter is the connection-oriented channel index)
  925. * @param Attr_Handle Handle of the characteristic value to be written
  926. * @param Attribute_Val_Length Length of the value to be written
  927. * @param Attribute_Val Value to be written
  928. * @return Value indicating success or error code.
  929. */
  930. tBleStatus aci_gatt_write_without_resp(
  931. uint16_t Connection_Handle,
  932. uint16_t Attr_Handle,
  933. uint8_t Attribute_Val_Length,
  934. const uint8_t* Attribute_Val);
  935. /**
  936. * @brief ACI_GATT_SIGNED_WRITE_WITHOUT_RESP
  937. * Starts a signed write without response from the server.
  938. * The procedure is used to write a characteristic value with an authentication
  939. * signature without waiting for any response from the server. It cannot be
  940. * used when the link is encrypted.
  941. * The length of the value to be written must not exceed (ATT_MTU - 15). On
  942. * STM32WB, it must also not exceed (BLE_CMD_MAX_PARAM_LEN - 5) i.e. 250 for
  943. * BLE_CMD_MAX_PARAM_LEN default value.
  944. *
  945. * @param Connection_Handle Connection handle for which the command applies.
  946. * Values:
  947. * - 0x0000 ... 0x0EFF
  948. * @param Attr_Handle Handle of the characteristic value to be written
  949. * @param Attribute_Val_Length Length of the value to be written
  950. * @param Attribute_Val Value to be written
  951. * @return Value indicating success or error code.
  952. */
  953. tBleStatus aci_gatt_signed_write_without_resp(
  954. uint16_t Connection_Handle,
  955. uint16_t Attr_Handle,
  956. uint8_t Attribute_Val_Length,
  957. const uint8_t* Attribute_Val);
  958. /**
  959. * @brief ACI_GATT_CONFIRM_INDICATION
  960. * Allow application to confirm indication. This command has to be sent when
  961. * the application receives the event ACI_GATT_INDICATION_EVENT.
  962. *
  963. * @param Connection_Handle Specifies the ATT bearer for which the command
  964. * applies.
  965. * Values:
  966. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  967. * connection handle)
  968. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  969. * parameter is the connection-oriented channel index)
  970. * @return Value indicating success or error code.
  971. */
  972. tBleStatus aci_gatt_confirm_indication(uint16_t Connection_Handle);
  973. /**
  974. * @brief ACI_GATT_WRITE_RESP
  975. * Allow or reject a write request from a client.
  976. * This command has to be sent by the application when it receives the
  977. * ACI_GATT_WRITE_PERMIT_REQ_EVENT. If the write can be allowed, then the
  978. * status and error code have to be set to 0. If the write cannot be allowed,
  979. * then the status has to be set to 1 and the error code has to be set to the
  980. * error code that has to be passed to the client.
  981. *
  982. * @param Connection_Handle Specifies the ATT bearer for which the command
  983. * applies.
  984. * Values:
  985. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  986. * connection handle)
  987. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  988. * parameter is the connection-oriented channel index)
  989. * @param Attr_Handle Handle of the attribute that was passed in the event
  990. * ACI_GATT_WRITE_PERMIT_REQ_EVENT
  991. * @param Write_status If the value can be written or not.
  992. * Values:
  993. * - 0x00: The value can be written to the attribute specified by
  994. * attr_handle
  995. * - 0x01: The value cannot be written to the attribute specified by the
  996. * attr_handle
  997. * @param Error_Code The error code that has to be passed to the client in case
  998. * the write has to be rejected
  999. * @param Attribute_Val_Length Length of the value to be written as passed in
  1000. * the event ACI_GATT_WRITE_PERMIT_REQ_EVENT
  1001. * @param Attribute_Val Value as passed in the event
  1002. * ACI_GATT_WRITE_PERMIT_REQ_EVENT
  1003. * @return Value indicating success or error code.
  1004. */
  1005. tBleStatus aci_gatt_write_resp(
  1006. uint16_t Connection_Handle,
  1007. uint16_t Attr_Handle,
  1008. uint8_t Write_status,
  1009. uint8_t Error_Code,
  1010. uint8_t Attribute_Val_Length,
  1011. const uint8_t* Attribute_Val);
  1012. /**
  1013. * @brief ACI_GATT_ALLOW_READ
  1014. * Allow the GATT server to send a response to a read request from a client.
  1015. * The application has to send this command when it receives the
  1016. * ACI_GATT_READ_PERMIT_REQ_EVENT or ACI_GATT_READ_MULTI_PERMIT_REQ_EVENT. This
  1017. * command indicates to the stack that the response can be sent to the client.
  1018. * So if the application wishes to update any of the attributes before they are
  1019. * read by the client, it must update the characteristic values using the
  1020. * ACI_GATT_UPDATE_CHAR_VALUE and then give this command. The application
  1021. * should perform the required operations within 30 seconds. Otherwise the GATT
  1022. * procedure will be timeout.
  1023. *
  1024. * @param Connection_Handle Specifies the ATT bearer for which the command
  1025. * applies.
  1026. * Values:
  1027. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  1028. * connection handle)
  1029. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  1030. * parameter is the connection-oriented channel index)
  1031. * @return Value indicating success or error code.
  1032. */
  1033. tBleStatus aci_gatt_allow_read(uint16_t Connection_Handle);
  1034. /**
  1035. * @brief ACI_GATT_SET_SECURITY_PERMISSION
  1036. * This command sets the security permission for the attribute handle
  1037. * specified. It is allowed only for the Client Characteristic Configuration
  1038. * descriptor.
  1039. *
  1040. * @param Serv_Handle Handle of the service which contains the attribute whose
  1041. * security permission has to be modified
  1042. * @param Attr_Handle Handle of the attribute whose security permission has to
  1043. * be modified
  1044. * @param Security_Permissions Security permission flags.
  1045. * Flags:
  1046. * - 0x00: None
  1047. * - 0x01: AUTHEN_READ (Need authentication to read)
  1048. * - 0x02: AUTHOR_READ (Need authorization to read)
  1049. * - 0x04: ENCRY_READ (Need encryption to read)
  1050. * - 0x08: AUTHEN_WRITE (need authentication to write)
  1051. * - 0x10: AUTHOR_WRITE (need authorization to write)
  1052. * - 0x20: ENCRY_WRITE (need encryption to write)
  1053. * @return Value indicating success or error code.
  1054. */
  1055. tBleStatus aci_gatt_set_security_permission(
  1056. uint16_t Serv_Handle,
  1057. uint16_t Attr_Handle,
  1058. uint8_t Security_Permissions);
  1059. /**
  1060. * @brief ACI_GATT_SET_DESC_VALUE
  1061. * This command sets the value of the descriptor specified by Char_Desc_Handle.
  1062. *
  1063. * @param Serv_Handle Handle of the service which contains the characteristic
  1064. * descriptor
  1065. * @param Char_Handle Handle of the characteristic which contains the
  1066. * descriptor
  1067. * @param Char_Desc_Handle Handle of the descriptor whose value has to be set
  1068. * @param Val_Offset Offset from which the descriptor value has to be updated
  1069. * @param Char_Desc_Value_Length Length of the descriptor value
  1070. * @param Char_Desc_Value Descriptor value
  1071. * @return Value indicating success or error code.
  1072. */
  1073. tBleStatus aci_gatt_set_desc_value(
  1074. uint16_t Serv_Handle,
  1075. uint16_t Char_Handle,
  1076. uint16_t Char_Desc_Handle,
  1077. uint16_t Val_Offset,
  1078. uint8_t Char_Desc_Value_Length,
  1079. const uint8_t* Char_Desc_Value);
  1080. /**
  1081. * @brief ACI_GATT_READ_HANDLE_VALUE
  1082. * Reads the value of the attribute handle specified from the local GATT
  1083. * database.
  1084. *
  1085. * @param Attr_Handle Handle of the attribute to read
  1086. * @param Offset Offset from which the value needs to be read
  1087. * @param Value_Length_Requested Maximum number of octets to be returned as
  1088. * attribute value
  1089. * @param[out] Length Length of the attribute value
  1090. * @param[out] Value_Length Length in octets of the Value parameter
  1091. * @param[out] Value Attribute value
  1092. * @return Value indicating success or error code.
  1093. */
  1094. tBleStatus aci_gatt_read_handle_value(
  1095. uint16_t Attr_Handle,
  1096. uint16_t Offset,
  1097. uint16_t Value_Length_Requested,
  1098. uint16_t* Length,
  1099. uint16_t* Value_Length,
  1100. uint8_t* Value);
  1101. /**
  1102. * @brief ACI_GATT_UPDATE_CHAR_VALUE_EXT
  1103. * This command is a more flexible version of ACI_GATT_UPDATE_CHAR_VALUE to
  1104. * support update of long attribute up to 512 bytes and indicate selectively
  1105. * the generation of Indication/Notification.
  1106. * The description notes for the ACI_GATT_UPDATE_CHAR_VALUE command also apply
  1107. * here.
  1108. *
  1109. * @param Conn_Handle_To_Notify Specifies the client(s) to be notified.
  1110. * Values:
  1111. * - 0x0000: Notify all subscribed clients on their unenhanced ATT
  1112. * bearer
  1113. * - 0x0001 ... 0x0EFF: Notify one client on the specified unenhanced
  1114. * ATT bearer (the parameter is the connection handle)
  1115. * - 0xEA00 ... 0xEA3F: Notify one client on the specified enhanced ATT
  1116. * bearer (the LSB-byte of the parameter is the connection-oriented
  1117. * channel index)
  1118. * @param Service_Handle Handle of service to which the characteristic belongs
  1119. * @param Char_Handle Handle of the characteristic declaration
  1120. * @param Update_Type Allow Notification or Indication generation, if enabled
  1121. * in the client characteristic configuration descriptor
  1122. * Flags:
  1123. * - 0x00: Do not notify
  1124. * - 0x01: Notification
  1125. * - 0x02: Indication
  1126. * @param Char_Length Total length of the characteristic value.
  1127. * In case of a variable size characteristic, this field specifies the
  1128. * new length of the characteristic value after the update; in case of
  1129. * fixed length characteristic this field is ignored.
  1130. * @param Value_Offset The offset from which the attribute value has to be
  1131. * updated.
  1132. * @param Value_Length Length of the Value parameter in octets.
  1133. * On STM32WB, this value must not exceed (BLE_CMD_MAX_PARAM_LEN - 12)
  1134. * i.e. 243 for BLE_CMD_MAX_PARAM_LEN default value.
  1135. * @param Value Updated characteristic value
  1136. * @return Value indicating success or error code.
  1137. */
  1138. tBleStatus aci_gatt_update_char_value_ext(
  1139. uint16_t Conn_Handle_To_Notify,
  1140. uint16_t Service_Handle,
  1141. uint16_t Char_Handle,
  1142. uint8_t Update_Type,
  1143. uint16_t Char_Length,
  1144. uint16_t Value_Offset,
  1145. uint8_t Value_Length,
  1146. const uint8_t* Value);
  1147. /**
  1148. * @brief ACI_GATT_DENY_READ
  1149. * This command is used to deny the GATT server to send a response to a read
  1150. * request from a client.
  1151. * The application may send this command when it receives the
  1152. * ACI_GATT_READ_PERMIT_REQ_EVENT or ACI_GATT_READ_MULTI_PERMIT_REQ_EVENT.
  1153. * This command indicates to the stack that the client is not allowed to read
  1154. * the requested characteristic due to e.g. application restrictions.
  1155. * The Error code shall be either 0x08 (Insufficient Authorization) or a value
  1156. * in the range 0x80-0x9F (Application Error).
  1157. * The application should issue the ACI_GATT_DENY_READ or ACI_GATT_ALLOW_READ
  1158. * command within 30 seconds from the reception of the
  1159. * ACI_GATT_READ_PERMIT_REQ_EVENT or ACI_GATT_READ_MULTI_PERMIT_REQ_EVENT
  1160. * events; otherwise the GATT procedure issues a timeout.
  1161. *
  1162. * @param Connection_Handle Specifies the ATT bearer for which the command
  1163. * applies.
  1164. * Values:
  1165. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  1166. * connection handle)
  1167. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  1168. * parameter is the connection-oriented channel index)
  1169. * @param Error_Code Error code for the command
  1170. * Values:
  1171. * - 0x08: Insufficient Authorization
  1172. * - 0x80 ... 0x9F: Application Error
  1173. * @return Value indicating success or error code.
  1174. */
  1175. tBleStatus aci_gatt_deny_read(uint16_t Connection_Handle, uint8_t Error_Code);
  1176. /**
  1177. * @brief ACI_GATT_SET_ACCESS_PERMISSION
  1178. * This command sets the access permission for the attribute handle specified.
  1179. *
  1180. * @param Serv_Handle Handle of the service which contains the attribute whose
  1181. * access permission has to be modified
  1182. * @param Attr_Handle Handle of the attribute whose security permission has to
  1183. * be modified
  1184. * @param Access_Permissions Access permission
  1185. * Flags:
  1186. * - 0x00: None
  1187. * - 0x01: READ
  1188. * - 0x02: WRITE
  1189. * - 0x04: WRITE_WO_RESP
  1190. * - 0x08: SIGNED_WRITE
  1191. * @return Value indicating success or error code.
  1192. */
  1193. tBleStatus aci_gatt_set_access_permission(
  1194. uint16_t Serv_Handle,
  1195. uint16_t Attr_Handle,
  1196. uint8_t Access_Permissions);
  1197. /**
  1198. * @brief ACI_GATT_STORE_DB
  1199. * This command forces the saving of the GATT database for all active
  1200. * connections. Note that, by default, the GATT database is saved per active
  1201. * connection at the time of disconnection.
  1202. *
  1203. * @return Value indicating success or error code.
  1204. */
  1205. tBleStatus aci_gatt_store_db(void);
  1206. /**
  1207. * @brief ACI_GATT_SEND_MULT_NOTIFICATION
  1208. * This command sends a Multiple Handle Value Notification over the ATT bearer
  1209. * specified in parameter. The handles provided as parameters must be the
  1210. * handles of the characteristic declarations.
  1211. *
  1212. * @param Connection_Handle Specifies the ATT bearer for which the command
  1213. * applies.
  1214. * Values:
  1215. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  1216. * connection handle)
  1217. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  1218. * parameter is the connection-oriented channel index)
  1219. * @param Number_of_Handles Number of handles in the following table
  1220. * Values:
  1221. * - 0x02 ... 0x7E
  1222. * @param Handle_Entry See @ref Handle_Entry_t
  1223. * @return Value indicating success or error code.
  1224. */
  1225. tBleStatus aci_gatt_send_mult_notification(
  1226. uint16_t Connection_Handle,
  1227. uint8_t Number_of_Handles,
  1228. const Handle_Entry_t* Handle_Entry);
  1229. /**
  1230. * @brief ACI_GATT_READ_MULTIPLE_VAR_CHAR_VALUE
  1231. * Starts a procedure to read multiple variable length characteristic values
  1232. * from a server.
  1233. * The command must specify the handles of the characteristic values to be
  1234. * read.
  1235. * When the procedure is completed, a ACI_GATT_PROC_COMPLETE_EVENT event is
  1236. * generated. Before procedure completion the response packets are given
  1237. * through ACI_ATT_READ_MULTIPLE_RESP_EVENT event.
  1238. *
  1239. * @param Connection_Handle Specifies the ATT bearer for which the command
  1240. * applies.
  1241. * Values:
  1242. * - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
  1243. * connection handle)
  1244. * - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
  1245. * parameter is the connection-oriented channel index)
  1246. * @param Number_of_Handles Number of handles in the following table
  1247. * Values:
  1248. * - 0x02 ... 0x7E
  1249. * @param Handle_Entry See @ref Handle_Entry_t
  1250. * @return Value indicating success or error code.
  1251. */
  1252. tBleStatus aci_gatt_read_multiple_var_char_value(
  1253. uint16_t Connection_Handle,
  1254. uint8_t Number_of_Handles,
  1255. const Handle_Entry_t* Handle_Entry);
  1256. #endif /* BLE_GATT_ACI_H__ */