Skip to content

Commit 9a63f9d

Browse files
alwa-nordicfabiobaltieri
authored andcommitted
Bluetooth: Host: Doc bt_conn_foreach includes disconnected
A user reported confusion about whether disconnected `bt_conn` are meant to be found by `bt_conn_foreach`. The confusion likely stems from the inprecise wording "existing connections". This commit doucments `bt_conn_foreach` as it is: A low-level API for iterating trough all `bt_conn` objects, connected or not. This commit also includes a warning about possibly unintutive behavior in preemptible threads. Fixes: #53996 Signed-off-by: Aleksander Wasaznik <[email protected]>
1 parent 98e280a commit 9a63f9d

File tree

1 file changed

+11
-1
lines changed
  • include/zephyr/bluetooth

1 file changed

+11
-1
lines changed

include/zephyr/bluetooth/conn.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,17 @@ struct bt_conn *bt_conn_ref(struct bt_conn *conn);
216216
*/
217217
void bt_conn_unref(struct bt_conn *conn);
218218

219-
/** @brief Iterate through all existing connections.
219+
/** @brief Iterate through all bt_conn objects.
220+
*
221+
* Iterates trough all bt_conn objects that are alive in the Host allocator.
222+
*
223+
* To find established connections, combine this with @ref bt_conn_get_info.
224+
* Check that @ref bt_conn_info.state is @ref BT_CONN_STATE_CONNECTED.
225+
*
226+
* Thread safety: This API is thread safe, but it does not guarantee a
227+
* sequentially-consistent view for objects allocated during the current
228+
* invocation of this API. E.g. If preempted while allocations A then B then C
229+
* happen then results may include A and C but miss B.
220230
*
221231
* @param type Connection Type
222232
* @param func Function to call for each connection.

0 commit comments

Comments
 (0)