From 35a22bb989aa0856332c07bea568d1b5679297d4 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 2 Apr 2020 13:45:41 +0200 Subject: [PATCH] tools: Fix command for reading extended controller information --- tools/btmgmt.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 5da70ea2c..e40dbd199 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -1401,7 +1401,7 @@ static void ext_index_rsp(uint8_t status, uint16_t len, const void *param, void *user_data) { const struct mgmt_rp_read_ext_index_list *rp = param; - uint16_t count, index_filter = PTR_TO_UINT(user_data); + uint16_t count; unsigned int i; if (status != 0) { @@ -1430,9 +1430,6 @@ static void ext_index_rsp(uint8_t status, uint16_t len, const void *param, uint16_t index = le16_to_cpu(rp->entry[i].index); char *busstr = hci_bustostr(rp->entry[i].bus); - if (index_filter != MGMT_INDEX_NONE && index_filter != index) - continue; - switch (rp->entry[i].type) { case 0x00: print("Primary controller (hci%u,%s)", index, busstr); @@ -1471,13 +1468,23 @@ static void ext_index_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static void cmd_extinfo( - int argc, char **argv) +static void cmd_extinfo(int argc, char **argv) { - if (!mgmt_send(mgmt, MGMT_OP_READ_EXT_INDEX_LIST, - MGMT_INDEX_NONE, 0, NULL, - ext_index_rsp, UINT_TO_PTR(index), NULL)) { - error("Unable to send ext_index_list cmd"); + if (mgmt_index == MGMT_INDEX_NONE) { + if (!mgmt_send(mgmt, MGMT_OP_READ_EXT_INDEX_LIST, + MGMT_INDEX_NONE, 0, NULL, + ext_index_rsp, mgmt, NULL)) { + error("Unable to send ext_index_list cmd"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + return; + } + + if (!mgmt_send(mgmt, MGMT_OP_READ_EXT_INFO, mgmt_index, 0, NULL, + ext_info_rsp, + UINT_TO_PTR(mgmt_index), NULL)) { + error("Unable to send ext_read_info cmd"); return bt_shell_noninteractive_quit(EXIT_FAILURE); } } -- 2.47.3