@@ -94,7 +94,7 @@ namespace {
94
94
#define BLE_CONFIG_RF_PATH_GAIN_RX (0 )
95
95
96
96
// 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
98
98
#define BLE_CONFIG_MAX_INTERVAL (80 ) // Time = Value x 1.25 ms = 100ms
99
99
#define BLE_CONFIG_LATENCY (0 )
100
100
#define BLE_CONFIG_TIMEOUT (100 ) // Time = Value x 10 ms = 1s
@@ -678,12 +678,17 @@ void BLEManagerImpl::HandleConnectParams(volatile sl_bt_msg_t * evt)
678
678
{
679
679
sl_bt_evt_connection_parameters_t * con_param_evt = (sl_bt_evt_connection_parameters_t *) &(evt->data );
680
680
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)
682
687
{
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 );
685
690
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);
687
692
}
688
693
689
694
PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
0 commit comments