Skip to contentSkip to conversation

Input service and multiple adapters

Bluez-devel Daniel Gollub 2 participants 3 messages Mar 25, 2007 – Mar 27, 2007 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi folks,

i started playing around with the Input DBUS API and found an obscurity whe= n =

multiple bluetooth adapters are used. Actually this is a really rare use =

case...

If i use Adapter A and call CreateDevice() and Connect() to an input device=
.. =

everything works as expected. If Adapter A got unplugged/broken and got =

replaced by Adapter B and call CreateDevice() for the same input device. Th= e =

result will be org.bluez.input.AlreadyExists

Again.. this is a really rare use case, but is it intended to only have one =

input device configuration for the system? What about having input device =

configuration for each Adapter?

(ugly) Example:

Interface=B7 org.bluez.input.Manager
Object path=B7 /org/bluez/input/{Adapter MAC Address ...}

This makes also the integration in the GUI a bit easier. So we can display =

which input device is configured per adapter. And suppress the output of =

bluetooth input devices if the responsible adapter is unplugged/off.

Or am i completely wrong and missed something...
... if not i fear the same problem for the Audio DBUS API as well.

best regards,
Daniel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDE=
VDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#1 lore raw
Quoted 6 lines · Daniel Gollub

Hi folks,

i started playing around with the Input DBUS API and found an obscurity when multiple bluetooth adapters are used. Actually this is a really rare use case...

Quoted 6 lines

If i use Adapter A and call CreateDevice() and Connect() to an input device .. everything works as expected. If Adapter A got unplugged/broken and got replaced by Adapter B and call CreateDevice() for the same input device. The result will be org.bluez.input.AlreadyExists

Again.. this is a really rare use case, but is it intended to only have one

No, it is pretty common.
I have one USB cable at home, with a hub and everything (including BT dongles) connected to it and one USB cable at work, again with a BT dongle. And then i have a BT dongle in my pocket for on-the-road usage.

Signature · 14 lines
Stefan Seyfried

"Any ideas, John?"
"Well, surrounding them's out." 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
#2 lore raw
In reply to Daniel Gollub

Hi Marcel,

as discussed in #bluez we should store the address of the adapter. I renamed GetAddress() to GetPeerAddress() and added a new function GetLocalAddress(). Simple patch attachted ... i hope everyone is happy with this one...

best regards,
Daniel

Index: input/device.c
===================================================================
RCS file: /cvsroot/bluez/utils/input/device.c,v
retrieving revision 1.37

device.c +27 -3
diff -u -p -r1.37 device.c
@@ -889,7 +889,28 @@ static DBusHandlerResult device_is_conne
 	return send_message_and_unref(conn, reply);
 }
 
-static DBusHandlerResult device_get_address(DBusConnection *conn,
+static DBusHandlerResult device_get_local_address(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	struct device *idev = data;
+	DBusMessage *reply;
+	char addr[18];
+	const char *paddr = addr;
+
+	ba2str(&idev->src, addr);
+
+	reply = dbus_message_new_method_return(msg);
+	if (!reply)
+		return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+	dbus_message_append_args(reply,
+			DBUS_TYPE_STRING, &paddr,
+			DBUS_TYPE_INVALID);
+
+	return send_message_and_unref(conn, reply);
+}
+
+static DBusHandlerResult device_get_peer_address(DBusConnection *conn,
 						DBusMessage *msg, void *data)
 {
 	struct device *idev = data;
@@ -983,8 +1004,11 @@ static DBusHandlerResult device_message(
 	if (strcmp(member, "IsConnected") == 0)
 		return device_is_connected(conn, msg, data);
 
-	if (strcmp(member, "GetAddress") == 0)
-		return device_get_address(conn, msg, data);
+	if (strcmp(member, "GetLocalAddress") == 0)
+		return device_get_local_address(conn, msg, data);
+
+	if (strcmp(member, "GetPeerAddress") == 0)
+		return device_get_peer_address(conn, msg, data);
 
 	if (strcmp(member, "GetName") == 0)
 		return device_get_name(conn, msg, data);

Index: input/input-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/input/input-api.txt,v retrieving revision 1.8

input-api.txt +7 -1
diff -u -p -r1.8 input-api.txt
@@ -48,7 +48,13 @@ Service		org.bluez.input
 Interface	org.bluez.input.Device
 Object path	/org/bluez/input/{keyboard*|mouse*|...}
 
-Methods		string GetAddress()
+Methods		string GetLocalAddress()
+
+			Returns the adapter address.
+
+			Example: "00:11:22:33:44:55"
+
+		string GetPeerAddress()
 
 			Returns the device address.
 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel