Skip to content

Commit

Permalink
[CSA-CP]ble connection parameters negociation (#91)
Browse files Browse the repository at this point in the history
Co-authored-by: Kiel Oleson <[email protected]>
Co-authored-by: Ricardo Casallas <[email protected]>
  • Loading branch information
3 people authored Nov 11, 2024
1 parent c8371e1 commit 31317ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/platform/silabs/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
int32_t SendBLEAdvertisementCommand(void);
#else
void HandleConnectEvent(volatile sl_bt_msg_t * evt);
void HandleConnectParams(volatile sl_bt_msg_t * evt);
void HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt);
void HandleWriteEvent(volatile sl_bt_msg_t * evt);
void UpdateMtu(volatile sl_bt_msg_t * evt);
Expand Down
28 changes: 26 additions & 2 deletions src/platform/silabs/efr32/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,21 @@ void BLEManagerImpl::HandleConnectEvent(volatile sl_bt_msg_t * evt)
PlatformMgr().ScheduleWork(DriveBLEState, 0);
}

void BLEManagerImpl::HandleConnectParams(volatile sl_bt_msg_t * evt)
{
sl_bt_evt_connection_parameters_t * con_param_evt = (sl_bt_evt_connection_parameters_t *) &(evt->data);

if (con_param_evt->timeout < BLE_CONFIG_TIMEOUT)
{
ChipLogProgress(DeviceLayer, "Request to increase the connection timeout from %d to %d", con_param_evt->timeout,
BLE_CONFIG_TIMEOUT);
sl_bt_connection_set_parameters(con_param_evt->connection, BLE_CONFIG_MIN_INTERVAL, BLE_CONFIG_MAX_INTERVAL,
BLE_CONFIG_LATENCY, BLE_CONFIG_TIMEOUT, BLE_CONFIG_MIN_CE_LENGTH, BLE_CONFIG_MAX_CE_LENGTH);
}

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

void BLEManagerImpl::HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt)
{
sl_bt_evt_connection_closed_t * conn_evt = (sl_bt_evt_connection_closed_t *) &(evt->data);
Expand Down Expand Up @@ -1061,11 +1076,20 @@ extern "C" void sl_bt_on_event(sl_bt_msg_t * evt)
}
break;
case sl_bt_evt_connection_parameters_id: {
// ChipLogProgress(DeviceLayer, "Connection parameter ID received");
ChipLogProgress(DeviceLayer, "Connection parameter ID received - i:%d, l:%d, t:%d, sm:%d",
evt->data.evt_connection_parameters.interval, evt->data.evt_connection_parameters.latency,
evt->data.evt_connection_parameters.timeout, evt->data.evt_connection_parameters.security_mode);
chip::DeviceLayer::Internal::BLEMgrImpl().HandleConnectParams(evt);
}
break;
case sl_bt_evt_connection_phy_status_id: {
// ChipLogProgress(DeviceLayer, "PHY update procedure is completed");
ChipLogProgress(DeviceLayer, "Connection phy status ID received - phy:%d", evt->data.evt_connection_phy_status.phy);
}
break;
case sl_bt_evt_connection_data_length_id: {
ChipLogProgress(DeviceLayer, "Connection data length ID received - txL:%d, txT:%d, rxL:%d, rxL:%d",
evt->data.evt_connection_data_length.tx_data_len, evt->data.evt_connection_data_length.tx_time_us,
evt->data.evt_connection_data_length.rx_data_len, evt->data.evt_connection_data_length.rx_time_us);
}
break;
case sl_bt_evt_connection_closed_id: {
Expand Down

0 comments on commit 31317ce

Please sign in to comment.