2010-07-23 17:48:31

by Ed Tsang

[permalink] [raw]
Subject: How to past connect complete event status (page timeout) to apps

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




2010-07-28 14:04:29

by Ed Tsang

[permalink] [raw]
Subject: Re: How to past connect complete event status (page timeout) to apps

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




2010-07-23 20:15:30

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: How to past connect complete event status (page timeout) to apps

Hi,

On Fri, Jul 23, 2010 at 8:48 PM, Ed Tsang <[email protected]> wrote:
> 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");

--
Luiz Augusto von Dentz
Computer Engineer