All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Emit device_found when RSSI changes.
@ 2009-05-05  6:32 Jaikumar Ganesh
  2009-05-18  2:27 ` Manuel Naranjo
  0 siblings, 1 reply; 4+ messages in thread
From: Jaikumar Ganesh @ 2009-05-05  6:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jaikumar Ganesh

When the RSSI of the remote device changes, emit
device found. Currently, we were not sending
emit_device_found signal, when the RSSI of already
found devices gets updated.

Signed-off-by: Jaikumar Ganesh <jaikumar@google.com>
---
 src/adapter.c  |   24 +++++++++---------------
 src/dbus-hci.c |   10 ++++++++--
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index d9914e2..1ec076d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2639,6 +2639,15 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
 	g_free(alias);
 }
 
+void adapter_update_found_devices_for_rssi(struct btd_adapter *adapter,
+				struct remote_dev_info *dev, int8_t rssi)
+{
+	dev->rssi = rssi;
+	adapter->found_devices = g_slist_sort(adapter->found_devices,
+						(GCompareFunc) dev_rssi_cmp);
+	adapter_emit_device_found(adapter, dev);
+}
+
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 				int8_t rssi, uint32_t class, const char *name,
 				const char *alias, gboolean legacy,
@@ -2650,13 +2659,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	bacpy(&match.bdaddr, bdaddr);
 	match.name_status = NAME_ANY;
 
-	dev = adapter_search_found_devices(adapter, &match);
-	if (dev) {
-		if (rssi == dev->rssi)
-			return;
-		goto done;
-	}
-
 	dev = g_new0(struct remote_dev_info, 1);
 
 	bacpy(&dev->bdaddr, bdaddr);
@@ -2669,14 +2671,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	dev->name_status = name_status;
 
 	adapter->found_devices = g_slist_prepend(adapter->found_devices, dev);
-
-done:
-	dev->rssi = rssi;
-
-	adapter->found_devices = g_slist_sort(adapter->found_devices,
-						(GCompareFunc) dev_rssi_cmp);
-
-	adapter_emit_device_found(adapter, dev);
 }
 
 int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr)
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index 932682a..d7df415 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -668,9 +668,15 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 	memset(&match, 0, sizeof(struct remote_dev_info));
 	bacpy(&match.bdaddr, peer);
 	match.name_status = NAME_SENT;
-	/* if found: don't send the name again */
+	/* 
+	 * if found and rssi has changed, emit device_found
+	 * if found: don't send the name again.
+	 */
 	dev = adapter_search_found_devices(adapter, &match);
-	if (dev)
+	if (dev && dev->rssi != rssi) {
+		adapter_update_found_devices_for_rssi(adapter, dev, rssi);
+		return;
+	} else if (dev)
 		return;
 
 	/* the inquiry result can be triggered by NON D-Bus client */
-- 
1.5.4.3


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

* Re: [PATCH] Emit device_found when RSSI changes.
  2009-05-05  6:32 [PATCH] Emit device_found when RSSI changes Jaikumar Ganesh
@ 2009-05-18  2:27 ` Manuel Naranjo
       [not found]   ` <e8892a6a0905172014h798119c4m3b36e7e6efed8bb4@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Manuel Naranjo @ 2009-05-18  2:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jaikumar Ganesh

Guys,
> When the RSSI of the remote device changes, emit
> device found. Currently, we were not sending
> emit_device_found signal, when the RSSI of already
> found devices gets updated.
>   
Is there any reason why this patch hasn't been applied? I've been using 
it for a while and it seems to work pretty well.

I wouldn't mind keep my packages patched, but if it can be merged it's 
even better.

Thanks,
Manuel
> Signed-off-by: Jaikumar Ganesh <jaikumar@google.com>
> ---
>  src/adapter.c  |   24 +++++++++---------------
>  src/dbus-hci.c |   10 ++++++++--
>  2 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index d9914e2..1ec076d 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -2639,6 +2639,15 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
>  	g_free(alias);
>  }
>  
> +void adapter_update_found_devices_for_rssi(struct btd_adapter *adapter,
> +				struct remote_dev_info *dev, int8_t rssi)
> +{
> +	dev->rssi = rssi;
> +	adapter->found_devices = g_slist_sort(adapter->found_devices,
> +						(GCompareFunc) dev_rssi_cmp);
> +	adapter_emit_device_found(adapter, dev);
> +}
> +
>  void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
>  				int8_t rssi, uint32_t class, const char *name,
>  				const char *alias, gboolean legacy,
> @@ -2650,13 +2659,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
>  	bacpy(&match.bdaddr, bdaddr);
>  	match.name_status = NAME_ANY;
>  
> -	dev = adapter_search_found_devices(adapter, &match);
> -	if (dev) {
> -		if (rssi == dev->rssi)
> -			return;
> -		goto done;
> -	}
> -
>  	dev = g_new0(struct remote_dev_info, 1);
>  
>  	bacpy(&dev->bdaddr, bdaddr);
> @@ -2669,14 +2671,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
>  	dev->name_status = name_status;
>  
>  	adapter->found_devices = g_slist_prepend(adapter->found_devices, dev);
> -
> -done:
> -	dev->rssi = rssi;
> -
> -	adapter->found_devices = g_slist_sort(adapter->found_devices,
> -						(GCompareFunc) dev_rssi_cmp);
> -
> -	adapter_emit_device_found(adapter, dev);
>  }
>  
>  int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr)
> diff --git a/src/dbus-hci.c b/src/dbus-hci.c
> index 932682a..d7df415 100644
> --- a/src/dbus-hci.c
> +++ b/src/dbus-hci.c
> @@ -668,9 +668,15 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
>  	memset(&match, 0, sizeof(struct remote_dev_info));
>  	bacpy(&match.bdaddr, peer);
>  	match.name_status = NAME_SENT;
> -	/* if found: don't send the name again */
> +	/* 
> +	 * if found and rssi has changed, emit device_found
> +	 * if found: don't send the name again.
> +	 */
>  	dev = adapter_search_found_devices(adapter, &match);
> -	if (dev)
> +	if (dev && dev->rssi != rssi) {
> +		adapter_update_found_devices_for_rssi(adapter, dev, rssi);
> +		return;
> +	} else if (dev)
>  		return;
>  
>  	/* the inquiry result can be triggered by NON D-Bus client */
>   


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

* Re: [PATCH] Emit device_found when RSSI changes.
       [not found]   ` <e8892a6a0905172014h798119c4m3b36e7e6efed8bb4@mail.gmail.com>
@ 2009-05-18  3:30     ` Manuel Naranjo
  2009-05-18 21:20       ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Manuel Naranjo @ 2009-05-18  3:30 UTC (permalink / raw)
  To: Jaikumar Ganesh; +Cc: linux-bluetooth

Jaikumar
> Hi Manuel,
>   This fix got implemented as part of bunch of changed made by Luiz in 
> the DeviceFound code namely,
>
> http://git.kernel.org/?p=bluetooth/bluez.git;a=commit;h=66ef7864f7820f41d7331942bcb6256ff68d7614
>
> Thanks
> Jaikumar
Oops sorry I missed it. So it will send a result each time there's an 
inquriry result no matter if RSSI changes or not. That's why I missed it.

Manuel

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

* Re: [PATCH] Emit device_found when RSSI changes.
  2009-05-18  3:30     ` Manuel Naranjo
@ 2009-05-18 21:20       ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2009-05-18 21:20 UTC (permalink / raw)
  To: Manuel Naranjo; +Cc: Jaikumar Ganesh, linux-bluetooth

Hi Manuel,

> >   This fix got implemented as part of bunch of changed made by Luiz in 
> > the DeviceFound code namely,
> >
> > http://git.kernel.org/?p=bluetooth/bluez.git;a=commit;h=66ef7864f7820f41d7331942bcb6256ff68d7614
> >
> > Thanks
> > Jaikumar
> Oops sorry I missed it. So it will send a result each time there's an 
> inquriry result no matter if RSSI changes or not. That's why I missed it.

is this still an issue with the latest code from the GIT repository?

Regards

Marcel



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

end of thread, other threads:[~2009-05-18 21:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-05  6:32 [PATCH] Emit device_found when RSSI changes Jaikumar Ganesh
2009-05-18  2:27 ` Manuel Naranjo
     [not found]   ` <e8892a6a0905172014h798119c4m3b36e7e6efed8bb4@mail.gmail.com>
2009-05-18  3:30     ` Manuel Naranjo
2009-05-18 21:20       ` Marcel Holtmann

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.