Skip to content

Commit

Permalink
bluetooth: nrf52: Fix issue that fails to re-scan after disconnection
Browse files Browse the repository at this point in the history
BLE central has an issue that fails to re-scan after disconnection with
any peripheral device. It is caused by timeout setting of scan parameter
used by connection. So it changes to re-scan without timeout as well as
initial scan.
  • Loading branch information
SPRESENSE committed Nov 14, 2024
1 parent bbf8e91 commit a2c074f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sdk/modules/bluetooth/hal/nrf52/ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ int BLE_GapConnect(BLE_GapAddr *addr)
int ret = BLE_SUCCESS;
int errCode = 0;
ble_gap_addr_t peerAddr = {0};
ble_gap_scan_params_t scanParams;

if(addr == NULL) {
return -EINVAL;
Expand All @@ -740,7 +741,8 @@ int BLE_GapConnect(BLE_GapAddr *addr)
* application wait connection infinitely.
*/

gapMem.scanParams.timeout = CONNECTION_TIMEOUT;
memcpy(&scanParams, &gapMem.scanParams, sizeof(scanParams));
scanParams.timeout = CONNECTION_TIMEOUT;

gapMem.connParams.min_conn_interval = MIN_CONNECTION_INTERVAL;
gapMem.connParams.max_conn_interval = MAX_CONNECTION_INTERVAL;
Expand All @@ -749,7 +751,7 @@ int BLE_GapConnect(BLE_GapAddr *addr)
peerAddr.addr_type = addr->type;
memcpy(peerAddr.addr, addr->addr, BLE_GAP_ADDR_LENGTH);
errCode = sd_ble_gap_connect(&peerAddr,
&gapMem.scanParams,
&scanParams,
&gapMem.connParams,
APP_BLE_CONN_CFG_TAG);
ret = bleConvertErrorCode((uint32_t)errCode);
Expand Down

0 comments on commit a2c074f

Please sign in to comment.