BLE_Quiet() now resets the timer.
This commit is contained in:
parent
bb778a065f
commit
f367b5ae5b
2 changed files with 49 additions and 4 deletions
|
@ -340,11 +340,54 @@ SystemKResult_T BLE_Quiet(uint32_t duration_ms)
|
|||
|
||||
if (Is_Quiet == true)
|
||||
{
|
||||
// Already quiet; no action needed.
|
||||
return SYSTEMK_RESULT_SUCCESS;
|
||||
// Already quiet; reset timer with new duration if duration_ms > 0.
|
||||
if (duration_ms > 0)
|
||||
{
|
||||
// Stop and delete existing timer if it exists.
|
||||
if (BLEUnquietTimer != NULL)
|
||||
{
|
||||
xTimerStop(BLEUnquietTimer, 0);
|
||||
xTimerDelete(BLEUnquietTimer, 0);
|
||||
BLEUnquietTimer = NULL;
|
||||
}
|
||||
|
||||
// Create and start new timer with the new duration.
|
||||
BLEUnquietTimer = xTimerCreateStatic(
|
||||
"BLEUnquietTimer",
|
||||
pdMS_TO_TICKS(duration_ms),
|
||||
pdFALSE,
|
||||
(void *)0,
|
||||
Unquiet_Timer_Callback,
|
||||
&xBLEUnquietTimerBuffer);
|
||||
|
||||
if (BLEUnquietTimer == NULL)
|
||||
{
|
||||
KLOG_ERROR(TAG, "Couldn't create the BLEUnquietTimer!");
|
||||
result = SYSTEMK_RESULT_FAILED_TO_CREATE_RTOS_TIMER;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xTimerStart(BLEUnquietTimer, 0) != pdPASS)
|
||||
{
|
||||
KLOG_ERROR(TAG, "Couldn't start the BLEUnquietTimer!");
|
||||
result = SYSTEMK_RESULT_FAILED_TO_START_RTOS_TIMER;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If duration_ms is 0, stop and delete the timer to stay quiet indefinitely.
|
||||
if (BLEUnquietTimer != NULL)
|
||||
{
|
||||
xTimerStop(BLEUnquietTimer, 0);
|
||||
xTimerDelete(BLEUnquietTimer, 0);
|
||||
BLEUnquietTimer = NULL;
|
||||
}
|
||||
}
|
||||
result = SYSTEMK_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
if (Host_And_Controller_Synced == true)
|
||||
else if (Host_And_Controller_Synced == true)
|
||||
{
|
||||
Is_Quiet = true;
|
||||
|
||||
|
@ -369,12 +412,14 @@ SystemKResult_T BLE_Quiet(uint32_t duration_ms)
|
|||
if (BLEUnquietTimer == NULL)
|
||||
{
|
||||
KLOG_ERROR(TAG, "Couldn't create the BLEUnquietTimer!");
|
||||
result = SYSTEMK_RESULT_FAILED_TO_CREATE_RTOS_TIMER;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xTimerStart(BLEUnquietTimer, 0) != pdPASS)
|
||||
{
|
||||
KLOG_ERROR(TAG, "Couldn't start the BLEUnquietTimer!");
|
||||
result = SYSTEMK_RESULT_FAILED_TO_START_RTOS_TIMER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit bb915121e8e9c8b2679397f4554fa9bc2d836b67
|
||||
Subproject commit 88c81dc405ef5d10fcf67d80d349bc1a7924e6f9
|
Loading…
Add table
Add a link
Reference in a new issue