[PATCH] btproxy: Simplify Bluetooth proxy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

At the moment every time we use btproxy we have to down Bluetooth
device. This is very unhandy especially when connection to proxy ends
and other connections always fail. Add HCIDEVDOWN ioctl before binding
to user channel.
---
 tools/btproxy.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/btproxy.c b/tools/btproxy.c
index ee4dadd..02ae53d 100644
--- a/tools/btproxy.c
+++ b/tools/btproxy.c
@@ -39,6 +39,7 @@
 #include <termios.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
+#include <sys/ioctl.h>
 #include <sys/un.h>
 
 #include <netdb.h>
@@ -50,6 +51,8 @@
 #include "monitor/bt.h"
 #include "h5.h"
 
+#define HCIDEVDOWN	_IOW('H', 202, int)
+
 #define HCI_BREDR	0x00
 #define HCI_AMP		0x01
 
@@ -576,6 +579,12 @@ static int open_channel(uint16_t index)
 		return -1;
 	}
 
+	if (ioctl(fd, HCIDEVDOWN, hci_index) < 0) {
+		close(fd);
+		perror("Failed to down hci device");
+		return -1;
+	}
+
 	memset(&addr, 0, sizeof(addr));
 	addr.hci_family = AF_BLUETOOTH;
 	addr.hci_dev = index;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux