Hi Chengyi, On Fri, Jun 28, 2024 at 6:15 AM Chengyi Zhao <zhaochengyi@xxxxxxxxxxxxx> wrote: > > When a user initiates pairing with a BLE Bluetooth mouse, > MGMT_STATUS_CONNECT_FAILED(0x04) is returned with a low > probability, resulting in pairing failure. To improve > user experience, retry bonding is performed when > MGMT_STATUS_CONNECT_FAILED is returned. > > log: > bluetoothd[1539]: src/adapter.c:pair_device_complete() Connect Failed (0x04) > bluetoothd[1539]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr DD:EC:0F:57:A9:2E type 2 status 0x4 > bluetoothd[1539]: src/device.c:device_bonding_complete() bonding 0x5591f87230 status 0x04 > bluetoothd[1539]: src/device.c:btd_device_set_temporary() temporary 1 > bluetoothd[1539]: src/device.c:device_bonding_failed() status 4 > > HCI package: > Frame 2969: 7 bytes on wire (56 bits), 7 bytes captured (56 bits) > Bluetooth > Bluetooth HCI H4 > Bluetooth HCI Event - Disconnect Complete > Event Code: Disconnect Complete (0x05) > Parameter Total Length: 4 > Status: Success (0x00) > Connection Handle: 0x0040 > Reason: Connection Failed to be Established (0x3e) > --- > src/adapter.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/src/adapter.c b/src/adapter.c > index bdc5bf920..ca5eb077c 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -8367,6 +8367,16 @@ static void bonding_attempt_complete(struct btd_adapter *adapter, > } > } > > + if (status == MGMT_STATUS_CONNECT_FAILED) { > + if (device != NULL) { > + > + DBG("status is 0x%x, retry it.", status); > + > + if (device_bonding_attempt_retry(device) == 0) > + return; > + } > + } There is already an if statement to handle retrying, not sure why you didn't modify it? > /* Ignore disconnects during retry. */ > if (status == MGMT_STATUS_DISCONNECTED && > device && device_is_retrying(device)) > -- > 2.20.1 > > -- Luiz Augusto von Dentz