summaryrefslogtreecommitdiff
path: root/tools/bluemoon.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-01-14 03:12:51 -0800
committerMarcel Holtmann <marcel@holtmann.org>2014-01-14 03:14:38 -0800
commit6f10ace263deb93cd4bfb90126d13d08d1d5a630 (patch)
treeed014475586e0a73d1a917c8fe8c66fd9490b569 /tools/bluemoon.c
parent696645cef66727daa5769b0f387bc1bff9da15a6 (diff)
downloadbluez-6f10ace263deb93cd4bfb90126d13d08d1d5a630.tar.gz
tools: Add support activating/deactivating traces
Diffstat (limited to 'tools/bluemoon.c')
-rw-r--r--tools/bluemoon.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/tools/bluemoon.c b/tools/bluemoon.c
index b9e4dce77..2a969080c 100644
--- a/tools/bluemoon.c
+++ b/tools/bluemoon.c
@@ -84,6 +84,13 @@ struct cmd_write_bd_address {
uint8_t bdaddr[6];
} __attribute__ ((packed));
+#define CMD_ACT_DEACT_TRACES 0xfc43
+struct cmd_act_deact_traces {
+ uint8_t tx_trace;
+ uint8_t tx_arq;
+ uint8_t rx_trace;
+} __attribute__ ((packed));
+
static struct bt_hci *hci_dev;
static uint16_t hci_index = 0;
@@ -93,6 +100,7 @@ static const char *set_bdaddr_value = NULL;
static bool reset_on_exit = false;
static bool use_manufacturer_mode = false;
static bool get_bddata = false;
+static bool set_traces = false;
static void reset_complete(const void *data, uint8_t size, void *user_data)
{
@@ -204,6 +212,32 @@ static void read_bd_addr_complete(const void *data, uint8_t size,
write_bd_address_complete, NULL, NULL);
}
+static void act_deact_traces_complete(const void *data, uint8_t size,
+ void *user_data)
+{
+ uint8_t status = *((uint8_t *) data);
+
+ if (status) {
+ fprintf(stderr, "Failed to activate traces (0x%02x)\n", status);
+ shutdown_device();
+ return;
+ }
+
+ shutdown_device();
+}
+
+static void act_deact_traces(void)
+{
+ struct cmd_act_deact_traces cmd;
+
+ cmd.tx_trace = 0x03;
+ cmd.tx_arq = 0x03;
+ cmd.rx_trace = 0x03;
+
+ bt_hci_send(hci_dev, CMD_ACT_DEACT_TRACES, &cmd, sizeof(cmd),
+ act_deact_traces_complete, NULL, NULL);
+}
+
static void write_bd_data_complete(const void *data, uint8_t size,
void *user_data)
{
@@ -215,6 +249,11 @@ static void write_bd_data_complete(const void *data, uint8_t size,
return;
}
+ if (set_traces) {
+ act_deact_traces();
+ return;
+ }
+
shutdown_device();
}
@@ -284,6 +323,11 @@ static void enter_manufacturer_mode_complete(const void *data, uint8_t size,
return;
}
+ if (set_traces) {
+ act_deact_traces();
+ return;
+ }
+
shutdown_device();
}
@@ -406,6 +450,7 @@ static void usage(void)
static const struct option main_options[] = {
{ "bdaddr", optional_argument, NULL, 'A' },
{ "bddata", no_argument, NULL, 'D' },
+ { "traces", no_argument, NULL, 'T' },
{ "reset", no_argument, NULL, 'R' },
{ "index", required_argument, NULL, 'i' },
{ "version", no_argument, NULL, 'v' },
@@ -422,7 +467,7 @@ int main(int argc, char *argv[])
for (;;) {
int opt;
- opt = getopt_long(argc, argv, "A::DRi:vh", main_options, NULL);
+ opt = getopt_long(argc, argv, "A::DTRi:vh", main_options, NULL);
if (opt < 0)
break;
@@ -436,6 +481,10 @@ int main(int argc, char *argv[])
use_manufacturer_mode = true;
get_bddata = true;
break;
+ case 'T':
+ use_manufacturer_mode = true;
+ set_traces = true;
+ break;
case 'R':
reset_on_exit = true;
break;