Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v4] android/hidhost: Remove reconnect logic
@ 2014-09-05 10:37 Lukasz Rymanowski
  2014-09-05 10:47 ` Szymon Janc
  0 siblings, 1 reply; 2+ messages in thread
From: Lukasz Rymanowski @ 2014-09-05 10:37 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lukasz Rymanowski

GATT can handle reconnect now, so lets remove that part of code from
here
---
v4 - rebase only 

 android/hidhost.c | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/android/hidhost.c b/android/hidhost.c
index ebed56d..657fa8f 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -109,7 +109,6 @@ struct hid_device {
 	struct bt_uhid	*uhid;
 	uint8_t		last_hid_msg;
 	struct bt_hog	*hog;
-	guint		reconnect_id;
 	int		sec_level;
 };
 
@@ -125,9 +124,6 @@ static void hid_device_free(void *data)
 {
 	struct hid_device *dev = data;
 
-	if (dev->reconnect_id > 0)
-		g_source_remove(dev->reconnect_id);
-
 	if (dev->ctrl_watch > 0)
 		g_source_remove(dev->ctrl_watch);
 
@@ -768,19 +764,6 @@ fail:
 	hid_device_remove(dev);
 }
 
-static gboolean hog_reconnect(void *user_data)
-{
-	struct hid_device *dev = user_data;
-
-	DBG("");
-
-	dev->reconnect_id = 0;
-
-	bt_gatt_connect_app(hog_app, &dev->dst);
-
-	return FALSE;
-}
-
 static void hog_conn_cb(const bdaddr_t *addr, int err, void *attrib)
 {
 	GSList *l;
@@ -792,11 +775,10 @@ static void hog_conn_cb(const bdaddr_t *addr, int err, void *attrib)
 	if (err < 0) {
 		if (!dev)
 			return;
-		if (dev->hog && !dev->reconnect_id) {
+		if (dev->hog) {
 			bt_hid_notify_state(dev,
 						HAL_HIDHOST_STATE_DISCONNECTED);
 			bt_hog_detach(dev->hog);
-			dev->reconnect_id = g_idle_add(hog_reconnect, dev);
 			return;
 		}
 		goto fail;
@@ -829,6 +811,9 @@ static void hog_conn_cb(const bdaddr_t *addr, int err, void *attrib)
 
 	bt_hid_notify_state(dev, HAL_HIDHOST_STATE_CONNECTED);
 
+	if (!bt_gatt_add_autoconnect(hog_app, &dev->dst))
+		error("hidhost: Could not add to autoconnect list");
+
 	return;
 
 fail:
@@ -1497,6 +1482,9 @@ static void hid_unpaired_cb(const bdaddr_t *addr, uint8_t type)
 	ba2str(addr, address);
 	DBG("Unpaired device %s", address);
 
+	if (hog_app)
+		bt_gatt_remove_autoconnect(hog_app, addr);
+
 	hid_device_remove(dev);
 }
 
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] android/hidhost: Remove reconnect logic
  2014-09-05 10:37 [PATCH v4] android/hidhost: Remove reconnect logic Lukasz Rymanowski
@ 2014-09-05 10:47 ` Szymon Janc
  0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2014-09-05 10:47 UTC (permalink / raw)
  To: Lukasz Rymanowski; +Cc: linux-bluetooth

Hi Łukasz,

On Friday 05 of September 2014 12:37:37 Lukasz Rymanowski wrote:
> GATT can handle reconnect now, so lets remove that part of code from
> here
> ---
> v4 - rebase only 
> 
>  android/hidhost.c | 26 +++++++-------------------
>  1 file changed, 7 insertions(+), 19 deletions(-)
> 
> diff --git a/android/hidhost.c b/android/hidhost.c
> index ebed56d..657fa8f 100644
> --- a/android/hidhost.c
> +++ b/android/hidhost.c
> @@ -109,7 +109,6 @@ struct hid_device {
>  	struct bt_uhid	*uhid;
>  	uint8_t		last_hid_msg;
>  	struct bt_hog	*hog;
> -	guint		reconnect_id;
>  	int		sec_level;
>  };
>  
> @@ -125,9 +124,6 @@ static void hid_device_free(void *data)
>  {
>  	struct hid_device *dev = data;
>  
> -	if (dev->reconnect_id > 0)
> -		g_source_remove(dev->reconnect_id);
> -
>  	if (dev->ctrl_watch > 0)
>  		g_source_remove(dev->ctrl_watch);
>  
> @@ -768,19 +764,6 @@ fail:
>  	hid_device_remove(dev);
>  }
>  
> -static gboolean hog_reconnect(void *user_data)
> -{
> -	struct hid_device *dev = user_data;
> -
> -	DBG("");
> -
> -	dev->reconnect_id = 0;
> -
> -	bt_gatt_connect_app(hog_app, &dev->dst);
> -
> -	return FALSE;
> -}
> -
>  static void hog_conn_cb(const bdaddr_t *addr, int err, void *attrib)
>  {
>  	GSList *l;
> @@ -792,11 +775,10 @@ static void hog_conn_cb(const bdaddr_t *addr, int err, void *attrib)
>  	if (err < 0) {
>  		if (!dev)
>  			return;
> -		if (dev->hog && !dev->reconnect_id) {
> +		if (dev->hog) {
>  			bt_hid_notify_state(dev,
>  						HAL_HIDHOST_STATE_DISCONNECTED);
>  			bt_hog_detach(dev->hog);
> -			dev->reconnect_id = g_idle_add(hog_reconnect, dev);
>  			return;
>  		}
>  		goto fail;
> @@ -829,6 +811,9 @@ static void hog_conn_cb(const bdaddr_t *addr, int err, void *attrib)
>  
>  	bt_hid_notify_state(dev, HAL_HIDHOST_STATE_CONNECTED);
>  
> +	if (!bt_gatt_add_autoconnect(hog_app, &dev->dst))
> +		error("hidhost: Could not add to autoconnect list");
> +
>  	return;
>  
>  fail:
> @@ -1497,6 +1482,9 @@ static void hid_unpaired_cb(const bdaddr_t *addr, uint8_t type)
>  	ba2str(addr, address);
>  	DBG("Unpaired device %s", address);
>  
> +	if (hog_app)
> +		bt_gatt_remove_autoconnect(hog_app, addr);
> +
>  	hid_device_remove(dev);
>  }

Applied. Thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-05 10:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-05 10:37 [PATCH v4] android/hidhost: Remove reconnect logic Lukasz Rymanowski
2014-09-05 10:47 ` Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox