From 6a42cbdb53d856a364a0c0fac28a732b55bc1cd9 Mon Sep 17 00:00:00 2001 From: Sharvil Nanavati Date: Thu, 16 Jul 2015 02:55:27 -0700 Subject: [PATCH] Add a SCO routing command to net_hci. This allows us to change the SCO routing parameters at runtime while debugging / doing device bringup. Change-Id: I8bafb7c7fb7ad7470d378cd14a7ee4aad63f3b9b --- tools/hci/main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/hci/main.c b/tools/hci/main.c index fc433bcda..ae0640029 100644 --- a/tools/hci/main.c +++ b/tools/hci/main.c @@ -27,6 +27,7 @@ static int help(int argc, char **argv); static int set_discoverable(int argc, char **argv); static int set_name(int argc, char **argv); static int set_pcm_loopback(int argc, char **argv); +static int set_sco_route(int argc, char **argv); static bool write_hci_command(hci_packet_t type, const void *packet, size_t length); static const command_t *find_command(const char *name); @@ -37,6 +38,7 @@ static const command_t commands[] = { { "setDiscoverable", "(true|false) - whether the controller should be discoverable.", set_discoverable }, { "setName", " - sets the device's Bluetooth name to .", set_name }, { "setPcmLoopback", "(true|false) - enables or disables PCM loopback on the controller.", set_pcm_loopback }, + { "setScoRoute", "(pcm|i2s|uart) - sets the SCO packet route to one of the specified buses.", set_sco_route }, }; static int help(int argc, char **argv) { @@ -120,6 +122,31 @@ static int set_pcm_loopback(int argc, char **argv) { return !write_hci_command(HCI_PACKET_COMMAND, packet, ARRAY_SIZE(packet)); } +static int set_sco_route(int argc, char **argv) { + if (argc != 1) { + printf("SCO route parameter must be specified.\n"); + return 1; + } + + uint8_t route = 0xFF; + if (!strcmp(argv[0], "pcm")) + route = 0; + else if (!strcmp(argv[0], "i2s")) + route = 3; + else if (!strcmp(argv[0], "uart")) + route = 1; + + if (route == 0xFF) { + printf("Invalid SCO route specified: %s\n", argv[0]); + return 2; + } + + uint8_t packet[] = { 0x1C, 0xFC, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00 }; + packet[3] = route; + + return !write_hci_command(HCI_PACKET_COMMAND, packet, ARRAY_SIZE(packet)); +} + int main(int argc, char **argv) { if (argc < 2) { usage(argv[0]); -- 2.11.0