bmsd/ispindels.c

changeset 790
98bd22f6629b
parent 718
59b02b64131b
child 799
cf145b35d65f
--- a/bmsd/ispindels.c	Thu Mar 24 15:46:36 2022 +0100
+++ b/bmsd/ispindels.c	Fri Jun 17 16:18:04 2022 +0200
@@ -3,7 +3,7 @@
  * @brief Handle ispindels data
  * @author Michiel Broek <mbroek at mbse dot eu>
  *
- * Copyright (C) 2019-2020
+ * Copyright (C) 2019-2022
  *
  * This file is part of the bms (Brewery Management System)
  *
@@ -201,7 +201,7 @@
     sys_ispindel_list	*ispindel, *tmpp;
     struct json_object  *jobj, *metric, *val;
     bool		new_ispindel = true;
-    char		*datetime, buf[65], *line, *logfile;
+    char		*datetime, buf[65], *line, *logfile, *query = malloc(512);
     struct tm           *mytime;
     time_t              timestamp;
     FILE		*fp;
@@ -327,6 +327,16 @@
         line = xstrcat(line, (char *)",");
 	line = xstrcat(line, ispindel->uuid);
 
+	snprintf(query, 511, "INSERT INTO log_ispindel SET code='%s', datetime='%s', " \
+			"temperature='%.4f', plato='%.5f', sg='%.5f', battery='%.6f', " \
+			"angle='%.5f', refresh='%d', uuid='%s'",
+			ispindel->beercode, datetime, ispindel->temperature, ispindel->gravity,
+			1.00001 + (0.0038661 * ispindel->gravity) + (1.3488e-5 * ispindel->gravity * ispindel->gravity) +
+				(4.3074e-8 * ispindel->gravity * ispindel->gravity * ispindel->gravity),
+			ispindel->battery, ispindel->angle, ispindel->interval, ispindel->uuid);
+	//syslog(LOG_NOTICE, "%s", query);
+	bms_mysql_query(query);
+
 	/*
 	 * Build logfile name
 	 */

mercurial