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);
{ "setDiscoverable", "(true|false) - whether the controller should be discoverable.", set_discoverable },
{ "setName", "<name> - sets the device's Bluetooth name to <name>.", 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) {
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]);