-
Notifications
You must be signed in to change notification settings - Fork 0
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 #2
Changes from 7 commits
5a40f80
6b81817
41f5afb
cfc4116
e9a2727
2950473
1ada11d
0c11404
fad339d
05c6527
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,8 +247,10 @@ 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 (400) | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer. | ||
TimerHandle_t sbleSendIndicationTimeoutTimer; // FreeRTOS sw timer. | ||
|
||
const uint8_t UUID_CHIPoBLEService[] = { 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, | ||
0x00, 0x10, 0x00, 0x00, 0xF6, 0xFF, 0x00, 0x00 }; | ||
|
@@ -293,6 +295,13 @@ CHIP_ERROR BLEManagerImpl::_Init() | |
BleAdvTimeoutHandler // timer callback handler | ||
); | ||
|
||
sbleSendIndicationTimeoutTimer = xTimerCreate("SendIndicationTimer", // 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 | ||
BleSendIndicationTimeoutHandler // timer callback handler | ||
); | ||
|
||
mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); | ||
mFlags.Set(Flags::kFastAdvertisingEnabled, true); | ||
PlatformMgr().ScheduleWork(DriveBLEState, 0); | ||
|
@@ -471,6 +480,11 @@ 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()); | ||
|
||
ChipLogProgress(DeviceLayer, "StartTimer start"); | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
StartBleSendIndicationTimeoutTimer(BLE_SEND_INDICATION_TIMER_PERIOD_MS); | ||
ChipLogProgress(DeviceLayer, "StartTimer Stop"); | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (status != RSI_SUCCESS) | ||
{ | ||
ChipLogProgress(DeviceLayer, "indication failed with error code %lx ", status); | ||
|
@@ -925,12 +939,20 @@ void BLEManagerImpl::HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId) | |
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; | ||
event.CHIPoBLEIndicateConfirm.ConId = conId; | ||
PlatformMgr().PostEventOrDie(&event); | ||
CancelBleSendIndicationTimeoutTimer(); | ||
} | ||
|
||
// TODO:: Need to Implement | ||
|
||
void BLEManagerImpl::HandleSoftTimerEvent(void) | ||
{ | ||
// TODO:: Need to Implement | ||
uint8_t connHandle = 1; | ||
ChipLogProgress(DeviceLayer, "BLEManagerImpl::HandleSoftTimerEvent CHIPOBLE_PROTOCOL_ABORT"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this log ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log to tell we are aborting the connection because of timeout There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this an error case? The function name suggests a handler for Soft Timer Event. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it is same in EFR32 as well |
||
ChipDeviceEvent event; | ||
event.Type = DeviceEventType::kCHIPoBLEConnectionError; | ||
event.CHIPoBLEConnectionError.ConId = connHandle; | ||
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; | ||
ChipLogProgress(DeviceLayer, "BLEManagerImpl::HandleSoftTimerEvent CHIPOBLE_PROTOCOL_ABORT"); | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
PlatformMgr().PostEventOrDie(&event); | ||
} | ||
|
||
bool BLEManagerImpl::RemoveConnection(uint8_t connectionHandle) | ||
|
@@ -1101,6 +1123,37 @@ void BLEManagerImpl::StartBleAdvTimeoutTimer(uint32_t aTimeoutInMs) | |
} | ||
} | ||
|
||
|
||
void BLEManagerImpl::BleSendIndicationTimeoutHandler(TimerHandle_t xTimer) | ||
{ | ||
ChipLogProgress(DeviceLayer, "BleSendIndicationTimeoutHandler::Start"); | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sInstance.HandleSoftTimerEvent(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The log should be given here and should it be a progress log ? |
||
} | ||
|
||
void BLEManagerImpl::CancelBleSendIndicationTimeoutTimer(void) | ||
{ | ||
if (xTimerStop(sbleSendIndicationTimeoutTimer, pdMS_TO_TICKS(0)) == pdFAIL) | ||
{ | ||
ChipLogError(DeviceLayer, "Failed to stop BledAdv timeout timer"); | ||
} | ||
} | ||
|
||
void BLEManagerImpl::StartBleSendIndicationTimeoutTimer(uint32_t aTimeoutInMs) | ||
{ | ||
if (xTimerIsTimerActive(sbleSendIndicationTimeoutTimer)) | ||
{ | ||
CancelBleAdvTimeoutTimer(); | ||
} | ||
|
||
// timer is not active, change its period to required value (== restart). | ||
// FreeRTOS- Block for a maximum of 100 ticks if the change period command | ||
// cannot immediately be sent to the timer command queue. | ||
if (xTimerChangePeriod(sbleSendIndicationTimeoutTimer, pdMS_TO_TICKS(aTimeoutInMs), pdMS_TO_TICKS(100)) != pdPASS) | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
ChipLogError(DeviceLayer, "Failed to start BledAdv timeout timer"); | ||
} | ||
} | ||
|
||
void BLEManagerImpl::DriveBLEState(intptr_t arg) | ||
{ | ||
sInstance.DriveBLEState(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't these be in the header file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header file is common for both efr32 and rs911x so keeping it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this code there, so I guess this can be added to this, or this code can be moved from there to here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated