Permalink
Browse files

Add ledc command to hcitool

This command allows for low-level LE connections to be disconnected
by handle.
  • Loading branch information...
1 parent 57f39cd commit 65d1af240b5329139716eee9f373f0431f5dc1be Vinicius Costa Gomes committed Jul 13, 2010
Showing with 51 additions and 0 deletions.
  1. +51 −0 tools/hcitool.c
View
@@ -2538,6 +2538,56 @@ static void cmd_lecc(int dev_id, int argc, char **argv)
hci_close_dev(dd);
}
+static struct option ledc_options[] = {
+ { "help", 0, 0, 'h' },
+ { 0, 0, 0, 0 }
+};
+
+static const char *ledc_help =
+ "Usage:\n"
+ "\tledc <handle> [reason]\n";
+
+static void cmd_ledc(int dev_id, int argc, char **argv)
+{
+ int err, opt, dd;
+ uint16_t handle;
+ uint8_t reason;
+
+ for_each_opt(opt, ledc_options, NULL) {
+ switch (opt) {
+ default:
+ printf("%s", ledc_help);
+ return;
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 1) {
+ printf("%s", ledc_help);
+ return;
+ }
+
+ dd = hci_open_dev(dev_id);
+ if (dd < 0) {
+ perror("Could not open device");
+ exit(1);
+ }
+
+ handle = atoi(argv[0]);
+
+ reason = (argc > 1) ? atoi(argv[1]) : HCI_OE_USER_ENDED_CONNECTION;
+
+ err = hci_disconnect(dd, handle, reason, 10000);
+ if (err < 0) {
+ perror("Could not disconnect");
+ exit(1);
+ }
+
+ hci_close_dev(dd);
+}
+
static struct {
char *cmd;
void (*func)(int dev_id, int argc, char **argv);
@@ -2569,6 +2619,7 @@ static struct {
{ "clock", cmd_clock, "Read local or remote clock" },
{ "lescan", cmd_lescan, "Start LE scan" },
{ "lecc", cmd_lecc, "Create a LE Connection", },
+ { "ledc", cmd_ledc, "Disconnect a LE Connection", },
{ NULL, NULL, 0 }
};

0 comments on commit 65d1af2

Please sign in to comment.