diff --git a/src/platform/silabs/BLEManagerImpl.h b/src/platform/silabs/BLEManagerImpl.h index 69e5720387ef65..3c503e524ff004 100644 --- a/src/platform/silabs/BLEManagerImpl.h +++ b/src/platform/silabs/BLEManagerImpl.h @@ -201,7 +201,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla #if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE) protected: - static void OnSendIndicationTimeout(System::Layer * aLayer, void * appState); + static void OnSendIndicationTimeout(TimerHandle_t xTimer); #endif }; diff --git a/src/platform/silabs/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/rs911x/BLEManagerImpl.cpp index eaf6b8095318a1..df880eb8551a4f 100644 --- a/src/platform/silabs/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/rs911x/BLEManagerImpl.cpp @@ -237,6 +237,7 @@ namespace { #define BLE_CONFIG_MAX_CE_LENGTH (0xFFFF) // Leave to max value TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer. +TimerHandle_t sbleIndicationTimeoutTimer; const uint8_t UUID_CHIPoBLEService[] = { 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xF6, 0xFF, 0x00, 0x00 }; @@ -270,11 +271,17 @@ CHIP_ERROR BLEManagerImpl::_Init() mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; // Create FreeRTOS sw timer for BLE timeouts and interval change. - sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer", // Just a text name, not used by the RTOS kernel - pdMS_TO_TICKS(BLE_DEFAULT_TIMER_PERIOD_MS), // == default timer period - false, // no timer reload (==one-shot) - (void *) this, // init timer id = ble obj context - BleAdvTimeoutHandler // timer callback handler + sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer", // Just a text name, not used by the RTOS kernel + pdMS_TO_TICKS(BLE_DEFAULT_TIMER_PERIOD_MS), // == default timer period + false, // no timer reload (==one-shot) + (void *) this, // init timer id = ble obj context + BleAdvTimeoutHandler // timer callback handler + ); + sbleIndicationTimeoutTimer = xTimerCreate("BleIndicationTimer", // Just a text name, not used by the RTOS kernel + pdMS_TO_TICKS(BLE_SEND_INDICATION_TIMER_PERIOD_MS), // == default timer period + false, // no timer reload (==one-shot) + (void *) this, // init timer id = ble obj context + OnSendIndicationTimeout // timer callback handler ); mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); @@ -285,7 +292,7 @@ CHIP_ERROR BLEManagerImpl::_Init() return err; } -void BLEManagerImpl::OnSendIndicationTimeout(System::Layer * aLayer, void * appState) +void BLEManagerImpl::OnSendIndicationTimeout(TimerHandle_t xTimer) { // TODO: change the connection handle with the ble device ID uint8_t connHandle = 1; @@ -475,8 +482,10 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU } // start timer for the indication Confirmation Event - DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(BLE_SEND_INDICATION_TIMER_PERIOD_MS), - OnSendIndicationTimeout, this); + if (xTimerStart(sbleIndicationTimeoutTimer, pdMS_TO_TICKS(0)) == pdFAIL) + { + ChipLogError(DeviceLayer, "Failed to start indication timer"); + } return true; } @@ -924,7 +933,10 @@ void BLEManagerImpl::HandleRXCharWrite(rsi_ble_event_write_t * evt) void BLEManagerImpl::HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId) { // stop the indication confirmation timer - DeviceLayer::SystemLayer().CancelTimer(OnSendIndicationTimeout, this); + if (xTimerStop(sbleIndicationTimeoutTimer, pdMS_TO_TICKS(0)) == pdFAIL) + { + ChipLogError(DeviceLayer, "Failed to stop indication timer"); + } ChipDeviceEvent event; event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = conId;