2014-05-15 09:55:38

by Bharat Bhusan Panda

[permalink] [raw]
Subject: [PATCH ] Add device type info to device info(btd_device)

Add device type information whether LE or BR/EDR or
LE/BR/EDR to device info, which can be further
exposed as a device property.

Signed-off-by: Bharat Panda <[email protected]>
---
src/adapter.c | 6 ++++++
src/device.c | 11 +++++++++++
2 files changed, 17 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index f5abfe3..5154448 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -4355,6 +4355,12 @@ static void update_found_devices(struct btd_adapter *adapter,
!(eir_data.flags & EIR_BREDR_UNSUP))
device_set_bredr_support(dev, true);

+ if (eir_data.flags & (EIR_BREDR_UNSUP))
+ device_set_le_support(dev, true);
+
+ if (eir_data.flags & (EIR_CONTROLLER | EIR_SIM_HOST | (!EIR_BREDR_UNSUP)))
+ device_set_dual_mode_support(dev, true);
+
if (eir_data.name != NULL && eir_data.name_complete)
device_store_cached_name(dev, eir_data.name);

diff --git a/src/device.c b/src/device.c
index 41637b3..f88a1b1 100644
--- a/src/device.c
+++ b/src/device.c
@@ -169,6 +169,7 @@ struct btd_device {
char *path;
bool bredr;
bool le;
+ bool dual_mode;
bool pending_paired; /* "Paired" waiting for SDP */
bool svc_refreshed;
GSList *svc_callbacks;
@@ -2472,6 +2473,16 @@ void device_set_bredr_support(struct btd_device *device, bool bredr)
device->bredr = bredr;
}

+void device_set_le_support(struct btd_device *device, bool le)
+{
+ device->le= le;
+}
+
+void device_set_dual_mode_support(struct btd_device *device, bool dual_mode)
+{
+ device->dual_mode= dual_mode;
+}
+
void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type)
{
if (bdaddr_type == BDADDR_BREDR)
--
1.7.9.5



2014-05-15 13:16:03

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH ] Add device type info to device info(btd_device)

Hi Bharat,

On Thu, May 15, 2014, Bharat Panda wrote:
> Add device type information whether LE or BR/EDR or
> LE/BR/EDR to device info, which can be further
> exposed as a device property.
>
> Signed-off-by: Bharat Panda <[email protected]>
> ---
> src/adapter.c | 6 ++++++
> src/device.c | 11 +++++++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index f5abfe3..5154448 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -4355,6 +4355,12 @@ static void update_found_devices(struct btd_adapter *adapter,
> !(eir_data.flags & EIR_BREDR_UNSUP))
> device_set_bredr_support(dev, true);
>
> + if (eir_data.flags & (EIR_BREDR_UNSUP))
> + device_set_le_support(dev, true);

Simply the address type should be enough to know that LE is supported.
No need to check for any AD flags. Anyway, it seems to me that this
chunk is addressing the only real issue (although in a wrong way), but
I'll get to that later.

> + if (eir_data.flags & (EIR_CONTROLLER | EIR_SIM_HOST | (!EIR_BREDR_UNSUP)))
> + device_set_dual_mode_support(dev, true);

Since Bluetooth 4.1 these flags should not be set and can be ignored
(see volume 3, part C, section 13.1.1).

> @@ -169,6 +169,7 @@ struct btd_device {
> char *path;
> bool bredr;
> bool le;
> + bool dual_mode;

This seems completely pointless to me since dual_mode == true would be
exactly the same as bredr && le.

So, regarding the only potential issue that I could see: it seems we're
lacking code for updating LE support if a device was first discovered
and created over BR/EDR and then we come across it later through LE
discovery. In such a case dev->le would stay untouched.

I just pushed several patches related to this which should hopefully fix
the issue. Let me know if something is still not working for you the way
you'd want with latest git.

Johan