Skip to contentSkip to conversation

DBus GetRemoteName problem

PATCH In review Frederic Danis 2 participants 3 messages Jun 6, 2006 – Jun 7, 2006 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 DBus GetRemoteName problem

Hello,

When I use GetRemoteName of dbus-test program I receive a DiscoveryCompleted signal after the RemoteNameUpdated (or RemoteNameFailed) signal. You can find attached a patch to fix this.

Hope this helps.

Regards

Fred

Signature · 7 lines
-----------------------------------------------
It is not by improving the oil lamp that one invents the electric bulb!
-----------------------------------------------
Danis Frederic            PalmSource Europe
Software engineer
Mail : mailto:[email protected]
-----------------------------------------------
dbus-adapter.c renamed from dbus-adapter.c.orig +1 -2
@@ -1255,8 +1255,7 @@
 	 * Otherwise, send the HCI cmd to get the remote name
 	 */
 	if (dbus_data->discover_state == STATE_IDLE) {
-		if (!disc_device_req_name(dbus_data))
-			dbus_data->discover_state = STATE_RESOLVING_NAMES;
+		disc_device_req_name(dbus_data);
 	}
 
 	return error_request_deferred(conn, msg);

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

#1 lore raw

Hi Frederic,

It's necessary consider some extra conditions:

1. DiscoverDevices running
2. DiscoverDevicesWithoutNameResolving running
3. non D-Bus inquiry request(eg: hcitool, kbluetoothd, ..)
4. After receive a connection complete event, a HCI remote name request is sent to update the remote name

The GetRemoteName request can arrive under these conditions.

I already fixed this bug, but it needs more tests.

Claudio.

Signature · 3 lines
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT
Quoted 40 lines · Frederic Danis

Hello,

When I use GetRemoteName of dbus-test program I receive a DiscoveryCompleted signal after the RemoteNameUpdated (or RemoteNameFailed) signal.
You can find attached a patch to fix this.

Hope this helps.

Regards

Fred

--
-----------------------------------------------
It is not by improving the oil lamp that one invents the electric bulb!
-----------------------------------------------
Danis Frederic PalmSource Europe
Software engineer
Mail : mailto:[email protected]
-----------------------------------------------

dbus-adapter.c 2006-06-06 14:51:57.000000000 +0200 renamed from dbus-adapter.c.orig 2006-06-06 11:35:32.000000000 +0200 +1 -2
@@ -1255,8 +1255,7 @@
         * Otherwise, send the HCI cmd to get the remote name
         */
        if (dbus_data->discover_state == STATE_IDLE) {
-               if (!disc_device_req_name(dbus_data))
-                       dbus_data->discover_state = STATE_RESOLVING_NAMES;
+               disc_device_req_name(dbus_data);
        }
 
        return error_request_deferred(conn, msg);
Quoted 7 lines

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

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

#2 lore raw

Hi Marcel, Fred,

Here is the patch to fix the extra DiscoveryCompleted signal sent. I added an extra field in the discovered_dev_info list to handle the scenario when GetRemoteName request is received while there is a DiscoverDevicesWithoutNameResolving running.

I also included some code cleanup.

Do you have comments or another suggestion to fix this problem?

Claudio.

Quoted 70 lines · Claudio Takahasi

Hi Frederic,

It's necessary consider some extra conditions:

1. DiscoverDevices running
2. DiscoverDevicesWithoutNameResolving running
3. non D-Bus inquiry request(eg: hcitool, kbluetoothd, ..)
4. After receive a connection complete event, a HCI remote name request is sent to update the remote name

The GetRemoteName request can arrive under these conditions.

I already fixed this bug, but it needs more tests.

Claudio.

--
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT

Quoted 47 lines · Frederic Danis

Hello,

When I use GetRemoteName of dbus-test program I receive a DiscoveryCompleted signal after the RemoteNameUpdated (or RemoteNameFailed) signal.
You can find attached a patch to fix this.

Hope this helps.

Regards

Fred

--
-----------------------------------------------
It is not by improving the oil lamp that one invents the electric bulb!
-----------------------------------------------
Danis Frederic PalmSource Europe
Software engineer
Mail : mailto:[email protected]
-----------------------------------------------

dbus-adapter.c 2006-06-06 14:51:57.000000000 +0200 renamed from dbus-adapter.c.orig 2006-06-06 11:35:32.000000000 +0200 +1 -2
@@ -1255,8 +1255,7 @@
         * Otherwise, send the HCI cmd to get the remote name
         */
        if (dbus_data->discover_state == STATE_IDLE) {
-               if (!disc_device_req_name(dbus_data))
-                       dbus_data->discover_state = STATE_RESOLVING_NAMES;
+               disc_device_req_name(dbus_data);
        }
 
        return error_request_deferred(conn, msg);

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

Signature · 3 lines
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT

Index: dbus-adapter.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-adapter.c,v retrieving revision 1.55

dbus-adapter.c +4 -6
diff -u -r1.55 dbus-adapter.c
@@ -1248,16 +1248,14 @@
 
 	/* put the request name in the queue to resolve name */
 	str2ba(peer_addr, &peer_bdaddr);
-	disc_device_append(&dbus_data->disc_devices, &peer_bdaddr, NAME_PENDING);
+	disc_device_append(&dbus_data->disc_devices, &peer_bdaddr, NAME_PENDING, RESOLVE_NAME);
 
 	/* 
 	 * if there is a discover process running, just queue the request.
 	 * Otherwise, send the HCI cmd to get the remote name
 	 */
-	if (dbus_data->discover_state == STATE_IDLE) {
-		if (!disc_device_req_name(dbus_data))
-			dbus_data->discover_state = STATE_RESOLVING_NAMES;
-	}
+	if (dbus_data->discover_state == STATE_IDLE)
+		disc_device_req_name(dbus_data);
 
 	return error_request_deferred(conn, msg);
 }
@@ -2070,7 +2068,7 @@
 	if (strcmp("DiscoverDevicesWithoutNameResolving", method) == 0)
 		dbus_data->discover_type = WITHOUT_NAME_RESOLVING;
 	else 
-		dbus_data->discover_type = RESOLVE_NAMES;
+		dbus_data->discover_type = RESOLVE_NAME;
 		
 	dbus_data->requestor_name = strdup(dbus_message_get_sender(msg));
 

Index: dbus.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus.c,v
retrieving revision 1.126

dbus.c +90 -86

299 lines not on this page · raw message

Index: dbus.h
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus.h,v
retrieving revision 1.88

dbus.h +6 -4
diff -u -r1.88 dbus.h
@@ -63,13 +63,14 @@
 	STATE_IDLE,
 	STATE_DISCOVER,
 	STATE_RESOLVING_NAMES
-}discover_state_t;
+} discover_state_t;
 
 /* discover type  */
-#define WITHOUT_NAME_RESOLVING		0
-#define RESOLVE_NAMES			1
+#define WITHOUT_NAME_RESOLVING		1 /* D-Bus and non D-Bus request */
+#define RESOLVE_NAME			2	
 
 typedef enum {
+	NAME_ANY,
 	NAME_PENDING,
 	NAME_SENT
 } name_status_t;
@@ -77,6 +78,7 @@
 struct discovered_dev_info {
 	bdaddr_t bdaddr;
 	name_status_t name_status;
+	int discover_type;
 };
 
 struct bonding_request_info {
@@ -190,7 +192,7 @@
 int active_conn_find_by_bdaddr(const void *data, const void *user_data);
 void bonding_request_free(struct bonding_request_info *dev);
 void disc_device_info_free(void *data, void *user_data);
-int disc_device_append(struct slist **list, bdaddr_t *bdaddr, name_status_t name_status);
+int disc_device_append(struct slist **list, bdaddr_t *bdaddr, name_status_t name_status, int discover_type);
 int disc_device_req_name(struct hci_dbus_data *dbus_data);
 
 int discoverable_timeout_handler(void *data);

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