Skip to content

Commit f3c453b

Browse files
committed
BLE: Handle NULL parameters in Gap::connect.
1 parent 7941a6f commit f3c453b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

features/FEATURE_BLE/source/generic/GenericGap.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ 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-
4847
/*
4948
* Return true if value is included in the range [lower_bound : higher_bound]
5049
*/
@@ -491,6 +490,22 @@ ble_error_t GenericGap::connect(
491490
const ConnectionParams_t* connectionParams,
492491
const GapScanningParams* scanParams
493492
) {
493+
ConnectionParams_t default_connection_params = {
494+
/* min conn interval */ 50,
495+
/* max conn interval */ 100,
496+
/* slave latency */ 0,
497+
/* supervision timeout */ 600
498+
};
499+
GapScanningParams default_scan_params;
500+
501+
if (connectionParams == NULL) {
502+
connectionParams = &default_connection_params;
503+
}
504+
505+
if (scanParams == NULL) {
506+
scanParams = &default_scan_params;
507+
}
508+
494509
if (is_scan_params_valid(scanParams) == false) {
495510
return BLE_ERROR_PARAM_OUT_OF_RANGE;
496511
}

0 commit comments

Comments
 (0)