Skip to content

Commit 2f0bce1

Browse files
authored
Merge branch 'master' into esp32/add_thread_br_ota
2 parents ad949c7 + b02badf commit 2f0bce1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/platform/silabs/efr32/BLEManagerImpl.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ namespace {
9494
#define BLE_CONFIG_RF_PATH_GAIN_RX (0)
9595

9696
// Default Connection parameters
97-
#define BLE_CONFIG_MIN_INTERVAL (16) // Time = Value x 1.25 ms = 30ms
97+
#define BLE_CONFIG_MIN_INTERVAL (16) // Time = Value x 1.25 ms = 20ms
9898
#define BLE_CONFIG_MAX_INTERVAL (80) // Time = Value x 1.25 ms = 100ms
9999
#define BLE_CONFIG_LATENCY (0)
100100
#define BLE_CONFIG_TIMEOUT (100) // Time = Value x 10 ms = 1s
@@ -678,12 +678,17 @@ void BLEManagerImpl::HandleConnectParams(volatile sl_bt_msg_t * evt)
678678
{
679679
sl_bt_evt_connection_parameters_t * con_param_evt = (sl_bt_evt_connection_parameters_t *) &(evt->data);
680680

681-
if (con_param_evt->timeout < BLE_CONFIG_TIMEOUT)
681+
uint16_t desiredTimeout = con_param_evt->timeout < BLE_CONFIG_TIMEOUT ? BLE_CONFIG_TIMEOUT : con_param_evt->timeout;
682+
683+
// For better stability, renegotiate the connection parameters if the received ones from the central are outside
684+
// of our defined constraints
685+
if (desiredTimeout != con_param_evt->timeout || con_param_evt->interval < BLE_CONFIG_MIN_INTERVAL ||
686+
con_param_evt->interval > BLE_CONFIG_MAX_INTERVAL)
682687
{
683-
ChipLogProgress(DeviceLayer, "Request to increase the connection timeout from %d to %d", con_param_evt->timeout,
684-
BLE_CONFIG_TIMEOUT);
688+
ChipLogProgress(DeviceLayer, "Renegotiate BLE connection parameters to minInterval:%d, maxInterval:%d, timeout:%d",
689+
BLE_CONFIG_MIN_INTERVAL, BLE_CONFIG_MAX_INTERVAL, desiredTimeout);
685690
sl_bt_connection_set_parameters(con_param_evt->connection, BLE_CONFIG_MIN_INTERVAL, BLE_CONFIG_MAX_INTERVAL,
686-
BLE_CONFIG_LATENCY, BLE_CONFIG_TIMEOUT, BLE_CONFIG_MIN_CE_LENGTH, BLE_CONFIG_MAX_CE_LENGTH);
691+
BLE_CONFIG_LATENCY, desiredTimeout, BLE_CONFIG_MIN_CE_LENGTH, BLE_CONFIG_MAX_CE_LENGTH);
687692
}
688693

689694
PlatformMgr().ScheduleWork(DriveBLEState, 0);

0 commit comments

Comments
 (0)