Skip to content

Commit

Permalink
Fix for the Matter tx timer for indication
Browse files Browse the repository at this point in the history
  • Loading branch information
shgutte committed Feb 27, 2024
1 parent 303bb08 commit 04f0337
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 29 deletions.
9 changes: 1 addition & 8 deletions src/platform/silabs/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@

#pragma once
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE

#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
#define BLE_MIN_CONNECTION_INTERVAL_MS 45 // 45 msec
#define BLE_MAX_CONNECTION_INTERVAL_MS 45 // 45 msec
#define BLE_SLAVE_LATENCY_MS 0
#define BLE_TIMEOUT_MS 400
#endif // (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
#include "FreeRTOS.h"
#include "timers.h"
#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
Expand Down Expand Up @@ -211,7 +204,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
uint8_t GetTimerHandle(uint8_t connectionHandle, bool allocate);


#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
protected:
static void OnSendIndicationTimeout(System::Layer * aLayer, void * appState);
#endif
Expand Down
41 changes: 20 additions & 21 deletions src/platform/silabs/rs911x/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ extern "C" {
#include <setup_payload/AdditionalDataPayloadGenerator.h>
#endif

#define BLE_MIN_CONNECTION_INTERVAL_MS 45 // 45 msec
#define BLE_MAX_CONNECTION_INTERVAL_MS 45 // 45 msec
#define BLE_SLAVE_LATENCY_MS 0
#define BLE_TIMEOUT_MS 400
#define BLE_DEFAULT_TIMER_PERIOD_MS (1)
#define BLE_SEND_INDICATION_TIMER_PERIOD_MS (5000)

extern sl_wfx_msg_t event_msg;

StaticTask_t rsiBLETaskStruct;
Expand Down Expand Up @@ -246,9 +253,6 @@ namespace {
#define BLE_CONFIG_MIN_CE_LENGTH (0) // Leave to min value
#define BLE_CONFIG_MAX_CE_LENGTH (0xFFFF) // Leave to max value

#define BLE_DEFAULT_TIMER_PERIOD_MS (1)
#define BLE_SEND_INDICATION_TIMER_PERIOD_MS (10)

TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer.

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

void BLEManagerImpl::OnSendIndicationTimeout(System::Layer * aLayer, void * appState)
{
uint8_t connHandle = 1;
ChipLogProgress(DeviceLayer, "BLEManagerImpl::HandleSoftTimerEvent CHIPOBLE_PROTOCOL_ABORT");
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEConnectionError;
event.CHIPoBLEConnectionError.ConId = connHandle;
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT;
PlatformMgr().PostEventOrDie(&event);
}

uint16_t BLEManagerImpl::_NumConnections(void)
{
uint16_t numCons = 0;
Expand Down Expand Up @@ -424,6 +439,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)

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

void BLEManagerImpl::OnSendIndicationTimeout(System::Layer * aLayer, void * appState)
{
BLEManagerImpl * pBLEManagerImpl = reinterpret_cast<BLEManagerImpl *>(appState);
pBLEManagerImpl->HandleSoftTimerEvent();
}


bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId,
PacketBufferHandle data)
Expand Down Expand Up @@ -935,19 +947,6 @@ void BLEManagerImpl::HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId)
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
event.CHIPoBLEIndicateConfirm.ConId = conId;
DeviceLayer::SystemLayer().CancelTimer(OnSendIndicationTimeout, this);
PlatformMgr().PostEventOrDie(&event);
}


void BLEManagerImpl::HandleSoftTimerEvent(void)
{
uint8_t connHandle = 1;
ChipLogProgress(DeviceLayer, "BLEManagerImpl::HandleSoftTimerEvent CHIPOBLE_PROTOCOL_ABORT");
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEConnectionError;
event.CHIPoBLEConnectionError.ConId = connHandle;
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT;
PlatformMgr().PostEventOrDie(&event);
}

Expand Down

0 comments on commit 04f0337

Please sign in to comment.