From 98676d410bde71425e4d56cf7e29b4757fb0c97c Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 12 Jun 2024 15:11:44 -0400 Subject: [PATCH] device: Fix storing conn parameters without first attempting to use them Some controller seems to have problems to use connections parameters that comes from PPCP as seem bellow, so instead of storing the parameters immediately this wait the MGMT_EV_NEW_CONN_PARAM to confirm the connection parameters are save to be stored: < HCI Command: LE Extended Create Connection (0x08|0x0043) plen 42 Filter policy: Accept list is not used (0x00) Own address type: Public (0x00) Peer address type: Random (0x01) Peer address: FE:D5:D9:EC:AB:99 (Static) Initiating PHYs: 0x03 Entry 0: LE 1M Scan interval: 60.000 msec (0x0060) Scan window: 60.000 msec (0x0060) Min connection interval: 7.50 msec (0x0006) Max connection interval: 4000.00 msec (0x0c80) Connection latency: 0 (0x0000) Supervision timeout: 5000 msec (0x01f4) Min connection length: 0.000 msec (0x0000) Max connection length: 0.000 msec (0x0000) Entry 1: LE 2M Scan interval: 60.000 msec (0x0060) Scan window: 60.000 msec (0x0060) Min connection interval: 7.50 msec (0x0006) Max connection interval: 4000.00 msec (0x0c80) Connection latency: 0 (0x0000) Supervision timeout: 5000 msec (0x01f4) Min connection length: 0.000 msec (0x0000) Max connection length: 0.000 msec (0x0000) > HCI Event: Command Status (0x0f) plen 4 LE Extended Create Connection (0x08|0x0043) ncmd 1 Status: Invalid HCI Command Parameters (0x12) Fixes: https://github.com/bluez/bluez/issues/876 --- src/device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/device.c b/src/device.c index 5dc1cd0cd..90626204a 100644 --- a/src/device.c +++ b/src/device.c @@ -7346,10 +7346,10 @@ void btd_device_set_conn_param(struct btd_device *device, uint16_t min_interval, uint16_t max_interval, uint16_t latency, uint16_t timeout) { - btd_adapter_store_conn_param(device->adapter, &device->bdaddr, - device->bdaddr_type, min_interval, - max_interval, latency, - timeout); + /* Attempt to load the new connection parameters, in case it is + * successful the MGMT_EV_NEW_CONN_PARAM will be generated which will + * then trigger btd_adapter_store_conn_param. + */ btd_adapter_load_conn_param(device->adapter, &device->bdaddr, device->bdaddr_type, min_interval, max_interval, latency, -- 2.47.3