diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2006-08-24 20:24:11 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2006-08-24 20:24:11 +0000 |
commit | 5d0f59f6c5ea8208c7c2e51b1a4abca4d8f971ef (patch) | |
tree | 0ab715c5a1daaa89ecf4ddc407f558b47cdd9431 /hcid/dbus-adapter.c | |
parent | 657ab7521130ad1335cfb2f0352b59a2516c41fb (diff) |
CancelBonding improved
Diffstat (limited to 'hcid/dbus-adapter.c')
-rw-r--r-- | hcid/dbus-adapter.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c index 75232a7b..07583d77 100644 --- a/hcid/dbus-adapter.c +++ b/hcid/dbus-adapter.c @@ -1793,7 +1793,6 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu { struct hci_dbus_data *dbus_data = data; struct slist *l; - DBusMessage *reply = NULL; DBusError err; bdaddr_t peer_bdaddr; const char *peer_addr; @@ -1831,6 +1830,8 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu if (dd < 0) return error_no_such_adapter(conn, msg); + dbus_data->bonding->cancel = dbus_message_ref(msg); + l = slist_find(dbus_data->active_conn, &peer_bdaddr, active_conn_find_by_bdaddr); if (!l) { @@ -1866,29 +1867,31 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu return error_failed(conn, msg, bt_error(rp.status)); } - dbus_data->bonding->cancel = dbus_message_ref(msg); + /* + * if the HCI doesn't support cancel create connection cmd let + * the create connection complete event arrives with page timeout. + * Bonding in progress will be returned to requestors. + */ + } else { struct active_conn_info *cinfo = l->data; - /* FIXME: if waiting remote PIN, which HCI cmd must be sent? */ - - /* reply to cancel bonding */ - reply = dbus_message_new_method_return(msg); - send_reply_and_unref(conn, reply); - - /* Reply to the create bonding request */ - error_authentication_canceled(conn, dbus_data->bonding->rq); - name_listener_remove(conn, dbus_message_get_sender(dbus_data->bonding->rq), - (name_cb_t) create_bond_req_exit, dbus_data); + /* for unlock PIN Code Request */ + hci_send_cmd(dd, OGF_LINK_CTL, OCF_PIN_CODE_NEG_REPLY, 6, &peer_bdaddr); - /* disconnect from the remote device */ + /* + * Disconnect from the remote device for safety, maybe the + * Controller already received the reply for PIN Code Request + */ if (dbus_data->bonding->disconnect) { - if (hci_disconnect(dd, htobs(cinfo->handle), HCI_OE_USER_ENDED_CONNECTION, 1000) < 0) + if (hci_disconnect(dd, htobs(cinfo->handle), HCI_AUTHENTICATION_FAILURE, 1000) < 0) error("Disconnect failed"); } - bonding_request_free(dbus_data->bonding); - dbus_data->bonding = NULL; + /* + * If disconnect can't be applied and the PIN Code Request + * was already replied let the Controller's timer to expire + */ } hci_close_dev(dd); |