Skip to content

Commit 04f0337

Browse files
committed
Fix for the Matter tx timer for indication
1 parent 303bb08 commit 04f0337

File tree

2 files changed

+21
-29
lines changed

2 files changed

+21
-29
lines changed

src/platform/silabs/BLEManagerImpl.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@
2424

2525
#pragma once
2626
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
27-
28-
#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
29-
#define BLE_MIN_CONNECTION_INTERVAL_MS 45 // 45 msec
30-
#define BLE_MAX_CONNECTION_INTERVAL_MS 45 // 45 msec
31-
#define BLE_SLAVE_LATENCY_MS 0
32-
#define BLE_TIMEOUT_MS 400
33-
#endif // (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
3427
#include "FreeRTOS.h"
3528
#include "timers.h"
3629
#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
@@ -211,7 +204,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
211204
uint8_t GetTimerHandle(uint8_t connectionHandle, bool allocate);
212205

213206

214-
#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
207+
#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
215208
protected:
216209
static void OnSendIndicationTimeout(System::Layer * aLayer, void * appState);
217210
#endif

src/platform/silabs/rs911x/BLEManagerImpl.cpp

+20-21
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ extern "C" {
6868
#include <setup_payload/AdditionalDataPayloadGenerator.h>
6969
#endif
7070

71+
#define BLE_MIN_CONNECTION_INTERVAL_MS 45 // 45 msec
72+
#define BLE_MAX_CONNECTION_INTERVAL_MS 45 // 45 msec
73+
#define BLE_SLAVE_LATENCY_MS 0
74+
#define BLE_TIMEOUT_MS 400
75+
#define BLE_DEFAULT_TIMER_PERIOD_MS (1)
76+
#define BLE_SEND_INDICATION_TIMER_PERIOD_MS (5000)
77+
7178
extern sl_wfx_msg_t event_msg;
7279

7380
StaticTask_t rsiBLETaskStruct;
@@ -246,9 +253,6 @@ namespace {
246253
#define BLE_CONFIG_MIN_CE_LENGTH (0) // Leave to min value
247254
#define BLE_CONFIG_MAX_CE_LENGTH (0xFFFF) // Leave to max value
248255

249-
#define BLE_DEFAULT_TIMER_PERIOD_MS (1)
250-
#define BLE_SEND_INDICATION_TIMER_PERIOD_MS (10)
251-
252256
TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer.
253257

254258
const uint8_t UUID_CHIPoBLEService[] = { 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
@@ -302,6 +306,17 @@ CHIP_ERROR BLEManagerImpl::_Init()
302306
return err;
303307
}
304308

309+
void BLEManagerImpl::OnSendIndicationTimeout(System::Layer * aLayer, void * appState)
310+
{
311+
uint8_t connHandle = 1;
312+
ChipLogProgress(DeviceLayer, "BLEManagerImpl::HandleSoftTimerEvent CHIPOBLE_PROTOCOL_ABORT");
313+
ChipDeviceEvent event;
314+
event.Type = DeviceEventType::kCHIPoBLEConnectionError;
315+
event.CHIPoBLEConnectionError.ConId = connHandle;
316+
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT;
317+
PlatformMgr().PostEventOrDie(&event);
318+
}
319+
305320
uint16_t BLEManagerImpl::_NumConnections(void)
306321
{
307322
uint16_t numCons = 0;
@@ -424,6 +439,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
424439

425440
case DeviceEventType::kCHIPoBLEIndicateConfirm: {
426441
ChipLogProgress(DeviceLayer, "_OnPlatformEvent kCHIPoBLEIndicateConfirm");
442+
DeviceLayer::SystemLayer().CancelTimer(OnSendIndicationTimeout, this);
427443
HandleIndicationConfirmation(event->CHIPoBLEIndicateConfirm.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX);
428444
}
429445
break;
@@ -466,11 +482,7 @@ uint16_t BLEManagerImpl::GetMTU(BLE_CONNECTION_OBJECT conId) const
466482
return (conState != NULL) ? conState->mtu : 0;
467483
}
468484

469-
void BLEManagerImpl::OnSendIndicationTimeout(System::Layer * aLayer, void * appState)
470-
{
471-
BLEManagerImpl * pBLEManagerImpl = reinterpret_cast<BLEManagerImpl *>(appState);
472-
pBLEManagerImpl->HandleSoftTimerEvent();
473-
}
485+
474486

475487
bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId,
476488
PacketBufferHandle data)
@@ -935,19 +947,6 @@ void BLEManagerImpl::HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId)
935947
ChipDeviceEvent event;
936948
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
937949
event.CHIPoBLEIndicateConfirm.ConId = conId;
938-
DeviceLayer::SystemLayer().CancelTimer(OnSendIndicationTimeout, this);
939-
PlatformMgr().PostEventOrDie(&event);
940-
}
941-
942-
943-
void BLEManagerImpl::HandleSoftTimerEvent(void)
944-
{
945-
uint8_t connHandle = 1;
946-
ChipLogProgress(DeviceLayer, "BLEManagerImpl::HandleSoftTimerEvent CHIPOBLE_PROTOCOL_ABORT");
947-
ChipDeviceEvent event;
948-
event.Type = DeviceEventType::kCHIPoBLEConnectionError;
949-
event.CHIPoBLEConnectionError.ConId = connHandle;
950-
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT;
951950
PlatformMgr().PostEventOrDie(&event);
952951
}
953952

0 commit comments

Comments
 (0)