Skip to contentSkip to conversation

Add SetRemoteProperties method for OOB COD setting

PATCH In review Bartosz Szatkowski 3 participants 5 messages Aug 22, 2011 – Jul 23, 2012 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 Add SetRemoteProperties method for OOB COD setting

Add method for suppling class of device through OOB mechanism, to be available at pairing phase. At this point it may be presented to the user, by agent, in confirmation request (or whatever).

---
 doc/oob-api.txt   |   13 ++++
 plugins/dbusoob.c |  164 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 177 insertions(+), 0 deletions(-)
doc/oob-api.txt +13 -0
index d838712..0324758 100644
@@ -36,3 +36,16 @@ Methods		array{byte} hash, array{byte} randomizer ReadLocalData()
 
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InvalidArguments
+
+		void SetRemoteProperties(string address, dict data)
+
+			This method set new properties for device with specified
+			address, to be used when device is created.
+			On success DeviceFound signal will be emitted.
+
+			Currently supported keys:
+
+				Class		uint32
+
+			Possible errors: org.bluez.Error.Failed
+					 org.bluez.Error.InvalidArguments
plugins/dbusoob.c +164 -0

188 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#1 lore raw

PATCH v2 2/3 Add support for OOB data in SetRemoteProperties

Now its possible to exchange OOB simple pairing data through DBus API method with other device properties.

---
 doc/oob-api.txt   |    5 ++++-
 plugins/dbusoob.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletions(-)
doc/oob-api.txt +4 -1
index 0324758..500ef15 100644
@@ -41,11 +41,14 @@ Methods		array{byte} hash, array{byte} randomizer ReadLocalData()
 
 			This method set new properties for device with specified
 			address, to be used when device is created.
-			On success DeviceFound signal will be emitted.
+			On success DeviceFound signal will be emitted (except
+			situations when only hash and randomizer is supplied).
 
 			Currently supported keys:
 
 				Class		uint32
+				Hash		array{byte}
+				Randomizer	array{byte}
 
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InvalidArguments
plugins/dbusoob.c +47 -0

71 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#2 lore raw

PATCH v2 3/3 Add support for name in OOB SetRemoteProperties

In reply to Bartosz Szatkowski
---
 doc/oob-api.txt   |    1 +
 plugins/dbusoob.c |   34 ++++++++++++++++++++++++++++++++++
 src/storage.c     |    2 +-
 src/storage.h     |    2 +-
 4 files changed, 37 insertions(+), 2 deletions(-)
doc/oob-api.txt +1 -0
index 500ef15..2d0d096 100644
@@ -49,6 +49,7 @@ Methods		array{byte} hash, array{byte} randomizer ReadLocalData()
 				Class		uint32
 				Hash		array{byte}
 				Randomizer	array{byte}
+				Name		String
 
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InvalidArguments
plugins/dbusoob.c +34 -0
index f0bbd14..412cd67 100644
@@ -59,6 +59,7 @@ struct oob_remote_parameters {
 	uint32_t class;
 	uint8_t *hash;
 	uint8_t *randomizer;
+	const char *name;
 	gboolean device_found;
 };
 
@@ -191,6 +192,10 @@ static void emit_device_found(const char *path,
 		dict_append_entry(&dict, "Class", DBUS_TYPE_UINT32,
 							&params->class);
 
+	if (params->name != NULL)
+		dict_append_entry(&dict, "Name", DBUS_TYPE_STRING,
+							&params->name);
+
 	dbus_message_iter_close_container(&iter, &dict);
 
 	g_dbus_send_message(connection, signal);
@@ -255,6 +260,29 @@ static void set_oob_data(struct btd_adapter *adapter,
 		error("Adding remote OOB data failed");
 }
 
+static DBusMessage *parse_name(DBusMessageIter *value,
+			struct oob_remote_parameters *params, DBusMessage *msg)
+{
+	if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_STRING)
+		return btd_error_invalid_args(msg);
+
+	dbus_message_iter_get_basic(value, &params->name);
+
+	return NULL;
+}
+
+static void set_name(struct oob_remote_parameters *params)
+{
+	if (write_device_name(&params->local, &params->peer,
+							params->name) < 0) {
+		error("Setting device name failed");
+
+		return;
+	}
+
+	params->device_found = TRUE;
+}
+
 static DBusMessage *parse_property(const char *property,
 				DBusMessageIter *value, DBusMessage *msg,
 				struct oob_remote_parameters *params)
@@ -262,6 +290,9 @@ static DBusMessage *parse_property(const char *property,
 	if (g_str_equal("Class", property))
 		return parse_class(value, params, msg);
 
+	if (g_str_equal("Name", property))
+		return parse_name(value, params, msg);
+
 	if (g_str_equal("Hash", property))
 		return parse_oob_data(value, &params->hash, msg);
 
@@ -277,6 +308,9 @@ static void set_properties(struct btd_adapter *adapter,
 	if (params->class != 0)
 		set_class(params);
 
+	if (params->name != NULL)
+		set_name(params);
+
 	if (params->hash != NULL && params->randomizer != NULL)
 		set_oob_data(adapter, params);
 
src/storage.c +1 -1
index 1f3da6e..414d158 100644
@@ -321,7 +321,7 @@ int read_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t *class)
 	return 0;
 }
 
-int write_device_name(bdaddr_t *local, bdaddr_t *peer, char *name)
+int write_device_name(bdaddr_t *local, bdaddr_t *peer, const char *name)
 {
 	char filename[PATH_MAX + 1], addr[18], str[249];
 	int i;
src/storage.h +1 -1
index bb64727..78513ac 100644
@@ -38,7 +38,7 @@ int write_local_class(bdaddr_t *bdaddr, uint8_t *class);
 int read_local_class(bdaddr_t *bdaddr, uint8_t *class);
 int write_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class);
 int read_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t *class);
-int write_device_name(bdaddr_t *local, bdaddr_t *peer, char *name);
+int write_device_name(bdaddr_t *local, bdaddr_t *peer, const char *name);
 int read_device_name(const char *src, const char *dst, char *name);
 int write_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data);
 int read_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data);
Signature · 1 line
1.7.4.1
#3 lore raw
In reply to Bartosz Szatkowski

Hi Bartosz (and whoever is interested in OOB pairing),

Quoted 7 lines · Bartosz Szatkowski

Add method for suppling class of device through OOB mechanism, to be available at pairing phase. At this point it may be presented to the user, by agent, in confirmation request (or whatever).

---
 doc/oob-api.txt   |   13 ++++
 plugins/dbusoob.c |  164 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 177 insertions(+), 0 deletions(-)

These patches never went upstream but I'd like to revive the discussion around them.

Quoted 11 lines
doc/oob-api.txt +3 -0
index d838712..0324758 100644
@@ -36,3 +36,16 @@ Methods		array{byte} hash, array{byte} randomizer ReadLocalData()
 
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InvalidArguments
+
+		void SetRemoteProperties(string address, dict data)
+

doc/oob-api.txt Methods array{byte} hash, array{byte} randomizer ReadLocalData() · line 51

Quoted 10 lines
doc/oob-api.txt +10 -0
+			This method set new properties for device with specified
+			address, to be used when device is created.
+			On success DeviceFound signal will be emitted.
+
+			Currently supported keys:
+
+				Class		uint32
+
+			Possible errors: org.bluez.Error.Failed
+					 org.bluez.Error.InvalidArguments

Now that we're starting to prepare BlueZ 5 we can make more radical changes to the D-Bus APIs. E.g. I don't think we need a separate SetRemoteProperties method but the existing AddRemoteData one could simply be changed to take a dictionary which would usually just include the keys "Randomizer" and "Hash" but could also include other info like "Class".

Thoughts? Is anyone actually actively using the current OutOfBand D-Bus interface?

Johan

#4 lore raw
Quoted 1 line · On Thursday 28 of June 2012 14:33:21 Johan Hedberg wrote:

Hi Bartosz (and whoever is interested in OOB pairing),

Hi,

Quoted 32 lines · Bartosz Szatkowski
Quoted 7 lines

Add method for suppling class of device through OOB mechanism, to be available at pairing phase. At this point it may be presented to the user, by agent, in confirmation request (or whatever).

---
 doc/oob-api.txt   |   13 ++++
 plugins/dbusoob.c |  164 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 177 insertions(+), 0 deletions(-)

These patches never went upstream but I'd like to revive the discussion around them.

Quoted 20 lines
doc/oob-api.txt +12 -0
index d838712..0324758 100644
@@ -36,3 +36,16 @@ Methods		array{byte} hash, array{byte} randomizer ReadLocalData()
 
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InvalidArguments
+
+		void SetRemoteProperties(string address, dict data)
+
+			This method set new properties for device with specified
+			address, to be used when device is created.
+			On success DeviceFound signal will be emitted.
+
+			Currently supported keys:
+
+				Class		uint32
+
+			Possible errors: org.bluez.Error.Failed
Quoted 8 lines

doc/oob-api.txt Methods array{byte} hash, array{byte} randomizer ReadLocalData() · line 51

Quoted 1 line
doc/oob-api.txt +1 -0
+					 org.bluez.Error.InvalidArguments

Now that we're starting to prepare BlueZ 5 we can make more radical changes to the D-Bus APIs. E.g. I don't think we need a separate SetRemoteProperties method but the existing AddRemoteData one could simply be changed to take a dictionary which would usually just include the keys "Randomizer" and "Hash" but could also include other info like "Class".

In general dbusoob was intended to be only simple dbus wrapper for oob.h functionality (mostly for testing purposes) and proper oob channel 'backend' should be used with real usecases. But dbusoob is still usefull if one wants to have oob handling developed outside of bluez (e.g. as some Android application).

I think changing to dictionary is good move as this will make API more flexible and easier to extend.

Yet, I'm not sure how we should handle other (than hash and randomizer) info coming from oob channel. Just write it down so we can show them in device properties after pairing? Or simulate inquiry result with device found signal (as with commented patch)? Second would probably require some additional comments in adapter api.

Quoted 3 lines

Thoughts? Is anyone actually actively using the current OutOfBand D-Bus interface?

Some time ago I've created patch(es) [1] for Android ICS that make use of dbusoob api instead of google's bluez oob implementation.

Also neard is currently using dbusoob but this should be dropped in favor of neard specific plugin in bluez.

[1] https://android-review.googlesource.com/#/c/36650/

Signature · 2 lines
BR
Szymon Janc