Thu, 14 Mar 2024 19:37:53 +0100
Create installation directories
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
631 | 2 | * Copyright (C) 2016-2023 |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of the mbsePi-apps |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * mbsePi-apps is distributed in the hope that it will be useful, but |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | #include "thermferm.h" |
628
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
24 | #include <sys/ioctl.h> |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
25 | #include <linux/wireless.h> |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
26 | #include "rdconfig.h" |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
27 | #include "devices.h" |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | #include "xutil.h" |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | #include "mqtt.h" |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | extern sys_config Config; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | extern int debug; |
550
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
33 | extern int my_shutdown; |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
34 | extern int my_reboot; |
506 | 35 | extern const char UNITMODE[5][8]; |
566 | 36 | extern const char UNITSTAGE[4][12]; |
506 | 37 | extern const char PROFSTATE[5][6]; |
38 | extern const char TEMPSTATE[3][8]; | |
39 | ||
40 | int Sequence = 0; | |
41 | ||
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | /* Global variables for use in callbacks. */ |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | int mqtt_qos = 0; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | int mqtt_status = STATUS_CONNECTING; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | int mqtt_mid_sent = 0; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | int mqtt_last_mid = -1; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | int mqtt_last_mid_sent = -1; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | int mqtt_connected = TRUE; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | int mqtt_disconnect_sent = FALSE; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | int mqtt_connect_lost = FALSE; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | int mqtt_my_shutdown = FALSE; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | int mqtt_use = FALSE; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | int keepalive = 60; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | unsigned int max_inflight = 20; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | struct mosquitto *mosq = NULL; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | char *state = NULL; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | char my_hostname[256]; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | |
598
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
63 | #ifndef HAVE_WIRINGPI_H |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
64 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
65 | /* |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
66 | * Code from wiringPi written by Gordon Henderson. |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
67 | * Copied here to have some sort of hardware detection without wiringPi. |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
68 | */ |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
69 | const char *piModelNames [20] = |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
70 | { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
71 | "Model A", // 0 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
72 | "Model B", // 1 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
73 | "Model A+", // 2 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
74 | "Model B+", // 3 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
75 | "Pi 2", // 4 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
76 | "Alpha", // 5 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
77 | "CM", // 6 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
78 | "Unknown07", // 07 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
79 | "Pi 3", // 08 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
80 | "Pi Zero", // 09 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
81 | "CM3", // 10 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
82 | "Unknown11", // 11 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
83 | "Pi Zero-W", // 12 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
84 | "Pi 3B+", // 13 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
85 | "Pi 3A+", // 14 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
86 | "Unknown15", // 15 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
87 | "CM3+", // 16 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
88 | "Unknown17", // 17 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
89 | "Unknown18", // 18 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
90 | "Unknown19", // 19 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
91 | }; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
92 | const char *piRevisionNames [16] = |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
93 | { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
94 | "00", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
95 | "01", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
96 | "02", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
97 | "03", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
98 | "04", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
99 | "05", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
100 | "06", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
101 | "07", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
102 | "08", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
103 | "09", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
104 | "10", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
105 | "11", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
106 | "12", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
107 | "13", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
108 | "14", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
109 | "15", |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
110 | } ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
111 | const char *piMakerNames [16] = |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
112 | { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
113 | "Sony", // 0 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
114 | "Egoman", // 1 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
115 | "Embest", // 2 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
116 | "Unknown", // 3 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
117 | "Embest", // 4 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
118 | "Unknown05", // 5 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
119 | "Unknown06", // 6 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
120 | "Unknown07", // 7 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
121 | "Unknown08", // 8 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
122 | "Unknown09", // 9 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
123 | "Unknown10", // 10 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
124 | "Unknown11", // 11 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
125 | "Unknown12", // 12 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
126 | "Unknown13", // 13 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
127 | "Unknown14", // 14 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
128 | "Unknown15", // 15 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
129 | } ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
130 | const int piMemorySize [8] = |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
131 | { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
132 | 256, // 0 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
133 | 512, // 1 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
134 | 1024, // 2 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
135 | 0, // 3 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
136 | 0, // 4 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
137 | 0, // 5 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
138 | 0, // 6 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
139 | 0, // 7 |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
140 | } ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
141 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
142 | void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
143 | { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
144 | FILE *cpuFd ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
145 | char line [120] ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
146 | char *c ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
147 | unsigned int revision ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
148 | int bRev, bType, bProc, bMfg, bMem, bWarranty ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
149 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
150 | *model = -1; // Mark no info |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
151 | if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL) { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
152 | syslog(LOG_NOTICE, "Unable to open /proc/cpuinfo") ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
153 | return; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
154 | } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
155 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
156 | while (fgets (line, 120, cpuFd) != NULL) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
157 | if (strncmp (line, "Revision", 8) == 0) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
158 | break ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
159 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
160 | fclose (cpuFd) ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
161 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
162 | if (strncmp (line, "Revision", 8) != 0) { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
163 | syslog(LOG_NOTICE, "No \"Revision\" line"); |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
164 | return; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
165 | } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
166 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
167 | // Chomp trailing CR/NL |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
168 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
169 | for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
170 | *c = 0 ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
171 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
172 | if (debug) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
173 | fprintf(stdout, "piBoardId: Revision string: %s\n", line) ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
174 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
175 | // Need to work out if it's using the new or old encoding scheme: |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
176 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
177 | // Scan to the first character of the revision number |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
178 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
179 | for (c = line ; *c ; ++c) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
180 | if (*c == ':') |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
181 | break ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
182 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
183 | if (*c != ':') { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
184 | syslog(LOG_NOTICE, "Bogus \"Revision\" line (no colon)") ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
185 | return; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
186 | } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
187 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
188 | // Chomp spaces |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
189 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
190 | ++c ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
191 | while (isspace (*c)) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
192 | ++c ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
193 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
194 | if (!isxdigit (*c)) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
195 | syslog(LOG_NOTICE, "Bogus \"Revision\" line (no hex digit at start of revision)") ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
196 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
197 | revision = (unsigned int)strtol (c, NULL, 16) ; // Hex number with no leading 0x |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
198 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
199 | // Check for new way: |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
200 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
201 | if ((revision & (1 << 23)) != 0) { // New way |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
202 | if (debug) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
203 | fprintf(stdout, "piBoardId: New Way: revision is: %08X\n", revision) ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
204 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
205 | bRev = (revision & (0x0F << 0)) >> 0 ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
206 | bType = (revision & (0xFF << 4)) >> 4 ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
207 | bProc = (revision & (0x0F << 12)) >> 12 ; // Not used for now. |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
208 | bMfg = (revision & (0x0F << 16)) >> 16 ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
209 | bMem = (revision & (0x07 << 20)) >> 20 ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
210 | bWarranty = (revision & (0x03 << 24)) != 0 ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
211 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
212 | *model = bType ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
213 | *rev = bRev ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
214 | *mem = bMem ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
215 | *maker = bMfg ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
216 | *warranty = bWarranty ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
217 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
218 | if (debug) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
219 | fprintf(stdout, "piBoardId: rev: %d, type: %d, proc: %d, mfg: %d, mem: %d, warranty: %d\n", bRev, bType, bProc, bMfg, bMem, bWarranty) ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
220 | } else { // Old way |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
221 | if (debug) |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
222 | fprintf(stdout, "piBoardId: Old Way: revision is: %s\n", c) ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
223 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
224 | if (!isdigit (*c)) { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
225 | syslog(LOG_NOTICE, "Bogus \"Revision\" line (no digit at start of revision)") ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
226 | return; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
227 | } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
228 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
229 | // Make sure its long enough |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
230 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
231 | if (strlen (c) < 4) { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
232 | syslog(LOG_NOTICE, "Bogus \"Revision\" line (not long enough)") ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
233 | return; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
234 | } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
235 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
236 | // If longer than 4, we'll assume it's been overvolted |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
237 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
238 | *warranty = strlen (c) > 4 ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
239 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
240 | // Extract last 4 characters: |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
241 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
242 | c = c + strlen (c) - 4 ; |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
243 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
244 | // Fill out the replys as appropriate |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
245 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
246 | /**/ if (strcmp (c, "0002") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
247 | else if (strcmp (c, "0003") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_1 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
248 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
249 | else if (strcmp (c, "0004") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_SONY ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
250 | else if (strcmp (c, "0005") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
251 | else if (strcmp (c, "0006") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
252 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
253 | else if (strcmp (c, "0007") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
254 | else if (strcmp (c, "0008") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_SONY ; ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
255 | else if (strcmp (c, "0009") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
256 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
257 | else if (strcmp (c, "000d") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
258 | else if (strcmp (c, "000e") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_SONY ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
259 | else if (strcmp (c, "000f") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
260 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
261 | else if (strcmp (c, "0010") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_SONY ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
262 | else if (strcmp (c, "0013") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_EMBEST ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
263 | else if (strcmp (c, "0016") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_SONY ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
264 | else if (strcmp (c, "0019") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
265 | else if (strcmp (c, "0011") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_1 ; *mem = 1 ; *maker = PI_MAKER_SONY ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
266 | else if (strcmp (c, "0014") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_1 ; *mem = 1 ; *maker = PI_MAKER_EMBEST ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
267 | else if (strcmp (c, "0017") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_1 ; *mem = 1 ; *maker = PI_MAKER_SONY ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
268 | else if (strcmp (c, "001a") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_1 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
269 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
270 | else if (strcmp (c, "0012") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_1 ; *mem = 0 ; *maker = PI_MAKER_SONY ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
271 | else if (strcmp (c, "0015") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_1 ; *mem = 1 ; *maker = PI_MAKER_EMBEST ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
272 | else if (strcmp (c, "0018") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_1 ; *mem = 0 ; *maker = PI_MAKER_SONY ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
273 | else if (strcmp (c, "001b") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_1 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
274 | |
602
ca795b871158
Fix for non Pi hardware and virtual Pi's.
Chiel Broek <mbse@mbse.eu>
parents:
598
diff
changeset
|
275 | else { *model = -1 ; *rev = 0 ; *mem = 0 ; *maker = 0 ; } |
598
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
276 | } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
277 | } |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
278 | #endif |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
279 | |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
280 | |
506 | 281 | |
282 | char *payload_header(void) | |
283 | { | |
284 | char *tmp, buf[128]; | |
285 | ||
286 | tmp = xstrcpy((char *)"{\"timestamp\":"); | |
287 | sprintf(buf, "%ld", time(NULL)); | |
288 | tmp = xstrcat(tmp, buf); | |
289 | tmp = xstrcat(tmp, (char *)",\"seq\":"); | |
290 | sprintf(buf, "%d", Sequence++); | |
291 | tmp = xstrcat(tmp, buf); | |
292 | tmp = xstrcat(tmp, (char *)",\"metric\":"); | |
293 | return tmp; | |
294 | } | |
295 | ||
296 | ||
297 | ||
298 | char *topic_base(char *msgtype) | |
299 | { | |
300 | char *tmp; | |
301 | ||
302 | tmp = xstrcpy((char *)"mbv1.0/fermenters/"); | |
303 | tmp = xstrcat(tmp, msgtype); | |
304 | tmp = xstrcat(tmp, (char *)"/"); | |
305 | tmp = xstrcat(tmp, my_hostname); | |
306 | return tmp; | |
307 | } | |
308 | ||
309 | ||
310 | ||
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
311 | void my_connect_callback(struct mosquitto *my_mosq, void *obj, int result) |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
312 | { |
506 | 313 | char *topic = NULL; |
314 | ||
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
315 | if (mqtt_connect_lost) { |
506 | 316 | mqtt_connect_lost = FALSE; |
317 | syslog(LOG_NOTICE, "MQTT: reconnect: %s", mosquitto_connack_string(result)); | |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
318 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
319 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
320 | if (!result) { |
506 | 321 | topic = topic_base((char *)"NCMD"); |
322 | topic = xstrcat(topic, (char *)"/#"); | |
323 | mosquitto_subscribe(mosq, NULL, topic, 0); | |
324 | free(topic); | |
325 | topic = topic_base((char *)"DCMD"); | |
326 | topic = xstrcat(topic, (char *)"/#"); | |
327 | mosquitto_subscribe(mosq, NULL, topic, 0); | |
328 | free(topic); | |
329 | topic = NULL; | |
330 | mqtt_status = STATUS_CONNACK_RECVD; | |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
331 | } else { |
506 | 332 | syslog(LOG_NOTICE, "MQTT: my_connect_callback: %s\n", mosquitto_connack_string(result)); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
333 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
334 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
335 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
336 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
337 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
338 | void my_disconnect_callback(struct mosquitto *my_mosq, void *obj, int rc) |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
339 | { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
340 | if (mqtt_my_shutdown) { |
500
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
341 | syslog(LOG_NOTICE, "MQTT: acknowledged DISCONNECT from %s", Config.mqtt_host); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
342 | mqtt_connected = FALSE; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
343 | } else { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
344 | /* |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
345 | * The remote server was brought down. We must keep running |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
346 | */ |
500
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
347 | syslog(LOG_NOTICE, "MQTT: received DISCONNECT from %s, connection lost", Config.mqtt_host); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
348 | mqtt_connect_lost = TRUE; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
349 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
350 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
351 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
352 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
353 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
354 | void my_publish_callback(struct mosquitto *my_mosq, void *obj, int mid) |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
355 | { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
356 | mqtt_last_mid_sent = mid; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
357 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
358 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
359 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
360 | |
506 | 361 | void my_subscribe_callback(struct mosquitto *my_mosq, void *userdata, int mid, int qos_count, const int *granted_qos) |
362 | { | |
363 | int i; | |
364 | ||
365 | syslog(LOG_NOTICE, "Subscribed (mid: %d): %d", mid, granted_qos[0]); | |
366 | for (i = 1; i < qos_count; i++) { | |
367 | syslog(LOG_NOTICE, " %d", granted_qos[i]); | |
368 | } | |
369 | } | |
370 | ||
371 | ||
372 | ||
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
373 | void my_log_callback(struct mosquitto *my_mosq, void *obj, int level, const char *str) |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
374 | { |
591
95cf33f8021f
Removed writing local unit data logs
Michiel Broek <mbroek@mbse.eu>
parents:
582
diff
changeset
|
375 | // if (debug) |
95cf33f8021f
Removed writing local unit data logs
Michiel Broek <mbroek@mbse.eu>
parents:
582
diff
changeset
|
376 | // fprintf(stdout, "MQTT: %s\n", str); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
377 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
378 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
379 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
380 | |
506 | 381 | void my_message_callback(struct mosquitto *my_mosq, void *userdata, const struct mosquitto_message *message) |
382 | { | |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
383 | char *message_type, *message_node, *message_alias; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
384 | units_list *unit; |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
385 | prof_step *step, *oldstep; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
386 | struct json_object *jobj, *metric, *val, *setpoint, *profile, *profile1, *steps, *step1; |
550
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
387 | time_t timestamp; |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
388 | int timediff; |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
389 | |
506 | 390 | if (message->payloadlen) { |
550
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
391 | /* |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
392 | * Process received commands |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
393 | */ |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
394 | strtok(message->topic, "/"); // Ignore mbv1.0 |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
395 | strtok(NULL, "/"); // Ignore group_id |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
396 | message_type = strtok(NULL, "/"); |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
397 | message_node = strtok(NULL, "/\0"); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
398 | message_alias = strtok(NULL, "\0"); |
550
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
399 | |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
400 | jobj = json_tokener_parse(message->payload); |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
401 | if (json_object_object_get_ex(jobj, "timestamp", &val)) { |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
402 | timestamp = json_object_get_int(val); |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
403 | timediff = (int)timestamp - time(NULL); |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
404 | if ((timediff < 61) && (timediff > -61)) { |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
405 | if (json_object_object_get_ex(jobj, "metric", &metric)) { |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
406 | if ((json_object_object_get_ex(metric, "Node Control/Reboot", &val)) && (strcmp(message_type, "NCMD") == 0)) { |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
407 | if (json_object_get_boolean(val) == true) { |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
408 | syslog(LOG_NOTICE, "MQTT: `Node Control/Reboot' command"); |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
409 | /* |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
410 | * Reboot. The erver process will restart which is handled |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
411 | * in the main thread loop. |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
412 | */ |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
413 | my_reboot = my_shutdown = TRUE; |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
414 | return; |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
415 | } |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
416 | } |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
417 | if ((json_object_object_get_ex(metric, "Node Control/Rebirth", &val)) && (strcmp(message_type, "NCMD") == 0)) { |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
418 | if (json_object_get_boolean(val) == true) { |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
419 | /* |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
420 | * Resend all birth certificates. |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
421 | */ |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
422 | syslog(LOG_NOTICE, "MQTT: `Node Control/Rebirth' command"); |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
423 | publishNData(true, 0); |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
424 | publishDBirthAll(); |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
425 | return; |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
426 | } |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
427 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
428 | |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
429 | /* |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
430 | * DCMD, commands and configuration changes for a single fermenter. |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
431 | */ |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
432 | if ((strcmp(message_type, "DCMD") == 0) && message_node && message_alias) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
433 | syslog(LOG_NOTICE, "%s", (char *)json_object_get_string(metric)); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
434 | for (unit = Config.units ; unit; unit = unit->next) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
435 | if (strcmp(unit->alias, message_alias) == 0) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
436 | syslog(LOG_NOTICE, "MQTT: DCMD for %s/%s", (char *)message_node, (char *)message_alias); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
437 | if (json_object_object_get_ex(metric, "stage", &val)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
438 | for (int i = 0; i < 4; i++) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
439 | if (strcmp((char *)json_object_get_string(val), UNITSTAGE[i]) == 0) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
440 | if (unit->stage != i) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
441 | syslog(LOG_NOTICE, "DCMD change fermenter %s: stage to %s", message_alias, UNITSTAGE[i]); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
442 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
443 | unit->stage = i; |
575
86496d2bc4bb
Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.
Michiel Broek <mbroek@mbse.eu>
parents:
571
diff
changeset
|
444 | if ((unit->mode != UNITMODE_OFF) && ! unit->event_msg) |
86496d2bc4bb
Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.
Michiel Broek <mbroek@mbse.eu>
parents:
571
diff
changeset
|
445 | unit->event_msg = xstrcpy((char *)UNITSTAGE[i]); |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
446 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
447 | break; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
448 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
449 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
450 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
451 | |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
452 | if (json_object_object_get_ex(metric, "mode", &val)) { |
571
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
453 | for (int i = 0; i < 5; i++) { |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
454 | if (strcmp((char *)json_object_get_string(val), UNITMODE[i]) == 0) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
455 | if (unit->mode != i) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
456 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
457 | /* Initialize log if the unit is turned on */ |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
458 | if ((unit->mode == UNITMODE_OFF) && (i != UNITMODE_OFF)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
459 | unit->mqtt_flag |= MQTT_FLAG_BIRTH; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
460 | } |
571
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
461 | if (i == UNITMODE_PROFILE) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
462 | /* Do some checks and refuse profile mode cannot be set */ |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
463 | if (unit->profile_uuid == NULL) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
464 | syslog(LOG_NOTICE, "Fermenter unit %s refuse profile, not loaded", message_alias); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
465 | break; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
466 | } |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
467 | } |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
468 | syslog(LOG_NOTICE, "DCMD change fermenter %s: mode to %s", message_alias, UNITMODE[i]); |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
469 | unit->mode = i; |
575
86496d2bc4bb
Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.
Michiel Broek <mbroek@mbse.eu>
parents:
571
diff
changeset
|
470 | if ((unit->mode != UNITMODE_OFF) && ! unit->event_msg) |
86496d2bc4bb
Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.
Michiel Broek <mbroek@mbse.eu>
parents:
571
diff
changeset
|
471 | unit->event_msg = xstrcpy((char *)UNITMODE[i]); |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
472 | /* Allways turn everything off after a mode change */ |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
473 | unit->PID_cool->OutP = unit->PID_heat->OutP = 0.0; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
474 | unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; |
582
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
579
diff
changeset
|
475 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->light_state = unit->light_timer = 0; |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
476 | unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
477 | device_out(unit->heater_address, unit->heater_state); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
478 | device_out(unit->cooler_address, unit->cooler_state); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
479 | device_out(unit->fan_address, unit->fan_state); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
480 | device_out(unit->light_address, unit->light_state); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
481 | if (unit->mode == UNITMODE_PROFILE) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
482 | /* |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
483 | * Set a sane default until it will be overruled by the |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
484 | * main processing loop. |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
485 | */ |
571
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
486 | unit->prof_target_lo = unit->profile_inittemp_lo; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
487 | unit->prof_target_hi = unit->profile_inittemp_hi;; |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
488 | unit->prof_fridge_mode = 0; |
571
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
489 | unit->prof_state = PROFILE_OFF; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
490 | unit->prof_started = unit->prof_paused = unit->prof_primary_done = 0; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
491 | unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
492 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
493 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
494 | break; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
495 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
496 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
497 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
498 | |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
499 | if (json_object_object_get_ex(metric, "setpoint", &setpoint)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
500 | if ((unit->mode == UNITMODE_FRIDGE) || (unit->mode == UNITMODE_BEER)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
501 | /* |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
502 | * Only set new setpoints if running in FRIDGE or in BEER mode. |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
503 | */ |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
504 | if (json_object_object_get_ex(setpoint, "low", &val)) |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
505 | unit->PID_heat->SetP = json_object_get_double(val); |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
506 | if (json_object_object_get_ex(setpoint, "high", &val)) |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
507 | unit->PID_cool->SetP = json_object_get_double(val); |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
577
diff
changeset
|
508 | if (unit->mode == UNITMODE_FRIDGE) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
577
diff
changeset
|
509 | unit->fridge_set_lo = unit->PID_heat->SetP; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
577
diff
changeset
|
510 | unit->fridge_set_hi = unit->PID_cool->SetP; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
577
diff
changeset
|
511 | } else { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
577
diff
changeset
|
512 | unit->beer_set_lo = unit->PID_heat->SetP; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
577
diff
changeset
|
513 | unit->beer_set_hi = unit->PID_cool->SetP; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
577
diff
changeset
|
514 | } |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
515 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
516 | syslog(LOG_NOTICE, "DCMD change fermenter %s: setpoints %.1f %.1f", message_alias, unit->PID_heat->SetP, unit->PID_cool->SetP); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
517 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
518 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
519 | |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
520 | if ((json_object_object_get_ex(metric, "heater", &setpoint)) && (unit->mode == UNITMODE_NONE)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
521 | if (json_object_object_get_ex(setpoint, "state", &val)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
522 | if (json_object_get_int(val) != unit->heater_state) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
523 | unit->heater_state = json_object_get_int(val); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
524 | if (unit->heater_state) // Safety |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
525 | unit->cooler_state = 0; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
526 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
527 | syslog(LOG_NOTICE, "DCMD change fermenter %s: heater_state to %d", message_alias, unit->heater_state); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
528 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
529 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
530 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
531 | |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
532 | if ((json_object_object_get_ex(metric, "cooler", &setpoint)) && (unit->mode == UNITMODE_NONE)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
533 | if (json_object_object_get_ex(setpoint, "state", &val)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
534 | if (json_object_get_int(val) != unit->cooler_state) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
535 | unit->cooler_state = json_object_get_int(val); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
536 | if (unit->cooler_state) |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
537 | unit->heater_state = 0; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
538 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
539 | syslog(LOG_NOTICE, "DCMD change fermenter %s: cooler_state to %d", message_alias, unit->cooler_state); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
540 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
541 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
542 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
543 | |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
544 | if ((json_object_object_get_ex(metric, "fan", &setpoint)) && (unit->mode == UNITMODE_NONE)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
545 | if (json_object_object_get_ex(setpoint, "state", &val)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
546 | if (json_object_get_int(val) != unit->fan_state) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
547 | unit->fan_state = json_object_get_int(val); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
548 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
549 | syslog(LOG_NOTICE, "DCMD change fermenter %s: fan_state to %d", message_alias, unit->fan_state); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
550 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
551 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
552 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
553 | |
582
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
579
diff
changeset
|
554 | if (json_object_object_get_ex(metric, "light", &setpoint)) { |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
555 | if (json_object_object_get_ex(setpoint, "state", &val)) { |
582
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
579
diff
changeset
|
556 | if (json_object_get_int(val) > 0) { |
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
579
diff
changeset
|
557 | unit->light_timer = 300; // 5 minutes |
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
579
diff
changeset
|
558 | syslog(LOG_NOTICE, "DCMD set fermenter %s: light_timer 300", message_alias); |
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
579
diff
changeset
|
559 | if (!unit->light_state) { |
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
579
diff
changeset
|
560 | unit->light_state = 1; |
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
579
diff
changeset
|
561 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
579
diff
changeset
|
562 | syslog(LOG_NOTICE, "DCMD change fermenter %s: light_state to %d", message_alias, unit->light_state); |
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
579
diff
changeset
|
563 | } |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
564 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
565 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
566 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
567 | |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
568 | if ((json_object_object_get_ex(metric, "product", &setpoint)) && (unit->mode == UNITMODE_OFF)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
569 | if (json_object_object_get_ex(setpoint, "code", &val)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
570 | if (strcmp((char *)json_object_get_string(val), unit->product_code)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
571 | free(unit->product_code); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
572 | unit->product_code = xstrcpy((char *)json_object_get_string(val)); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
573 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
574 | syslog(LOG_NOTICE, "DCMD change fermenter %s: product_code to `%s'", message_alias, unit->product_code); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
575 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
576 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
577 | if (json_object_object_get_ex(setpoint, "name", &val)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
578 | if (strcmp((char *)json_object_get_string(val), unit->product_name)) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
579 | free(unit->product_name); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
580 | unit->product_name = xstrcpy((char *)json_object_get_string(val)); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
581 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
582 | syslog(LOG_NOTICE, "DCMD change fermenter %s: product_name to `%s'", message_alias, unit->product_name); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
583 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
584 | } |
571
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
585 | if (json_object_object_get_ex(setpoint, "uuid", &val)) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
586 | if (strcmp((char *)json_object_get_string(val), unit->product_uuid)) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
587 | free(unit->product_uuid); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
588 | unit->product_uuid = xstrcpy((char *)json_object_get_string(val)); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
589 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
590 | syslog(LOG_NOTICE, "DCMD change fermenter %s: product_uuid to `%s'", message_alias, unit->product_uuid); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
591 | } |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
592 | } |
579
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
593 | if (json_object_object_get_ex(setpoint, "yeast_lo", &val)) { |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
594 | unit->yeast_lo = json_object_get_double(val); |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
595 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
596 | syslog(LOG_NOTICE, "DCMD change fermenter %s: yeast_lo to `%.1f'", message_alias, unit->yeast_lo); |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
597 | } |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
598 | if (json_object_object_get_ex(setpoint, "yeast_hi", &val)) { |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
599 | unit->yeast_hi = json_object_get_double(val); |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
600 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
606
798dd0c4fd00
Version 0.9.9 Don't flag fermenter death if the unit is turned off. Fix a wrong log message. Send unit data even if the unit is turned off.
Michiel Broek <mbroek@mbse.eu>
parents:
602
diff
changeset
|
601 | syslog(LOG_NOTICE, "DCMD change fermenter %s: yeast_hi to `%.1f'", message_alias, unit->yeast_hi); |
579
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
602 | } |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
603 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
604 | |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
605 | if (json_object_object_get_ex(metric, "profile", &profile)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
606 | if (json_object_object_get_ex(profile, "command", &profile1)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
607 | syslog(LOG_NOTICE, "profile command"); |
571
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
608 | if (unit->mode == UNITMODE_PROFILE) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
609 | char *cmd = xstrcpy((char *)json_object_get_string(profile1)); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
610 | if (! strcmp(cmd, (char *)"off")) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
611 | if (unit->prof_state == PROFILE_DONE) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
612 | unit->prof_state = PROFILE_OFF; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
613 | syslog(LOG_NOTICE, "DCMD change fermenter `%s' profile to OFF", message_alias); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
614 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
615 | } |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
616 | } else if (! strcmp(cmd, (char *)"pause")) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
617 | if (unit->prof_state == PROFILE_RUN) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
618 | unit->prof_state = PROFILE_PAUSE; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
619 | syslog(LOG_NOTICE, "DCMD change fermenter `%s' profile to PAUSE", message_alias); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
620 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
621 | } else if (unit->prof_state == PROFILE_PAUSE) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
622 | unit->prof_state = PROFILE_RUN; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
623 | syslog(LOG_NOTICE, "DCMD change fermenter `%s' profile resume RUN", message_alias); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
624 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
625 | } |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
626 | } else if (! strcmp(cmd, (char *)"start")) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
627 | if (unit->prof_state == PROFILE_OFF) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
628 | unit->prof_state = PROFILE_RUN; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
629 | unit->prof_started = time(NULL); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
630 | unit->prof_paused = unit->prof_primary_done = 0; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
631 | unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
632 | syslog(LOG_NOTICE, "DCMD change fermenter `%s' profile start RUN", message_alias); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
633 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
575
86496d2bc4bb
Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.
Michiel Broek <mbroek@mbse.eu>
parents:
571
diff
changeset
|
634 | if (! unit->event_msg) |
86496d2bc4bb
Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.
Michiel Broek <mbroek@mbse.eu>
parents:
571
diff
changeset
|
635 | unit->event_msg = xstrcpy((char *)"Profile start"); |
571
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
636 | } |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
637 | } else if (! strcmp(cmd, (char *)"abort")) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
638 | if ((unit->prof_state == PROFILE_RUN) || (unit->prof_state == PROFILE_PAUSE)) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
639 | unit->prof_state = PROFILE_OFF; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
640 | unit->prof_started = unit->prof_paused = unit->prof_primary_done = 0; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
641 | unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
642 | syslog(LOG_NOTICE, "DCMD change fermenter `%s' profile ABORT", message_alias); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
643 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
575
86496d2bc4bb
Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.
Michiel Broek <mbroek@mbse.eu>
parents:
571
diff
changeset
|
644 | if (! unit->event_msg) |
86496d2bc4bb
Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.
Michiel Broek <mbroek@mbse.eu>
parents:
571
diff
changeset
|
645 | unit->event_msg = xstrcpy((char *)"Profile abort"); |
571
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
646 | } |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
647 | } else if (! strcmp(cmd, (char *)"done")) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
648 | if (unit->prof_state == PROFILE_DONE) { |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
649 | unit->prof_state = PROFILE_OFF; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
650 | unit->prof_started = unit->prof_paused = unit->prof_primary_done = 0; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
651 | unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
652 | syslog(LOG_NOTICE, "DCMD change fermenter `%s' profile OFF", message_alias); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
653 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
654 | } |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
655 | } |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
656 | free(cmd); |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
657 | cmd = NULL; |
6f8eda55ec2c
Version 0.9.1. Added fermentation profiles via MQTT. Added uuid field for loaded product. Removed some debug messages in the simulator. Removed dead code and debug messages from the lcd driver.
Michiel Broek <mbroek@mbse.eu>
parents:
570
diff
changeset
|
658 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
659 | } else if (json_object_object_get_ex(profile, "uuid", &profile1)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
660 | if ((unit->prof_state == PROFILE_OFF) || (unit->prof_state == PROFILE_DONE) || (unit->prof_state == PROFILE_ABORT)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
661 | if (unit->profile_uuid) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
662 | free(unit->profile_uuid); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
663 | if (unit->profile_name) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
664 | free(unit->profile_name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
665 | if (unit->profile_steps) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
666 | for (step = unit->profile_steps; step; step = oldstep) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
667 | if (step->name) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
668 | free(step->name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
669 | oldstep = step->next; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
670 | free(step); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
671 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
672 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
673 | unit->profile_steps = NULL; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
674 | unit->profile_duration = unit->profile_totalsteps = 0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
675 | unit->profile_uuid = xstrcpy((char *)json_object_get_string(profile1)); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
676 | if (json_object_object_get_ex(profile, "name", &val)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
677 | unit->profile_name = xstrcpy((char *)json_object_get_string(val)); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
678 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
679 | if (json_object_object_get_ex(profile, "inittemp", &setpoint)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
680 | if (json_object_object_get_ex(setpoint, "low", &val)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
681 | unit->profile_inittemp_lo = json_object_get_double(val); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
682 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
683 | if (json_object_object_get_ex(setpoint, "high", &val)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
684 | unit->profile_inittemp_hi = json_object_get_double(val); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
685 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
686 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
687 | if (json_object_object_get_ex(profile, "fridgemode", &val)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
688 | unit->profile_fridge_mode = json_object_get_int(val); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
689 | if (unit->profile_fridge_mode) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
690 | unit->profile_fridge_mode = 100; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
691 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
692 | if (json_object_object_get_ex(profile, "steps", &steps)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
693 | int arraylen = json_object_array_length(steps); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
694 | syslog(LOG_NOTICE, "profile new profile: start %d steps", arraylen); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
695 | for (int i = 0; i < arraylen; i++) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
696 | /* |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
697 | * Parse the array of steps |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
698 | */ |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
699 | step1 = json_object_array_get_idx(steps, i); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
700 | unit->profile_totalsteps++; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
701 | |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
702 | step = (prof_step *)malloc(sizeof(prof_step)); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
703 | step->next = NULL; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
704 | step->name = NULL; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
705 | step->steptime = step->resttime = step->fridge_mode = 0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
706 | step->target_lo = step->target_hi = 20.0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
707 | |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
708 | if (json_object_object_get_ex(step1, "name", &val)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
709 | step->name = xstrcpy((char *)json_object_get_string(val)); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
710 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
711 | if (json_object_object_get_ex(step1, "steptime", &val)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
712 | step->steptime = json_object_get_int(val); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
713 | unit->profile_duration += step->steptime; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
714 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
715 | if (json_object_object_get_ex(step1, "resttime", &val)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
716 | step->resttime = json_object_get_int(val); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
717 | unit->profile_duration += step->resttime; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
718 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
719 | if (json_object_object_get_ex(step1, "fridgemode", &val)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
720 | step->fridge_mode = json_object_get_int(val); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
721 | if (step->fridge_mode) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
722 | step->fridge_mode = 100; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
723 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
724 | if (json_object_object_get_ex(step1, "target_lo", &val)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
725 | step->target_lo = json_object_get_double(val); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
726 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
727 | if (json_object_object_get_ex(step1, "target_hi", &val)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
728 | step->target_hi = json_object_get_double(val); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
729 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
730 | |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
731 | syslog(LOG_NOTICE, "profile new profile: add step %d", unit->profile_totalsteps); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
732 | if (unit->profile_steps == NULL) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
733 | unit->profile_steps = step; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
734 | } else { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
735 | for (oldstep = unit->profile_steps; oldstep; oldstep = oldstep->next) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
736 | if (oldstep->next == NULL) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
737 | oldstep->next = step; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
738 | break; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
739 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
740 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
741 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
742 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
743 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
744 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
745 | syslog(LOG_NOTICE, "DCMD change fermenter %s: install profile `%s'", message_alias, unit->profile_name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
746 | wrconfig(); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
747 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
748 | } else { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
749 | if ((unit->prof_state == PROFILE_OFF) || (unit->prof_state == PROFILE_DONE) || (unit->prof_state == PROFILE_ABORT)) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
750 | syslog(LOG_NOTICE, "DCMD change fermenter %s: delete profile `%s'", message_alias, unit->profile_name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
751 | if (unit->profile_uuid) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
752 | free(unit->profile_uuid); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
753 | if (unit->profile_name) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
754 | free(unit->profile_name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
755 | unit->profile_uuid = unit->profile_name = NULL; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
756 | if (unit->profile_steps) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
757 | for (step = unit->profile_steps; step; step = oldstep) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
758 | if (step->name) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
759 | free(step->name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
760 | oldstep = step->next; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
761 | free(step); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
762 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
763 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
764 | unit->profile_steps = NULL; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
765 | unit->profile_inittemp_lo = unit->profile_inittemp_hi = 20.0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
766 | unit->prof_percent = unit->profile_fridge_mode = 0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
767 | unit->prof_state = PROFILE_OFF; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
768 | unit->profile_duration = unit->profile_totalsteps = 0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
769 | unit->prof_started = unit->prof_paused = unit->prof_primary_done = (time_t)0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
770 | unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
771 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
772 | wrconfig(); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
773 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
774 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
775 | } |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
776 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
777 | |
569
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
778 | if (unit->mqtt_flag) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
779 | if (unit->mqtt_flag & MQTT_FLAG_BIRTH) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
780 | publishDBirth(unit); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
781 | } else { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
782 | publishDData(unit); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
783 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
784 | if (unit->mqtt_flag & MQTT_FLAG_DEATH) { |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
785 | publishDDeath(unit); |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
786 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
787 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
788 | } |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
789 | return; |
9c69d43bfb06
Version 0.9.0. Implemented DCMD via mqtt to set stage, mode, setpoint low and high. Implemeted DCMD via mqtt to set heater, cooler, fan and light state. Implemented DCMD via mqtt to set product code and name. Set the PID's in fridge mode without idle range offset, that was an old leftover setting that was obsolete.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
790 | } |
550
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
791 | syslog(LOG_NOTICE, "MQTT: %s payload not understood\n", (char *)message->payload); |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
792 | return; |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
793 | } |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
794 | } else { |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
795 | syslog(LOG_NOTICE, "MQTT: got payload with timestamp %d seconds error", timediff); |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
796 | return; |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
797 | } |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
798 | } |
04c942cded91
Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents:
549
diff
changeset
|
799 | |
506 | 800 | syslog(LOG_NOTICE, "MQTT: message callback %s :: %d", message->topic, message->payloadlen); |
801 | } else { | |
802 | syslog(LOG_NOTICE, "MQTT: message callback %s (null)", message->topic); | |
803 | } | |
804 | } | |
805 | ||
806 | ||
807 | ||
808 | void publisher(struct mosquitto *my_mosq, char *topic, char *payload, bool retain) { | |
809 | // publish the data | |
810 | if (payload) | |
811 | mosquitto_publish(my_mosq, &mqtt_mid_sent, topic, strlen(payload), payload, mqtt_qos, retain); | |
812 | else | |
813 | mosquitto_publish(my_mosq, &mqtt_mid_sent, topic, 0, NULL, mqtt_qos, retain); | |
814 | } | |
815 | ||
816 | ||
817 | ||
515
7ab5cf2afc0c
Only send domoticz changed values
Michiel Broek <mbroek@mbse.eu>
parents:
514
diff
changeset
|
818 | void pub_domoticz_temp(int idx, int value) { |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
819 | char *dload = NULL; |
515
7ab5cf2afc0c
Only send domoticz changed values
Michiel Broek <mbroek@mbse.eu>
parents:
514
diff
changeset
|
820 | char sidx[10], sval[20]; |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
821 | |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
822 | if (idx == 0) |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
823 | return; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
824 | |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
825 | sprintf(sidx, "%d", idx); |
515
7ab5cf2afc0c
Only send domoticz changed values
Michiel Broek <mbroek@mbse.eu>
parents:
514
diff
changeset
|
826 | sprintf(sval, "%.3f", value / 1000.0); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
827 | |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
828 | dload = xstrcpy((char *)"{\"command\":\"udevice\",\"idx\":"); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
829 | dload = xstrcat(dload, sidx); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
830 | dload = xstrcat(dload, (char *)",\"nvalue\":0,\"svalue\":\""); |
515
7ab5cf2afc0c
Only send domoticz changed values
Michiel Broek <mbroek@mbse.eu>
parents:
514
diff
changeset
|
831 | dload = xstrcat(dload, sval); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
832 | dload = xstrcat(dload, (char *)"\"}"); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
833 | publisher(mosq, (char *)"domoticz/in", dload, false); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
834 | free(dload); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
835 | dload = NULL; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
836 | } |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
837 | |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
838 | |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
839 | |
514
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
840 | void pub_domoticz_output(int idx, int value) { |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
841 | char *dload = NULL; |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
842 | char sidx[10], sval[10]; |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
843 | |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
844 | if (idx == 0) |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
845 | return; |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
846 | |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
847 | sprintf(sidx, "%d", idx); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
848 | sprintf(sval, "%d", value); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
849 | |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
850 | dload = xstrcpy((char *)"{\"command\":\"udevice\",\"idx\":"); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
851 | dload = xstrcat(dload, sidx); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
852 | dload = xstrcat(dload, (char *)",\"nvalue\":"); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
853 | if (value >= 50) |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
854 | dload = xstrcat(dload, (char *)"1"); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
855 | else |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
856 | dload = xstrcat(dload, (char *)"0"); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
857 | dload = xstrcat(dload, (char *)",\"svalue\":\""); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
858 | dload = xstrcat(dload, sval); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
859 | dload = xstrcat(dload, (char *)"\"}"); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
860 | publisher(mosq, (char *)"domoticz/in", dload, false); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
861 | free(dload); |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
862 | dload = NULL; |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
863 | } |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
864 | |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
865 | |
f5a00ad53329
Changed state messages to domoticz
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
866 | |
506 | 867 | char *unit_data(units_list *unit, bool birth) |
868 | { | |
869 | char *payload = NULL; | |
870 | char buf[128]; | |
871 | bool comma = false; | |
872 | prof_step *pstep; | |
873 | ||
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
874 | payload = xstrcpy((char *)"{"); |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
875 | |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
876 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
877 | * Fixed unit values, never change these! |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
878 | */ |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
879 | if (birth) { |
506 | 880 | payload = xstrcat(payload, (char *)"\"uuid\":\""); |
881 | payload = xstrcat(payload, unit->uuid); | |
882 | payload = xstrcat(payload, (char *)"\",\"alias\":\""); | |
883 | payload = xstrcat(payload, unit->alias); | |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
884 | payload = xstrcat(payload, (char *)"\","); |
506 | 885 | } |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
886 | |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
887 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
888 | * Product (beer) loaded information. |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
889 | */ |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
890 | if ((unit->product_name && strlen(unit->product_name)) || |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
891 | (unit->product_code && strlen(unit->product_code)) || |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
892 | (unit->product_uuid && strlen(unit->product_uuid))) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
893 | comma = false; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
894 | payload = xstrcat(payload, (char *)"\"product\":{"); |
564
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
895 | if (unit->product_uuid && strlen(unit->product_uuid) && strcmp((char *)"(null)", unit->product_uuid)) { |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
896 | payload = xstrcat(payload, (char *)"\"uuid\":\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
897 | payload = xstrcat(payload, unit->product_uuid); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
898 | payload = xstrcat(payload, (char *)"\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
899 | comma = true; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
900 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
901 | if (unit->product_code && strlen(unit->product_code)) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
902 | if (comma) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
903 | payload = xstrcat(payload, (char *)","); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
904 | payload = xstrcat(payload, (char *)"\"code\":\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
905 | payload = xstrcat(payload, unit->product_code); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
906 | payload = xstrcat(payload, (char *)"\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
907 | comma = true; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
908 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
909 | if (unit->product_name && strlen(unit->product_name)) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
910 | if (comma) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
911 | payload = xstrcat(payload, (char *)","); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
912 | payload = xstrcat(payload, (char *)"\"name\":\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
913 | payload = xstrcat(payload, unit->product_name); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
914 | payload = xstrcat(payload, (char *)"\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
915 | } |
579
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
916 | sprintf(buf, "%.1f", unit->yeast_lo); |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
917 | payload = xstrcat(payload, (char *)",\"yeast_lo\":"); |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
918 | payload = xstrcat(payload, buf); |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
919 | sprintf(buf, "%.1f", unit->yeast_hi); |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
920 | payload = xstrcat(payload, (char *)",\"yeast_hi\":"); |
7032693272f1
Concept for yeast limits settings.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
921 | payload = xstrcat(payload, buf); |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
922 | payload = xstrcat(payload, (char *)"}"); |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
923 | } |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
924 | |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
925 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
926 | * Air temperature sensor |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
927 | */ |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
928 | if (unit->air_address) { |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
929 | payload = xstrcat(payload, (char *)",\"air\":{\"address\":\""); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
930 | payload = xstrcat(payload, unit->air_address); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
931 | payload = xstrcat(payload, (char *)"\",\"state\":\""); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
932 | payload = xstrcat(payload, (char *)TEMPSTATE[unit->air_state]); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
933 | payload = xstrcat(payload, (char *)"\",\"temperature\":"); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
934 | sprintf(buf, "%.3f", unit->air_temperature / 1000.0); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
935 | payload = xstrcat(payload, buf); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
936 | payload = xstrcat(payload, (char *)"}"); |
608
a69b5d92fd72
Changed pub_domoticz mqtt publishing.
Michiel Broek <mbroek@mbse.eu>
parents:
606
diff
changeset
|
937 | pub_domoticz_temp(unit->air_idx, unit->air_temperature); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
938 | } else { |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
939 | payload = xstrcat(payload, (char *)",\"air\":null"); |
506 | 940 | } |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
941 | |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
942 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
943 | * Beer temperature sensor |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
944 | */ |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
945 | if (unit->beer_address) { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
946 | payload = xstrcat(payload, (char *)",\"beer\":{\"address\":\""); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
947 | payload = xstrcat(payload, unit->beer_address); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
948 | payload = xstrcat(payload, (char *)"\",\"state\":\""); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
949 | payload = xstrcat(payload, (char *)TEMPSTATE[unit->beer_state]); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
950 | payload = xstrcat(payload, (char *)"\",\"temperature\":"); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
951 | sprintf(buf, "%.3f", unit->beer_temperature / 1000.0); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
952 | payload = xstrcat(payload, buf); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
953 | payload = xstrcat(payload, (char *)"}"); |
608
a69b5d92fd72
Changed pub_domoticz mqtt publishing.
Michiel Broek <mbroek@mbse.eu>
parents:
606
diff
changeset
|
954 | pub_domoticz_temp(unit->beer_idx, unit->beer_temperature); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
955 | } else { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
956 | payload = xstrcat(payload, (char *)",\"beer\":null"); |
506 | 957 | } |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
958 | |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
959 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
960 | * External chiller temperature sensor |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
961 | */ |
518
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
962 | if (unit->chiller_address) { |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
963 | payload = xstrcat(payload, (char *)",\"chiller\":{\"address\":\""); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
964 | payload = xstrcat(payload, unit->chiller_address); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
965 | payload = xstrcat(payload, (char *)"\",\"state\":\""); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
966 | payload = xstrcat(payload, (char *)TEMPSTATE[unit->chiller_state]); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
967 | payload = xstrcat(payload, (char *)"\",\"temperature\":"); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
968 | sprintf(buf, "%.3f", unit->chiller_temperature / 1000.0); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
969 | payload = xstrcat(payload, buf); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
970 | payload = xstrcat(payload, (char *)"}"); |
608
a69b5d92fd72
Changed pub_domoticz mqtt publishing.
Michiel Broek <mbroek@mbse.eu>
parents:
606
diff
changeset
|
971 | pub_domoticz_temp(unit->chiller_idx, unit->chiller_temperature); |
518
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
972 | } else { |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
973 | payload = xstrcat(payload, (char *)",\"chiller\":null"); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
974 | } |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
515
diff
changeset
|
975 | |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
976 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
977 | * Heater control, power 0..100% and usage count. |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
978 | */ |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
979 | if (unit->heater_address) { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
980 | payload = xstrcat(payload, (char *)",\"heater\":{\"address\":\""); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
981 | payload = xstrcat(payload, unit->heater_address); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
982 | payload = xstrcat(payload, (char *)"\",\"state\":"); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
983 | sprintf(buf, "%d", unit->heater_state); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
984 | payload = xstrcat(payload, buf); |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
985 | payload = xstrcat(payload, (char *)",\"usage\":"); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
986 | sprintf(buf, "%d", unit->heater_usage); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
987 | payload = xstrcat(payload, buf); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
988 | payload = xstrcat(payload, (char *)"}"); |
608
a69b5d92fd72
Changed pub_domoticz mqtt publishing.
Michiel Broek <mbroek@mbse.eu>
parents:
606
diff
changeset
|
989 | pub_domoticz_output(unit->heater_idx, unit->heater_state); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
990 | } else { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
991 | payload = xstrcat(payload, (char *)",\"heater\":null"); |
506 | 992 | } |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
993 | |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
994 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
995 | * Cooler control, power 0..100% and usage counter. |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
996 | */ |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
997 | if (unit->cooler_address) { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
998 | payload = xstrcat(payload, (char *)",\"cooler\":{\"address\":\""); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
999 | payload = xstrcat(payload, unit->cooler_address); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1000 | payload = xstrcat(payload, (char *)"\",\"state\":"); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1001 | sprintf(buf, "%d", unit->cooler_state); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1002 | payload = xstrcat(payload, buf); |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1003 | payload = xstrcat(payload, (char *)",\"usage\":"); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1004 | sprintf(buf, "%d", unit->cooler_usage); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1005 | payload = xstrcat(payload, buf); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1006 | payload = xstrcat(payload, (char *)"}"); |
608
a69b5d92fd72
Changed pub_domoticz mqtt publishing.
Michiel Broek <mbroek@mbse.eu>
parents:
606
diff
changeset
|
1007 | pub_domoticz_output(unit->cooler_idx, unit->cooler_state); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1008 | } else { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1009 | payload = xstrcat(payload, (char *)",\"cooler\":null"); |
506 | 1010 | } |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1011 | |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1012 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1013 | * Fan control, 0..100% and usage counter. |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1014 | */ |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1015 | if (unit->fan_address) { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1016 | payload = xstrcat(payload, (char *)",\"fan\":{\"address\":\""); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1017 | payload = xstrcat(payload, unit->fan_address); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1018 | payload = xstrcat(payload, (char *)"\",\"state\":"); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1019 | sprintf(buf, "%d", unit->fan_state); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1020 | payload = xstrcat(payload, buf); |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1021 | payload = xstrcat(payload, (char *)",\"usage\":"); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1022 | sprintf(buf, "%d", unit->fan_usage); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1023 | payload = xstrcat(payload, buf); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1024 | payload = xstrcat(payload, (char *)"}"); |
608
a69b5d92fd72
Changed pub_domoticz mqtt publishing.
Michiel Broek <mbroek@mbse.eu>
parents:
606
diff
changeset
|
1025 | pub_domoticz_output(unit->fan_idx, unit->fan_state); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1026 | } else { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1027 | payload = xstrcat(payload, (char *)",\"fan\":null"); |
506 | 1028 | } |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1029 | |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1030 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1031 | * Interior lights control, 0..100% and usage counter. |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1032 | */ |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1033 | if (unit->light_address) { |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1034 | payload = xstrcat(payload, (char *)",\"light\":{\"address\":\""); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1035 | payload = xstrcat(payload, unit->light_address); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1036 | payload = xstrcat(payload, (char *)"\",\"state\":"); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1037 | sprintf(buf, "%d", unit->light_state); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1038 | payload = xstrcat(payload, buf); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1039 | payload = xstrcat(payload, (char *)",\"usage\":"); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1040 | sprintf(buf, "%d", unit->light_usage); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1041 | payload = xstrcat(payload, buf); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1042 | payload = xstrcat(payload, (char *)"}"); |
608
a69b5d92fd72
Changed pub_domoticz mqtt publishing.
Michiel Broek <mbroek@mbse.eu>
parents:
606
diff
changeset
|
1043 | pub_domoticz_output(unit->light_idx, unit->light_state); |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1044 | } else { |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1045 | payload = xstrcat(payload, (char *)",\"light\":null"); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1046 | } |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1047 | |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1048 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1049 | * Door sensor. |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1050 | */ |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1051 | if (unit->door_address) { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1052 | payload = xstrcat(payload, (char *)",\"door\":{\"address\":\""); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1053 | payload = xstrcat(payload, unit->door_address); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1054 | payload = xstrcat(payload, (char *)"\",\"state\":"); |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1055 | sprintf(buf, "%d", (unit->door_state) ? 0:1); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1056 | payload = xstrcat(payload, buf); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1057 | payload = xstrcat(payload, (char *)"}"); |
608
a69b5d92fd72
Changed pub_domoticz mqtt publishing.
Michiel Broek <mbroek@mbse.eu>
parents:
606
diff
changeset
|
1058 | pub_domoticz_output(unit->door_idx, unit->door_state); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1059 | } else { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1060 | payload = xstrcat(payload, (char *)",\"door\":null"); |
506 | 1061 | } |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1062 | |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1063 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1064 | * PSU status |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1065 | */ |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1066 | if (unit->psu_address) { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1067 | payload = xstrcat(payload, (char *)",\"psu\":{\"address\":\""); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1068 | payload = xstrcat(payload, unit->psu_address); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1069 | payload = xstrcat(payload, (char *)"\",\"state\":"); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1070 | sprintf(buf, "%d", unit->psu_state); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1071 | payload = xstrcat(payload, buf); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1072 | payload = xstrcat(payload, (char *)"}"); |
608
a69b5d92fd72
Changed pub_domoticz mqtt publishing.
Michiel Broek <mbroek@mbse.eu>
parents:
606
diff
changeset
|
1073 | pub_domoticz_output(unit->psu_idx, unit->psu_state); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1074 | } else { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1075 | payload = xstrcat(payload, (char *)",\"psu\":null"); |
506 | 1076 | } |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1077 | |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1078 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1079 | * Working mode and setpoints |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1080 | */ |
564
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
1081 | payload = xstrcat(payload, (char *)",\"stage\":\""); |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
1082 | payload = xstrcat(payload, (char *)UNITSTAGE[unit->stage]); |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
1083 | payload = xstrcat(payload, (char *)"\",\"mode\":\""); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1084 | payload = xstrcat(payload, (char *)UNITMODE[unit->mode]); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1085 | payload = xstrcat(payload, (char *)"\",\"setpoint\":{\"low\":"); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1086 | sprintf(buf, "%.1f", unit->PID_heat->SetP); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1087 | payload = xstrcat(payload, buf); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1088 | payload = xstrcat(payload, (char *)",\"high\":"); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1089 | sprintf(buf, "%.1f", unit->PID_cool->SetP); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1090 | payload = xstrcat(payload, buf); |
546
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1091 | payload = xstrcat(payload, (char *)"},\"alarm\":"); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1092 | sprintf(buf, "%d", unit->alarm_flag); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1093 | payload = xstrcat(payload, buf); |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1094 | |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1095 | /* |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1096 | * Loaded profile and state |
d2e8626e7118
Changed alarm message and mqtt message order
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1097 | */ |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1098 | if (unit->profile_uuid) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1099 | payload = xstrcat(payload, (char *)",\"profile\":{\"uuid\":\""); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1100 | payload = xstrcat(payload, unit->profile_uuid); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1101 | payload = xstrcat(payload, (char *)"\",\"name\":\""); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1102 | payload = xstrcat(payload, unit->profile_name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1103 | payload = xstrcat(payload, (char *)"\",\"state\":\""); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1104 | payload = xstrcat(payload, (char *)PROFSTATE[unit->prof_state]); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1105 | payload = xstrcat(payload, (char *)"\",\"percent\":"); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1106 | sprintf(buf, "%d", unit->prof_percent); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1107 | payload = xstrcat(payload, buf); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1108 | payload = xstrcat(payload, (char *)",\"inittemp\":{\"low\":"); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1109 | sprintf(buf, "%.1f", unit->profile_inittemp_lo); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1110 | payload = xstrcat(payload, buf); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1111 | payload = xstrcat(payload, (char *)",\"high\":"); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1112 | sprintf(buf, "%.1f", unit->profile_inittemp_hi); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1113 | payload = xstrcat(payload, buf); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1114 | payload = xstrcat(payload, (char *)"},\"fridgemode\":"); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1115 | sprintf(buf, "%d", unit->profile_fridge_mode); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1116 | payload = xstrcat(payload, buf); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1117 | comma = false; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1118 | if (unit->profile_steps) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1119 | payload = xstrcat(payload, (char *)",\"steps\":["); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1120 | for (pstep = unit->profile_steps; pstep; pstep = pstep->next) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1121 | if (comma) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1122 | payload = xstrcat(payload, (char *)","); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1123 | payload = xstrcat(payload, (char *)"{\"resttime\":"); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1124 | sprintf(buf, "%d", pstep->resttime); |
548
2924fe4911d9
Versie 0.8.1. Geen DDATA als fermenter uit staat. Profile JSON formaat is nu werkend.
Michiel Broek <mbroek@mbse.eu>
parents:
547
diff
changeset
|
1125 | payload = xstrcat(payload, buf); |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1126 | payload = xstrcat(payload, (char *)",\"steptime\":"); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1127 | sprintf(buf, "%d", pstep->steptime); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1128 | payload = xstrcat(payload, buf); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1129 | payload = xstrcat(payload, (char *)",\"target\":{\"low\":"); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1130 | sprintf(buf, "%.1f", pstep->target_lo); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1131 | payload = xstrcat(payload, buf); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1132 | payload = xstrcat(payload, (char *)",\"high\":"); |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1133 | sprintf(buf, "%.1f", pstep->target_hi); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1134 | payload = xstrcat(payload, buf); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1135 | payload = xstrcat(payload, (char *)"},\"fridgemode\":"); |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1136 | sprintf(buf, "%d", pstep->fridge_mode); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1137 | payload = xstrcat(payload, buf); |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1138 | if (pstep->name) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1139 | payload = xstrcat(payload, (char *)",\"name\":\""); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1140 | payload = xstrcat(payload, pstep->name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1141 | payload = xstrcat(payload, (char *)"\""); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1142 | } |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1143 | payload = xstrcat(payload, (char *)"}"); |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1144 | comma = true; |
506 | 1145 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1146 | payload = xstrcat(payload, (char *)"]"); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1147 | } else { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1148 | payload = xstrcat(payload, (char *)",\"steps\":null"); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1149 | } |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1150 | payload = xstrcat(payload, (char *)"}"); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1151 | } else { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1152 | payload = xstrcat(payload, (char *)",\"profile\":null"); |
506 | 1153 | } |
1154 | payload = xstrcat(payload, (char *)"}"); | |
1155 | ||
1156 | return payload; | |
1157 | } | |
1158 | ||
1159 | ||
1160 | ||
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1161 | /** |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1162 | * @brief Publish DBIRTH for all active units. If there are no active units, don't |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1163 | * publish anything. This function should be called at program start. |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1164 | */ |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1165 | void publishDBirthAll(void) |
506 | 1166 | { |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1167 | char *topic = NULL, *payload = NULL, *payloadu = NULL; |
506 | 1168 | units_list *unit; |
1169 | int comma = FALSE; | |
1170 | ||
1171 | payload = payload_header(); | |
1172 | payload = xstrcat(payload, (char *)"{\"units\":["); | |
1173 | for (unit = Config.units; unit; unit = unit->next) { | |
606
798dd0c4fd00
Version 0.9.9 Don't flag fermenter death if the unit is turned off. Fix a wrong log message. Send unit data even if the unit is turned off.
Michiel Broek <mbroek@mbse.eu>
parents:
602
diff
changeset
|
1174 | // if (unit->mode != UNITMODE_OFF) { |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1175 | if (comma) |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1176 | payload = xstrcat(payload, (char *)","); |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1177 | payloadu = unit_data(unit, true); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1178 | payload = xstrcat(payload, payloadu); |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1179 | comma = TRUE; |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1180 | free(payloadu); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1181 | payloadu = NULL; |
606
798dd0c4fd00
Version 0.9.9 Don't flag fermenter death if the unit is turned off. Fix a wrong log message. Send unit data even if the unit is turned off.
Michiel Broek <mbroek@mbse.eu>
parents:
602
diff
changeset
|
1182 | // } |
506 | 1183 | } |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1184 | if (comma) { // Only publish if there is at least one unit active. |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1185 | payload = xstrcat(payload, (char *)"]}}"); |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1186 | topic = topic_base((char *)"DBIRTH"); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1187 | publisher(mosq, topic, payload, true); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1188 | free(topic); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1189 | topic = NULL; |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1190 | } |
506 | 1191 | free(payload); |
1192 | payload = NULL; | |
1193 | } | |
1194 | ||
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1195 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1196 | |
506 | 1197 | void publishDData(units_list *unit) |
1198 | { | |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1199 | char *payload = NULL, *payloadu = NULL, *topic = NULL; |
506 | 1200 | |
1201 | if (mqtt_use) { | |
1202 | payload = payload_header(); | |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1203 | payloadu = unit_data(unit, false); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1204 | payload = xstrcat(payload, payloadu); |
506 | 1205 | payload = xstrcat(payload, (char *)"}"); |
1206 | topic = xstrcat(topic_base((char *)"DDATA"), (char *)"/"); | |
1207 | topic = xstrcat(topic, unit->alias); | |
1208 | publisher(mosq, topic, payload, false); | |
1209 | free(payload); | |
1210 | payload = NULL; | |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1211 | free(payloadu); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1212 | payloadu = NULL; |
506 | 1213 | free(topic); |
1214 | topic = NULL; | |
1215 | } | |
1216 | } | |
1217 | ||
1218 | ||
1219 | ||
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1220 | void publishDBirth(units_list *unit) |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1221 | { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1222 | char *payload = NULL, *topic = NULL; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1223 | |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1224 | if (mqtt_use) { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1225 | payload = payload_header(); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1226 | payload = xstrcat(payload, unit_data(unit, true)); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1227 | payload = xstrcat(payload, (char *)"}"); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1228 | topic = xstrcat(topic_base((char *)"DBIRTH"), (char *)"/"); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1229 | topic = xstrcat(topic, unit->alias); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1230 | publisher(mosq, topic, payload, true); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1231 | free(payload); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1232 | payload = NULL; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1233 | free(topic); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1234 | topic = NULL; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1235 | } |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1236 | } |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1237 | |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1238 | |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1239 | |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1240 | void publishDDeath(units_list *unit) |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1241 | { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1242 | char *topic = NULL; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1243 | |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1244 | if (mqtt_use) { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1245 | // First delete presistent DBIRTH topic |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1246 | topic = xstrcat(topic_base((char *)"DBIRTH"), (char *)"/"); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1247 | topic = xstrcat(topic, unit->alias); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1248 | publisher(mosq, topic, NULL, true); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1249 | free(topic); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1250 | topic = NULL; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1251 | topic = xstrcat(topic_base((char *)"DDEATH"), (char *)"/"); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1252 | topic = xstrcat(topic, unit->alias); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1253 | publisher(mosq, topic, NULL, true); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1254 | free(topic); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1255 | topic = NULL; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1256 | } |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1257 | } |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1258 | |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1259 | |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1260 | |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1261 | void publishDLog(units_list *unit) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1262 | { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1263 | char buf[32], *payload = NULL, *topic = NULL; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1264 | bool comma = false; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1265 | |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1266 | if (mqtt_use) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1267 | payload = payload_header(); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1268 | payload = xstrcat(payload, (char *)"{"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1269 | |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1270 | if ((unit->product_name && strlen(unit->product_name)) || |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1271 | (unit->product_code && strlen(unit->product_code)) || |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1272 | (unit->product_uuid && strlen(unit->product_uuid))) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1273 | comma = false; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1274 | payload = xstrcat(payload, (char *)"\"product\":{"); |
564
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
1275 | if (unit->product_uuid && strlen(unit->product_uuid) && strcmp((char *)"(null)", unit->product_uuid)) { |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1276 | payload = xstrcat(payload, (char *)"\"uuid\":\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1277 | payload = xstrcat(payload, unit->product_uuid); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1278 | payload = xstrcat(payload, (char *)"\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1279 | comma = true; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1280 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1281 | if (unit->product_code && strlen(unit->product_code)) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1282 | if (comma) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1283 | payload = xstrcat(payload, (char *)","); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1284 | payload = xstrcat(payload, (char *)"\"code\":\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1285 | payload = xstrcat(payload, unit->product_code); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1286 | payload = xstrcat(payload, (char *)"\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1287 | comma = true; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1288 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1289 | if (unit->product_name && strlen(unit->product_name)) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1290 | if (comma) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1291 | payload = xstrcat(payload, (char *)","); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1292 | payload = xstrcat(payload, (char *)"\"name\":\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1293 | payload = xstrcat(payload, unit->product_name); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1294 | payload = xstrcat(payload, (char *)"\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1295 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1296 | payload = xstrcat(payload, (char *)"}"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1297 | comma = true; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1298 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1299 | |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1300 | if (comma) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1301 | payload = xstrcat(payload, (char *)","); |
564
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
1302 | payload = xstrcat(payload, (char *)"\"stage\":\""); |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
1303 | payload = xstrcat(payload, (char *)UNITSTAGE[unit->stage]); |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
1304 | payload = xstrcat(payload, (char *)"\",\"mode\":\""); |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1305 | payload = xstrcat(payload, (char *)UNITMODE[unit->mode]); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1306 | payload = xstrcat(payload, (char *)"\",\"temperature\":{"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1307 | comma = false; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1308 | if (unit->air_address) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1309 | payload = xstrcat(payload, (char *)"\"air\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1310 | sprintf(buf, "%.3f", unit->air_temperature / 1000.0); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1311 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1312 | comma = true; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1313 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1314 | if (unit->beer_address) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1315 | if (comma) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1316 | payload = xstrcat(payload, (char *)","); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1317 | payload = xstrcat(payload, (char *)"\"beer\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1318 | sprintf(buf, "%.3f", unit->beer_temperature / 1000.0); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1319 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1320 | comma = true; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1321 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1322 | if (unit->chiller_address) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1323 | if (comma) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1324 | payload = xstrcat(payload, (char *)","); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1325 | payload = xstrcat(payload, (char *)"\"chiller\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1326 | sprintf(buf, "%.3f", unit->chiller_temperature / 1000.0); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1327 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1328 | comma = true; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1329 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1330 | if (Config.temp_address) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1331 | if (comma) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1332 | payload = xstrcat(payload, (char *)","); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1333 | payload = xstrcat(payload, (char *)"\"room\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1334 | sprintf(buf, "%.1f", Config.temp_value / 1000.0); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1335 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1336 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1337 | payload = xstrcat(payload, (char *)"},\"setpoint\":{\"low\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1338 | sprintf(buf, "%.1f", unit->PID_heat->SetP); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1339 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1340 | payload = xstrcat(payload, (char *)",\"high\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1341 | sprintf(buf, "%.1f", unit->PID_cool->SetP); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1342 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1343 | payload = xstrcat(payload, (char *)"}"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1344 | if (unit->heater_address) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1345 | payload = xstrcat(payload, (char *)",\"heater\":{\"power\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1346 | sprintf(buf, "%d", unit->heater_state); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1347 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1348 | payload = xstrcat(payload, (char *)",\"usage\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1349 | sprintf(buf, "%d", unit->heater_usage); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1350 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1351 | payload = xstrcat(payload, (char *)"}"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1352 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1353 | if (unit->cooler_address) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1354 | payload = xstrcat(payload, (char *)",\"cooler\":{\"power\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1355 | sprintf(buf, "%d", unit->cooler_state); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1356 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1357 | payload = xstrcat(payload, (char *)",\"usage\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1358 | sprintf(buf, "%d", unit->cooler_usage); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1359 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1360 | payload = xstrcat(payload, (char *)"}"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1361 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1362 | if (unit->fan_address) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1363 | payload = xstrcat(payload, (char *)",\"fan\":{\"power\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1364 | sprintf(buf, "%d", unit->fan_state); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1365 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1366 | payload = xstrcat(payload, (char *)",\"usage\":"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1367 | sprintf(buf, "%d", unit->fan_usage); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1368 | payload = xstrcat(payload, buf); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1369 | payload = xstrcat(payload, (char *)"}"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1370 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1371 | // sg |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1372 | if (unit->event_msg) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1373 | payload = xstrcat(payload, (char *)",\"event\":\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1374 | payload = xstrcat(payload, unit->event_msg); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1375 | payload = xstrcat(payload, (char *)"\""); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1376 | } |
555
c6f04bfcec2c
Add fermenter uuid to the DLOG message
Michiel Broek <mbroek@mbse.eu>
parents:
554
diff
changeset
|
1377 | payload = xstrcat(payload, (char *)",\"fermenter_uuid\":\""); |
c6f04bfcec2c
Add fermenter uuid to the DLOG message
Michiel Broek <mbroek@mbse.eu>
parents:
554
diff
changeset
|
1378 | payload = xstrcat(payload, unit->uuid); |
c6f04bfcec2c
Add fermenter uuid to the DLOG message
Michiel Broek <mbroek@mbse.eu>
parents:
554
diff
changeset
|
1379 | payload = xstrcat(payload, (char *)"\"}}"); |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1380 | |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1381 | topic = xstrcat(topic_base((char *)"DLOG"), (char *)"/"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1382 | topic = xstrcat(topic, unit->alias); |
577
7a29f835e20a
DLOG messages are no longer retained.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
1383 | publisher(mosq, topic, payload, false); |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1384 | free(payload); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1385 | payload = NULL; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1386 | free(topic); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1387 | topic = NULL; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1388 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1389 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1390 | |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1391 | |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1392 | |
506 | 1393 | void publishNData(bool birth, int flag) |
1394 | { | |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1395 | char *topic = NULL, *payload = NULL, sidx[10], buf[64]; |
506 | 1396 | struct utsname ubuf; |
1397 | bool comma = false; | |
598
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1398 | int model, rev, mem, maker, warranty; |
506 | 1399 | |
1400 | payload = payload_header(); | |
1401 | payload = xstrcat(payload, (char *)"{"); | |
1402 | ||
540
5a26429abbf8
Versie 0.6.7. Globale uuid toegevoegd voor de NBIRTH payload.
Michiel Broek <mbroek@mbse.eu>
parents:
535
diff
changeset
|
1403 | if (birth) { |
5a26429abbf8
Versie 0.6.7. Globale uuid toegevoegd voor de NBIRTH payload.
Michiel Broek <mbroek@mbse.eu>
parents:
535
diff
changeset
|
1404 | payload = xstrcat(payload, (char *)"\"uuid\":\""); |
5a26429abbf8
Versie 0.6.7. Globale uuid toegevoegd voor de NBIRTH payload.
Michiel Broek <mbroek@mbse.eu>
parents:
535
diff
changeset
|
1405 | payload = xstrcat(payload, Config.uuid); |
544
e2889b17f48c
Versie 0.6.8. Code cleanup. Publish NDATA MQTT bericht iedere 5 minuten of als er een THB wijziging is.
Michiel Broek <mbroek@mbse.eu>
parents:
543
diff
changeset
|
1406 | payload = xstrcat(payload, (char *)"\","); |
508
9e67c5f9c994
Add Raspberry support in MQTT init message
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
1407 | #ifdef HAVE_WIRINGPI_H |
563
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1408 | /* |
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1409 | * Get the info from the WiringPi libary |
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1410 | */ |
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1411 | piBoardId (&model, &rev, &mem, &maker, &warranty); |
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1412 | payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\"Raspberry Pi "); |
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1413 | payload = xstrcat(payload, (char *)piMakerNames[maker]); |
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1414 | payload = xstrcat(payload, (char *)"\",\"hardwaremodel\":\""); |
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1415 | payload = xstrcat(payload, (char *)piModelNames[model]); |
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1416 | payload = xstrcat(payload, (char *)" rev "); |
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1417 | payload = xstrcat(payload, (char *)piRevisionNames[rev]); |
ca2fafcf3294
On Raspberry with WiringPi better hardware info is sent with NBIRTH
Michiel Broek <mbroek@mbse.eu>
parents:
561
diff
changeset
|
1418 | payload = xstrcat(payload, (char *)"\""); |
508
9e67c5f9c994
Add Raspberry support in MQTT init message
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
1419 | #else |
598
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1420 | /* |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1421 | * Get the info from the internal function |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1422 | */ |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1423 | piBoardId (&model, &rev, &mem, &maker, &warranty); |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1424 | if (model != -1) { |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1425 | payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\"Raspberry Pi "); |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1426 | payload = xstrcat(payload, (char *)piMakerNames[maker]); |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1427 | payload = xstrcat(payload, (char *)"\",\"hardwaremodel\":\""); |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1428 | payload = xstrcat(payload, (char *)piModelNames[model]); |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1429 | payload = xstrcat(payload, (char *)" rev "); |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1430 | payload = xstrcat(payload, (char *)piRevisionNames[rev]); |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1431 | payload = xstrcat(payload, (char *)"\""); |
363dc36d2450
Added wiringPi hardware detection code.
Michiel Broek <mbroek@mbse.eu>
parents:
591
diff
changeset
|
1432 | } else if (uname(&ubuf) == 0) { |
544
e2889b17f48c
Versie 0.6.8. Code cleanup. Publish NDATA MQTT bericht iedere 5 minuten of als er een THB wijziging is.
Michiel Broek <mbroek@mbse.eu>
parents:
543
diff
changeset
|
1433 | payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\""); |
e2889b17f48c
Versie 0.6.8. Code cleanup. Publish NDATA MQTT bericht iedere 5 minuten of als er een THB wijziging is.
Michiel Broek <mbroek@mbse.eu>
parents:
543
diff
changeset
|
1434 | payload = xstrcat(payload, ubuf.machine); |
e2889b17f48c
Versie 0.6.8. Code cleanup. Publish NDATA MQTT bericht iedere 5 minuten of als er een THB wijziging is.
Michiel Broek <mbroek@mbse.eu>
parents:
543
diff
changeset
|
1435 | payload = xstrcat(payload, (char *)"\",\"hardwaremodel\":\"Unknown\""); |
e2889b17f48c
Versie 0.6.8. Code cleanup. Publish NDATA MQTT bericht iedere 5 minuten of als er een THB wijziging is.
Michiel Broek <mbroek@mbse.eu>
parents:
543
diff
changeset
|
1436 | } else { |
e2889b17f48c
Versie 0.6.8. Code cleanup. Publish NDATA MQTT bericht iedere 5 minuten of als er een THB wijziging is.
Michiel Broek <mbroek@mbse.eu>
parents:
543
diff
changeset
|
1437 | payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\"Unknown\",\"hardwaremodel\":\"Unknown\""); |
e2889b17f48c
Versie 0.6.8. Code cleanup. Publish NDATA MQTT bericht iedere 5 minuten of als er een THB wijziging is.
Michiel Broek <mbroek@mbse.eu>
parents:
543
diff
changeset
|
1438 | } |
508
9e67c5f9c994
Add Raspberry support in MQTT init message
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
1439 | #endif |
9e67c5f9c994
Add Raspberry support in MQTT init message
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
1440 | if (uname(&ubuf) == 0) { |
506 | 1441 | payload = xstrcat(payload, (char *)",\"os\":\""); |
1442 | payload = xstrcat(payload, ubuf.sysname); | |
1443 | payload = xstrcat(payload, (char *)"\",\"os_version\":\""); | |
1444 | payload = xstrcat(payload, ubuf.release); | |
1445 | payload = xstrcat(payload, (char *)"\""); | |
1446 | } else { | |
1447 | payload = xstrcat(payload, (char *)",\"os\":\"Unknown\",\"os_version\":\"Unknown\""); | |
1448 | } | |
1449 | ||
1450 | payload = xstrcat(payload, (char *)",\"FW\":\""); | |
1451 | payload = xstrcat(payload, (char *)VERSION); | |
1452 | payload = xstrcat(payload, (char *)"\"}"); | |
1453 | comma = true; | |
1454 | } | |
1455 | ||
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1456 | if (Config.temp_address || Config.hum_address) { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1457 | if (comma) |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1458 | payload = xstrcat(payload, (char *)","); |
541 | 1459 | payload = xstrcat(payload, (char *)"\"THB\":{"); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1460 | if (Config.temp_address) { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1461 | payload = xstrcat(payload, (char *)"\"temperature\":"); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1462 | sprintf(buf, "%.1f", Config.temp_value / 1000.0); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1463 | payload = xstrcat(payload, buf); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1464 | } |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1465 | if (Config.temp_address && Config.hum_address) |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1466 | payload = xstrcat(payload, (char *)","); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1467 | if (Config.hum_address) { |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1468 | payload = xstrcat(payload, (char *)"\"humidity\":"); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1469 | sprintf(buf, "%.1f", Config.hum_value / 1000.0); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1470 | payload = xstrcat(payload, buf); |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1471 | } |
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
509
diff
changeset
|
1472 | payload = xstrcat(payload, (char *)"}"); |
506 | 1473 | } |
549
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1474 | |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1475 | /* |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1476 | * Find our network information |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1477 | */ |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1478 | FILE *f; |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1479 | char line[100], *ifname, *c, ip[NI_MAXHOST]; |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1480 | struct ifaddrs *ifaddr, *ifa; |
628
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1481 | int family, s, sock, rssi; |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1482 | struct iwreq wrq; |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1483 | struct iw_statistics iwstats; |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1484 | char essid[IW_ESSID_MAX_SIZE+1]; |
549
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1485 | |
628
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1486 | if ((f = fopen("/proc/net/route" , "r"))) { |
549
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1487 | while (fgets(line, 100, f)) { |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1488 | ifname = strtok(line , " \t"); |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1489 | c = strtok(NULL , " \t"); |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1490 | |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1491 | // Take the entry with destination '00000000' |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1492 | if (ifname != NULL && c != NULL && (strcmp(c , "00000000") == 0)) { |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1493 | |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1494 | if (getifaddrs(&ifaddr) == -1) { |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1495 | syslog(LOG_NOTICE, "error getifaddrs error %d", errno); |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1496 | goto neterr; |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1497 | } |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1498 | |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1499 | //Walk through linked list, maintaining head pointer so we can free list later |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1500 | for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1501 | if (ifa->ifa_addr == NULL) { |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1502 | continue; |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1503 | } |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1504 | |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1505 | family = ifa->ifa_addr->sa_family; |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1506 | |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1507 | if ((strcmp( ifa->ifa_name, ifname) == 0) && (family == AF_INET)) { |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1508 | s = getnameinfo(ifa->ifa_addr, (family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), ip, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1509 | if (s != 0) { |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1510 | syslog(LOG_NOTICE, "getnameinfo() error=%d for %s", errno, ifname); |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1511 | goto neterr; |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1512 | } |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1513 | payload = xstrcat(payload, (char *)",\"net\":{\"address\":\""); |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1514 | payload = xstrcat(payload, ip); |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1515 | payload = xstrcat(payload, (char *)"\",\"ifname\":\""); |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1516 | payload = xstrcat(payload, ifname); |
628
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1517 | payload = xstrcat(payload, (char *)"\""); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1518 | |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1519 | /* |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1520 | * Now detect WiFi on this interface. |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1521 | */ |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1522 | strncpy(wrq.ifr_name, ifa->ifa_name, IFNAMSIZ-1); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1523 | |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1524 | if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1525 | syslog(LOG_NOTICE, "Error %d opening INET socket", errno); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1526 | } else { |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1527 | wrq.u.essid.pointer = essid; |
629 | 1528 | if (ioctl(sock, SIOCGIWESSID, &wrq) != -1) { |
628
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1529 | payload = xstrcat(payload, (char *)",\"ssid\":\""); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1530 | payload = xstrcat(payload, wrq.u.essid.pointer); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1531 | payload = xstrcat(payload, (char *)"\""); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1532 | } |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1533 | |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1534 | memset(&iwstats, 0, sizeof(iwstats)); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1535 | wrq.u.data.pointer = &iwstats; |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1536 | wrq.u.data.length = sizeof(struct iw_statistics); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1537 | wrq.u.data.flags = 1; |
629 | 1538 | if (ioctl(sock, SIOCGIWSTATS, &wrq) != -1) { |
628
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1539 | if ((iwstats.qual.updated & (IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID)) == 0) { |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1540 | /* iwstats.qual.level is __u8 */ |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1541 | if (iwstats.qual.updated & IW_QUAL_DBM) { |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1542 | rssi = (iwstats.qual.level > 63) ? iwstats.qual.level - 0x100 : iwstats.qual.level; |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1543 | } else { |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1544 | /* level seems 0..100% */ |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1545 | if (iwstats.qual.level > 90) |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1546 | rssi = -10; |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1547 | else |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1548 | rssi = (iwstats.qual.level - 100); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1549 | } |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1550 | payload = xstrcat(payload, (char *)",\"rssi\":"); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1551 | sprintf(buf, "%d", rssi); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1552 | payload = xstrcat(payload, buf); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1553 | } else { |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1554 | syslog(LOG_NOTICE, "Signal level is invalid"); |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1555 | } |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1556 | } |
632
9bd017df749b
Version 0.9.13. Close socket after use, fixes too much files open.
Michiel Broek <mbroek@mbse.eu>
parents:
631
diff
changeset
|
1557 | close(sock); |
628
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1558 | } |
32082a19912c
Design wifi parameter reporting
Michiel Broek <mbroek@mbse.eu>
parents:
616
diff
changeset
|
1559 | payload = xstrcat(payload, (char *)"}"); |
549
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1560 | } |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1561 | } |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1562 | |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1563 | freeifaddrs(ifaddr); |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1564 | } |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1565 | } |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1566 | fclose(f); |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1567 | } |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1568 | neterr: |
ee1bcad035f0
Versie 0.8.2. Node NBIRTH payload heeft nu netwerk informatie.
Michiel Broek <mbroek@mbse.eu>
parents:
548
diff
changeset
|
1569 | |
506 | 1570 | payload = xstrcat(payload, (char *)"}}"); |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1571 | if (birth) { |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1572 | topic = topic_base((char *)"NBIRTH"); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1573 | publisher(mosq, topic, payload, true); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1574 | } else { |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1575 | topic = topic_base((char *)"NDATA"); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1576 | publisher(mosq, topic, payload, false); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1577 | } |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1578 | free(topic); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1579 | topic = NULL; |
506 | 1580 | free(payload); |
1581 | payload = NULL; | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1582 | |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1583 | if ((Config.temp_address || Config.hum_address) && Config.temp_hum_idx) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1584 | sprintf(sidx, "%d", Config.temp_hum_idx); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1585 | sprintf(buf, "%.1f;%.1f;0", Config.temp_value / 1000.0, Config.hum_value / 1000.0); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1586 | |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1587 | payload = xstrcpy((char *)"{\"command\":\"udevice\",\"idx\":"); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1588 | payload = xstrcat(payload, sidx); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1589 | payload = xstrcat(payload, (char *)",\"nvalue\":0,\"svalue\":\""); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1590 | payload = xstrcat(payload, buf); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1591 | payload = xstrcat(payload, (char *)"\"}"); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1592 | publisher(mosq, (char *)"domoticz/in", payload, false); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1593 | free(payload); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1594 | payload = NULL; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1595 | } |
506 | 1596 | } |
1597 | ||
1598 | ||
1599 | ||
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1600 | void mqtt_connect(void) |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1601 | { |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1602 | char *id = NULL, *topic; |
506 | 1603 | char err[1024]; |
1604 | int rc; | |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1605 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1606 | /* |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1607 | * Initialize mosquitto communication |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1608 | */ |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1609 | gethostname(my_hostname, 255); |
612
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1610 | if (strchr(my_hostname, '.')) { |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1611 | char *p = strchr(my_hostname, '.'); |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1612 | *p = '\0'; |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1613 | } |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1614 | mosquitto_lib_init(); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1615 | id = xstrcpy((char *)"thermferm/"); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1616 | id = xstrcat(id, my_hostname); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1617 | if (strlen(id) > MOSQ_MQTT_ID_MAX_LENGTH) { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1618 | /* |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1619 | * Enforce maximum client id length of 23 characters |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1620 | */ |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1621 | id[MOSQ_MQTT_ID_MAX_LENGTH] = '\0'; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1622 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1623 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1624 | mosq = mosquitto_new(id, TRUE, NULL); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1625 | if (!mosq) { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1626 | switch(errno) { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1627 | case ENOMEM: |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1628 | syslog(LOG_NOTICE, "MQTT: mosquitto_new: Out of memory"); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1629 | break; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1630 | case EINVAL: |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1631 | syslog(LOG_NOTICE, "MQTT: mosquitto_new: Invalid id"); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1632 | break; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1633 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1634 | mosquitto_lib_cleanup(); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1635 | return; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1636 | } |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1637 | free(id); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1638 | id = NULL; |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1639 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1640 | /* |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1641 | * Set our will |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1642 | */ |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1643 | topic = topic_base((char *)"NDEATH"); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1644 | if ((rc = mosquitto_will_set(mosq, topic, 0, NULL, mqtt_qos, false))) { |
506 | 1645 | if (rc > MOSQ_ERR_SUCCESS) |
1646 | syslog(LOG_NOTICE, "MQTT: mosquitto_will_set: %s", mosquitto_strerror(rc)); | |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1647 | mosquitto_lib_cleanup(); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1648 | return; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1649 | } |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1650 | free(topic); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1651 | |
509 | 1652 | if (debug) |
1653 | mosquitto_log_callback_set(mosq, my_log_callback); | |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1654 | mosquitto_max_inflight_messages_set(mosq, max_inflight); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1655 | mosquitto_connect_callback_set(mosq, my_connect_callback); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1656 | mosquitto_disconnect_callback_set(mosq, my_disconnect_callback); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1657 | mosquitto_publish_callback_set(mosq, my_publish_callback); |
506 | 1658 | mosquitto_message_callback_set(mosq, my_message_callback); |
1659 | mosquitto_subscribe_callback_set(mosq, my_subscribe_callback); | |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1660 | |
612
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1661 | if (Config.mqtt_username) { |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1662 | if (Config.mqtt_password) { |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1663 | rc = mosquitto_username_pw_set(mosq, Config.mqtt_username, Config.mqtt_password); |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1664 | } else { |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1665 | rc = mosquitto_username_pw_set(mosq, Config.mqtt_username, NULL); |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1666 | } |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1667 | if (rc == MOSQ_ERR_INVAL) { |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1668 | syslog(LOG_NOTICE, "MQTT: mosquitto_username_pw_set: Invalid id"); |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1669 | } else if (rc == MOSQ_ERR_NOMEM) { |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1670 | syslog(LOG_NOTICE, "MQTT: mosquitto_username_pw_set: Out of memory"); |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1671 | } |
452f79a5ad71
Make sure the hostname doesn't contain the domain name. Added Slackare init and setup scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
610
diff
changeset
|
1672 | if (rc != MOSQ_ERR_SUCCESS) { |
610
5563ee815701
Implemented MQTT user/password auth.
Michiel Broek <mbroek@mbse.eu>
parents:
608
diff
changeset
|
1673 | mosquitto_lib_cleanup(); |
5563ee815701
Implemented MQTT user/password auth.
Michiel Broek <mbroek@mbse.eu>
parents:
608
diff
changeset
|
1674 | return; |
5563ee815701
Implemented MQTT user/password auth.
Michiel Broek <mbroek@mbse.eu>
parents:
608
diff
changeset
|
1675 | } |
5563ee815701
Implemented MQTT user/password auth.
Michiel Broek <mbroek@mbse.eu>
parents:
608
diff
changeset
|
1676 | } |
5563ee815701
Implemented MQTT user/password auth.
Michiel Broek <mbroek@mbse.eu>
parents:
608
diff
changeset
|
1677 | |
500
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
1678 | if ((rc = mosquitto_connect(mosq, Config.mqtt_host, Config.mqtt_port, keepalive))) { |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1679 | if (rc == MOSQ_ERR_ERRNO) { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1680 | strerror_r(errno, err, 1024); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1681 | syslog(LOG_NOTICE, "MQTT: mosquitto_connect: error: %s", err); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1682 | } else { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1683 | syslog(LOG_NOTICE, "MQTT: mosquitto_connect: unable to connect (%d)", rc); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1684 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1685 | mosquitto_lib_cleanup(); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1686 | syslog(LOG_NOTICE, "MQTT: will run without an MQTT broker."); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1687 | } else { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1688 | mqtt_use = TRUE; |
500
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
1689 | syslog(LOG_NOTICE, "MQTT: connected with %s:%d", Config.mqtt_host, Config.mqtt_port); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1690 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1691 | /* |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1692 | * Initialise is complete, report our presence state |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1693 | */ |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1694 | mosquitto_loop_start(mosq); |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
1695 | publishNData(true, 0); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1696 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1697 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1698 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1699 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1700 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1701 | void mqtt_disconnect(void) |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1702 | { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1703 | int rc; |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1704 | char *topic; |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1705 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1706 | if (mqtt_use) { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1707 | /* |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1708 | * Final publish 0 to clients/<hostname>/thermferm/state |
504
862de87f9f89
Added some MQTT publish clear functions. Version 0.5.8
Michiel Broek <mbroek@mbse.eu>
parents:
500
diff
changeset
|
1709 | * After that, remove the retained topic. |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1710 | */ |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1711 | syslog(LOG_NOTICE, "MQTT disconnecting"); |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1712 | topic = topic_base((char *)"DBIRTH"); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1713 | publisher(mosq, topic, NULL, true); // Not always needed, but ... |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1714 | free(topic); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1715 | topic = topic_base((char *)"DDEATH"); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1716 | publisher(mosq, topic, NULL, true); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1717 | free(topic); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1718 | topic = topic_base((char *)"NBIRTH"); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1719 | publisher(mosq, topic, NULL, true); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1720 | free(topic); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1721 | topic = topic_base((char *)"NDEATH"); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1722 | publisher(mosq, topic, NULL, true); |
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1723 | free(topic); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1724 | mqtt_last_mid = mqtt_mid_sent; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1725 | mqtt_status = STATUS_WAITING; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1726 | mqtt_my_shutdown = TRUE; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1727 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1728 | do { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1729 | if (mqtt_status == STATUS_WAITING) { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1730 | if (mqtt_last_mid_sent == mqtt_last_mid && mqtt_disconnect_sent == FALSE) { |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1731 | mosquitto_disconnect(mosq); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1732 | mqtt_disconnect_sent = TRUE; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1733 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1734 | usleep(100000); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1735 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1736 | rc = MOSQ_ERR_SUCCESS; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1737 | } while (rc == MOSQ_ERR_SUCCESS && mqtt_connected); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1738 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1739 | mosquitto_loop_stop(mosq, FALSE); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1740 | mosquitto_destroy(mosq); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1741 | mosquitto_lib_cleanup(); |
506 | 1742 | mqtt_use = FALSE; |
534
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1743 | mqtt_status = STATUS_CONNECTING; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1744 | mqtt_mid_sent = 0; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1745 | mqtt_last_mid = -1; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1746 | mqtt_last_mid_sent = -1; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1747 | mqtt_connected = TRUE; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1748 | mqtt_disconnect_sent = FALSE; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1749 | mqtt_connect_lost = FALSE; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1750 | mqtt_my_shutdown = FALSE; |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1751 | syslog(LOG_NOTICE, "MQTT disconnected"); |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1752 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1753 | } |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1754 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1755 |