diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 202c055..63284e0 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
Command Code: 0x000D
Controller Index: <controller id>
- Command Parameters: Low_Energy (1 Octet)
+ Command Parameters: Mode (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.
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 6c7e44a..e196c78 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
#define MGMT_SETTING_BREDR 0x00000080
#define MGMT_SETTING_HS 0x00000100
#define MGMT_SETTING_LE 0x00000200
+#define MGMT_SETTING_LE_PERIPHERAL 0x00000400
#define MGMT_OP_READ_INFO 0x0004
struct mgmt_rp_read_info {
#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 c300ae9..a6dc086 100644
--- a/monitor/control.c
+++ b/monitor/control.c
static const char *settings_str[] = {
"powered", "connectable", "fast-connectable", "discoverable",
- "pairable", "link-security", "ssp", "br/edr", "hs", "le"
+ "pairable", "link-security", "ssp", "br/edr", "hs", "le",
+ "le-peripheral"
};
static void mgmt_new_settings(uint16_t len, const void *buf)
diff --git a/src/mgmt.c b/src/mgmt.c
index 627fb4b..bef66cd 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
return mgmt_set_mode(index, MGMT_OP_SET_SSP, ssp);
}
-static int mgmt_set_low_energy(int index, gboolean le)
+static int mgmt_set_low_energy(int index, uint8_t mode)
{
- DBG("index %d le %d", index, le);
- return mgmt_set_mode(index, MGMT_OP_SET_LE, le);
+ DBG("index %d mode %d", index, mode);
+ return mgmt_set_mode(index, MGMT_OP_SET_LE, mode);
}
static inline int mgmt_powered(uint32_t settings)
if (mgmt_low_energy(info->supported_settings) &&
!mgmt_low_energy(settings))
- mgmt_set_low_energy(index, TRUE);
+ mgmt_set_low_energy(index, MGMT_LE_CENTRAL);
}
static void mgmt_update_powered(struct btd_adapter *adapter,
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 2084b59..d20a966 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
"br/edr",
"hs",
"le" ,
+ "le-peripheral",
};
static void print_settings(uint32_t settings)
static void cmd_le(int mgmt_sk, uint16_t index, int argc, char **argv)
{
- cmd_setting(mgmt_sk, index, MGMT_OP_SET_LE, argc, 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);
+ }
}
static void class_rsp(int mgmt_sk, uint16_t op, uint16_t id, uint8_t status,