@@ -1752,6 +1752,53 @@ static void cmd_exp_debug(int argc, char **argv)
}
}
+static void print_mgmt_tlv(void *data, void *user_data)
+{
+ const struct mgmt_tlv *entry = data;
+ char buf[256];
+
+ bin2hex(entry->value, entry->length, buf, sizeof(buf));
+ print("Type: 0x%04x\tLength: %02hhu\tValue: %s", entry->type,
+ entry->length, buf);
+}
+
+static void read_sysconfig_rsp(uint8_t status, uint16_t len, const void *param,
+ void *user_data)
+{
+ struct mgmt_tlv_list *tlv_list;
+ struct mgmt_tlv *entry;
+
+ if (status != 0) {
+ error("Read system configuration failed with status "
+ "0x%02x (%s)", status, mgmt_errstr(status));
+ return;
+ }
+
+ tlv_list = mgmt_tlv_list_load_from_buf(param, len);
+ if (!tlv_list) {
+ error("Unable to parse response of read system configuration");
+ return;
+ }
+
+ mgmt_tlv_list_foreach(tlv_list, print_mgmt_tlv, NULL);
+ mgmt_tlv_list_free(tlv_list);
+}
+
+static void cmd_read_sysconfig(int argc, char **argv)
+{
+ uint16_t index;
+
+ index = mgmt_index;
+ if (index == MGMT_INDEX_NONE)
+ index = 0;
+
+ if (!mgmt_send(mgmt, MGMT_OP_READ_DEF_SYSTEM_CONFIG, index,
+ 0, NULL, read_sysconfig_rsp, NULL, NULL)) {
+ error("Unable to send read system configuration cmd");
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+}
+
static void auto_power_enable_rsp(uint8_t status, uint16_t len,
const void *param, void *user_data)
{
@@ -5030,6 +5077,8 @@ static const struct bt_shell_menu main_menu = {
cmd_expinfo, "Show experimental features" },
{ "exp-debug", "<on/off>",
cmd_exp_debug, "Set debug feature" },
+ { "read-sysconfig", NULL,
+ cmd_read_sysconfig, "Read System Configuration" },
{} },
};
Add command read-sysconfig in btmgmt Example usage: localhost ~ # btmgmt [mgmt]# read-sysconfig Type: 0x0000 Length: 02 Value: 0000 Type: 0x0001 Length: 02 Value: 0008 ... Type: 0x001f Length: 01 Value: 01 Reviewed-by: apusaka@chromium.org --- (no changes since v1) tools/btmgmt.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)