Skip to contentSkip to conversation

How to past connect complete event status (page timeout) to apps

DISCUSSION Ed Tsang 2 participants 3 messages Jul 23, 2010 – Jul 28, 2010 Bluetooth drivers

lore
Share & tools
lore

Ed Tsang

author
#0 lore raw

Hi, I tried to implement my apps to do different things depend on the failed connection attempt.
On Hci dump I could saw the connect complete status is different depend on the actual failure (e.g. 0x10 accept timeout, 0x06, PIN missing, 0x04 page timeout). But the apps (base on obex-client) is not able to see those status code.
The obex-client attempt a sdp_connect and then g_io_add_watch. On the
callback, we could see the G_IO_ERROR but I could not figure out a way to get more detail on the failed condition. I tried look into the Bluez and could not figure what to change to pass those connect event status up..
Anyone could offer some advise/hint...

Cheers,
Ed

#1 lore raw

Hi,

Quoted 11 lines · Ed Tsang

Hi,  I tried to implement my apps to do different things depend on the failed connection attempt.
On Hci dump I could saw the connect complete status is different depend on the actual failure (e.g. 0x10 accept timeout, 0x06, PIN missing, 0x04 page timeout).  But the apps (base on obex-client) is not able to see those status code.
  The obex-client attempt a sdp_connect and then g_io_add_watch.  On the callback, we could see the G_IO_ERROR but I could not figure out a way to get more detail on the failed condition.  I tried look into the Bluez and could not figure what to change to pass those connect event status up.. Anyone could offer some advise/hint...

Well first you will not get the same error on the socket, they will be translated to errno but the errors will be very similar e.g: page timeout is mapped to EHOSTDOWN.

But it seems we have a bug in obex-client, basically we need to check SO_ERROR with getsockopt before proceeding with sdp_set_notify. If you are fixing this please have a look at btio.c, it should be ok and it seems ofono does it in a similar fashion:

	/* If the user aborted this connect attempt */
	if ((cond & G_IO_NVAL) || check_nval(io))
		return FALSE;

	if (cond & G_IO_OUT) {
		int err = 0, sock = g_io_channel_unix_get_fd(io);
		socklen_t len = sizeof(err);

		if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &len) < 0)
			err = errno;

		if (err)
			g_set_error(&gerr, BT_IO_ERROR,
					BT_IO_ERROR_CONNECT_FAILED, "%s (%d)",
					strerror(err), err);
	} else if (cond & (G_IO_HUP | G_IO_ERR))
		g_set_error(&gerr, BT_IO_ERROR, BT_IO_ERROR_CONNECT_FAILED,
				"HUP or ERR on socket");
Signature · 2 lines
Luiz Augusto von Dentz
Computer Engineer
author
#2 lore raw

Luiz, Got it working now EHOSTDOWN, ETIMEOUT... I could not fix the git, as my private branch out of 0.14.

What I did is inject at some of the call back (service_callback,
rfcomm_callback..).

     if (cond & (G_IO_NVAL | G_IO_ERR)) {
        int err = 0, sock = g_io_channel_unix_get_fd(io);
        socklen_t len = sizeof(err);

        if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &len) < 0)
            err = errno;  /* then send it to the agent via a new method*/
        }

--------
Basically I will see G_IO_ERR when it fail (for those test case that I am
working on).
One question that I hope you could help me is to how to tune the timing for
ETIMEOUT, GW_OBEX_ERROR_TIMEOUT. I tried to search (timeout|TIMEOUT) and did not get too far.

Cheers
Ed