Thu, 05 Mar 2020 21:19:14 +0100
Added private yeastlab pdf list
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * @file ispindels.c |
568
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
3 | * @brief Handle ispindels data |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * @author Michiel Broek <mbroek at mbse dot eu> |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
6 | * Copyright (C) 2019-2020 |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This file is part of the bms (Brewery Management System) |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * This is free software; you can redistribute it and/or modify it |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * under the terms of the GNU General Public License as published by the |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * Free Software Foundation; either version 2, or (at your option) any |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * later version. |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * bms is distributed in the hope that it will be useful, but |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * General Public License for more details. |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * You should have received a copy of the GNU General Public License |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | */ |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | #include "bms.h" |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | #include "xutil.h" |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | #include "ispindels.h" |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | #include "mysql.h" |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | #include "nodes.h" |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | sys_ispindel_list *ispindels = NULL; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | extern int debug; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | extern sys_config Config; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | extern MYSQL *con; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | extern MYSQL_RES *res_set; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | extern MYSQL_ROW row; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
43 | void ispindel_set(char *node, char *payload) |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | sys_ispindel_list *ispindel, *tmpp; |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
46 | struct json_object *jobj, *metric, *val; |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
47 | bool new_ispindel = true; |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
48 | char *datetime, buf[65], *line, *logfile; |
568
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
49 | struct tm *mytime; |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
50 | time_t timestamp; |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
51 | FILE *fp; |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | |
579
1253a237b620
Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
53 | // if (debug) |
1253a237b620
Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
54 | // printf("ispindel_set: %s %s\n", node, payload); |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | /* |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | * Search ispindel record in the memory array and use it if found. |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | */ |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | if (ispindels) { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | for (tmpp = ispindels; tmpp; tmpp = tmpp->next) { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | if (strcmp(tmpp->node, node) == 0) { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | new_ispindel = false; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | ispindel = tmpp; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | break; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | |
579
1253a237b620
Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
69 | // if (debug) |
1253a237b620
Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
70 | // printf("new_ispindel %s\n", new_ispindel ? "true":"false"); |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | /* |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | * Allocate new ispindel if not yet known. |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | */ |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | if (new_ispindel) { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | ispindel = (sys_ispindel_list *)malloc(sizeof(sys_ispindel_list)); |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | memset(ispindel, 0, sizeof(sys_ispindel_list)); |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | ispindel->node = xstrcpy(node); |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
79 | ispindel->mode = xstrcpy((char *)"OFF"); |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | if (! ispindel->online) { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | ispindel->online = true; |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
84 | syslog(LOG_NOTICE, "Online ispindel %s mode %s", node, ispindel->mode); |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | /* |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
88 | * Process the JSON formatted payload. |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
89 | * Update only the fields that are found in the payload. |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | */ |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
91 | jobj = json_tokener_parse(payload); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
92 | |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
93 | if (json_object_object_get_ex(jobj, "unit", &metric)) { |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
94 | if (json_object_object_get_ex(metric, "uuid", &val)) { |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
95 | if (ispindel->uuid) |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
96 | free(ispindel->uuid); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
97 | ispindel->uuid = xstrcpy((char *)json_object_get_string(val)); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
98 | } |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
99 | if (json_object_object_get_ex(metric, "alias", &val)) { |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
100 | if (ispindel->alias) |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
101 | free(ispindel->alias); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
102 | ispindel->alias = xstrcpy((char *)json_object_get_string(val)); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
103 | } |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
104 | if (json_object_object_get_ex(metric, "alarm", &val)) { |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
105 | ispindel->alarm = json_object_get_int(val); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
106 | } |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
107 | if (json_object_object_get_ex(metric, "interval", &val)) { |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
108 | ispindel->interval = json_object_get_int(val); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
109 | } |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
110 | if (json_object_object_get_ex(metric, "angle", &val)) { |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
111 | ispindel->angle = json_object_get_double(val); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
112 | } |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
113 | if (json_object_object_get_ex(metric, "temperature", &val)) { |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
114 | ispindel->temperature = json_object_get_double(val); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
115 | } |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
116 | if (json_object_object_get_ex(metric, "battery", &val)) { |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
117 | ispindel->battery = json_object_get_double(val); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
118 | } |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
119 | if (json_object_object_get_ex(metric, "gravity", &val)) { |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
120 | ispindel->gravity = json_object_get_double(val); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
121 | } |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | |
579
1253a237b620
Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
124 | // ispindel_dump(ispindel); |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | if (new_ispindel) { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | if (ispindels == NULL) { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | ispindels = ispindel; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | } else { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | for (tmpp = ispindels; tmpp; tmpp = tmpp->next) { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | if (tmpp->next == NULL) { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | tmpp->next = ispindel; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | break; |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | ispindel_mysql_insert(ispindel); |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
138 | } else { |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | ispindel_mysql_update(ispindel); |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | } |
568
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
141 | |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
142 | /* |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
143 | * The data is complete, see if we can write a log entry. |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
144 | */ |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
145 | if (ispindel->beercode && strlen(ispindel->beercode) && ispindel->beername && strlen(ispindel->beername) && |
579
1253a237b620
Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
146 | ispindel->online && (strcmp(ispindel->mode, (char *)"ON") == 0)) { |
568
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
147 | datetime = malloc(72); |
579
1253a237b620
Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
148 | timestamp = time(NULL); |
568
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
149 | mytime = localtime(×tamp); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
150 | snprintf(datetime, 72, "%04d-%02d-%02d %02d:%02d:%02d", |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
151 | mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
152 | |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
153 | line = xstrcpy(datetime); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
154 | line = xstrcat(line, (char *)","); |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
155 | snprintf(buf, 64, "%.4f", ispindel->temperature); |
568
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
156 | line = xstrcat(line, buf); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
157 | line = xstrcat(line, (char *)","); |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
158 | snprintf(buf, 64, "%.5f", ispindel->gravity); |
568
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
159 | line = xstrcat(line, buf); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
160 | line = xstrcat(line, (char *)","); |
579
1253a237b620
Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
161 | snprintf(buf, 64, "%.5f", 1 + (ispindel->gravity / (258.6 - ((ispindel->gravity / 258.2) * 227.1)))); |
1253a237b620
Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
162 | line = xstrcat(line, buf); |
1253a237b620
Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
163 | line = xstrcat(line, (char *)","); |
587
31caffee8c9c
Changed several float precision values. Changed some database fields to double. Everything has now the same precision as received values from the iSpindel.
Michiel Broek <mbroek@mbse.eu>
parents:
579
diff
changeset
|
164 | snprintf(buf, 64, "%.6f", ispindel->battery); |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
165 | line = xstrcat(line, buf); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
166 | line = xstrcat(line, (char *)","); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
167 | snprintf(buf, 64, "%.5f", ispindel->angle); |
568
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
168 | line = xstrcat(line, buf); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
169 | line = xstrcat(line, (char *)","); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
170 | snprintf(buf, 64, "%d", ispindel->interval); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
171 | line = xstrcat(line, buf); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
172 | line = xstrcat(line, (char *)","); |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
173 | line = xstrcat(line, ispindel->uuid); |
568
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
174 | |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
175 | /* |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
176 | * Build logfile name |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
177 | */ |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
178 | logfile = xstrcpy(Config.web_root); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
179 | logfile = xstrcat(logfile, (char *)"/log/ispindel/"); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
180 | logfile = xstrcat(logfile, ispindel->beercode); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
181 | logfile = xstrcat(logfile, (char *)" "); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
182 | logfile = xstrcat(logfile, ispindel->beername); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
183 | logfile = xstrcat(logfile, (char *)".log"); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
184 | |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
185 | fp = fopen(logfile, "a"); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
186 | if (fp) { |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
187 | fprintf(fp, "%s\n", line); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
188 | fclose(fp); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
189 | } else { |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
190 | syslog(LOG_NOTICE, "cannot append to `%s'", logfile); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
191 | } |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
192 | |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
193 | free(logfile); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
194 | logfile = NULL; |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
195 | free(line); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
196 | line = NULL; |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
197 | free(datetime); |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
198 | datetime = NULL; |
6f3c24e21deb
Added ispindel logging. Updated the documentation.
Michiel Broek <mbroek@mbse.eu>
parents:
567
diff
changeset
|
199 | } |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
200 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
202 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
203 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | /* |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | * Process iSpindel MQTT message. |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
206 | */ |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
207 | void ispindel_birth_data(char *topic, char *payload) |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | { |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
209 | char *message_type, *edge_node; |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
211 | strtok(topic, "/"); // ignore namespace |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
212 | strtok(NULL, "/"); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
213 | message_type = strtok(NULL, "/"); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
214 | edge_node = strtok(NULL, "/\0"); |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
216 | if (strcmp("DBIRTH", message_type) == 0) { |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
217 | ispindel_set(edge_node, payload); |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
218 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | void ispindel_dump(sys_ispindel_list *ispindel) |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | { |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | if (debug) { |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
226 | printf("node/alias %s / %s\n", ispindel->node, ispindel->alias); |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
227 | printf("uuid %s\n", ispindel->uuid); |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
228 | printf("online %s\n", ispindel->online ? "yes":"no"); |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
229 | printf("mode %s\n", ispindel->mode); |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
230 | printf("product %s / %s\n", ispindel->beercode, ispindel->beername); |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
231 | printf("tilt %.5f\n", ispindel->angle); |
587
31caffee8c9c
Changed several float precision values. Changed some database fields to double. Everything has now the same precision as received values from the iSpindel.
Michiel Broek <mbroek@mbse.eu>
parents:
579
diff
changeset
|
232 | printf("temperature %.4f\n", ispindel->temperature); |
31caffee8c9c
Changed several float precision values. Changed some database fields to double. Everything has now the same precision as received values from the iSpindel.
Michiel Broek <mbroek@mbse.eu>
parents:
579
diff
changeset
|
233 | printf("battery %.6f\n", ispindel->battery); |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
234 | printf("gravity %.5f\n", ispindel->gravity); |
567
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | printf("interval %d\n", ispindel->interval); |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
237 | } |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
238 | |
6bf0afc33e70
Initial code for iSpindel support in the daemon
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
239 |