From 44d8adf63a14f7ec31401f78f056626b1c80e4e6 Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Thu, 15 Aug 2019 16:01:06 +0200
Subject: [PATCH] fix(ble): Do not try to schedule 0 tick WSF timers

---
 epicardium/ble/ble.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/epicardium/ble/ble.c b/epicardium/ble/ble.c
index a2cdf9e4..ddaf6f4e 100644
--- a/epicardium/ble/ble.c
+++ b/epicardium/ble/ble.c
@@ -1,7 +1,6 @@
 #include "modules/log.h"
 
 #include "fs_util.h"
-
 #include "wsf_types.h"
 #include "wsf_buf.h"
 #include "wsf_trace.h"
@@ -162,6 +161,13 @@ static void scheduleTimer(void)
 	if (timerRunning) {
 		//printf("time_to_next_expire = %d\n", time_to_next_expire);
 		//printf("change period\n");
+		/* We need to make sure not to schedule a 0 ticks timer.
+		 * Maybe it would also be enough to simply call the dispatcher
+		 * in this case... */
+		if (time_to_next_expire == 0) {
+			time_to_next_expire = 1;
+		}
+
 		if (timerWakeup != NULL) {
 			xTimerChangePeriod(
 				timerWakeup,
-- 
GitLab