Skip to content

Commit b9350bb

Browse files
committed
Workround bug in xTimerIsTimerActive.
With arduino-esp32 2.0.1, xTimerIsTimerActive will sometimes return pdTRUE even though the timer has expired, so and extra check was added.
1 parent 297743d commit b9350bb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/nimble/nimble_npl_os.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ ble_npl_callout_stop(struct ble_npl_callout *co)
235235
static inline bool
236236
ble_npl_callout_is_active(struct ble_npl_callout *co)
237237
{
238-
return xTimerIsTimerActive(co->handle) == pdTRUE;
238+
/* Workaround for bug in xTimerIsTimerActive with latest arduino core.
239+
* Sometimes xTimerIsTimerActive returns pdTRUE even though the timer has expired, so we double check.
240+
*/
241+
return xTimerIsTimerActive(co->handle) == pdTRUE && xTimerGetExpiryTime(co->handle) > xTaskGetTickCountFromISR();
239242
}
240243

241244
static inline ble_npl_time_t

0 commit comments

Comments
 (0)