From 59f3c86802efc58a45d0c16f740f7b5901023f5e Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Sat, 14 Dec 2024 07:19:35 +0100 Subject: [PATCH] samples: Bluetooth: central multilink get version info Update central multilink sample to get version info to verify actual data transmissions will succeed, and there is no disconnect with reason connection fail to be established. Signed-off-by: Vinayak Kariappa Chettimada --- .../central_multilink/src/central_multilink.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/samples/bluetooth/central_multilink/src/central_multilink.c b/samples/bluetooth/central_multilink/src/central_multilink.c index c36783f47ec..537b323efa4 100644 --- a/samples/bluetooth/central_multilink/src/central_multilink.c +++ b/samples/bluetooth/central_multilink/src/central_multilink.c @@ -281,6 +281,27 @@ static struct bt_conn_cb conn_callbacks = { #endif /* CONFIG_BT_USER_DATA_LEN_UPDATE */ }; +static void remote_info(struct bt_conn *conn, void *data) +{ + struct bt_conn_remote_info remote_info; + char addr[BT_ADDR_LE_STR_LEN]; + int err; + + bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); + + printk("Get remote info %s...\n", addr); + err = bt_conn_get_remote_info(conn, &remote_info); + if (err) { + printk("Failed remote info %s.\n", addr); + return; + } + printk("success.\n"); + + uint8_t *actual_count = (void *)data; + + (*actual_count)++; +} + static void disconnect(struct bt_conn *conn, void *data) { char addr[BT_ADDR_LE_STR_LEN]; @@ -322,6 +343,18 @@ int init_central(uint8_t max_conn, uint8_t iterations) is_disconnecting = true; + /* Let us perform version exchange on all connections to ensure + * there is actual communication. + */ + uint8_t actual_count = 0U; + + bt_conn_foreach(BT_CONN_TYPE_LE, remote_info, &actual_count); + if (actual_count < conn_count_max) { + k_sleep(K_MSEC(10)); + + continue; + } + /* Lets wait sufficiently to ensure a stable connection * before starting to disconnect for next iteration. */