add detection of reconnect
authorTeodor Sigaev <teodor@sigaev.ru>
Wed, 20 Apr 2016 19:19:39 +0000 (22:19 +0300)
committerTeodor Sigaev <teodor@sigaev.ru>
Wed, 20 Apr 2016 19:19:39 +0000 (22:19 +0300)
main.c

diff --git a/main.c b/main.c
index f283be0..b4d75a1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -93,6 +93,12 @@ main_loop() {
 
                trinketClose();
 
+               if (collected > 0 && prevDose[collected - 1] > curDose)
+               {
+                       tlog(TL_WARN, "Reconnect or full reset detected");
+                       collected = 0;
+               }
+
                if (collected <= tics) {
                        prevDose[collected++] = curDose;
                } else {