summaryrefslogtreecommitdiffstats
path: root/tools/btconfig.c
blob: 0e25915c950040a7a70ca84fb164338cbe03e812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/** Bluetooth configuration for dream (debug only)  */

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/uio.h>
#include <unistd.h>

#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#include <bluetooth/sco.h>

int vendor_setup_pcm(int sock) {
    /* Use vendor-specific HCI commands to set up SCO over HCI pr PCM */
    int rc;
    unsigned char type = HCI_COMMAND_PKT;
    hci_command_hdr hdr;
    /* HCI_VS_Write_SCO_Configuration_Island3
    * This command is used to configure the codec interface paramters and
    * includes configuration of the PCM clock rate which is relevant when BT
    * core is generating the clock. This command MUST be used by the host in
    * order to use PCM interface.
    * */
    hdr.opcode = 0xFD06;
    unsigned char cmd[] = {
        0x00, 0x08,         // clock rate: 2048 kHz
        0x01,               // BRF6300 is input (slave)
        0x40, 0x1f, 00, 00, // frame sync frequency: 8kHz
        0x01, 00,           // frame sync duty cycle: 1 PCM clock
        0x01,               // frame sync edge: falling
        0x00,               // frame sync polarity: active high
        0x00,               // reserved
        // CHANNEL 1
        0x10, 0x00,         // out sample size: 16 bits
        0x00, 0x00,         // out sample offset in frame: 0 PCM clock cycle
        0x00,               // out edge: rising
        0x0E, 0x00,         // in sample size: 14 bits
        0x01, 0x00,         // in sample offset in frame: 1 PCM clock cycle
        0x00,               // in edge: rising
        0x00,               // reserved
        // CHANNEL 2  (not used)
        0x00, 0x00,
        0x00, 0x00,
        0x00,
        0x00, 0x00,
        0x00, 0x00,
        0x00,
        0x00,
        };
    hdr.plen = sizeof(cmd);
    struct iovec iov[] = {
       { &type, 1 },
       { &hdr, sizeof(hdr) },
       { &cmd, sizeof(cmd) },
    };
    int total_len = 1 + sizeof(hdr) + sizeof(cmd);
    errno = 0;
    rc = writev(sock, iov, sizeof(iov)/sizeof(iov[0]));
    if (rc != total_len) {
       printf("Can't write %d bytes (wrote %d) to HCI socket: %s (%d)!\n",
            total_len, rc, strerror(errno), errno);
       return -1;
    }
    return 0;
}

int vendor_status(int sock) {
    /* Use vendor-specific HCI command to get system status */
    int rc;
    unsigned char type = HCI_COMMAND_PKT;
    hci_command_hdr hdr;
    /* HCI_VS_Get_System_Status */
    hdr.opcode = 0xFE1F;
    unsigned char cmd[] = {};
    hdr.plen = sizeof(cmd);
    struct iovec iov[] = {
       { &type, 1 },
       { &hdr, sizeof(hdr) },
       { &cmd, sizeof(cmd) },
    };
    int total_len = 1 + sizeof(hdr) + sizeof(cmd);
    errno = 0;
    rc = writev(sock, iov, sizeof(iov)/sizeof(iov[0]));
    if (rc != total_len) {
       printf("Can't write %d bytes (wrote %d) to HCI socket: %s (%d)!\n",
            total_len, rc, strerror(errno), errno);
       return -1;
    }
    return 0;
}

int vendor_sleep(int sock, int enable) {
    /* Use vendor-specific HCI command to go into deep sleep mode */
    int rc;
    unsigned char type = HCI_COMMAND_PKT;
    hci_command_hdr hdr;
    /* HCI_VS_Sleep_Mode_Configuration */
    hdr.opcode = 0xFD0C;
    unsigned char cmd[] = {
        0x01,   // big sleep (1 enable)
        enable ? 0x01 : 0x00,   // deep sleep (1 enable)
        0x00,   // deep sleep protocol mode: HCILL
        0xFF,   // reserved
        0xFF,   // output pull: don't change
        0xFF,   // input pull: don't change
        0x00,   // reserved
        0x00,   // deep sleep timeouut: 0
    };
    hdr.plen = sizeof(cmd);
    struct iovec iov[] = {
       { &type, 1 },
       { &hdr, sizeof(hdr) },
       { &cmd, sizeof(cmd) },
    };
    int total_len = 1 + sizeof(hdr) + sizeof(cmd);
    errno = 0;
    rc = writev(sock, iov, sizeof(iov)/sizeof(iov[0]));
    if (rc != total_len) {
       printf("Can't write %d bytes (wrote %d) to HCI socket: %s (%d)!\n",
            total_len, rc, strerror(errno), errno);
       return -1;
    }
    return 0;
}

int vendor_uart_baudrate(int sock, uint32_t rate) {
    /* Use vendor-specific HCI command to set uart baud rate */
    int rc;
    unsigned char type = HCI_COMMAND_PKT;
    hci_command_hdr hdr;
    printf("Setting baud rate to %d\n", rate);
    /* HCI_VS_Sleep_Mode_Configuration */
    hdr.opcode = 0xFF36;
    hdr.plen = sizeof(rate);
    struct iovec iov[] = {
       { &type, 1 },
       { &hdr, sizeof(hdr) },
       { &rate, sizeof(rate) },
    };
    int total_len = 1 + sizeof(hdr) + sizeof(rate);
    errno = 0;
    rc = writev(sock, iov, sizeof(iov)/sizeof(iov[0]));
    if (rc != total_len) {
       printf("Can't write %d bytes (wrote %d) to HCI socket: %s (%d)!\n",
            total_len, rc, strerror(errno), errno);
       return -1;
    }
    return 0;
}

int vendor_setup_pcm2(int sock) {
   int rc;
   unsigned char type = HCI_COMMAND_PKT;
   hci_command_hdr hdr;
   // HCI_VS_Write_CODEC_Config_Enhanced_Island3
   hdr.opcode = 0xFD07;
   unsigned char cmd[] = {
       0x00,            // PCM clock shutdown: disabled
       0x00, 0x00,      // PCM clock start
       0x00, 0x00,      // PCM clock stop
       0x00,            // reserved
       // Channel 1
       0x04,            // din order: MSB first, don't swap bytes, shift sample
       0x04,            // dout order: MSB first, don't swap bytes, shift sample
       0x02,            // dout mode: Hi-Z when idle
       0x00,            // dout duplication: disabled
       0x00, 0x00, 0x00, 0x00, // tx_dup_value
       0x00,            // data quant: bitwise
       0x00,            // reserved
       // Channel 2
       0x00,            // din order
       0x00,            // dout order
       0x00,            // dout mode
       0x00,            // dout duplication
       0x00, 0x00, 0x00, 0x00, // tx_dup_value
       0x00,            // data quant
       0x00,            // reserved
    };
   hdr.plen = sizeof(cmd);
   struct iovec iov[] = {
       { &type, 1 },
       { &hdr, sizeof(hdr) },
       { &cmd, sizeof(cmd) },
   };
   int total_len = 1 + sizeof(hdr) + sizeof(cmd);
   errno = 0;
   rc = writev(sock, iov, sizeof(iov)/sizeof(iov[0]));
   if (rc != total_len) {
       printf("Can't write %d bytes (wrote %d) to HCI socket: %s (%d)!\n",
            total_len, rc, strerror(errno), errno);
       return -1;
   }
   return 0;
}

int vendor_coexist(int sock, int enable) {
    /* Use vendor-specific HCI command to set up WIFI coexistance*/
    int rc;
    unsigned char type = HCI_COMMAND_PKT;
    hci_command_hdr hdr;
    /* HCI_VS_Write_Wlan_Configuration */
    hdr.opcode = 0xFD1D;
    unsigned char cmd[] = {
        0x04,     // enable: SG2.0
        0x01,     // polarity: active high
        0xE9, 0x05, // priority: TDD, page, page scan, inquiry, inquiry scan, sniff, SCO/eSCO
        0x00, 0x00, // connection handle select
        0x00,     // connection handle: disable
        0x00,     // frequency mask: disable
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,  // freq mask: dont change
        0x04,     // wlan0 mux: IO14
        0x01,     // wlan0 input pull: enabled
        0x00,     // wlan1 mux: IO4
        0x01,     // wlan1 input pull: enabled
        0x02,     // wlan2 mux: IO3
        0x01,     // wlan2 input pull: enabled
        0x00,     // wlan3 mux: PA_OFF on IO1
        0xFF,     // wlan3 input pull: don't cahnge
        enable? 0x00 : 0x01,     // wlan interface: enable/disable
    };
    hdr.plen = sizeof(cmd);
    struct iovec iov[] = {
       { &type, 1 },
       { &hdr, sizeof(hdr) },
       { &cmd, sizeof(cmd) },
    };
    int total_len = 1 + sizeof(hdr) + sizeof(cmd);
    errno = 0;
    rc = writev(sock, iov, sizeof(iov)/sizeof(iov[0]));
    if (rc != total_len) {
       printf("Can't write %d bytes (wrote %d) to HCI socket: %s (%d)!\n",
            total_len, rc, strerror(errno), errno);
       return -1;
    }
    return 0;
}

int setup_loopback1(int sock) {
   int rc;
   unsigned char type = HCI_COMMAND_PKT;
   hci_command_hdr hdr;
   // HCI_VS_Set_PCM_Loopback_Configuration_Island3 (0xFD04)
   hdr.opcode = 0xFD04;
   unsigned char cmd[] = {
       0xFF, 0x00,      // delay: 255 frame's
   };
   hdr.plen = sizeof(cmd);
   struct iovec iov[] = {
       { &type, 1 },
       { &hdr, sizeof(hdr) },
       { &cmd, sizeof(cmd) },
   };
   int total_len = 1 + sizeof(hdr) + sizeof(cmd);
   errno = 0;
   rc = writev(sock, iov, sizeof(iov)/sizeof(iov[0]));
   if (rc != total_len) {
       printf("Can't write %d bytes (wrote %d) to HCI socket: %s (%d)!\n",
            total_len, rc, strerror(errno), errno);
       return -1;
   }
   return 0;
}

int setup_loopback2(int sock, int on) {
   int rc;
   unsigned char type = HCI_COMMAND_PKT;
   hci_command_hdr hdr;
   // HCI_VS_Set_PCM_Loopback_Enable (0xFE28)
   hdr.opcode = 0xFE28;
   printf("loopback %s\n", on ? "ON" : "OFF");
   unsigned char cmd[] = {
       on ? 0x01 : 0x00,  // enable
   };
   hdr.plen = sizeof(cmd);
   struct iovec iov[] = {
       { &type, 1 },
       { &hdr, sizeof(hdr) },
       { &cmd, sizeof(cmd) },
   };
   int total_len = 1 + sizeof(hdr) + sizeof(cmd);
   errno = 0;
   rc = writev(sock, iov, sizeof(iov)/sizeof(iov[0]));
   if (rc != total_len) {
       printf("Can't write %d bytes (wrote %d) to HCI socket: %s (%d)!\n",
            total_len, rc, strerror(errno), errno);
       return -1;
   }
   return 0;
}


int write_voice_setting(int sock) {
   int rc;
   unsigned char type = HCI_COMMAND_PKT;
   hci_command_hdr hdr;
   // HCI_Write_Voice_Setting (0x0026)
   hdr.opcode = 0x0026;
   unsigned char cmd[] = {
       0x00, 0x00,
   };
   hdr.plen = sizeof(cmd);
   struct iovec iov[] = {
       { &type, 1 },
       { &hdr, sizeof(hdr) },
       { &cmd, sizeof(cmd) },
   };
   int total_len = 1 + sizeof(hdr) + sizeof(cmd);
   errno = 0;
   rc = writev(sock, iov, sizeof(iov)/sizeof(iov[0]));
   if (rc != total_len) {
       printf("Can't write %d bytes (wrote %d) to HCI socket: %s (%d)!\n",
            total_len, rc, strerror(errno), errno);
       return -1;
   }
   return 0;
}

static int vendor_specific_sco_setup(int hcifd, int over_hci) {
    /* Use vendor-specific HCI commands to set up SCO over HCI or PCM */
    int rc;
    unsigned char type = HCI_COMMAND_PKT;
    hci_command_hdr hdr;
    /* HCI_VS_Write_SCO_Configuration.
     * Once this command is issued, it is valid for all new SCO channels
     * created. It is used to determine the following paramters
     * SCO Connection type - Host (voice over HCI) or Codec
     * TX packet length used for flow control calculations
     * TX Buffer max latency determines how much time the data can be in the TX
     * buffer before being flushed out. Applicable only if flow control is
     * disabled.
     */
    hdr.opcode = 0xFE10;
    hdr.plen = 0x05;
    struct hci_sco_t {
        unsigned char conn_type;
        unsigned char packet_size;
        unsigned char max_latency[2];
        unsigned char bad_crc;
    } __attribute__((packed)) hci_sco;
    hci_sco.packet_size = 0x00; /* packet size--keep current setting */
    hci_sco.max_latency[0] = 0x00;
    hci_sco.max_latency[1] = 0x00; /* max latency--keep current setting */
    hci_sco.bad_crc     = 0xFF; /* bad CRC handling--keep current setting */
    struct iovec iov[3] = {
        { &type, 1 },
        { &hdr, sizeof(hdr) },
        { &hci_sco, sizeof(hci_sco) }
    };
    int total_len = 1 + sizeof(hdr) + sizeof(hci_sco);
    printf("Setting Vendor-specific SCO over %s.\n",
         (over_hci ? "HCI" : "PCM"));
    errno = 0;
    hci_sco.conn_type = (unsigned char)(over_hci ? 0x01 : 0x00);
    rc = writev(hcifd, iov, sizeof(iov)/sizeof(iov[0]));
    if (rc != total_len) {
        printf("Can't write %d bytes (wrote %d) to HCI socket: %s (%d)!\n",
             total_len, rc, strerror(errno), errno);
        return -1;
    }
    return 0;
}

int get_hci_sock() {
    int sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
    struct sockaddr_hci addr;
    int opt;

    if(sock < 0) {
        printf("Can't create raw socket!\n");
        return -1;
    }

    opt = 1;
    printf("Setting data direction.\n");
    if (setsockopt(sock, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
        printf("Error setting data direction\n");
        return -1;
    }

    /* Bind socket to the HCI device */
    addr.hci_family = AF_BLUETOOTH;
    addr.hci_dev = 0;  // hci0
    printf("Binding to HCI device.\n");
    if(bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
        printf("Can't attach to device hci0. %s(%d)\n",
             strerror(errno),
             errno);
        return -1;
    }
    return sock;
}

static const int num_devices = 3;
static const char device_names[3][20] = {
    "moto",
    "jabra250",
    "jabra125",
};
static const bdaddr_t device_addrs[3] = {
    {0xE1, 0x9C, 0x97, 0x2E, 0x0B, 0x00},
    {0x5E, 0x88, 0x26, 0xA4, 0x07, 0x00},
    {0xE3, 0xFD, 0x93, 0x8F, 0x16, 0x00},
};

void print_bdaddr(const bdaddr_t* bdaddr) {
    uint8_t* b = (uint8_t*)bdaddr;
    printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
            b[5], b[4], b[3], b[2], b[1], b[0]);
}

const bdaddr_t* get_remote_address(char* name) {
    int i;
    for (i=0; i<num_devices; i++) {
        if (strcmp(name, device_names[i]) == 0) {
            printf("Using ");
            print_bdaddr(&device_addrs[i]);
            return &device_addrs[i];
        }
    }
    printf("Unknown device: %s\n", name);
    for (i=0; i<num_devices; i++) {
        printf("%s ", device_names[i]);
        print_bdaddr(&device_addrs[i]);
    }
    exit(1);
}

void sco_setup(char *device_name) {
    struct sockaddr_sco sco_addr;
    int sco_sock;

    sco_sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
    if (sco_sock < 0) {
        printf("Could not create SCO socket\n");
        return;
    }

    /* Bind to local address */
    memset(&sco_addr, 0, sizeof(sco_addr));
    sco_addr.sco_family = AF_BLUETOOTH;
    hci_devba(0, &sco_addr.sco_bdaddr);
    printf("Local BDADDR is: ");
    print_bdaddr(&sco_addr.sco_bdaddr);
    printf("Binding...\n");
    if (bind(sco_sock, (struct sockaddr *) &sco_addr, sizeof(sco_addr)) < 0) {
        printf("Could not bind SCO socket\n");
        return;
    }

    memset(&sco_addr, 0, sizeof(sco_addr));
    sco_addr.sco_family = AF_BLUETOOTH;
    memcpy(&sco_addr.sco_bdaddr, get_remote_address(device_name), sizeof(bdaddr_t));
    printf("Connecting SCO socket...\n");
    print_bdaddr(&sco_addr.sco_bdaddr);
    if(connect(sco_sock, (struct sockaddr *)&sco_addr, sizeof(sco_addr)) < 0) {
        printf("Could not connect to SCO socket\n");
        return;
    }

    printf("SCO socket connected\n");

    struct sco_options opts;
    struct sco_conninfo conninfo;

    socklen_t len = sizeof(opts);

    if (getsockopt(sco_sock, SOL_SCO, SCO_OPTIONS, &opts, &len) < 0) {
        printf("Couldn't not get SCO socket options\n");
        return;
    }
    printf("SCO MTU: %d\n", opts.mtu);

    len = sizeof(conninfo);
    if (getsockopt(sco_sock, SOL_SCO, SCO_CONNINFO, &conninfo, &len) < 0) {
        printf("Couldn't get SCO connection options\n");
        return;
    }
    printf("SCO HCI handle: %d\n", conninfo.hci_handle);
    printf("SCO HCI device class: %02x%02x%02x\n",
              conninfo.dev_class[0],
              conninfo.dev_class[1],
              conninfo.dev_class[2]);
}



int main(int argc, char **argv) {
    if (argc == 1) {
        goto usage;
    }

    if (argc >= 2 && strcmp(argv[1], "pcm_setup") == 0 ) {
        int sock = get_hci_sock();
        if (sock < 0) {
            printf("Could not open hci socket\n");
            return -1;
        }
        if (vendor_specific_sco_setup(sock, 0 /* set up over PCM */) < 0) {
            printf("Could not set up SCO\n");
            return -1;
        }
        sleep(1);
        if (vendor_setup_pcm(sock) < 0) {
            printf("Could not setup up PCM\n");
            return -1;
        }
        sleep(1);
    } else if (argc >= 2 && strcmp(argv[1], "pcm_setup2") == 0 ) {
        int sock = get_hci_sock();
        if (sock < 0) {
            printf("Could not open hci socket\n");
            return -1;
        }
        if (vendor_setup_pcm2(sock) < 0) {
            printf("Could not setup up PCM\n");
            return -1;
        }
        sleep(1);
    } else if (argc >= 2 && strcmp(argv[1], "loopback") == 0 ) {
        int enable = 1;
        if (argc > 2) {
            if (strcmp(argv[2], "off") == 0) {
                enable = 0;
            }
        }
        int sock = get_hci_sock();
        if (sock < 0) {
            printf("Could not open hci socket\n");
            return -1;
        }
        setup_loopback1(sock);
        setup_loopback2(sock, enable);
        sleep(1);
    } else if (argc >= 2 && strcmp(argv[1], "sleep") == 0 ) {
        int enable = 1;
        if (argc > 2) {
            if (strcmp(argv[2], "off") == 0) {
                enable = 0;
            }
        }
        int sock = get_hci_sock();
        if (sock < 0) {
            printf("Could not open hci socket\n");
            return -1;
        }
        vendor_sleep(sock, enable);
        sleep(1);
    } else if (argc >= 2 && strcmp(argv[1], "coed") == 0 ) {
        int enable = 1;
        if (argc > 2) {
            if (strcmp(argv[2], "off") == 0) {
                enable = 0;
            }
        }
        int sock = get_hci_sock();
        if (sock < 0) {
            printf("Could not open hci socket\n");
            return -1;
        }
        vendor_coexist(sock, enable);
        sleep(1);
    } else if (argc >= 3 && strcmp(argv[1], "rate") == 0 ) {
        uint32_t rate = atoi(argv[2]);
        int sock = get_hci_sock();
        if (sock < 0) {
            printf("Could not open hci socket\n");
            return -1;
        }
        vendor_uart_baudrate(sock, rate);
        sleep(1);
    } else if (argc >= 2 && strcmp(argv[1], "vs_status") == 0 ) {
        int sock = get_hci_sock();
        if (sock < 0) {
            printf("Could not open hci socket\n");
            return -1;
        }
        vendor_status(sock);
        sleep(1);
    } else if (argc >= 3 && strcmp(argv[1], "sco_setup") == 0 ) {
        sco_setup(argv[2]);
        sleep(100000000);
    } else {
usage:
        printf("Usage:\n");
        printf("\tbtconfig sleep [on|off]\n");
        printf("\tbtconfig vs_status\n");
        printf("\tbtconfig pcm_setup\n");
        printf("\tbtconfig pcm_setup2\n");
        printf("\tbtconfig sco_setup DEVICE_ALIAS\n");
        printf("\tbtconfig loopback [on|off]\n");
        printf("\tbtconfig coed [on|off]\n");
        printf("\tbtconfig rate RATE\n");
        printf("\n");
        return 0;
    }

    return 0;
}