Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp8941235pxu; Mon, 28 Dec 2020 02:07:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyprA472cH41Opd6VezeD9HUltgjuHhJLKY7JbYKNZWN4VuMU/1lSzkGOSuDsQh/Yxqenkg X-Received: by 2002:a17:906:1291:: with SMTP id k17mr41186463ejb.288.1609150066445; Mon, 28 Dec 2020 02:07:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609150066; cv=none; d=google.com; s=arc-20160816; b=d1rMbskuNkRzZ+so9J8dmj2KEVm+bkHJshuAGB0hIctgKVAD+0heSNDETsRyMsBuue qCw/ArR0MBfQdSOttC4N8YP9GsJVbROO1CRaxKPIZU5Sr38Kkx4GyIBOd7EYghL+Dmtk j2IKlPfZb5kgGt+W9/WU7IwR6E+0rADcIIKUjAiDUBcQRu3xXnSEA34qafG5Hv4Dh4mY AKrF6QAdni2M8CBsSGvKsAU9HdgXRGahiKgAUSdFW3BWqeBFYPonyYneCwzvxEB9qjSI MyYBZA1+6VNomge5Luxe6ymod4fWaVYsDi4tsmf4PBj6SiVtH64RXzP2eIjgzCCPOV0j 41zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=J2n6YIvt4zqJQtx4TNVo84THrt9CDungO41tQh0sK+g=; b=KIwQ1T2IFOQX2C0bLUxHQIiW5iU1brZxb1CCI8Jwb0Bb7+Em011fr+VcrklutHd63+ qkSAod5/MY+eBNx98Fj7ucZ2iDW6ZE+VieVMwogp2mjUl6WzvPI46BJSq0UiwnWysgz7 0lSdfPAzLjaUorJ2GTn7a36XDFx4LB92n/k6QiH0B1eXwKw2O4iBNShBh/kGNhZ2hprA Ky1i3gbCmFHv/spDtplidJg7JAS/tLrQt78ihumlEOdrvGn+1wdhHLHNjx6kU35F9wde 9HqyyPeex0f/+FE826VIGq5ZZhM+EtD1W0ACjqjV7ckhYkNNdLFFIZYwbIw/TN9fvdrk AYEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=F3FHdEaw; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s25si18247157ejz.414.2020.12.28.02.07.04; Mon, 28 Dec 2020 02:07:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=F3FHdEaw; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbgL1KFv (ORCPT + 99 others); Mon, 28 Dec 2020 05:05:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727094AbgL1KFv (ORCPT ); Mon, 28 Dec 2020 05:05:51 -0500 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EE6CC061795 for ; Mon, 28 Dec 2020 02:05:11 -0800 (PST) Received: by mail-qk1-x749.google.com with SMTP id x74so7762228qkb.12 for ; Mon, 28 Dec 2020 02:05:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=J2n6YIvt4zqJQtx4TNVo84THrt9CDungO41tQh0sK+g=; b=F3FHdEawCo80i2i9MW7UY5w4rH0BhVxOBWmGcGwr7NOny587TsXw2RuT+FnXcUk8jv 2Y9rwuIqJP0nNKGsb7ZetXh5iD9vn5VHS+2LtLUGwY7+iLi2Pkjv5NLTTYZSDat42+qz 8+KW+bY9AiTaI3hyf1FH+WGcW8I9lRezgGEKTE0RWYfj5j5V3KIIkiZHSIkf3BLy66VX 2YVi2prnZhuFtu4g0bQ+d1gOx8b6E0yJYntkLjnkqtYaXY8H/fOCTB/a0HhYZJmVoZHw P1Lrym+G/GPWv9Q9NsGqIOt2fRl2jc7dwxQ62J/EQvBPR2tAvdvgCmnIBRTFSyFFNIk9 CbYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=J2n6YIvt4zqJQtx4TNVo84THrt9CDungO41tQh0sK+g=; b=FkWCnucbW67iYIZx4Vs6sDQzGQ4dB2N4HvElHUxuHv6PJo+50WH+KcPfqnqg2VFYXh F15S26Lo9N7sKNmxy0siSVu6qLW/DnreW6PieqP3jsnrNiQmWedT7uEupQfxa+RtvCve t7ZIqodBp1HifcPC+ZGFuaUKJgHoz8Zk7YKy9M+mG257kz/2H5i9PVJ8nLDfuwpURfd0 efVV9lAMFNqpwuMBztXKrys3Xs8LzYVHLqnSL8PtUKWrbJgVdYfsiWz3TWTQuXSVoo7w 2AP5MQBPZijJhya4PsV3QEHHtSGsommESHQoOt2d1rHBwX8NDRmJ3tPLFuJjmUydUmDR 6Fbg== X-Gm-Message-State: AOAM532EWXiCPvUfkuYSj1+6PCoj701MnvVVzz2vlxOHoGXY0sr1Gu2Q 5ptwE73SViFM/OiQnMpHylaPDV5L4FkLa9LoLRgldtZkRVsKD0K5D7QrZjjGS3VrJB11T4Upcqy ggI7ET9IerxOUOHQMa/bRIADRp6bdQE7+LdFkCM9RLW3PmkhFG68g4HHC9N9wsXNWiB0A3IUqCj sJub7VhMqkrwg= Sender: "howardchung via sendgmr" X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:fd8f:: with SMTP id p15mr37474076qvr.48.1609149910290; Mon, 28 Dec 2020 02:05:10 -0800 (PST) Date: Mon, 28 Dec 2020 18:04:56 +0800 In-Reply-To: <20201228180429.Bluez.v2.1.Ie32770d0eed2e7739ce9d17d920766fb6aee8583@changeid> Message-Id: <20201228180429.Bluez.v2.2.I0c07c297925f838138b42674ab244572e6ea361b@changeid> Mime-Version: 1.0 References: <20201228180429.Bluez.v2.1.Ie32770d0eed2e7739ce9d17d920766fb6aee8583@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog Subject: [Bluez PATCH v2 2/4] btmgmt: Add command read-sysconfig From: Howard Chung To: linux-bluetooth , luiz.dentz@gmail.com Cc: mcchou@chromium.org, mmandlik@chromium.org, apusaka@chromium.org, Howard Chung Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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(+) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 2f7cb2efcc38..c766de862a12 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -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", "", cmd_exp_debug, "Set debug feature" }, + { "read-sysconfig", NULL, + cmd_read_sysconfig, "Read System Configuration" }, {} }, }; -- 2.29.2.729.g45daf8777d-goog