From 49ab8b0601cfa8380f68b9e57319984478751267 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 4 Dec 2008 15:51:04 +0200 Subject: Add support for the LegacyPairing property --- doc/device-api.txt | 7 +++++++ src/dbus-hci.c | 16 ++++++++++++++-- src/device.c | 7 +++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/doc/device-api.txt b/doc/device-api.txt index 980df628..e17be858 100644 --- a/doc/device-api.txt +++ b/doc/device-api.txt @@ -174,3 +174,10 @@ Properties string Address [readonly] object Adapter [readonly] The object path of the adpater the device belongs to. + + object LegacyPairing [readonly] + + Set to true if the device only supports the pre-2.1 + pairing mechanism. This property is useful in the + Adapter.DeviceFound to anticipate whether legacy or + secure simple pairing will occur. diff --git a/src/dbus-hci.c b/src/dbus-hci.c index 0ea3ad1e..9725010a 100644 --- a/src/dbus-hci.c +++ b/src/dbus-hci.c @@ -894,6 +894,7 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, const char *path, *icon, *paddr = peer_addr; struct remote_dev_info *dev, match; dbus_int16_t tmp_rssi = rssi; + dbus_bool_t legacy = TRUE; uint8_t name_type = 0x00; name_status_t name_status; int state; @@ -909,8 +910,10 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, write_remote_class(local, peer, class); - if (data) + if (data) { write_remote_eir(local, peer, data); + legacy = FALSE; + } /* * workaround to identify situation when the daemon started and @@ -984,7 +987,9 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, "Icon", DBUS_TYPE_STRING, &icon, "RSSI", DBUS_TYPE_INT16, &tmp_rssi, "Name", DBUS_TYPE_STRING, &name, - "Alias", DBUS_TYPE_STRING, &alias, NULL); + "Alias", DBUS_TYPE_STRING, &alias, + "LegacyPairing", DBUS_TYPE_BOOLEAN, &legacy, + NULL); if (name && name_type != 0x08) name_status = NAME_SENT; @@ -1059,12 +1064,18 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, const char *icon = class_to_icon(dev_info->class); const char *alias, *paddr = dstaddr; dbus_int16_t rssi = dev_info->rssi; + dbus_bool_t legacy; if (dev_info->alias) alias = dev_info->alias; else alias = name; + if (read_remote_eir(local, peer, NULL) < 0) + legacy = TRUE; + else + legacy = FALSE; + emit_device_found(adapter_path, dstaddr, "Address", DBUS_TYPE_STRING, &paddr, "Class", DBUS_TYPE_UINT32, &dev_info->class, @@ -1072,6 +1083,7 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, "RSSI", DBUS_TYPE_INT16, &rssi, "Name", DBUS_TYPE_STRING, &name, "Alias", DBUS_TYPE_STRING, &alias, + "LegacyPairing", DBUS_TYPE_BOOLEAN, &legacy, NULL); } diff --git a/src/device.c b/src/device.c index f8014e00..b385814c 100644 --- a/src/device.c +++ b/src/device.c @@ -254,6 +254,13 @@ static DBusMessage *get_properties(DBusConnection *conn, ptr = adapter_get_path(adapter); dict_append_entry(&dict, "Adapter", DBUS_TYPE_OBJECT_PATH, &ptr); + if (read_remote_eir(&src, &device->bdaddr, NULL) < 0) + boolean = TRUE; + else + boolean = FALSE; + + dict_append_entry(&dict, "LegacyPairing", DBUS_TYPE_BOOLEAN, &boolean); + dbus_message_iter_close_container(&iter, &dict); return reply; -- cgit