From: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Subject: [PATCH 12/16] android/gatt: Extract trigger le connection to new function
Date: Tue, 2 Sep 2014 12:09:57 +0200 [thread overview]
Message-ID: <1409652601-28689-13-git-send-email-lukasz.rymanowski@tieto.com> (raw)
In-Reply-To: <1409652601-28689-1-git-send-email-lukasz.rymanowski@tieto.com>
This will be needed in reconnect scenario
---
android/gatt.c | 41 ++++++++++++++++-------------------------
1 file changed, 16 insertions(+), 25 deletions(-)
diff --git a/android/gatt.c b/android/gatt.c
index 94a65cb..c614e6a 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1825,15 +1825,19 @@ static int connect_bredr(struct gatt_device *dev)
return 0;
}
-static bool auto_connect(struct gatt_device *dev)
+static bool auto_connect_le(struct gatt_device *dev)
{
- bool err;
-
- err = bt_auto_connect_add(&dev->bdaddr);
- if (!err)
- return false;
+ /* For LE devices use auto connect feature if possible */
+ if (bt_kernel_conn_control())
+ return bt_auto_connect_add(&dev->bdaddr);
- device_set_state(dev, DEVICE_CONNECT_INIT);
+ /* Trigger discovery if not already started */
+ if (!scanning) {
+ if (!bt_le_discovery_start()) {
+ error("gatt: Could not start scan");
+ return false;
+ }
+ }
return true;
}
@@ -1852,24 +1856,11 @@ static bool trigger_connection(struct app_connection *connection)
BDADDR_BREDR)
return connect_bredr(connection->device) == 0;
- /*
- * For LE devices use auto connect feature if possible
- * Note: Connection state is handled inside auto_connect() func
- */
- if (bt_kernel_conn_control())
- return auto_connect(connection->device);
-
- /* Trigger discovery if not already started */
- if (!scanning) {
- if (!bt_le_discovery_start()) {
- error("gatt: Could not start scan");
- ret = false;
- break;
- }
- }
-
- ret = true;
- device_set_state(connection->device, DEVICE_CONNECT_INIT);
+ /* For LE use auto connect feature */
+ ret = auto_connect_le(connection->device);
+ if (ret)
+ device_set_state(connection->device,
+ DEVICE_CONNECT_INIT);
break;
case DEVICE_CONNECTED:
send_app_connect_notify(connection, GATT_SUCCESS);
--
1.8.4
next prev 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 ` [PATCH 11/16] android/gatt: Notify apps interested in autoconnect about connection Lukasz Rymanowski
2014-09-02 10:09 ` Lukasz Rymanowski [this message]
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-13-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.