diff --git a/src/adapter.c b/src/adapter.c
index 5539d55..0e97e57 100644
--- a/src/adapter.c
+++ b/src/adapter.c
struct btd_device *device = l->data;
if (device_is_bonding(device, NULL))
- device_cancel_bonding(device,
+ device_bonding_failed(device,
HCI_OE_USER_ENDED_CONNECTION);
}
}
diff --git a/src/device.c b/src/device.c
index 4af2179..a56eba2 100644
--- a/src/device.c
+++ b/src/device.c
if (status) {
device_cancel_authentication(device, TRUE);
- device_cancel_bonding(device, status);
+ device_bonding_failed(device, status);
return;
}
return g_str_equal(sender, dbus_message_get_sender(bonding->msg));
}
+void device_bonding_failed(struct btd_device *device, uint8_t status)
+{
+ struct bonding_req *bonding = device->bonding;
+ DBusMessage *reply;
+
+ DBG("status %u", status);
+
+ if (!bonding)
+ return;
+
+ if (device->authr)
+ device_cancel_authentication(device, FALSE);
+
+ reply = new_authentication_return(bonding->msg, status);
+ g_dbus_send_message(btd_get_dbus_connection(), reply);
+
+ bonding_request_free(bonding);
+}
+
void device_cancel_bonding(struct btd_device *device, uint8_t status)
{
struct bonding_req *bonding = device->bonding;
diff --git a/src/device.h b/src/device.h
index 3128615..b9f8f76 100644
--- a/src/device.h
+++ b/src/device.h
gboolean device_is_connected(struct btd_device *device);
void device_bonding_complete(struct btd_device *device, uint8_t status);
gboolean device_is_bonding(struct btd_device *device, const char *sender);
+void device_bonding_failed(struct btd_device *device, uint8_t status);
void device_cancel_bonding(struct btd_device *device, uint8_t status);
int device_request_pincode(struct btd_device *device, gboolean secure);
int device_request_passkey(struct btd_device *device);
diff --git a/src/mgmt.c b/src/mgmt.c
index d70c941..798435f 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
if (device) {
if (device_is_bonding(device, NULL))
- device_cancel_bonding(device, ev->status);
+ device_bonding_failed(device, ev->status);
if (device_is_temporary(device))
adapter_remove_device(adapter, device, TRUE);
}