bmsd/ispindels.c

changeset 579
1253a237b620
parent 578
e75ce5bbda73
child 587
31caffee8c9c
--- a/bmsd/ispindels.c	Sun Jan 05 11:42:02 2020 +0100
+++ b/bmsd/ispindels.c	Sun Jan 05 17:04:56 2020 +0100
@@ -50,8 +50,8 @@
     time_t              timestamp;
     FILE		*fp;
 
-    if (debug)
-    	printf("ispindel_set: %s %s\n", node, payload);
+//    if (debug)
+//    	printf("ispindel_set: %s %s\n", node, payload);
 
     /*
      * Search ispindel record in the memory array and use it if found.
@@ -66,8 +66,8 @@
 	}
     }
 
-    if (debug)
-    	printf("new_ispindel %s\n", new_ispindel ? "true":"false");
+//    if (debug)
+//    	printf("new_ispindel %s\n", new_ispindel ? "true":"false");
 
     /*
      * Allocate new ispindel if not yet known.
@@ -121,7 +121,7 @@
         }
     }
 
-    ispindel_dump(ispindel);
+//    ispindel_dump(ispindel);
 
     if (new_ispindel) {
     	if (ispindels == NULL) {
@@ -143,8 +143,9 @@
      * The data is complete, see if we can write a log entry.
      */
     if (ispindel->beercode && strlen(ispindel->beercode) && ispindel->beername && strlen(ispindel->beername) &&
-	(strcmp(ispindel->mode, (char *)"ON") == 0)) {
+	ispindel->online && (strcmp(ispindel->mode, (char *)"ON") == 0)) {
 	datetime = malloc(72);
+	timestamp = time(NULL);
 	mytime = localtime(&timestamp);
     	snprintf(datetime, 72, "%04d-%02d-%02d %02d:%02d:%02d",
         	mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec);
@@ -157,6 +158,9 @@
 	snprintf(buf, 64, "%.5f", ispindel->gravity);
         line = xstrcat(line, buf);
         line = xstrcat(line, (char *)",");
+	snprintf(buf, 64, "%.5f", 1 + (ispindel->gravity / (258.6 - ((ispindel->gravity / 258.2) * 227.1))));
+	line = xstrcat(line, buf);
+        line = xstrcat(line, (char *)",");
         snprintf(buf, 64, "%.5f", ispindel->battery);
         line = xstrcat(line, buf);
         line = xstrcat(line, (char *)",");

mercurial