* [PATCH] android/bluetooth: Fix device found notification
@ 2014-08-19 13:45 Lukasz Rymanowski
2014-08-19 16:50 ` Szymon Janc
0 siblings, 1 reply; 2+ messages in thread
From: Lukasz Rymanowski @ 2014-08-19 13:45 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
If device is dual mode and can be seen on both LE and BREDR, then
bdaddr_type in device struct keeps LE address type of that device.
During discovery, we should take current bdaddr_type to decide about
passing that device up to application or not. Using dev->braddr_type might
be misleading
This patch fix scenario when remote device is known as LE device and
recently has been found on inquiry seesion as DUAL mode device. In such
case, based on braddr_type and eir flags we could incorectly skip
new device notification for Android framework.
---
android/bluetooth.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 5f163f1..64a7696 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1830,7 +1830,8 @@ static void update_device(struct device *dev, int8_t rssi,
HAL_EV_REMOTE_DEVICE_PROPS, size, buf);
}
-static bool is_new_device(const struct device *dev, unsigned int flags)
+static bool is_new_device(const struct device *dev, unsigned int flags,
+ uint8_t bdaddr_type)
{
if (dev->found)
return false;
@@ -1838,7 +1839,7 @@ static bool is_new_device(const struct device *dev, unsigned int flags)
if (dev->bredr_paired || dev->le_paired)
return false;
- if (dev->bdaddr_type != BDADDR_BREDR &&
+ if (bdaddr_type != BDADDR_BREDR &&
!(flags & (EIR_LIM_DISC | EIR_GEN_DISC)))
return false;
@@ -1867,7 +1868,7 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
* Device found event needs to be send also for known device if this is
* new discovery session. Otherwise framework will ignore it.
*/
- if (is_new_device(dev, eir.flags))
+ if (is_new_device(dev, eir.flags, bdaddr_type))
update_new_device(dev, rssi, &eir);
else
update_device(dev, rssi, &eir, bdaddr_type);
--
1.8.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] android/bluetooth: Fix device found notification
2014-08-19 13:45 [PATCH] android/bluetooth: Fix device found notification Lukasz Rymanowski
@ 2014-08-19 16:50 ` Szymon Janc
0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2014-08-19 16:50 UTC (permalink / raw)
To: Lukasz Rymanowski; +Cc: linux-bluetooth
Hi Łukasz,
On Tuesday 19 of August 2014 15:45:29 Lukasz Rymanowski wrote:
> If device is dual mode and can be seen on both LE and BREDR, then
> bdaddr_type in device struct keeps LE address type of that device.
>
> During discovery, we should take current bdaddr_type to decide about
> passing that device up to application or not. Using dev->braddr_type might
> be misleading
>
> This patch fix scenario when remote device is known as LE device and
> recently has been found on inquiry seesion as DUAL mode device. In such
> case, based on braddr_type and eir flags we could incorectly skip
> new device notification for Android framework.
> ---
> android/bluetooth.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 5f163f1..64a7696 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -1830,7 +1830,8 @@ static void update_device(struct device *dev, int8_t
> rssi, HAL_EV_REMOTE_DEVICE_PROPS, size, buf);
> }
>
> -static bool is_new_device(const struct device *dev, unsigned int flags)
> +static bool is_new_device(const struct device *dev, unsigned int flags,
> + uint8_t bdaddr_type)
> {
> if (dev->found)
> return false;
> @@ -1838,7 +1839,7 @@ static bool is_new_device(const struct device *dev,
> unsigned int flags) if (dev->bredr_paired || dev->le_paired)
> return false;
>
> - if (dev->bdaddr_type != BDADDR_BREDR &&
> + if (bdaddr_type != BDADDR_BREDR &&
> !(flags & (EIR_LIM_DISC | EIR_GEN_DISC)))
> return false;
>
> @@ -1867,7 +1868,7 @@ static void update_found_device(const bdaddr_t
> *bdaddr, uint8_t bdaddr_type, * Device found event needs to be send also
> for known device if this is * new discovery session. Otherwise framework
> will ignore it.
> */
> - if (is_new_device(dev, eir.flags))
> + if (is_new_device(dev, eir.flags, bdaddr_type))
> update_new_device(dev, rssi, &eir);
> else
> update_device(dev, rssi, &eir, bdaddr_type);
Patch applied, thanks.
--
BR
Szymon Janc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-19 16:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-19 13:45 [PATCH] android/bluetooth: Fix device found notification Lukasz Rymanowski
2014-08-19 16:50 ` Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).