Skip to content

Commit

Permalink
Added changes for BLE TX timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
shgutte committed Feb 29, 2024
1 parent 36f9ff6 commit 3822837
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/platform/silabs/rs911x/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ namespace {
#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.

Expand Down Expand Up @@ -465,12 +466,22 @@ 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)
{
int32_t status = 0;
status = rsi_ble_indicate_value(event_msg.resp_enh_conn.dev_addr, event_msg.rsi_ble_measurement_hndl, (data->DataLength()),
status = rsi_ble_indicate_value(event_msg.resp_enh_conn.dev_addr, event_msg.rsi_ble_measurement_hndl, (data->DataLength()),
data->Start());

// start timer for light indication confirmation. Long delay for spake2 indication
DeviceLayer::SystemLayer().StartTimer(Clock::Milliseconds32(BLE_SEND_INDICATION_TIMER_PERIOD_MS), OnSendIndicationTimeout, this);

if (status != RSI_SUCCESS)
{
ChipLogProgress(DeviceLayer, "indication failed with error code %lx ", status);
Expand Down Expand Up @@ -924,13 +935,20 @@ void BLEManagerImpl::HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId)
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
event.CHIPoBLEIndicateConfirm.ConId = conId;
DeviceLayer::SystemLayer().CancelTimer(BLEManagerImpl, this);
PlatformMgr().PostEventOrDie(&event);
}

// TODO:: Need to Implement

void BLEManagerImpl::HandleSoftTimerEvent(void)
{
// TODO:: Need to Implement
ChipLogProgress(DeviceLayer, "BLEManagerImpl::HandleSoftTimerEvent CHIPOBLE_PROTOCOL_ABORT");
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEConnectionError;
event.CHIPoBLEConnectionError.ConId = mIndConfId[evt->data.evt_system_soft_timer.handle];
sInstance.mIndConfId[evt->data.evt_system_soft_timer.handle] = kUnusedIndex;
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT;
PlatformMgr().PostEventOrDie(&event);
}

bool BLEManagerImpl::RemoveConnection(uint8_t connectionHandle)
Expand Down

0 comments on commit 3822837

Please sign in to comment.