add detection of reconnect
[trinked.git] / 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 {