diff options
author | Joseph Hwang <josephsih@chromium.org> | 2021-07-15 17:50:18 +0800 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2021-07-20 11:05:05 -0700 |
commit | e0ea1c9c0d72fd4ee8a182098b23a3f859d81d35 (patch) | |
tree | b75055103ac4f2a9a38613ba097c9c288b17582e | |
parent | 7be40ec8438e4c220804bd900c152b42b843d10b (diff) | |
download | bluez-e0ea1c9c0d72fd4ee8a182098b23a3f859d81d35.tar.gz |
tools: btmgmt: support quality experiment feature command
This patch adds the "exp-quality" command to btmgmt to enable/disable
the Bluetooth quality report.
-rw-r--r-- | tools/btmgmt.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tools/btmgmt.c b/tools/btmgmt.c index a6ac026dc..7d9082381 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -1842,6 +1842,52 @@ static void cmd_exp_privacy(int argc, char **argv) } } +static void exp_quality_rsp(uint8_t status, uint16_t len, const void *param, + void *user_data) +{ + if (status != 0) + error("Set Quality Report feature failed: 0x%02x (%s)", + status, mgmt_errstr(status)); + else + print("Quality Report feature successfully set"); + + bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_exp_quality(int argc, char **argv) +{ + /* 330859bc-7506-492d-9370-9a6f0614037f */ + static const uint8_t uuid[16] = { + 0x7f, 0x03, 0x14, 0x06, 0x6f, 0x9a, 0x70, 0x93, + 0x2d, 0x49, 0x06, 0x75, 0xbc, 0x59, 0x08, 0x33, + }; + struct mgmt_cp_set_exp_feature cp; + uint8_t val; + + if (mgmt_index == MGMT_INDEX_NONE) { + error("BQR feature requires a valid controller index"); + return; + } + + if (parse_setting(argc, argv, &val) == false) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (val != 0 && val != 1) { + error("Invalid value %u", val); + return; + } + + memset(&cp, 0, sizeof(cp)); + memcpy(cp.uuid, uuid, 16); + cp.action = val; + + if (mgmt_send(mgmt, MGMT_OP_SET_EXP_FEATURE, mgmt_index, + sizeof(cp), &cp, exp_quality_rsp, NULL, NULL) == 0) { + error("Unable to send quality report feature cmd"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } +} + static void print_mgmt_tlv(void *data, void *user_data) { const struct mgmt_tlv *entry = data; @@ -5547,6 +5593,8 @@ static const struct bt_shell_menu main_menu = { cmd_exp_debug, "Set debug feature" }, { "exp-privacy", "<on/off>", cmd_exp_privacy, "Set LL privacy feature" }, + { "exp-quality", "<on/off>", cmd_exp_quality, + "Set bluetooth quality report feature" }, { "read-sysconfig", NULL, cmd_read_sysconfig, "Read System Configuration" }, { "set-sysconfig", "<-v|-h> [options...]", |