From edb6ade25d395275585a9b52c2d7a22da6f57107 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Tue, 4 Oct 2011 15:30:57 -0300 Subject: [PATCH] Add continuous connection attempt If auto connect is enabled, queue another connection attempt until the adapter sets auto connect to FALSE. The behaviour depends on if the address is found in the advertising cache or not. --- src/device.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index 5243797f0..c3eaf450d 100644 --- a/src/device.c +++ b/src/device.c @@ -1760,6 +1760,8 @@ done: browse_request_free(req, shutdown); } +static gboolean att_connect(gpointer user_data); + static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data) { struct btd_device *device = user_data; @@ -1777,7 +1779,8 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data) device->browse = NULL; browse_request_free(req, TRUE); - } + } else if (device->auto_connect) + g_idle_add(att_connect, device); return; } @@ -2018,6 +2021,13 @@ void device_set_auto_connect(struct btd_device *device, gboolean enable) DBG("%s auto connect: %d", addr, enable); device->auto_connect = enable; + + if (device->attrib) { + DBG("Already connected"); + return; + } + + g_idle_add(att_connect, device); } void device_set_type(struct btd_device *device, device_type_t type) -- 2.11.0