Bluetooth: shell: Add connection type information to connections command
This prints information about the role and id along with connection parameters in case the connection is of LE type. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
fc9b7e62f0
commit
2a99d80403
1 changed files with 41 additions and 2 deletions
|
@ -2429,13 +2429,52 @@ static int cmd_bonds(const struct shell *shell, size_t argc, char *argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *role_str(uint8_t role)
|
||||||
|
{
|
||||||
|
switch (role) {
|
||||||
|
case BT_CONN_ROLE_MASTER:
|
||||||
|
return "Master";
|
||||||
|
case BT_CONN_ROLE_SLAVE:
|
||||||
|
return "Slave";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
static void connection_info(struct bt_conn *conn, void *user_data)
|
static void connection_info(struct bt_conn *conn, void *user_data)
|
||||||
{
|
{
|
||||||
char addr[BT_ADDR_LE_STR_LEN];
|
char addr[BT_ADDR_LE_STR_LEN];
|
||||||
int *conn_count = user_data;
|
int *conn_count = user_data;
|
||||||
|
struct bt_conn_info info;
|
||||||
|
|
||||||
|
if (bt_conn_get_info(conn, &info) < 0) {
|
||||||
|
shell_error(ctx_shell, "Unable to get info: conn %p", conn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (info.type) {
|
||||||
|
#if defined(CONFIG_BT_BREDR)
|
||||||
|
case BT_CONN_TYPE_BR:
|
||||||
|
bt_addr_to_str(info.br.dst, addr, sizeof(addr));
|
||||||
|
shell_print(ctx_shell, "#%u [BR][%s] %s", info.id,
|
||||||
|
role_str(info.role), addr);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case BT_CONN_TYPE_LE:
|
||||||
|
bt_addr_le_to_str(info.le.dst, addr, sizeof(addr));
|
||||||
|
shell_print(ctx_shell, "#%u [LE][%s] %s: Interval %u latency %u"
|
||||||
|
" timeout %u", info.id, role_str(info.role), addr,
|
||||||
|
info.le.interval, info.le.latency, info.le.timeout);
|
||||||
|
break;
|
||||||
|
#if defined(CONFIG_BT_ISO)
|
||||||
|
case BT_CONN_TYPE_ISO:
|
||||||
|
bt_addr_le_to_str(info.le.dst, addr, sizeof(addr));
|
||||||
|
shell_print(ctx_shell, "#%u [ISO][%s] %s", info.id,
|
||||||
|
role_str(info.role), addr);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
conn_addr_str(conn, addr, sizeof(addr));
|
|
||||||
shell_print(ctx_shell, "Remote Identity: %s", addr);
|
|
||||||
(*conn_count)++;
|
(*conn_count)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue