ble_gatt_aci.h 59 KB

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