Skip to content

Commit a93342f

Browse files
authored
Merge pull request #6151 from pan-/fix-generic-gap-connect
BLE: Fix generic gap connect
2 parents daf29dc + e91570e commit a93342f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

features/FEATURE_BLE/source/generic/GenericGap.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ static const uint16_t advertising_interval_max = 0x4000;
4444
static const uint16_t supervision_timeout_min = 0x000A;
4545
static const uint16_t supervision_timeout_max = 0x0C80;
4646

47+
static const Gap::ConnectionParams_t default_connection_params = {
48+
/* min conn interval */ 50,
49+
/* max conn interval */ 100,
50+
/* slave latency */ 0,
51+
/* supervision timeout */ 600
52+
};
53+
54+
static const GapScanningParams default_scan_params;
4755

4856
/*
4957
* Return true if value is included in the range [lower_bound : higher_bound]
@@ -491,6 +499,14 @@ ble_error_t GenericGap::connect(
491499
const ConnectionParams_t* connectionParams,
492500
const GapScanningParams* scanParams
493501
) {
502+
if (connectionParams == NULL) {
503+
connectionParams = &default_connection_params;
504+
}
505+
506+
if (scanParams == NULL) {
507+
scanParams = &default_scan_params;
508+
}
509+
494510
if (is_scan_params_valid(scanParams) == false) {
495511
return BLE_ERROR_PARAM_OUT_OF_RANGE;
496512
}
@@ -501,6 +517,9 @@ ble_error_t GenericGap::connect(
501517

502518
// TODO fix upper layer API, address type factorization is incorrect.
503519

520+
// Force scan stop before initiating the scan used for connection
521+
stopScan();
522+
504523
return _pal_gap.create_connection(
505524
scanParams->getInterval(),
506525
scanParams->getWindow(),

0 commit comments

Comments
 (0)