From b27b7757d4993be1c553d5a7f16f03bd2ae32713 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 9 Nov 2012 12:05:24 +0200 Subject: [PATCH] mgmt: Remove peripheral setting It's still not decided how this will be exposed in the end but most likely it wont be through mgmt (e.g. socket-based enabling is a probable choice). --- doc/mgmt-api.txt | 13 +------------ lib/mgmt.h | 5 ----- monitor/control.c | 3 +-- src/mgmt.c | 8 ++++---- tools/btmgmt.c | 28 +--------------------------- 5 files changed, 7 insertions(+), 50 deletions(-) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 6fe0080a6..202c05505 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -141,7 +141,6 @@ Read Controller Information Command 8 Basic Rate/Enhanced Data Rate 9 High Speed 10 Low Energy - 11 Peripheral This command generates a Command Complete event on success or a Command Status event on failure. @@ -304,15 +303,9 @@ Set Low Energy Command Command Code: 0x000D Controller Index: - Command Parameters: Mode (1 Octet) + Command Parameters: Low_Energy (1 Octet) Return Parameters: Current_Settings (4 Octets) - Possible mode values: - - 0x00 Off - 0x01 Central - 0x02 Peripheral - This command can be used when the controller is not powered and all settings will be programmed once powered. @@ -322,10 +315,6 @@ Set Low Energy Command This command generates a Command Complete event on success or a Command Status event on failure. - Setting the mode to Central will enable the Low Energy bit in - the supported settings. Setting the mode to Peripheral will enable - both the Low Energy and the Peripheral settings bits. - Set Device Class ================ diff --git a/lib/mgmt.h b/lib/mgmt.h index f8a975263..6c7e44a51 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -92,7 +92,6 @@ struct mgmt_rp_read_index_list { #define MGMT_SETTING_BREDR 0x00000080 #define MGMT_SETTING_HS 0x00000100 #define MGMT_SETTING_LE 0x00000200 -#define MGMT_SETTING_PERIPHERAL 0x00000400 #define MGMT_OP_READ_INFO 0x0004 struct mgmt_rp_read_info { @@ -136,10 +135,6 @@ struct mgmt_cp_set_discoverable { #define MGMT_OP_SET_LE 0x000D -#define MGMT_LE_OFF 0x00 -#define MGMT_LE_CENTRAL 0x01 -#define MGMT_LE_PERIPHERAL 0x02 - #define MGMT_OP_SET_DEV_CLASS 0x000E struct mgmt_cp_set_dev_class { uint8_t major; diff --git a/monitor/control.c b/monitor/control.c index ae1a7ae56..92dc93ab0 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -100,8 +100,7 @@ static void mgmt_controller_error(uint16_t len, const void *buf) static const char *settings_str[] = { "powered", "connectable", "fast-connectable", "discoverable", - "pairable", "link-security", "ssp", "br/edr", "hs", "le", - "peripheral" + "pairable", "link-security", "ssp", "br/edr", "hs", "le" }; static void mgmt_new_settings(uint16_t len, const void *buf) diff --git a/src/mgmt.c b/src/mgmt.c index 8fe510039..18a653ef1 100644 --- a/src/mgmt.c +++ b/src/mgmt.c @@ -247,10 +247,10 @@ static int mgmt_set_ssp(int index, gboolean ssp) return mgmt_set_mode(index, MGMT_OP_SET_SSP, ssp); } -static int mgmt_set_low_energy(int index, uint8_t mode) +static int mgmt_set_low_energy(int index, gboolean le) { - DBG("index %d mode %d", index, mode); - return mgmt_set_mode(index, MGMT_OP_SET_LE, mode); + DBG("index %d le %d", index, le); + return mgmt_set_mode(index, MGMT_OP_SET_LE, le); } static inline int mgmt_powered(uint32_t settings) @@ -336,7 +336,7 @@ static void update_settings(struct btd_adapter *adapter, uint32_t settings) if (mgmt_low_energy(info->supported_settings) && !mgmt_low_energy(settings)) - mgmt_set_low_energy(index, MGMT_LE_CENTRAL); + mgmt_set_low_energy(index, TRUE); } static void mgmt_update_powered(struct btd_adapter *adapter, diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 0ae31695a..ff6a46a71 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -235,7 +235,6 @@ static const char *settings_str[] = { "br/edr", "hs", "le" , - "peripheral", }; static void print_settings(uint32_t settings) @@ -1109,32 +1108,7 @@ static void cmd_hs(int mgmt_sk, uint16_t index, int argc, char **argv) static void cmd_le(int mgmt_sk, uint16_t index, int argc, char **argv) { - uint8_t val; - - if (argc < 2) { - printf("Specify \"off\", \"central\" or \"peripheral\"\n"); - exit(EXIT_FAILURE); - } - - if (strcasecmp(argv[1], "on") == 0 || - strcasecmp(argv[1], "yes") == 0 || - strcasecmp(argv[1], "central") == 0) - val = MGMT_LE_CENTRAL; - else if (strcasecmp(argv[1], "peripheral") == 0) - val = MGMT_LE_PERIPHERAL; - else if (strcasecmp(argv[1], "off") == 0) - val = MGMT_LE_OFF; - else - val = atoi(argv[1]); - - if (index == MGMT_INDEX_NONE) - index = 0; - - if (mgmt_send_cmd(mgmt_sk, MGMT_OP_SET_LE, index, &val, sizeof(val), - setting_rsp, NULL) < 0) { - fprintf(stderr, "Unable to send set_le cmd\n"); - exit(EXIT_FAILURE); - } + cmd_setting(mgmt_sk, index, MGMT_OP_SET_LE, argc, argv); } static void class_rsp(int mgmt_sk, uint16_t op, uint16_t id, uint8_t status, -- 2.47.3