summaryrefslogtreecommitdiff
path: root/tools/bluemoon.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2015-01-28 14:53:43 -0800
committerMarcel Holtmann <marcel@holtmann.org>2015-01-28 14:53:43 -0800
commit93171e386c0f31866c685c96bfe03f4208a6a865 (patch)
tree8d74363e148c2b0509b3952ed01ca5fc99f3ade3 /tools/bluemoon.c
parentc392b9bc820824da9f0ec38ddafb8d0f36f6f0a5 (diff)
downloadbluez-93171e386c0f31866c685c96bfe03f4208a6a865.tar.gz
tools: Add --raw option for bluemoon utility for active controllers
Diffstat (limited to 'tools/bluemoon.c')
-rw-r--r--tools/bluemoon.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/tools/bluemoon.c b/tools/bluemoon.c
index 663d1f9c0..b7c51978e 100644
--- a/tools/bluemoon.c
+++ b/tools/bluemoon.c
@@ -886,6 +886,7 @@ static const struct option main_options[] = {
{ "reset", no_argument, NULL, 'R' },
{ "coldboot", no_argument, NULL, 'B' },
{ "index", required_argument, NULL, 'i' },
+ { "raw", no_argument, NULL, 'r' },
{ "version", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
{ }
@@ -894,13 +895,14 @@ static const struct option main_options[] = {
int main(int argc, char *argv[])
{
const char *str;
+ bool use_raw = false;
sigset_t mask;
int exit_status;
for (;;) {
int opt;
- opt = getopt_long(argc, argv, "A::DF::C:TRBi:vh",
+ opt = getopt_long(argc, argv, "A::DF::C:TREi:rvh",
main_options, NULL);
if (opt < 0)
break;
@@ -946,6 +948,9 @@ int main(int argc, char *argv[])
}
hci_index = atoi(str);
break;
+ case 'r':
+ use_raw = true;
+ break;
case 'v':
printf("%s\n", VERSION);
return EXIT_SUCCESS;
@@ -977,10 +982,18 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS;
}
- hci_dev = bt_hci_new_user_channel(hci_index);
- if (!hci_dev) {
- fprintf(stderr, "Failed to open HCI user channel\n");
- return EXIT_FAILURE;
+ if (use_raw) {
+ hci_dev = bt_hci_new_raw_device(hci_index);
+ if (!hci_dev) {
+ fprintf(stderr, "Failed to open HCI raw device\n");
+ return EXIT_FAILURE;
+ }
+ } else {
+ hci_dev = bt_hci_new_user_channel(hci_index);
+ if (!hci_dev) {
+ fprintf(stderr, "Failed to open HCI user channel\n");
+ return EXIT_FAILURE;
+ }
}
bt_hci_send(hci_dev, CMD_READ_VERSION, NULL, 0,