Add new command unset-data for running the Unset Controller Data operation from MGMT API. --- tools/btmgmt.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 3ae0ecb..99f5562 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -1913,6 +1913,45 @@ static void cmd_set_data(int mgmt_sk, uint16_t index, int argc, char **argv) free(cp); } +static void unset_data_rsp(int mgmt_sk, uint16_t op, uint16_t id, + uint8_t status, void *rsp, uint16_t len, void *user_data) +{ + if (status != 0) { + fprintf(stderr, "%s failed, status 0x%02x (%s)\n", + mgmt_opstr(op), status, mgmt_errstr(status)); + exit(EXIT_FAILURE); + } + + exit(EXIT_SUCCESS); +} + +static void cmd_unset_data(int mgmt_sk, uint16_t index, int argc, char **argv) +{ + struct mgmt_cp_unset_controller_data cp; + + if (argc < 2) { + printf("Usage: btmgmt %s <data type>\n", argv[0]); + printf("\nexample: btmgmt %s 0xff\n", argv[0]); + printf("\nparameters:\n"); + printf("\t<data type>: 0x16 (service data) or 0xff\n" + "\t(manufacturer specific data).\n"); + + exit(EXIT_FAILURE); + } + + memset(&cp, 0, sizeof(cp)); + sscanf(argv[1], "%hhx", &cp.type); + + if (index == MGMT_INDEX_NONE) + index = 0; + + if (mgmt_send_cmd(mgmt_sk, MGMT_OP_UNSET_CONTROLLER_DATA, index, + &cp, sizeof(cp), unset_data_rsp, NULL) < 0) { + fprintf(stderr, "Unable to send unset controller data cmd\n"); + exit(EXIT_FAILURE); + } +} + static struct { char *cmd; void (*func)(int mgmt_sk, uint16_t index, int argc, char **argv); @@ -1947,6 +1986,7 @@ static struct { { "broadcaster",cmd_broadcaster,"Toggle Broadcaster Mode", }, { "observer", cmd_observer, "Toggle Observer Mode", }, { "set-data", cmd_set_data, "Set Controller Data", }, + { "unset-data", cmd_unset_data, "Unset Controller Data", }, { NULL, NULL, 0 } }; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html