[PATCHv6 03/19] android/socket: Implement listen on RFCOMM socket

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

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

Handle HAL socket listen call. Create RFCOMM socket and wait for events.
---
 android/socket.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/android/socket.c b/android/socket.c
index e19b2aa..b8d96f9 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -133,11 +133,17 @@ static struct profile_info *get_profile_by_uuid(const uint8_t *uuid)
 	return NULL;
 }
 
+static void accept_cb(GIOChannel *io, GError *err, gpointer user_data)
+{
+}
+
 static int handle_listen(void *buf)
 {
 	struct hal_cmd_sock_listen *cmd = buf;
 	struct profile_info *profile;
 	struct rfcomm_sock *rfsock;
+	GIOChannel *io;
+	GError *err = NULL;
 	int hal_fd;
 	int chan;
 
@@ -155,6 +161,27 @@ static int handle_listen(void *buf)
 	if (!rfsock)
 		return -1;
 
+	io = bt_io_listen(accept_cb, NULL, rfsock, NULL, &err,
+				BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
+				BT_IO_OPT_CHANNEL, chan,
+				BT_IO_OPT_INVALID);
+	if (!io) {
+		error("Failed listen: %s", err->message);
+		g_error_free(err);
+		cleanup_rfsock(rfsock);
+		return -1;
+	}
+
+	rfsock->real_sock = g_io_channel_unix_get_fd(io);
+	servers = g_list_append(servers, rfsock);
+
+	/* TODO: Add server watch */
+	g_io_channel_set_close_on_unref(io, TRUE);
+	g_io_channel_unref(io);
+
+	DBG("real_sock %d fd %d hal_fd %d", rfsock->real_sock, rfsock->fd,
+								hal_fd);
+
 	return hal_fd;
 }
 
-- 
1.7.10.4

--
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