OSDN Git Service

Initial Contribution
[android-x86/external-bluetooth-bluez.git] / utils / tools / hciattach.c
index 36f3c72..c373607 100644 (file)
@@ -42,6 +42,8 @@
 #include <sys/param.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
+#include <sys/endian.h>
+#include <sys/uio.h>
 
 #include <bluetooth/bluetooth.h>
 #include <bluetooth/hci.h>
 #define HCIUARTGETPROTO                _IOR('U', 201, int)
 #define HCIUARTGETDEVICE       _IOR('U', 202, int)
 
-#define HCI_UART_H4    0
+#define HCI_UART_H4            0
 #define HCI_UART_BCSP  1
 #define HCI_UART_3WIRE 2
 #define HCI_UART_H4DS  3
+#define HCI_UART_LL            4
 
 struct uart_t {
        char *type;
@@ -146,13 +149,14 @@ static int uart_speed(int s)
 static int set_speed(int fd, struct termios *ti, int speed)
 {
        cfsetospeed(ti, uart_speed(speed));
+       cfsetispeed(ti, uart_speed(speed));
        return tcsetattr(fd, TCSANOW, ti);
 }
 
 /* 
  * Read an HCI event from the given file descriptor.
  */
-static int read_hci_event(int fd, unsigned char* buf, int size) 
+int read_hci_event(int fd, unsigned char* buf, int size) 
 {
        int remain, r;
        int count = 0;
@@ -340,6 +344,12 @@ static int texas(int fd, struct uart_t *u, struct termios *ti)
        return 0;
 }
 
+extern int texasalt_init(int fd, int speed);
+
+int texasalt(int fd, struct uart_t *u, struct termios *ti) {
+       texasalt_init(fd, u->speed);
+}
+
 static int read_check(int fd, void *buf, int count)
 {
        int res;
@@ -1053,7 +1063,7 @@ struct uart_t uart[] = {
        { "any",        0x0000, 0x0000, HCI_UART_H4,   115200, 115200, FLOW_CTL, NULL, NULL     },
        { "ericsson",   0x0000, 0x0000, HCI_UART_H4,   57600,  115200, FLOW_CTL, NULL, ericsson },
        { "digi",       0x0000, 0x0000, HCI_UART_H4,   9600,   115200, FLOW_CTL, NULL, digi     },
-       { "texas",      0x0000, 0x0000, HCI_UART_H4,   115200, 115200, FLOW_CTL, NULL, texas    },
+       { "texas",      0x0000, 0x0000, HCI_UART_LL,   115200, 115200, FLOW_CTL, NULL, texasalt },
 
        { "bcsp",       0x0000, 0x0000, HCI_UART_BCSP, 115200, 115200, 0,        NULL, bcsp     },
 
@@ -1374,7 +1384,7 @@ int main(int argc, char *argv[])
 
        while (!__io_canceled) {
                p.revents = 0;
-               err = poll(&p, 1, 500);
+               err = poll(&p, 1, 5000);  // 5 seconds
                if (err < 0 && errno == EINTR)
                        continue;
                if (err)