All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Subject: [PATCH 11/16] android/gatt: Notify apps interested in autoconnect about connection
Date: Tue,  2 Sep 2014 12:09:56 +0200	[thread overview]
Message-ID: <1409652601-28689-12-git-send-email-lukasz.rymanowski@tieto.com> (raw)
In-Reply-To: <1409652601-28689-1-git-send-email-lukasz.rymanowski@tieto.com>

This patch makes sure that application interested in auto connect for
particular devices, will be notified about new connections.
---
 android/gatt.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/android/gatt.c b/android/gatt.c
index 2e978b9..94a65cb 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1385,6 +1385,21 @@ static struct app_connection *find_conn(const bdaddr_t *addr, int32_t app_id)
 								&conn_match);
 }
 
+static void create_app_connection(void *data, void *user_data)
+{
+	struct gatt_device *dev = user_data;
+	struct gatt_app *app;
+
+	app = find_app_by_id(PTR_TO_INT(data));
+	if (!app)
+		return;
+
+	DBG("Autoconnect application id=%d", app->id);
+
+	if (!find_conn(&dev->bdaddr, PTR_TO_INT(data)))
+		create_connection(dev, app);
+}
+
 static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 {
 	struct gatt_device *dev = user_data;
@@ -1431,7 +1446,8 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 
 	device_set_state(dev, DEVICE_CONNECTED);
 
-	bt_auto_connect_remove(&dev->bdaddr);
+	if (queue_isempty(dev->autoconnect_apps))
+		bt_auto_connect_remove(&dev->bdaddr);
 
 	/* Send exchange mtu request as we assume being client and server */
 	/* TODO: Dont exchange mtu if no client apps */
@@ -1456,6 +1472,12 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 	status = GATT_SUCCESS;
 
 reply:
+	/*
+	 * Make sure there are app_connections for all apps interested in auto
+	 * connect to that device
+	 */
+	queue_foreach(dev->autoconnect_apps, create_app_connection, dev);
+
 	if (!dev->conn_cnt) {
 		struct app_connection *conn;
 
-- 
1.8.4


  parent reply	other threads:[~2014-09-02 10:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02 10:09 [PATCH 00/16] Move reconnect logic from HOG to GATT Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 01/16] android/gatt: Fix for device type in gatt Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 02/16] android/hidhost: Remove invalid connecting state notification Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 03/16] android/hidhost: Allow to use cached dev when connecting Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 04/16] android/bluetooth: Add tracking if device is in white list Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 05/16] android/gatt: Add tracking for autoconnect apps Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 06/16] android/gatt: Add API to autoconnect GATT based devices Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 07/16] android/gatt: Add API to remove autoconnect GATT based device Lukasz Rymanowski
2014-09-02 15:27   ` Szymon Janc
2014-09-03  6:55     ` Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 08/16] android/gatt: Unsubscribe from autoconnect on unregister Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 09/16] android/gatt: Extract remove_autoconnect_device helper Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 10/16] android/gatt: Move find_conn up in the file Lukasz Rymanowski
2014-09-02 10:09 ` Lukasz Rymanowski [this message]
2014-09-02 10:09 ` [PATCH 12/16] android/gatt: Extract trigger le connection to new function Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 13/16] android/gatt: Move auto_connect_le() up in the file Lukasz Rymanowski
2014-09-02 10:09 ` [PATCH 14/16] android/gatt: Make sure GATT will reconnect after disconnection Lukasz Rymanowski
2014-09-02 10:10 ` [PATCH 15/16] android/gatt: Remove device from white list on device destroy Lukasz Rymanowski
2014-09-02 10:10 ` [PATCH 16/16] android/hidhost: Remove reconnect logic Lukasz Rymanowski
2014-09-02 15:19 ` [PATCH 00/16] Move reconnect logic from HOG to GATT Szymon Janc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409652601-28689-12-git-send-email-lukasz.rymanowski@tieto.com \
    --to=lukasz.rymanowski@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.