forked from project-chip/connectedhomeip
-
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5a40f80
Added changes for BLE TX timeout
shgutte 6b81817
Added changes for the BLE callback handler
shgutte 41f5afb
Added changes for the build error for the TX timer fix
shgutte cfc4116
Added changes for TX timer
shgutte e9a2727
Added restyler changes
shgutte 2950473
Updated the timer handlle
shgutte 1ada11d
Updated the timer timeout
shgutte 0c11404
Updated the timeout to support all chips
shgutte fad339d
Added req changes for send indicaiton
shgutte 05c6527
Added req changes
shgutte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,9 +246,8 @@ 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) | ||
|
||
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 +292,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 +477,9 @@ 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()); | ||
|
||
StartBleSendIndicationTimeoutTimer(BLE_SEND_INDICATION_TIMER_PERIOD_MS); | ||
|
||
if (status != RSI_SUCCESS) | ||
{ | ||
ChipLogProgress(DeviceLayer, "indication failed with error code %lx ", status); | ||
|
@@ -925,12 +934,19 @@ 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"); | ||
ChipDeviceEvent event; | ||
event.Type = DeviceEventType::kCHIPoBLEConnectionError; | ||
event.CHIPoBLEConnectionError.ConId = connHandle; | ||
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; | ||
PlatformMgr().PostEventOrDie(&event); | ||
} | ||
|
||
bool BLEManagerImpl::RemoveConnection(uint8_t connectionHandle) | ||
|
@@ -1101,6 +1117,36 @@ void BLEManagerImpl::StartBleAdvTimeoutTimer(uint32_t aTimeoutInMs) | |
} | ||
} | ||
|
||
|
||
void BLEManagerImpl::BleSendIndicationTimeoutHandler(TimerHandle_t xTimer) | ||
{ | ||
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(BLE_CONFIG_TIMEOUT)) != pdPASS) | ||
{ | ||
ChipLogError(DeviceLayer, "Failed to start BledAdv timeout timer"); | ||
} | ||
} | ||
|
||
void BLEManagerImpl::DriveBLEState(intptr_t arg) | ||
{ | ||
sInstance.DriveBLEState(); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what is this log ?
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.
Log to tell we are aborting the connection because of timeout
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is same in EFR32 as well