@@ -1216,10 +1216,22 @@ struct bt_gatt_exchange_params {
12161216 *
12171217 * @note Shall only be used once per connection.
12181218 *
1219+ * The Response comes in callback @p params->func. The callback is run from
1220+ * the BT RX thread. @p params must remain valid until start of callback.
1221+ *
1222+ * This function will block while the ATT request queue is full, except when
1223+ * called from the BT RX thread, as this would cause a deadlock.
1224+ *
12191225 * @param conn Connection object.
12201226 * @param params Exchange MTU parameters.
12211227 *
1222- * @return 0 in case of success or negative value in case of error.
1228+ * @retval 0 Successfully queued request. Will call @p params->func on
1229+ * resolution.
1230+ *
1231+ * @retval -ENOMEM ATT request queue is full and blocking would cause deadlock.
1232+ * Allow a pending request to resolve before retrying, or call this function
1233+ * outside the BT RX thread to get blocking behavior. Queue size is controlled
1234+ * by @kconfig{CONFIG_BT_L2CAP_TX_BUF_COUNT}.
12231235 */
12241236int bt_gatt_exchange_mtu (struct bt_conn * conn ,
12251237 struct bt_gatt_exchange_params * params );
@@ -1348,13 +1360,23 @@ struct bt_gatt_discover_params {
13481360 * For each attribute found the callback is called which can then decide
13491361 * whether to continue discovering or stop.
13501362 *
1351- * @note This procedure is asynchronous therefore the parameters need to
1352- * remains valid while it is active.
1363+ * The Response comes in callback @p params->func. The callback is run from
1364+ * the BT RX thread. @p params must remain valid until start of callback where
1365+ * iter `attr` is `NULL` or callback will return `BT_GATT_ITER_STOP`.
1366+ *
1367+ * This function will block while the ATT request queue is full, except when
1368+ * called from the BT RX thread, as this would cause a deadlock.
13531369 *
13541370 * @param conn Connection object.
13551371 * @param params Discover parameters.
13561372 *
1357- * @return 0 in case of success or negative value in case of error.
1373+ * @retval 0 Successfully queued request. Will call @p params->func on
1374+ * resolution.
1375+ *
1376+ * @retval -ENOMEM ATT request queue is full and blocking would cause deadlock.
1377+ * Allow a pending request to resolve before retrying, or call this function
1378+ * outside the BT RX thread to get blocking behavior. Queue size is controlled
1379+ * by @kconfig{CONFIG_BT_L2CAP_TX_BUF_COUNT}.
13581380 */
13591381int bt_gatt_discover (struct bt_conn * conn ,
13601382 struct bt_gatt_discover_params * params );
@@ -1433,13 +1455,22 @@ struct bt_gatt_read_params {
14331455 * caller will need to read the remaining data separately using the handle and
14341456 * offset.
14351457 *
1436- * @note This procedure is asynchronous therefore the parameters need to
1437- * remains valid while it is active.
1458+ * The Response comes in callback @p params->func. The callback is run from
1459+ * the BT RX thread. @p params must remain valid until start of callback.
1460+ *
1461+ * This function will block while the ATT request queue is full, except when
1462+ * called from the BT RX thread, as this would cause a deadlock.
14381463 *
14391464 * @param conn Connection object.
14401465 * @param params Read parameters.
14411466 *
1442- * @return 0 in case of success or negative value in case of error.
1467+ * @retval 0 Successfully queued request. Will call @p params->func on
1468+ * resolution.
1469+ *
1470+ * @retval -ENOMEM ATT request queue is full and blocking would cause deadlock.
1471+ * Allow a pending request to resolve before retrying, or call this function
1472+ * outside the BT RX thread to get blocking behavior. Queue size is controlled
1473+ * by @kconfig{CONFIG_BT_L2CAP_TX_BUF_COUNT}.
14431474 */
14441475int bt_gatt_read (struct bt_conn * conn , struct bt_gatt_read_params * params );
14451476
@@ -1471,16 +1502,24 @@ struct bt_gatt_write_params {
14711502
14721503/** @brief Write Attribute Value by handle
14731504 *
1474- * This procedure write the attribute value and return the result in the
1475- * callback.
1505+ * The Response comes in callback @p params->func. The callback is run from
1506+ * the BT RX thread. @p params must remain valid until start of callback.
14761507 *
1477- * @note This procedure is asynchronous therefore the parameters need to
1478- * remains valid while it is active.
1508+ * This function will block while the ATT request queue is full, except when
1509+ * called from Bluetooth event context. When called from Bluetooth context,
1510+ * this function will instead instead return `-ENOMEM` if it would block to
1511+ * avoid a deadlock.
14791512 *
14801513 * @param conn Connection object.
14811514 * @param params Write parameters.
14821515 *
1483- * @return 0 in case of success or negative value in case of error.
1516+ * @retval 0 Successfully queued request. Will call @p params->func on
1517+ * resolution.
1518+ *
1519+ * @retval -ENOMEM ATT request queue is full and blocking would cause deadlock.
1520+ * Allow a pending request to resolve before retrying, or call this function
1521+ * outside Bluetooth event context to get blocking behavior. Queue size is
1522+ * controlled by @kconfig{CONFIG_BT_L2CAP_TX_BUF_COUNT}.
14841523 */
14851524int bt_gatt_write (struct bt_conn * conn , struct bt_gatt_write_params * params );
14861525
@@ -1495,13 +1534,15 @@ int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params);
14951534 * resources for the callback but instead return an error.
14961535 * The number of pending callbacks can be increased with the
14971536 * @kconfig{CONFIG_BT_CONN_TX_MAX} option.
1498-
14991537 *
15001538 * @note By using a callback it also disable the internal flow control
15011539 * which would prevent sending multiple commands without waiting for
15021540 * their transmissions to complete, so if that is required the caller
15031541 * shall not submit more data until the callback is called.
15041542 *
1543+ * This function will block while the ATT request queue is full, except when
1544+ * called from the BT RX thread, as this would cause a deadlock.
1545+ *
15051546 * @param conn Connection object.
15061547 * @param handle Attribute handle.
15071548 * @param data Data to be written.
@@ -1510,7 +1551,12 @@ int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params);
15101551 * @param func Transmission complete callback.
15111552 * @param user_data User data to be passed back to callback.
15121553 *
1513- * @return 0 in case of success or negative value in case of error.
1554+ * @retval 0 Successfully queued request.
1555+ *
1556+ * @retval -ENOMEM ATT request queue is full and blocking would cause deadlock.
1557+ * Allow a pending request to resolve before retrying, or call this function
1558+ * outside the BT RX thread to get blocking behavior. Queue size is controlled
1559+ * by @kconfig{CONFIG_BT_L2CAP_TX_BUF_COUNT}.
15141560 */
15151561int bt_gatt_write_without_response_cb (struct bt_conn * conn , uint16_t handle ,
15161562 const void * data , uint16_t length ,
@@ -1522,13 +1568,21 @@ int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle,
15221568 * This procedure write the attribute value without requiring an
15231569 * acknowledgment that the write was successfully performed
15241570 *
1571+ * This function will block while the ATT request queue is full, except when
1572+ * called from the BT RX thread, as this would cause a deadlock.
1573+ *
15251574 * @param conn Connection object.
15261575 * @param handle Attribute handle.
15271576 * @param data Data to be written.
15281577 * @param length Data length.
15291578 * @param sign Whether to sign data
15301579 *
1531- * @return 0 in case of success or negative value in case of error.
1580+ * @retval 0 Successfully queued request.
1581+ *
1582+ * @retval -ENOMEM ATT request queue is full and blocking would cause deadlock.
1583+ * Allow a pending request to resolve before retrying, or call this function
1584+ * outside the BT RX thread to get blocking behavior. Queue size is controlled
1585+ * by @kconfig{CONFIG_BT_L2CAP_TX_BUF_COUNT}.
15321586 */
15331587static inline int bt_gatt_write_without_response (struct bt_conn * conn ,
15341588 uint16_t handle , const void * data ,
@@ -1630,13 +1684,27 @@ struct bt_gatt_subscribe_params {
16301684 * this callback. Notification callback with NULL data will not be called if
16311685 * subscription was removed by this method.
16321686 *
1687+ * The Response comes in callback @p params->func. The callback is run from
1688+ * the BT RX thread. @p params must remain valid until start of callback.
1689+ * The Notification callback @p params->notify is also called from the BT RX
1690+ * thread.
1691+ *
16331692 * @note Notifications are asynchronous therefore the parameters need to
16341693 * remain valid while subscribed.
16351694 *
1695+ * This function will block while the ATT request queue is full, except when
1696+ * called from the BT RX thread, as this would cause a deadlock.
1697+ *
16361698 * @param conn Connection object.
16371699 * @param params Subscribe parameters.
16381700 *
1639- * @return 0 in case of success or negative value in case of error.
1701+ * @retval 0 Successfully queued request. Will call @p params->write on
1702+ * resolution.
1703+ *
1704+ * @retval -ENOMEM ATT request queue is full and blocking would cause deadlock.
1705+ * Allow a pending request to resolve before retrying, or call this function
1706+ * outside the BT RX thread to get blocking behavior. Queue size is controlled
1707+ * by @kconfig{CONFIG_BT_L2CAP_TX_BUF_COUNT}.
16401708 */
16411709int bt_gatt_subscribe (struct bt_conn * conn ,
16421710 struct bt_gatt_subscribe_params * params );
@@ -1667,10 +1735,22 @@ int bt_gatt_resubscribe(uint8_t id, const bt_addr_le_t *peer,
16671735 * will be called if subscription was removed by this call, until then the
16681736 * parameters cannot be reused.
16691737 *
1738+ * The Response comes in callback @p params->func. The callback is run from
1739+ * the BT RX thread.
1740+ *
1741+ * This function will block while the ATT request queue is full, except when
1742+ * called from the BT RX thread, as this would cause a deadlock.
1743+ *
16701744 * @param conn Connection object.
16711745 * @param params Subscribe parameters.
16721746 *
1673- * @return 0 in case of success or negative value in case of error.
1747+ * @retval 0 Successfully queued request. Will call @p params->write on
1748+ * resolution.
1749+ *
1750+ * @retval -ENOMEM ATT request queue is full and blocking would cause deadlock.
1751+ * Allow a pending request to resolve before retrying, or call this function
1752+ * outside the BT RX thread to get blocking behavior. Queue size is controlled
1753+ * by @kconfig{CONFIG_BT_L2CAP_TX_BUF_COUNT}.
16741754 */
16751755int bt_gatt_unsubscribe (struct bt_conn * conn ,
16761756 struct bt_gatt_subscribe_params * params );
0 commit comments