Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs][Wi-Fi] Added Implementation for timeouts waiting for a TX Confirmation Event BLE #32333

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 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 @@ -209,6 +202,11 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
static void DriveBLEState(intptr_t arg);
static void BleAdvTimeoutHandler(TimerHandle_t xTimer);
uint8_t GetTimerHandle(uint8_t connectionHandle, bool allocate);

#if (SLI_SI91X_ENABLE_BLE || RSI_BLE_ENABLE)
protected:
static void OnSendIndicationTimeout(System::Layer * aLayer, void * appState);
#endif
};

/**
Expand Down
38 changes: 27 additions & 11 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
#define BLE_MAX_CONNECTION_INTERVAL_MS 45
#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 @@ -242,15 +249,13 @@ namespace {
#define BLE_CONFIG_MIN_INTERVAL (16) // Time = Value x 1.25 ms = 30ms
#define BLE_CONFIG_MAX_INTERVAL (80) // Time = Value x 1.25 ms = 100ms
#define BLE_CONFIG_LATENCY (0)
#define BLE_CONFIG_TIMEOUT (100) // Time = Value x 10 ms = 1s
#define BLE_CONFIG_MIN_CE_LENGTH (0) // Leave to min value
#define BLE_CONFIG_TIMEOUT (100) // Time = Value x 10 ms = 1s
#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)

TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer.

const uint8_t UUID_CHIPoBLEService[] = { 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
const uint8_t UUID_CHIPoBLEService[] = { 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,,
0x00, 0x10, 0x00, 0x00, 0xF6, 0xFF, 0x00, 0x00 };
const uint8_t ShortUUID_CHIPoBLEService[] = { 0xF6, 0xFF };
const ChipBleUUID ChipUUID_CHIPoBLEChar_RX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F,
Expand Down Expand Up @@ -301,6 +306,18 @@ CHIP_ERROR BLEManagerImpl::_Init()
return err;
}

void BLEManagerImpl::OnSendIndicationTimeout(System::Layer * aLayer, void * appState)
{
// TODO: change the connection handle with the ble device ID
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 @@ -423,6 +440,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 @@ -471,12 +489,16 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU
int32_t status = 0;
status = rsi_ble_indicate_value(event_msg.resp_enh_conn.dev_addr, event_msg.rsi_ble_measurement_hndl, (data->DataLength()),
data->Start());

if (status != RSI_SUCCESS)
{
ChipLogProgress(DeviceLayer, "indication failed with error code %lx ", status);
return false;
}

// start timer for the indication Confirmation Event
DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(BLE_SEND_INDICATION_TIMER_PERIOD_MS),
OnSendIndicationTimeout, this);
return true;
}

Expand Down Expand Up @@ -927,12 +949,6 @@ void BLEManagerImpl::HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId)
PlatformMgr().PostEventOrDie(&event);
}

// TODO:: Need to Implement
void BLEManagerImpl::HandleSoftTimerEvent(void)
{
// TODO:: Need to Implement
}

bool BLEManagerImpl::RemoveConnection(uint8_t connectionHandle)
{
CHIPoBLEConState * bleConnState = GetConnectionState(connectionHandle, true);
Expand Down
Loading