2017-12-13 13:51:07

by Szymon Janc

[permalink] [raw]
Subject: [PATCH v2 1/4] Add AddressType property for Adapter1 and Device1 interfaces

This provides information about address type being used. It is needed
for L2CAP sockets and PTS testing purposes.
---
doc/adapter-api.txt | 12 ++++++++++++
doc/device-api.txt | 13 +++++++++++++
2 files changed, 25 insertions(+)

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

The Bluetooth device address.

+ string AddressType [readonly]
+
+ The Bluetooth Address Type. For dual-mode and BR/EDR
+ only adapter this defaults to "public". Single mode LE
+ adapters may have either value. With privacy enabled
+ this contains type of Identity Address and not type of
+ address used for connection.
+
+ Possible values:
+ "public" - Public address
+ "random" - 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..1b448eef1 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -124,6 +124,19 @@ Properties string Address [readonly]

The Bluetooth device address of the remote device.

+ string AddressType [readonly]
+
+ The Bluetooth device Address Type. For dual-mode and
+ BR/EDR only devices this defaults to "public". Single
+ mode LE devices may have either value. If remote device
+ uses privacy than before pairing this represents address
+ type used for connection and Identity Address after
+ pairing.
+
+ Possible values:
+ "public" - Public address
+ "random" - Random address
+
string Name [readonly, optional]

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



2017-12-19 12:00:39

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] Add AddressType property for Adapter1 and Device1 interfaces

On Wednesday, 13 December 2017 14:51:07 CET Szymon Janc wrote:
> This provides information about address type being used. It is needed
> for L2CAP sockets and PTS testing purposes.
> ---
> doc/adapter-api.txt | 12 ++++++++++++
> doc/device-api.txt | 13 +++++++++++++
> 2 files changed, 25 insertions(+)
>
> diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
> index d852aa6b9..0533b674a 100644
> --- a/doc/adapter-api.txt
> +++ b/doc/adapter-api.txt
> @@ -149,6 +149,18 @@ Properties string Address [readonly]
>
> The Bluetooth device address.
>
> + string AddressType [readonly]
> +
> + The Bluetooth Address Type. For dual-mode and BR/EDR
> + only adapter this defaults to "public". Single mode LE
> + adapters may have either value. With privacy enabled
> + this contains type of Identity Address and not type of
> + address used for connection.
> +
> + Possible values:
> + "public" - Public address
> + "random" - 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..1b448eef1 100644
> --- a/doc/device-api.txt
> +++ b/doc/device-api.txt
> @@ -124,6 +124,19 @@ Properties string Address [readonly]
>
> The Bluetooth device address of the remote device.
>
> + string AddressType [readonly]
> +
> + The Bluetooth device Address Type. For dual-mode and
> + BR/EDR only devices this defaults to "public". Single
> + mode LE devices may have either value. If remote device
> + uses privacy than before pairing this represents address
> + type used for connection and Identity Address after
> + pairing.
> +
> + Possible values:
> + "public" - Public address
> + "random" - Random address
> +
> string Name [readonly, optional]
>
> The Bluetooth remote name. This value can not be

Applied.

--
pozdrawiam
Szymon Janc

2017-12-13 13:51:10

by Szymon Janc

[permalink] [raw]
Subject: [PATCH v2 4/4] client: Print Address type in show and info commands

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

diff --git a/client/main.c b/client/main.c
index f3369e89a..c435ee677 100644
--- a/client/main.c
+++ b/client/main.c
@@ -864,7 +864,16 @@ static void cmd_show(int argc, char *argv[])
return;

dbus_message_iter_get_basic(&iter, &address);
- bt_shell_printf("Controller %s\n", address);
+
+ if (g_dbus_proxy_get_property(proxy, "AddressType", &iter) == TRUE) {
+ const char *type;
+
+ dbus_message_iter_get_basic(&iter, &type);
+
+ bt_shell_printf("Controller %s (%s)\n", address, type);
+ } else {
+ bt_shell_printf("Controller %s\n", address);
+ }

print_property(proxy, "Name");
print_property(proxy, "Alias");
@@ -1435,7 +1444,16 @@ static void cmd_info(int argc, char *argv[])
return;

dbus_message_iter_get_basic(&iter, &address);
- bt_shell_printf("Device %s\n", address);
+
+ if (g_dbus_proxy_get_property(proxy, "AddressType", &iter) == TRUE) {
+ const char *type;
+
+ dbus_message_iter_get_basic(&iter, &type);
+
+ bt_shell_printf("Device %s (%s)\n", address, type);
+ } else {
+ bt_shell_printf("Device %s\n", address);
+ }

print_property(proxy, "Name");
print_property(proxy, "Alias");
--
2.14.3


2017-12-13 13:51:09

by Szymon Janc

[permalink] [raw]
Subject: [PATCH v2 3/4] device: Add support for AddressType property

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

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

+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->le && device->bdaddr_type == BDADDR_LE_RANDOM)
+ str = "random";
+ else
+ str = "public";
+
+ 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 +2623,7 @@ static const GDBusMethodTable device_methods[] = {

static const GDBusPropertyTable device_properties[] = {
{ "Address", "s", dev_property_get_address },
+ { "AddressType", "s", property_get_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 +3867,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, "AddressType");
}

void device_set_bredr_support(struct btd_device *device)
--
2.14.3


2017-12-13 13:51:08

by Szymon Janc

[permalink] [raw]
Subject: [PATCH v2 2/4] adapter: Add support for AddressType property

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

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

+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->current_settings & MGMT_SETTING_LE) &&
+ (adapter->bdaddr_type == BDADDR_LE_RANDOM))
+ str = "random";
+ else
+ str = "public";
+
+ 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 +3096,7 @@ static const GDBusMethodTable adapter_methods[] = {

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