2017-12-11 10:38:34

by Szymon Janc

[permalink] [raw]
Subject: [RFC 1/4] Add LEAddressType property for Adapter1 and Device1 interfaces

This provides information about LE Identity Address Type used. This
information is needed for L2CAP sockets and for PTS testing purposes.
---
doc/adapter-api.txt | 9 +++++++++
doc/device-api.txt | 9 +++++++++
2 files changed, 18 insertions(+)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index d852aa6b9..b5abdda39 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -149,6 +149,15 @@ Properties string Address [readonly]

The Bluetooth device address.

+ string LEAddressType [readonly, optional]
+
+ The Bluetooth device LE Identity Address Type. This is
+ present only if LE is supported by adapter.
+
+ Possible values:
+ "public" - Public address
+ "static" - Static Random address
+
string Name [readonly]

The Bluetooth system name (pretty hostname).
diff --git a/doc/device-api.txt b/doc/device-api.txt
index 8b69c2ef3..dfeca305c 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -124,6 +124,15 @@ Properties string Address [readonly]

The Bluetooth device address of the remote device.

+ string LEAddressType [readonly, optional]
+
+ The Bluetooth device LE Identity Address Type. This is
+ present only if device supports LE.
+
+ Possible values:
+ "public" - Public address
+ "static" - Static Random address
+
string Name [readonly, optional]

The Bluetooth remote name. This value can not be
--
2.14.3



2017-12-13 08:50:53

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [RFC 4/4] client: Print LEAddress type in show and info commands

Hi Szymon,

>>> ---
>>>
>>> client/main.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/client/main.c b/client/main.c
>>> index f3369e89a..a1d941e30 100644
>>> --- a/client/main.c
>>> +++ b/client/main.c
>>> @@ -872,6 +872,7 @@ static void cmd_show(int argc, char *argv[])
>>>
>>> print_property(proxy, "Powered");
>>> print_property(proxy, "Discoverable");
>>> print_property(proxy, "Pairable");
>>>
>>> + print_property(proxy, "LEAddressType");
>>>
>>> print_uuids(proxy);
>>> print_property(proxy, "Modalias");
>>> print_property(proxy, "Discovering");
>>>
>>> @@ -1447,6 +1448,7 @@ static void cmd_info(int argc, char *argv[])
>>>
>>> print_property(proxy, "Blocked");
>>> print_property(proxy, "Connected");
>>> print_property(proxy, "LegacyPairing");
>>>
>>> + print_property(proxy, "LEAddressType");
>>>
>>> print_uuids(proxy);
>>> print_property(proxy, "Modalias");
>>> print_property(proxy, "ManufacturerData");
>>>
>>> --
>>> 2.14.3
>>
>> Another alternative to adding the LE specific type would be to add it
>> as Manufacturer string so we can add the information of OUI if public
>> or add the information of "Static Random", "Resolvable Random", etc.
>
> I'd keep it simple - this should simply match to address type that needs to be
> passed when connecting L2CAP socket.

frankly, I prefer the capability to establish the L2CAP connection via D-Bus and return the socket fd that way as well. The D-Bus object types for devices do not really match any L2CAP socket address anyway. So if people want to establish a L2CAP connection oriented channel, they should be able to do that right from the D-Bus object manager they already in. We did the same for BR/EDR with the profile-api.txt and that should be a similar approach here.

Regards

Marcel


2017-12-13 08:47:07

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [RFC 1/4] Add LEAddressType property for Adapter1 and Device1 interfaces

Hi Szymon,

> This provides information about LE Identity Address Type used. This
> information is needed for L2CAP sockets and for PTS testing purposes.
> ---
> doc/adapter-api.txt | 9 +++++++++
> doc/device-api.txt | 9 +++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
> index d852aa6b9..b5abdda39 100644
> --- a/doc/adapter-api.txt
> +++ b/doc/adapter-api.txt
> @@ -149,6 +149,15 @@ Properties string Address [readonly]
>
> The Bluetooth device address.
>
> + string LEAddressType [readonly, optional]
> +
> + The Bluetooth device LE Identity Address Type. This is
> + present only if LE is supported by adapter.
> +
> + Possible values:
> + "public" - Public address
> + "static" - Static Random address
> +

actually just call this AddressType and have it default to public for dual-mode and BR/EDR controllers. In case of single-mode LE controller that really uses a static address name it “random”. The static part will be in the address itself.

> string Name [readonly]
>
> The Bluetooth system name (pretty hostname).
> diff --git a/doc/device-api.txt b/doc/device-api.txt
> index 8b69c2ef3..dfeca305c 100644
> --- a/doc/device-api.txt
> +++ b/doc/device-api.txt
> @@ -124,6 +124,15 @@ Properties string Address [readonly]
>
> The Bluetooth device address of the remote device.
>
> + string LEAddressType [readonly, optional]
> +
> + The Bluetooth device LE Identity Address Type. This is
> + present only if device supports LE.
> +
> + Possible values:
> + "public" - Public address
> + "static" - Static Random address
> +

And this is the same as above.

Regards

Marcel


2017-12-11 12:40:54

by Szymon Janc

[permalink] [raw]
Subject: Re: [RFC 1/4] Add LEAddressType property for Adapter1 and Device1 interfaces

Hi Luiz,

On Monday, 11 December 2017 12:59:18 CET Luiz Augusto von Dentz wrote:
> Hi Szymon,
>
> On Mon, Dec 11, 2017 at 8:38 AM, Szymon Janc <[email protected]>
wrote:
> > This provides information about LE Identity Address Type used. This
> > information is needed for L2CAP sockets and for PTS testing purposes.
> > ---
> >
> > doc/adapter-api.txt | 9 +++++++++
> > doc/device-api.txt | 9 +++++++++
> > 2 files changed, 18 insertions(+)
> >
> > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
> > index d852aa6b9..b5abdda39 100644
> > --- a/doc/adapter-api.txt
> > +++ b/doc/adapter-api.txt
> > @@ -149,6 +149,15 @@ Properties string Address [readonly]
> >
> > The Bluetooth device address.
> >
> > + string LEAddressType [readonly, optional]
> > +
> > + The Bluetooth device LE Identity Address Type.
> > This is + present only if LE is supported by
> > adapter. +
> > + Possible values:
> > + "public" - Public address
> > + "static" - Static Random address
> > +
> >
> > string Name [readonly]
> >
> > The Bluetooth system name (pretty hostname).
> >
> > diff --git a/doc/device-api.txt b/doc/device-api.txt
> > index 8b69c2ef3..dfeca305c 100644
> > --- a/doc/device-api.txt
> > +++ b/doc/device-api.txt
> > @@ -124,6 +124,15 @@ Properties string Address [readonly]
> >
> > The Bluetooth device address of the remote device.
> >
> > + string LEAddressType [readonly, optional]
> > +
> > + The Bluetooth device LE Identity Address Type.
> > This is + present only if device supports LE.
> > +
> > + Possible values:
> > + "public" - Public address
> > + "static" - Static Random address
> > +
> >
> > string Name [readonly, optional]
> >
> > The Bluetooth remote name. This value can not be
> >
> > --
> > 2.14.3
>
> Shouldn't we invest in a proper LE device interface then?

We could split Device1, although address type is stil needed for Adapter1.
And of course splitting interfaces is more work.

BTW after some more thinking I'd use "random" instead of "static" for address
type.

--
pozdrawiam
Szymon Janc

2017-12-11 12:40:25

by Szymon Janc

[permalink] [raw]
Subject: Re: [RFC 4/4] client: Print LEAddress type in show and info commands

Hi Luiz,

On Monday, 11 December 2017 13:10:28 CET Luiz Augusto von Dentz wrote:
> Hi Szymon,
>
> On Mon, Dec 11, 2017 at 8:38 AM, Szymon Janc <[email protected]>
wrote:
> > ---
> >
> > client/main.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/client/main.c b/client/main.c
> > index f3369e89a..a1d941e30 100644
> > --- a/client/main.c
> > +++ b/client/main.c
> > @@ -872,6 +872,7 @@ static void cmd_show(int argc, char *argv[])
> >
> > print_property(proxy, "Powered");
> > print_property(proxy, "Discoverable");
> > print_property(proxy, "Pairable");
> >
> > + print_property(proxy, "LEAddressType");
> >
> > print_uuids(proxy);
> > print_property(proxy, "Modalias");
> > print_property(proxy, "Discovering");
> >
> > @@ -1447,6 +1448,7 @@ static void cmd_info(int argc, char *argv[])
> >
> > print_property(proxy, "Blocked");
> > print_property(proxy, "Connected");
> > print_property(proxy, "LegacyPairing");
> >
> > + print_property(proxy, "LEAddressType");
> >
> > print_uuids(proxy);
> > print_property(proxy, "Modalias");
> > print_property(proxy, "ManufacturerData");
> >
> > --
> > 2.14.3
>
> Another alternative to adding the LE specific type would be to add it
> as Manufacturer string so we can add the information of OUI if public
> or add the information of "Static Random", "Resolvable Random", etc.

I'd keep it simple - this should simply match to address type that needs to be
passed when connecting L2CAP socket.

--
pozdrawiam
Szymon Janc

2017-12-11 12:10:28

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [RFC 4/4] client: Print LEAddress type in show and info commands

Hi Szymon,

On Mon, Dec 11, 2017 at 8:38 AM, Szymon Janc <[email protected]> wrote:
> ---
> client/main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/client/main.c b/client/main.c
> index f3369e89a..a1d941e30 100644
> --- a/client/main.c
> +++ b/client/main.c
> @@ -872,6 +872,7 @@ static void cmd_show(int argc, char *argv[])
> print_property(proxy, "Powered");
> print_property(proxy, "Discoverable");
> print_property(proxy, "Pairable");
> + print_property(proxy, "LEAddressType");
> print_uuids(proxy);
> print_property(proxy, "Modalias");
> print_property(proxy, "Discovering");
> @@ -1447,6 +1448,7 @@ static void cmd_info(int argc, char *argv[])
> print_property(proxy, "Blocked");
> print_property(proxy, "Connected");
> print_property(proxy, "LegacyPairing");
> + print_property(proxy, "LEAddressType");
> print_uuids(proxy);
> print_property(proxy, "Modalias");
> print_property(proxy, "ManufacturerData");
> --
> 2.14.3

Another alternative to adding the LE specific type would be to add it
as Manufacturer string so we can add the information of OUI if public
or add the information of "Static Random", "Resolvable Random", etc.

--
Luiz Augusto von Dentz

2017-12-11 11:59:18

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [RFC 1/4] Add LEAddressType property for Adapter1 and Device1 interfaces

Hi Szymon,

On Mon, Dec 11, 2017 at 8:38 AM, Szymon Janc <[email protected]> wrote:
> This provides information about LE Identity Address Type used. This
> information is needed for L2CAP sockets and for PTS testing purposes.
> ---
> doc/adapter-api.txt | 9 +++++++++
> doc/device-api.txt | 9 +++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
> index d852aa6b9..b5abdda39 100644
> --- a/doc/adapter-api.txt
> +++ b/doc/adapter-api.txt
> @@ -149,6 +149,15 @@ Properties string Address [readonly]
>
> The Bluetooth device address.
>
> + string LEAddressType [readonly, optional]
> +
> + The Bluetooth device LE Identity Address Type. This is
> + present only if LE is supported by adapter.
> +
> + Possible values:
> + "public" - Public address
> + "static" - Static Random address
> +
> string Name [readonly]
>
> The Bluetooth system name (pretty hostname).
> diff --git a/doc/device-api.txt b/doc/device-api.txt
> index 8b69c2ef3..dfeca305c 100644
> --- a/doc/device-api.txt
> +++ b/doc/device-api.txt
> @@ -124,6 +124,15 @@ Properties string Address [readonly]
>
> The Bluetooth device address of the remote device.
>
> + string LEAddressType [readonly, optional]
> +
> + The Bluetooth device LE Identity Address Type. This is
> + present only if device supports LE.
> +
> + Possible values:
> + "public" - Public address
> + "static" - Static Random address
> +
> string Name [readonly, optional]
>
> The Bluetooth remote name. This value can not be
> --
> 2.14.3

Shouldn't we invest in a proper LE device interface then?

--
Luiz Augusto von Dentz

2017-12-11 10:38:37

by Szymon Janc

[permalink] [raw]
Subject: [RFC 4/4] client: Print LEAddress type in show and info commands

---
client/main.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/client/main.c b/client/main.c
index f3369e89a..a1d941e30 100644
--- a/client/main.c
+++ b/client/main.c
@@ -872,6 +872,7 @@ static void cmd_show(int argc, char *argv[])
print_property(proxy, "Powered");
print_property(proxy, "Discoverable");
print_property(proxy, "Pairable");
+ print_property(proxy, "LEAddressType");
print_uuids(proxy);
print_property(proxy, "Modalias");
print_property(proxy, "Discovering");
@@ -1447,6 +1448,7 @@ static void cmd_info(int argc, char *argv[])
print_property(proxy, "Blocked");
print_property(proxy, "Connected");
print_property(proxy, "LegacyPairing");
+ print_property(proxy, "LEAddressType");
print_uuids(proxy);
print_property(proxy, "Modalias");
print_property(proxy, "ManufacturerData");
--
2.14.3


2017-12-11 10:38:36

by Szymon Janc

[permalink] [raw]
Subject: [RFC 3/4] device: Add support for LEAddressType property

---
src/device.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/src/device.c b/src/device.c
index 9f9c47807..02c97bdc6 100644
--- a/src/device.c
+++ b/src/device.c
@@ -727,6 +727,30 @@ static gboolean dev_property_get_address(const GDBusPropertyTable *property,
return TRUE;
}

+static gboolean property_exists_address_type(const GDBusPropertyTable *property,
+ void *user_data)
+{
+ struct btd_device *device = user_data;
+
+ return device->le ? TRUE : FALSE;
+}
+
+static gboolean property_get_address_type(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct btd_device *device = user_data;
+ const char *str;
+
+ if (device->bdaddr_type == BDADDR_LE_PUBLIC)
+ str = "public";
+ else
+ str = "static";
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str);
+
+ return TRUE;
+}
+
static gboolean dev_property_get_name(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
{
@@ -2607,6 +2631,8 @@ static const GDBusMethodTable device_methods[] = {

static const GDBusPropertyTable device_properties[] = {
{ "Address", "s", dev_property_get_address },
+ { "LEAddressType", "s", property_get_address_type, NULL,
+ property_exists_address_type },
{ "Name", "s", dev_property_get_name, NULL, dev_property_exists_name },
{ "Alias", "s", dev_property_get_alias, dev_property_set_alias },
{ "Class", "u", dev_property_get_class, NULL,
@@ -3850,6 +3876,8 @@ void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,

g_dbus_emit_property_changed(dbus_conn, device->path,
DEVICE_INTERFACE, "Address");
+ g_dbus_emit_property_changed(dbus_conn, device->path,
+ DEVICE_INTERFACE, "LEAddressType");
}

void device_set_bredr_support(struct btd_device *device)
--
2.14.3


2017-12-11 10:38:35

by Szymon Janc

[permalink] [raw]
Subject: [RFC 2/4] adapter: Add support for LEAddressType property

---
src/adapter.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 7ac3d20a1..35d9c63c4 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2539,6 +2539,30 @@ static gboolean property_get_address(const GDBusPropertyTable *property,
return TRUE;
}

+static gboolean property_exists_address_type(const GDBusPropertyTable *property,
+ void *user_data)
+{
+ struct btd_adapter *adapter = user_data;
+
+ return (adapter->current_settings & MGMT_SETTING_LE) ? TRUE : FALSE;
+}
+
+static gboolean property_get_address_type(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct btd_adapter *adapter = user_data;
+ const char *str;
+
+ if (adapter->bdaddr_type == BDADDR_LE_PUBLIC)
+ str = "public";
+ else
+ str = "static";
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str);
+
+ return TRUE;
+}
+
static gboolean property_get_name(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *user_data)
{
@@ -3079,6 +3103,8 @@ static const GDBusMethodTable adapter_methods[] = {

static const GDBusPropertyTable adapter_properties[] = {
{ "Address", "s", property_get_address },
+ { "LEAddressType", "s", property_get_address_type, NULL,
+ property_exists_address_type },
{ "Name", "s", property_get_name },
{ "Alias", "s", property_get_alias, property_set_alias },
{ "Class", "u", property_get_class },
--
2.14.3