Hi, On Fri, Jul 23, 2010 at 8:48 PM, Ed Tsang <netdesign_98@xxxxxxxxx> 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 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html