aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAnderson Briglia <anderson.briglia@openbossa.org>2010-09-06 11:18:16 -0400
committerJohan Hedberg <johan.hedberg@nokia.com>2010-09-06 19:07:47 +0300
commit5ca342ccaa7385676b16612ba614e8d7f135676a (patch)
tree4d19637ee62628b3ad371e980d9659114ce13ea1 /tools
parent3a9811d70863b4922f26f70d8aa1a8eb77e41998 (diff)
downloadbluez-5ca342ccaa7385676b16612ba614e8d7f135676a.tar.gz
hciconfig: add LE_SET_ADVERTISE_ENABLE cmd
This patch implements two new hciconfig commands: leadv and noleadv. These new hciconfig flags are responsible to LE_SET_ADVERTISE_ENABLE command implementation.
Diffstat (limited to 'tools')
-rw-r--r--tools/hciconfig.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 87dd1270..3627b7ca 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -149,6 +149,44 @@ static void cmd_scan(int ctl, int hdev, char *opt)
}
}
+static void cmd_le_adv(int ctl, int hdev, char *opt)
+{
+ struct hci_request rq;
+ le_set_advertise_enable_cp advertise_cp;
+ uint8_t status;
+ int dd, ret;
+
+ if (hdev < 0)
+ hdev = hci_get_route(NULL);
+
+ dd = hci_open_dev(hdev);
+ if (dd < 0) {
+ perror("Could not open device");
+ exit(1);
+ }
+
+ memset(&advertise_cp, 0, sizeof(advertise_cp));
+ if (strcmp(opt, "noleadv") == 0)
+ advertise_cp.enable = 0x00;
+ else
+ advertise_cp.enable = 0x01;
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_LE_CTL;
+ rq.ocf = OCF_LE_SET_ADVERTISE_ENABLE;
+ rq.cparam = &advertise_cp;
+ rq.clen = LE_SET_ADVERTISE_ENABLE_CP_SIZE;
+ rq.rparam = &status;
+ rq.rlen = 1;
+
+ ret = hci_send_req(dd, &rq, 100);
+ if (status || ret < 0)
+ fprintf(stderr, "Can't set advertise mode on hci%d: %s (%d)\n",
+ hdev, strerror(errno), errno);
+
+ hci_close_dev(dd);
+}
+
static void cmd_iac(int ctl, int hdev, char *opt)
{
int s = hci_open_dev(hdev);
@@ -1728,6 +1766,8 @@ static struct {
{ "revision", cmd_revision, 0, "Display revision information" },
{ "block", cmd_block, "<bdaddr>", "Add a device to the blacklist" },
{ "unblock", cmd_unblock, "<bdaddr>", "Remove a device from the blacklist" },
+ { "leadv", cmd_le_adv, 0, "Enable LE advertising" },
+ { "noleadv", cmd_le_adv, 0, "Disable LE advertising" },
{ NULL, NULL, 0 }
};