thermferm/server.c

Fri, 19 Apr 2024 20:56:55 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 19 Apr 2024 20:56:55 +0200
changeset 689
f94b525f7563
parent 687
f5d05b420732
child 693
3518c07737d8
permissions
-rw-r--r--

Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.

42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
2 * Copyright (C) 2008-2024
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of the mbsePi-apps
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * mbsePi-apps is distributed in the hope that it will be useful, but
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
213
2317b8d644fa Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents: 209
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
106
1bd9a16f5061 Added .h files
Michiel Broek <mbroek@mbse.eu>
parents: 101
diff changeset
23 #include "rdconfig.h"
46
000399c64d3f More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
24 #include "thermferm.h"
652
16d3d4b58b5b Moved all delay functions into a new general file.
Michiel Broek <mbroek@mbse.eu>
parents: 646
diff changeset
25 #include "delay.h"
184
db997a04fde3 Fixed switching problems
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
26 #include "devices.h"
106
1bd9a16f5061 Added .h files
Michiel Broek <mbroek@mbse.eu>
parents: 101
diff changeset
27 #include "server.h"
245
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
28 #include "lcd-buffer.h"
106
1bd9a16f5061 Added .h files
Michiel Broek <mbroek@mbse.eu>
parents: 101
diff changeset
29 #include "xutil.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: 493
diff changeset
30 #include "mqtt.h"
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
58
e8e7b46b705b Fixed compilation without wiringpi
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
32
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
33 extern int debug;
245
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
34 extern int run_pause;
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
35 extern int run_hold;
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
36 extern sys_config Config;
81
547bbe344886 Added list command
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
37 extern const char UNITMODE[5][8];
566
776a605befa5 Added Carbonation stage.
Michiel Broek <mbroek@mbse.eu>
parents: 564
diff changeset
38 extern const char UNITSTAGE[4][12];
101
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 100
diff changeset
39 extern const char TEMPSTATE[3][8];
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
40 extern const char DEVTYPE[8][6];
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
41 extern const char DEVPRESENT[4][6];
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
42 extern const char DEVDIR[7][11];
217
2922d439ff63 Added profile state ABORT
Michiel Broek <mbroek@mbse.eu>
parents: 213
diff changeset
43 extern const char PROFSTATE[5][6];
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
44 extern pthread_mutex_t mutexes[5];
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
45
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
646
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 645
diff changeset
47 int my_server_state = 0; /* Thread running state */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
48 int my_server_shutdown = 0; /* Thread shutdown */
646
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 645
diff changeset
49 int ls; /* listen socket */
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50
646
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 645
diff changeset
51 struct sockaddr_in myaddr_in; /* for local socket address */
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 645
diff changeset
52 struct sockaddr_in peeraddr_in; /* for peer socket address */
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
53
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
54 struct hostent *hp;
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
55
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
56 #define SS_BUFSIZE 4096
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
57 #define SS_TIMEOUT 300
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58
389
584d40bb4b09 Graph lines logging can handle longer logfiles and has a safety limit.
Michiel Broek <mbroek@mbse.eu>
parents: 381
diff changeset
59 #define MAX_INTERVALS 10
584d40bb4b09 Graph lines logging can handle longer logfiles and has a safety limit.
Michiel Broek <mbroek@mbse.eu>
parents: 381
diff changeset
60 const int GRAPH_INTERVAL[MAX_INTERVALS] = { 0, 1, 5, 15, 30, 60, 120, 240, 480, 960 };
584d40bb4b09 Graph lines logging can handle longer logfiles and has a safety limit.
Michiel Broek <mbroek@mbse.eu>
parents: 381
diff changeset
61 const int GRAPH_DATALINES[MAX_INTERVALS] = { 0, 800, 3200, 12000, 24000, 48000, 96000, 192000, 384000, 768000 };
329
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
62 const char MONTH[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
63
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
64
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
65 typedef struct _ls_list {
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
66 struct _ls_list *next; /* Next record pointer */
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
67 char d_name[256]; /* File name */
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
68 mode_t mode; /* File mode */
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
69 off_t size; /* File size */
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
70 time_t mtime; /* File modification time */
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
71 } ls_list;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
72
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
73
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
74
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
75 void tidy_lslist(ls_list **);
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
76 void fill_list(ls_list **, char *, mode_t, off_t, time_t);
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
77 int comp(ls_list **,ls_list **);
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
78 void sort_list(ls_list **);
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
79
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
80
46
000399c64d3f More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
81
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
82 /*
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
83 * Send message to client
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
84 */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
85 int srv_send(int s, const char *format, ...)
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
86 {
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
87 char out[SS_BUFSIZE];
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
88 va_list va_ptr;
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
89
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
90 if (s == -1)
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
91 return -1;
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
93 va_start(va_ptr, format);
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
94 vsnprintf(out, SS_BUFSIZE-1, format, va_ptr);
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
95 va_end(va_ptr);
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
96
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: 553
diff changeset
97 // if (debug) {
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: 553
diff changeset
98 // syslog(LOG_NOTICE, "send: \"%s\"", out);
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: 553
diff changeset
99 // }
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
100
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
101 if (send(s, out, strlen(out), 0) != strlen(out)) {
268
dda91dfa4aa8 All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
102 syslog(LOG_NOTICE, "srv_send failed");
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
103 return -1;
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
104 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 79
diff changeset
105
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
106 if (send(s, (char *)"\r\n", 2, 0) != 2) {
268
dda91dfa4aa8 All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
107 syslog(LOG_NOTICE, "srv_send failed");
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
108 return -1;
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
109 }
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
110
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
111 return 0;
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
112 }
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
113
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
114
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115
88
12259362595b Added SET commands
Michiel Broek <mbroek@mbse.eu>
parents: 87
diff changeset
116 /*
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
117 * Argument is a buffer of size SS_BUFSIZE.
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
118 * Return -1 if error, else the number of received
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
119 * character. \n is line end, ignore \r.
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
120 */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
121 int srv_recv(int s, char *buffer)
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
122 {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
123 int bytesloaded = 0;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
124 ssize_t ret;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
125 unsigned char buf;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
126 socklen_t fromlen;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
127
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
128 memset(buffer, 0, SS_BUFSIZE);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
129
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
130 while(1) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
131 /*
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
132 * read a single byte
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
133 */
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
134 fromlen = sizeof(peeraddr_in);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
135 ret = recvfrom(s, &buf, 1, 0, (struct sockaddr *)&peeraddr_in, &fromlen);
368
ac27038f4c70 Fix for server crash
Michiel Broek <mbroek@mbse.eu>
parents: 364
diff changeset
136 if (ret < 0) {
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
137 syslog(LOG_NOTICE, "recvfrom(): %s", strerror(errno));
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
138 return -1; /* error */
368
ac27038f4c70 Fix for server crash
Michiel Broek <mbroek@mbse.eu>
parents: 364
diff changeset
139 } else if (ret == 0) {
ac27038f4c70 Fix for server crash
Michiel Broek <mbroek@mbse.eu>
parents: 364
diff changeset
140 return -1; /* no data */
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
141 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
142
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
143 if (buf == '\n')
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
144 break;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
145
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
146 if (buf != '\r') {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
147 buffer[bytesloaded] = buf;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
148 bytesloaded++;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
149 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
150 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
151
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: 553
diff changeset
152 // if (debug) {
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: 553
diff changeset
153 // syslog(LOG_NOTICE, "recv: %d `%s'", bytesloaded, buffer);
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: 553
diff changeset
154 // }
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
155 return bytesloaded;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
156 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
157
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
158
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
159
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
160 /*
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
161 * Update the device inuse counter.
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
162 */
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
163 void device_count(int plus, char *uuid)
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
164 {
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
165 devices_list *device;
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
166
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
167 for (device = Config.devices; device; device = device->next) {
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
168 if (strcmp(device->uuid, uuid) == 0) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
169 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
170 if (plus == TRUE) {
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
171 device->inuse++;
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
172 } else {
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
173 if (device->inuse)
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
174 device->inuse--;
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
175 }
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
176 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
177 }
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
178 }
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
179 }
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
180
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
181
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
182
329
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
183 void tidy_lslist(ls_list **lap)
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
184 {
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
185 ls_list *tmp, *old;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
186
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
187 for (tmp = *lap; tmp; tmp = old) {
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
188 old = tmp->next;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
189 free(tmp);
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
190 }
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
191 *lap = NULL;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
192 }
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
193
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
194
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
195
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
196 void fill_list(ls_list **lap, char *name, mode_t mode, off_t size, time_t mtime)
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
197 {
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
198 ls_list **tmp;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
199
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
200 for (tmp = lap; *tmp; tmp = &((*tmp)->next));
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
201
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
202 *tmp = (ls_list *)malloc(sizeof(ls_list));
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
203 (*tmp)->next = NULL;
599
b44eb07cab48 Fix one byte too large buffer copy
Michiel Broek <mbroek@mbse.eu>
parents: 594
diff changeset
204 strncpy((*tmp)->d_name, name, 255);
329
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
205 (*tmp)->mode = mode;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
206 (*tmp)->size = size;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
207 (*tmp)->mtime = mtime;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
208 tmp = &((*tmp)->next);
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
209 }
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
210
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
211
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
212
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
213 void sort_list(ls_list **lap)
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
214 {
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
215 ls_list *ta, **vector;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
216 size_t n = 0, i;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
217
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
218 if (*lap == NULL)
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
219 return;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
220
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
221 for (ta = *lap; ta; ta = ta->next)
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
222 n++;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
223 vector = (ls_list **)malloc(n * sizeof(ls_list *));
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
224 i = 0;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
225
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
226 for (ta = *lap; ta; ta = ta->next) {
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
227 vector[i++] = ta;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
228 }
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
229 qsort(vector, n, sizeof(ls_list *), (int(*)(const void*, const void*))comp);
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
230
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
231 (*lap) = vector[0];
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
232 i = 1;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
233
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
234 for (ta = *lap; ta; ta = ta->next) {
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
235 if (i < n)
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
236 ta->next = vector[i++];
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
237 else
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
238 ta->next = NULL;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
239 }
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
240
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
241 free(vector);
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
242 return;
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
243 }
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
244
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
245
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
246
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
247 int comp(ls_list **lsp1, ls_list **lsp2)
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
248 {
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
249 return strcmp((*lsp1)->d_name, (*lsp2)->d_name);
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
250 }
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
251
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
252
517e1719006a Added ARCHIVE commands
Michiel Broek <mbroek@mbse.eu>
parents: 325
diff changeset
253
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
254 int delete_Device(char *uuid)
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
255 {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
256 devices_list *current = Config.devices;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
257 devices_list *previous = NULL;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
258
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
259 while (current) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
260 if (strcmp(current->uuid, uuid) == 0) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
261 if (previous == NULL) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
262 Config.devices = current->next;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
263 free(current->uuid);
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
264 current->uuid = NULL;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
265 free(current->address);
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
266 current->address = NULL;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
267 free(current->description);
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
268 current->description = NULL;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
269 free(current->comment);
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
270 current->comment = NULL;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
271 free(current);
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
272 return 1;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
273 } else {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
274 free(current->uuid);
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
275 current->uuid = NULL;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
276 free(current->address);
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
277 current->address = NULL;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
278 free(current->description);
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
279 current->description = NULL;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
280 free(current->comment);
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
281 current->comment = NULL;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
282 previous->next = current->next;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
283 free(current);
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
284 current = previous->next;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
285 return 1;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
286 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
287 } else {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
288 previous = current;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
289 current = current->next;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
290 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
291 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
292 return 0;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
293 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
294
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
295
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
296
81
547bbe344886 Added list command
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
297 /*
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
298 * DEVICE ADD type
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
299 * DEVICE DEL uuid
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
300 * DEVICE LIST
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
301 * DEVICE JSON
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
302 * DEVICE GET uuid
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
303 * DEVICE PUT uuid
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
304 * DEVICE JSON uuid
157
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
305 */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
306 int cmd_device(int s, char *buf)
157
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
307 {
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
308 char *opt, *param, *kwd, *val, ibuf[SS_BUFSIZE];
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
309 devices_list *device, *tmpd;
240
6bdda35b4a13 Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents: 237
diff changeset
310 int i, rc, rlen, ival;
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
311 uuid_t uu;
157
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
312
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
313 opt = strtok(buf, " \0");
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
314 opt = strtok(NULL, " \0");
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
315
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
316 if (opt == NULL) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
317 srv_send(s, (char *)"501 Subcommand missing");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
318 return 0;
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
319 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
320 param = strtok(NULL, "\0");
157
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
321
380
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
322 if (strcmp(opt, (char *)"HELP") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
323 srv_send(s, (char *)"100 Help text follows:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
324 srv_send(s, (char *)"Recognized commands:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
325 srv_send(s, (char *)"DEVICE ADD type Add device (RC433/DHT/I2C/SPI)");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
326 srv_send(s, (char *)"DEVICE DEL uuid Delete device by uuid");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
327 srv_send(s, (char *)"DEVICE LIST List all devices");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
328 srv_send(s, (char *)"DEVICE GET uuid Read device by uuid parameters");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
329 srv_send(s, (char *)"DEVICE PUT uuid Write device by uuid parameters");
681
1f81e52c5abf Minor details for server DEVICE commands. Added getdevice<s> php scripts.
Michiel Broek <mbroek@mbse.eu>
parents: 680
diff changeset
330 srv_send(s, (char *)"DEVICE JSON <uuid> Json list all or a single device");
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
331 srv_send(s, (char *)".");
380
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
332 return 0;
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
333 }
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
334
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
335 if (strcmp(opt, (char *)"LIST") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
336 srv_send(s, (char *)"212 Devices list follows:");
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
337 for (device = Config.devices; device; device = device->next) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
338 srv_send(s, (char *)"%s,%s,%d,%d,%s,%s,%d", device->uuid, device->address, device->subdevice,
345
9894b559441c Added device direction and value in devices maintenance screen
Michiel Broek <mbroek@mbse.eu>
parents: 344
diff changeset
339 device->inuse, device->comment, DEVDIR[device->direction], device->value + device->offset);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
340 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
341 srv_send(s, (char *)".");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
342 return 0;
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
343 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
344
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
345 if (strcmp(opt, (char *)"JSON") == 0) {
684
b2265c7e5707 Updated dependencies. Devices json data is created in de devices source for all places where it is needed. Added devices_ws function to broadcast all devices, to be used when any device is changed. The devices loop detects changes in input values and calls devices_ws if so. The server uses the general devices json data.
Michiel Broek <mbroek@mbse.eu>
parents: 681
diff changeset
346 char *payload = NULL, *payloadu = NULL, vbuf[64];
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
347 bool comma = false;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
348
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
349 if (param == NULL) {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
350 srv_send(s, (char *)"212 Devices json list follows:");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
351 payload = xstrcpy((char *)"[");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
352 for (device = Config.devices; device; device = device->next) {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
353 if (comma)
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
354 payload = xstrcat(payload, (char *)",");
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 684
diff changeset
355 payloadu = device_json(device);
684
b2265c7e5707 Updated dependencies. Devices json data is created in de devices source for all places where it is needed. Added devices_ws function to broadcast all devices, to be used when any device is changed. The devices loop detects changes in input values and calls devices_ws if so. The server uses the general devices json data.
Michiel Broek <mbroek@mbse.eu>
parents: 681
diff changeset
356 payload = xstrcat(payload, payloadu);
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
357 comma = true;
684
b2265c7e5707 Updated dependencies. Devices json data is created in de devices source for all places where it is needed. Added devices_ws function to broadcast all devices, to be used when any device is changed. The devices loop detects changes in input values and calls devices_ws if so. The server uses the general devices json data.
Michiel Broek <mbroek@mbse.eu>
parents: 681
diff changeset
358 free(payloadu);
b2265c7e5707 Updated dependencies. Devices json data is created in de devices source for all places where it is needed. Added devices_ws function to broadcast all devices, to be used when any device is changed. The devices loop detects changes in input values and calls devices_ws if so. The server uses the general devices json data.
Michiel Broek <mbroek@mbse.eu>
parents: 681
diff changeset
359 payloadu = NULL;
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
360 }
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
361 payload = xstrcat(payload, (char *)"]");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
362 srv_send(s, payload);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
363 srv_send(s, (char *)".");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
364 free(payload);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
365 payload = NULL;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
366 return 0;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
367 } else {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
368 for (device = Config.devices; device; device = device->next) {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
369 if (strcmp(device->uuid, param) == 0) {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
370 payload = xstrcpy((char *)"{\"type\":\"device\",\"unit\":\"");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
371 snprintf(vbuf, 63, "%d", device->subdevice);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
372 payload = xstrcat(payload, device->address);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
373 payload = xstrcat(payload, (char *)"-");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
374 payload = xstrcat(payload, vbuf);
684
b2265c7e5707 Updated dependencies. Devices json data is created in de devices source for all places where it is needed. Added devices_ws function to broadcast all devices, to be used when any device is changed. The devices loop detects changes in input values and calls devices_ws if so. The server uses the general devices json data.
Michiel Broek <mbroek@mbse.eu>
parents: 681
diff changeset
375 payload = xstrcat(payload, (char *)"\",\"metric\":");
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 684
diff changeset
376 payloadu = device_json(device);
684
b2265c7e5707 Updated dependencies. Devices json data is created in de devices source for all places where it is needed. Added devices_ws function to broadcast all devices, to be used when any device is changed. The devices loop detects changes in input values and calls devices_ws if so. The server uses the general devices json data.
Michiel Broek <mbroek@mbse.eu>
parents: 681
diff changeset
377 payload = xstrcat(payload, payloadu);
b2265c7e5707 Updated dependencies. Devices json data is created in de devices source for all places where it is needed. Added devices_ws function to broadcast all devices, to be used when any device is changed. The devices loop detects changes in input values and calls devices_ws if so. The server uses the general devices json data.
Michiel Broek <mbroek@mbse.eu>
parents: 681
diff changeset
378 free(payloadu);
b2265c7e5707 Updated dependencies. Devices json data is created in de devices source for all places where it is needed. Added devices_ws function to broadcast all devices, to be used when any device is changed. The devices loop detects changes in input values and calls devices_ws if so. The server uses the general devices json data.
Michiel Broek <mbroek@mbse.eu>
parents: 681
diff changeset
379 payloadu = NULL;
b2265c7e5707 Updated dependencies. Devices json data is created in de devices source for all places where it is needed. Added devices_ws function to broadcast all devices, to be used when any device is changed. The devices loop detects changes in input values and calls devices_ws if so. The server uses the general devices json data.
Michiel Broek <mbroek@mbse.eu>
parents: 681
diff changeset
380 payload = xstrcat(payload, (char *)"}");
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
381 srv_send(s, (char *)"213 Device json record follows:");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
382 srv_send(s, payload);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
383 free(payload);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
384 payload = NULL;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
385 srv_send(s, (char *)".");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
386 return 0;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
387 }
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
388 }
684
b2265c7e5707 Updated dependencies. Devices json data is created in de devices source for all places where it is needed. Added devices_ws function to broadcast all devices, to be used when any device is changed. The devices loop detects changes in input values and calls devices_ws if so. The server uses the general devices json data.
Michiel Broek <mbroek@mbse.eu>
parents: 681
diff changeset
389 srv_send(s, (char *)"{}");
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
390 srv_send(s, (char *)"440 No such device");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
391 return 0;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
392 }
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
393 }
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
394
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
395 if (param == NULL) {
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
396 srv_send(s, (char *)"502 Parameter missing");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
397 return 1;
157
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
398 }
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
399
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
400 if (strcmp(opt, (char *)"ADD") == 0) {
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
401 if ((strcmp(param, (char *)"RC433") == 0) || (strcmp(param, (char *)"DHT") == 0) ||
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
402 (strcmp(param, (char *)"I2C") == 0) || (strcmp(param, (char *)"SPI") == 0)) {
170
3cb99272b84b A bit of code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 167
diff changeset
403
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
404 device = (devices_list *)malloc(sizeof(devices_list));
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
405 device->next = NULL;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
406 device->uuid = malloc(37);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
407 uuid_generate(uu);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
408 uuid_unparse(uu, device->uuid);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
409 for (i = 0; i < 8; i++) {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
410 if (strcmp(param, DEVTYPE[i]) == 0) {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
411 device->type = i;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
412 break;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
413 }
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
414 }
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
415 device->direction = DEVDIR_UNDEF;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
416 device->value = device->offset = device->subdevice = device->inuse = 0;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
417 device->present = DEVPRESENT_UNDEF;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
418 device->address = xstrcpy((char *)"Enter address here");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
419 device->gpiopin = -1;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
420 device->description = xstrcpy((char *)"Describe me here");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
421 device->comment = xstrcpy((char *)"Comment here");
170
3cb99272b84b A bit of code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 167
diff changeset
422
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
423 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
424 if (Config.devices == NULL) {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
425 Config.devices = device;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
426 } else {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
427 for (tmpd = Config.devices; tmpd; tmpd = tmpd->next) {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
428 if (tmpd->next == NULL) {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
429 tmpd->next = device;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
430 break;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
431 }
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
432 }
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
433 }
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
434 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
435 syslog(LOG_NOTICE, "Device %s added", device->uuid);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
436 srv_send(s, (char *)"211 Device %s added", device->uuid);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
437 return 1;
157
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
438
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
439 } else {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
440 srv_send(s, (char *)"503 Parameter error");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
441 return 0;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
442 }
157
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
443 }
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
444
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
445 if (strcmp(opt, (char *)"DEL") == 0) {
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
446
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
447 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
448 rc = delete_Device(param);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
449 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
450 if (rc) {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
451 syslog(LOG_NOTICE, "Device %s deleted", param);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
452 srv_send(s, (char *)"211 Device %s deleted", param);
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
453 return 1;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
454 } else {
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
455 srv_send(s, (char *)"440 No such device");
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
456 return 0;
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
457 }
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
458 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
459
680
8b3c86124a08 Increased server buffersize from 1024 to 4096. Added DEVICE JSON <uuid> command. Added websocket response fermenter profile. The fermenter monitor screen is ready (maybe).
Michiel Broek <mbroek@mbse.eu>
parents: 678
diff changeset
460
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
461 if (strcmp(opt, (char *)"GET") == 0) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
462 for (device = Config.devices; device; device = device->next) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
463 if (strcmp(device->uuid, param) == 0) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
464 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
325
35b6f6605ae3 More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
465 int my_value = device->value;
35b6f6605ae3 More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
466 int my_timestamp = (int)device->timestamp;
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
467 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
468 srv_send(s, (char *)"213 Device record follows:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
469 srv_send(s, (char *)"TYPE,%s", DEVTYPE[device->type]);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
470 srv_send(s, (char *)"ADDRESS,%s", device->address);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
471 srv_send(s, (char *)"DIRECTION,%s", DEVDIR[device->direction]);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
472 srv_send(s, (char *)"VALUE,%d", my_value);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
473 srv_send(s, (char *)"OFFSET,%d", device->offset);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
474 srv_send(s, (char *)"PRESENT,%s", DEVPRESENT[device->present]);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
475 srv_send(s, (char *)"SUBDEVICE,%d", device->subdevice);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
476 srv_send(s, (char *)"GPIOPIN,%d", device->gpiopin);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
477 srv_send(s, (char *)"DESCRIPTION,%s", device->description);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
478 srv_send(s, (char *)"INUSE,%d", device->inuse);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
479 srv_send(s, (char *)"COMMENT,%s", device->comment);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
480 srv_send(s, (char *)"TIMESTAMP,%d", my_timestamp);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
481 srv_send(s, (char *)".");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
482 return 0;
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
483 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
484 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
485 srv_send(s, (char *)"440 No such device");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
486 return 0;
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
487 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
488
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
489 if (strcmp(opt, (char *)"PUT") == 0) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
490 for (device = Config.devices; device; device = device->next) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
491 if (strcmp(device->uuid, param) == 0) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
492 while (1) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
493 rlen = srv_recv(s, ibuf);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
494 if (rlen == -1) {
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
495 return 0;
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
496 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
497 if (strlen(ibuf)) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
498 if (strcmp(ibuf, (char *)".") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
499 srv_send(s, (char *)"219 Accepted Device record");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
500 return 1;
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
501 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
502 kwd = strtok(ibuf, ",\0");
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
503 val = strtok(NULL, "\0");
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
504 if (kwd && val) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
505 if (strcmp(kwd, (char *)"TYPE") == 0) {
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
506 for (i = 0; i < 8; i++) {
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
507 if (strcmp(val, DEVTYPE[i]) == 0) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
508 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
509 if (device->type != i)
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
510 syslog(LOG_NOTICE, "Device %s changed type %s to %s", device->uuid, DEVTYPE[device->type], DEVTYPE[i]);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
511 device->type = i;
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
512 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
513 break;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
514 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
515 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
516
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
517 } else if (strcmp(kwd, (char *)"DIRECTION") == 0) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
518 for (i = 0; i < 7; i++) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
519 if (strcmp(val, DEVDIR[i]) == 0) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
520 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
521 if (device->direction != i)
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
522 syslog(LOG_NOTICE, "Device %s changed direction %s to %s", device->uuid, DEVDIR[device->type], DEVDIR[i]);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
523 device->direction = i;
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
524 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
525 break;
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
526 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
527 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
528
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
529 } else if (strcmp(kwd, (char *)"VALUE") == 0) {
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
530 if (sscanf(val, "%d", &ival) == 1) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
531 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
325
35b6f6605ae3 More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
532 if (device->value != ival)
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
533 syslog(LOG_NOTICE, "Device %s changed value %d to %d", device->uuid, device->value, ival);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
534 device->value = ival;
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
535 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
536 }
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
537
209
c5b1dfd83e81 Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
538 } else if (strcmp(kwd, (char *)"OFFSET") == 0) {
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
539 if (sscanf(val, "%d", &ival) == 1) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
540 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
325
35b6f6605ae3 More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
541 if (device->offset != ival)
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
542 syslog(LOG_NOTICE, "Device %s changed offset %d to %d", device->uuid, device->offset, ival);
209
c5b1dfd83e81 Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
543 device->offset = ival;
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
544 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
545 }
209
c5b1dfd83e81 Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
546
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
547 } else if (strcmp(kwd, (char *)"PRESENT") == 0) {
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
548 for (i = 0; i < 4; i++) {
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
549 if (strcmp(val, DEVPRESENT[i]) == 0) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
550 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
551 if (device->present != i)
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
552 syslog(LOG_NOTICE, "Device %s changed present %s to %s", device->uuid, DEVPRESENT[device->present], DEVPRESENT[i]);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
553 device->present = i;
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
554 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
325
35b6f6605ae3 More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
555 break;
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
556 }
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
557 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
558
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
559 } else if (strcmp(kwd, (char *)"ADDRESS") == 0) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
560 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
561 if (device->address) {
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
562 if (strcmp(device->address, val))
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
563 syslog(LOG_NOTICE, "Device %s changed address `%s' to `%s'", device->uuid, device->address, val);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
564 free(device->address);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
565 }
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
566 device->address = xstrcpy(val);
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
567 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
568
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
569 } else if (strcmp(kwd, (char *)"SUBDEVICE") == 0) {
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
570 if (sscanf(val, "%d", &ival) == 1) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
571 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
572 if (device->subdevice != ival)
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
573 syslog(LOG_NOTICE, "Device %s changed subdevice %d to %d", device->uuid, device->subdevice, ival);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
574 device->subdevice = ival;
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
575 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
576 }
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
577
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
578 } else if (strcmp(kwd, (char *)"GPIOPIN") == 0) {
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
579 if (sscanf(val, "%d", &ival) == 1) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
580 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
581 if (device->gpiopin != ival)
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
582 syslog(LOG_NOTICE, "Device %s changed gpiopin %d to %d", device->uuid, device->gpiopin, ival);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
583 device->gpiopin = ival;
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
584 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
585 }
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
586
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
587 } else if (strcmp(kwd, (char *)"DESCRIPTION") == 0) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
588 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
589 if (device->description) {
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
590 if (strcmp(device->description, val))
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
591 syslog(LOG_NOTICE, "Device %s changed description `%s' to `%s'", device->uuid, device->description, val);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
592 free(device->description);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
593 }
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
594 device->description = xstrcpy(val);
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
595 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
596
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
597 } else if (strcmp(kwd, (char *)"COMMENT") == 0) {
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
598 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
599 if (device->comment) {
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
600 if (strcmp(device->comment, val))
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
601 syslog(LOG_NOTICE, "Device %s changed comment `%s' to `%s'", device->uuid, device->comment, val);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
602 free(device->comment);
276
a19cc3770f09 Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents: 274
diff changeset
603 }
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
604 device->comment = xstrcpy(val);
645
49eb753a958b All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents: 614
diff changeset
605 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
606
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
607 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
608 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
609 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
610 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
611 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
612 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
613 srv_send(s, (char *)"440 No such device");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
614 return 0;
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
615 }
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
616
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
617 srv_send(s, (char *)"504 Subcommand error");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
618 return 0;
157
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
619 }
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
620
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
621
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
622
259a018758f9 Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
623 /*
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
624 * GLOBAL GET
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
625 * GLOBAL PUT
678
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
626 * GLOBAL JSON
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
627 */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
628 int cmd_global(int s, char *buf)
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
629 {
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
630 char *opt, *kwd, *val, ibuf[SS_BUFSIZE];
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
631 int ival, rlen;
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
632
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
633 opt = strtok(buf, " \0");
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
634 opt = strtok(NULL, "\0");
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
635
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
636 if (opt == NULL) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
637 srv_send(s, (char *)"501 Subcommand missing");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
638 return 0;
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
639 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
640
380
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
641 if (strcmp(opt, (char *)"HELP") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
642 srv_send(s, (char *)"100 Help text follows:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
643 srv_send(s, (char *)"Recognized commands:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
644 srv_send(s, (char *)"GLOBAL GET Get global settings");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
645 srv_send(s, (char *)"GLOBAL PUT Put global settings");
678
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
646 srv_send(s, (char *)"GLOBAL JSON Get global json settings");
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
647 srv_send(s, (char *)".");
380
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
648 return 0;
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
649 }
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
650
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
651 if (strcmp(opt, (char *)"GET") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
652 srv_send(s, (char *)"213 Global Settings record follows:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
653 srv_send(s, (char *)"RELEASE,%s", VERSION);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
654 srv_send(s, (char *)"NAME,%s", Config.name);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
655 srv_send(s, (char *)"PORT,%d", Config.my_port);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
656 srv_send(s, (char *)"TEMPFORMAT,%c", Config.tempFormat);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
657 srv_send(s, (char *)"TEMP_ADDRESS,%s", Config.temp_address);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
658 srv_send(s, (char *)"TEMP_STATE,%s", TEMPSTATE[Config.temp_state]);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
659 srv_send(s, (char *)"TEMP_VALUE,%.1f", Config.temp_value / 1000.0);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
660 srv_send(s, (char *)"HUM_ADDRESS,%s", Config.hum_address);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
661 srv_send(s, (char *)"HUM_STATE,%s", TEMPSTATE[Config.hum_state]);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
662 srv_send(s, (char *)"HUM_VALUE,%.0f", Config.hum_value / 1000.0);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
663 srv_send(s, (char *)"TEMP_HUM_IDX,%d", Config.temp_hum_idx);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
664 srv_send(s, (char *)"LCD_COLS,%d", Config.lcd_cols);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
665 srv_send(s, (char *)"LCD_ROWS,%d", Config.lcd_rows);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
666 srv_send(s, (char *)"NEXT_UNIT,%d", Config.next_unit);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
667 srv_send(s, (char *)"MQTT_HOST,%s", Config.mqtt_host);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
668 srv_send(s, (char *)"MQTT_PORT,%d", Config.mqtt_port);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
669 srv_send(s, (char *)"MQTT_USER,%s", Config.mqtt_username);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
670 srv_send(s, (char *)"MQTT_PASS,%s", Config.mqtt_password);
676
09b5efe0c633 Add stylesheet, about page. Add menu for fermenters. Add websocket port setup to the config server.
Michiel Broek <mbroek@mbse.eu>
parents: 666
diff changeset
671 srv_send(s, (char *)"WEBSOCKET_PORT,%d", Config.websocket_port);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
672 srv_send(s, (char *)".");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
673 return 0;
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
674 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
675
678
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
676 if (strcmp(opt, (char *)"JSON") == 0) {
689
f94b525f7563 Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents: 687
diff changeset
677 char *payload = NULL;
678
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
678
689
f94b525f7563 Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents: 687
diff changeset
679 payload = global_json();
678
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
680 srv_send(s, (char *)"213 Global json data follows:");
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
681 srv_send(s, payload);
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
682 srv_send(s, (char *)".");
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
683 free(payload);
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
684 payload = NULL;
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
685 return 0;
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
686 }
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
687
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
688 if (strcmp(opt, (char *)"PUT") == 0) {
545
c382a6c58c20 Fixed compiling whithout mqtt support.
Michiel Broek <mbroek@mbse.eu>
parents: 542
diff changeset
689 int mqtt_reconnect = 0;
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
690 while (1) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
691 rlen = srv_recv(s, ibuf);
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
692 if (rlen == -1) {
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
693 return 0;
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
694 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
695 if (strlen(ibuf)) {
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
696 if (strcmp(ibuf, (char *)".") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
697 srv_send(s, (char *)"219 Accepted Global record");
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
698 if (mqtt_reconnect)
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
699 mqtt_connect();
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
700 return 1;
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
701 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
702 kwd = strtok(ibuf, ",\0");
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
703 val = strtok(NULL, "\0");
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
704 if (kwd) {
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
705 if (strcmp(kwd, (char *)"NAME") == 0) {
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
706 if (val && Config.name && strcmp(val, Config.name))
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
707 syslog(LOG_NOTICE, "Global name `%s' to `%s'", Config.name, val);
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
708 if (Config.name)
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
709 free(Config.name);
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
710 if (val)
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
711 Config.name = xstrcpy(val);
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
712 else
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
713 Config.name = NULL;
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
714
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
715 } else if (val && (strcmp(kwd, (char *)"PORT") == 0)) {
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
716 if (sscanf(val, "%d", &ival) == 1) {
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
717 if (Config.my_port != ival)
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
718 syslog(LOG_NOTICE, "Global port %d to %d", Config.my_port, ival);
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
719 Config.my_port = ival;
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
720 }
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
721
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
722 } else if (val && (strcmp(kwd, (char *)"TEMPFORMAT") == 0)) {
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
723 if ((val[0] == 'C') || (val[0] == 'F')) {
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
724 if (Config.tempFormat != val[0])
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
725 syslog(LOG_NOTICE, "Global port %c to %c", Config.tempFormat, val[0]);
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
726 Config.tempFormat = val[0];
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
727 }
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
728
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
729 } else if (strcmp(kwd, (char *)"TEMP_ADDRESS") == 0) {
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
730 if (val && Config.temp_address && (strcmp(val, Config.temp_address)))
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
731 syslog(LOG_NOTICE, "Global temperature address `%s' to `%s'", Config.temp_address, val);
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
732 if (Config.temp_address) {
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
733 device_count(FALSE, Config.temp_address);
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
734 free(Config.temp_address);
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
735 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
736 if (val) {
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
737 Config.temp_address = xstrcpy(val);
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
738 device_count(TRUE, Config.temp_address);
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
739 } else
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
740 Config.temp_address = NULL;
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
741
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
742 } else if (strcmp(kwd, (char *)"HUM_ADDRESS") == 0) {
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
743 if (val && Config.hum_address && (strcmp(val, Config.hum_address)))
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
744 syslog(LOG_NOTICE, "Global humidity address `%s' to `%s'", Config.hum_address, val);
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
745 if (Config.hum_address) {
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
746 device_count(FALSE, Config.hum_address);
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
747 free(Config.hum_address);
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
748 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
749 if (val) {
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
750 Config.hum_address = xstrcpy(val);
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
751 device_count(TRUE, Config.hum_address);
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
752 } else
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
753 Config.hum_address = NULL;
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
754
513
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
755 } else if (val && (strcmp(kwd, (char *)"TEMP_HUM_IDX") == 0)) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
756 if (sscanf(val, "%d", &ival) == 1) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
757 if (Config.temp_hum_idx != ival)
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
758 syslog(LOG_NOTICE, "Global Temp/Humidity idx %d to %d", Config.temp_hum_idx, ival);
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
759 Config.temp_hum_idx = ival;
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
760 }
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
761
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
762 } else if (val && (strcmp(kwd, (char *)"LCD_COLS") == 0)) {
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
763 if (sscanf(val, "%d", &ival) == 1) {
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
764 if (Config.lcd_cols != ival)
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
765 syslog(LOG_NOTICE, "Global LCD columns %d to %d", Config.lcd_cols, ival);
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
766 Config.lcd_cols = ival;
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
767 }
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
768
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
769 } else if (val && (strcmp(kwd, (char *)"LCD_ROWS") == 0)) {
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
770 if (sscanf(val, "%d", &ival) == 1) {
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
771 if (Config.lcd_rows != ival)
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
772 syslog(LOG_NOTICE, "Global LCD rows %d to %d", Config.lcd_rows, ival);
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
773 Config.lcd_rows = ival;
278
76c8a6f18e4d GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 276
diff changeset
774 }
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
775
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
776 } else if (strcmp(kwd, (char *)"MQTT_HOST") == 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
777 if (val && Config.mqtt_host && (strcmp(val, Config.mqtt_host)))
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
778 syslog(LOG_NOTICE, "Global MQTT host `%s' to `%s'", Config.mqtt_host, val);
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
779 mqtt_disconnect();
545
c382a6c58c20 Fixed compiling whithout mqtt support.
Michiel Broek <mbroek@mbse.eu>
parents: 542
diff changeset
780 mqtt_reconnect = 1;
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
781 if (Config.mqtt_host)
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
782 free(Config.mqtt_host);
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
783 if (val)
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
784 Config.mqtt_host = xstrcpy(val);
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
785 else
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
786 Config.mqtt_host = NULL;
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
787
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
788 } else if (val && (strcmp(kwd, (char *)"MQTT_PORT") == 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
789 if (sscanf(val, "%d", &ival) == 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
790 if (Config.mqtt_port != ival) {
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
791 syslog(LOG_NOTICE, "Global MQTT port %d to %d", Config.mqtt_port, ival);
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
792 mqtt_disconnect();
545
c382a6c58c20 Fixed compiling whithout mqtt support.
Michiel Broek <mbroek@mbse.eu>
parents: 542
diff changeset
793 mqtt_reconnect = 1;
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
794 Config.mqtt_port = ival;
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
795 }
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
796 }
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
797
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
798 } else if (strcmp(kwd, (char *)"MQTT_USER") == 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
799 if (val && Config.mqtt_username && (strcmp(val, Config.mqtt_username)))
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
800 syslog(LOG_NOTICE, "Global MQTT username `%s' to `%s'", Config.mqtt_username, val);
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
801 mqtt_disconnect();
545
c382a6c58c20 Fixed compiling whithout mqtt support.
Michiel Broek <mbroek@mbse.eu>
parents: 542
diff changeset
802 mqtt_reconnect = 1;
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
803 if (Config.mqtt_username)
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
804 free(Config.mqtt_username);
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
805 if (val)
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
806 Config.mqtt_username = xstrcpy(val);
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
807 else
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
808 Config.mqtt_username = NULL;
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
809
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
810 } else if (strcmp(kwd, (char *)"MQTT_PASS") == 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
811 if (val && Config.mqtt_password && (strcmp(val, Config.mqtt_password)))
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
812 syslog(LOG_NOTICE, "Global MQTT password `%s' to `%s'", Config.mqtt_password, val);
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
813 mqtt_disconnect();
545
c382a6c58c20 Fixed compiling whithout mqtt support.
Michiel Broek <mbroek@mbse.eu>
parents: 542
diff changeset
814 mqtt_reconnect = 1;
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
815 if (Config.mqtt_password)
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
816 free(Config.mqtt_password);
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
817 if (val)
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
818 Config.mqtt_password = xstrcpy(val);
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
819 else
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
820 Config.mqtt_password = NULL;
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
821
676
09b5efe0c633 Add stylesheet, about page. Add menu for fermenters. Add websocket port setup to the config server.
Michiel Broek <mbroek@mbse.eu>
parents: 666
diff changeset
822 } else if (val && (strcmp(kwd, (char *)"WEBSOCKET_PORT") == 0)) {
09b5efe0c633 Add stylesheet, about page. Add menu for fermenters. Add websocket port setup to the config server.
Michiel Broek <mbroek@mbse.eu>
parents: 666
diff changeset
823 if (sscanf(val, "%d", &ival) == 1) {
09b5efe0c633 Add stylesheet, about page. Add menu for fermenters. Add websocket port setup to the config server.
Michiel Broek <mbroek@mbse.eu>
parents: 666
diff changeset
824 if (Config.websocket_port != ival) {
09b5efe0c633 Add stylesheet, about page. Add menu for fermenters. Add websocket port setup to the config server.
Michiel Broek <mbroek@mbse.eu>
parents: 666
diff changeset
825 syslog(LOG_NOTICE, "Global Websocket port %d to %d", Config.websocket_port, ival);
09b5efe0c633 Add stylesheet, about page. Add menu for fermenters. Add websocket port setup to the config server.
Michiel Broek <mbroek@mbse.eu>
parents: 666
diff changeset
826 Config.websocket_port = ival;
09b5efe0c633 Add stylesheet, about page. Add menu for fermenters. Add websocket port setup to the config server.
Michiel Broek <mbroek@mbse.eu>
parents: 666
diff changeset
827 }
09b5efe0c633 Add stylesheet, about page. Add menu for fermenters. Add websocket port setup to the config server.
Michiel Broek <mbroek@mbse.eu>
parents: 666
diff changeset
828 }
09b5efe0c633 Add stylesheet, about page. Add menu for fermenters. Add websocket port setup to the config server.
Michiel Broek <mbroek@mbse.eu>
parents: 666
diff changeset
829
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
830 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
831 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
832 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
833 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
834 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
835
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
836 srv_send(s, (char *)"504 Subcommand error");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
837 return 0;
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
838 }
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
839
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
840
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
841
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
842 /*
81
547bbe344886 Added list command
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
843 * LIST
547bbe344886 Added list command
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
844 */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
845 int cmd_list(int s, char *buf)
81
547bbe344886 Added list command
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
846 {
536
e833bbd5e733 Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents: 534
diff changeset
847 char *opt;
84
ef4c0032b51f Can list the 1-wire bus
Michiel Broek <mbroek@mbse.eu>
parents: 81
diff changeset
848 units_list *unit;
81
547bbe344886 Added list command
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
849
87
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
850 opt = strtok(buf, " \0");
191
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 189
diff changeset
851 opt = strtok(NULL, " \0");
84
ef4c0032b51f Can list the 1-wire bus
Michiel Broek <mbroek@mbse.eu>
parents: 81
diff changeset
852
81
547bbe344886 Added list command
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
853 if (opt == NULL) {
92
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
854 /*
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
855 * Default, list available units
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
856 */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
857 srv_send(s, (char *)"212 Fermenter list follows:");
81
547bbe344886 Added list command
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
858 for (unit = Config.units; unit; unit = unit->next) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
859 srv_send(s, (char *)"%s,%s,%s", unit->uuid, unit->alias, UNITMODE[unit->mode]);
81
547bbe344886 Added list command
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
860 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
861 srv_send(s, (char *)".");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
862 return 0;
92
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
863
380
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
864 } else if (strcmp(opt, (char *)"HELP") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
865 srv_send(s, (char *)"100 Help text follows:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
866 srv_send(s, (char *)"Recognized commands:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
867 srv_send(s, (char *)"LIST List available units");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
868 srv_send(s, (char *)".");
380
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
869 return 0;
191
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 189
diff changeset
870 }
120
466c5cee0463 Added LIST LOG command
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
871
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
872 srv_send(s, (char *)"504 Subcommand error");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
873 return 0;
191
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 189
diff changeset
874 }
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 189
diff changeset
875
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 189
diff changeset
876
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 189
diff changeset
877
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
878 #ifdef USE_SIMULATOR
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
879 int delete_Simulator(char *uuid)
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
880 {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
881 simulator_list *current = Config.simulators;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
882 simulator_list *previous = NULL;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
883
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
884 while (current) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
885 if (strcmp(current->uuid, uuid) == 0) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
886 if (previous == NULL) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
887 Config.simulators = current->next;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
888 free(current->uuid);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
889 current->uuid = NULL;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
890 free(current->name);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
891 current->name = NULL;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
892 free(current);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
893 return 1;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
894 } else {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
895 free(current->uuid);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
896 current->uuid = NULL;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
897 free(current->name);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
898 current->name = NULL;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
899 previous->next = current->next;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
900 free(current);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
901 current = previous->next;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
902 return 1;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
903 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
904 } else {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
905 previous = current;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
906 current = current->next;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
907 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
908 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
909 return 0;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
910 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
911
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
912
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
913
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
914 /*
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
915 * SIMULATOR ADD name
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
916 * SIMULATOR DEL uuid
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
917 * SIMULATOR LIST
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
918 * SIMULATOR GET uuid
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
919 * SIMULATOR PUT uuid
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
920 */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
921 int cmd_simulator(int s, char *buf)
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
922 {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
923 char *opt, *param, *kwd, *val, ibuf[SS_BUFSIZE];
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
924 simulator_list *simulator, *tmps;
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
925 int rc, rlen, ival;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
926 float fval;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
927 uuid_t uu;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
928
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
929 opt = strtok(buf, " \0");
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
930 opt = strtok(NULL, " \0");
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
931
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
932 if (opt == NULL) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
933 srv_send(s, (char *)"501 Subcommand missing");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
934 return 0;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
935 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
936 param = strtok(NULL, "\0");
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
937
380
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
938 if (strcmp(opt, (char *)"HELP") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
939 srv_send(s, (char *)"100 Help text follows:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
940 srv_send(s, (char *)"Recognized commands:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
941 srv_send(s, (char *)"SIMULATOR ADD name Add a new Simulator with name");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
942 srv_send(s, (char *)"SIMULATOR DEL uuid Delete Simulator by uuid");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
943 srv_send(s, (char *)"SIMULATOR LIST List all Simulators");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
944 srv_send(s, (char *)"SIMULATOR GET uuid Get Simulator record by uuid");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
945 srv_send(s, (char *)"SIMULATOR PUT uuid Put Simulator record by uuid");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
946 srv_send(s, (char *)".");
380
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
947 return 0;
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
948 }
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
949
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
950 if (strcmp(opt, (char *)"LIST") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
951 srv_send(s, (char *)"212 Simulators list follows:");
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
952 for (simulator = Config.simulators; simulator; simulator = simulator->next) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
953 srv_send(s, (char *)"%s,%s", simulator->uuid, simulator->name);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
954 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
955 srv_send(s, (char *)".");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
956 return 0;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
957 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
958
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
959 if (param == NULL) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
960 srv_send(s, (char *)"502 Parameter missing");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
961 return 0;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
962 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
963
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
964 if (strcmp(opt, (char *)"ADD") == 0) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
965
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
966 /*
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
967 * For now, only one simulator is allowed.
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
968 */
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
969 if (Config.simulators) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
970 srv_send(s, (char *)"441 Maximum simulators reached");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
971 return 0;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
972 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
973
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
974 simulator = (simulator_list *)malloc(sizeof(simulator_list));
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
975 simulator->next = NULL;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
976 simulator->uuid = malloc(37);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
977 uuid_generate(uu);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
978 uuid_unparse(uu, simulator->uuid);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
979 simulator->name = xstrcpy(param);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
980 simulator->volume_air = 150;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
981 simulator->volume_beer = 50;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
982 simulator->room_temperature = simulator->air_temperature = simulator->beer_temperature = simulator->s_cool_temp = simulator->s_heat_temp = 20.0;
553
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
983 simulator->room_humidity = 48.6;
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
984 simulator->chiller_temperature = 1.5; /* Chiller temperature */
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
985 simulator->cooler_temp = 1.5; /* Cooling temperature */
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
986 simulator->cooler_time = 720; /* About 12 minutes for the cooler plate */
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
987 simulator->cooler_size = 0.8; /* 0.8 square meter cooler plate */
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
988 simulator->heater_temp = 150.0; /* Heating temperature */
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
989 simulator->heater_time = 3; /* 3 seconds to heat-up */
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
990 simulator->heater_size = 0.01; /* 0.01 square meter heater plate */
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
991 simulator->heater_state = simulator->cooler_state = 0;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
992 simulator->frigo_isolation = 0.002;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
993 simulator->s_yeast_heat = 0.0;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
994 simulator->s_yeast_started = simulator->s_cool_changed = simulator->s_heat_changed = (int)0;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
995
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
996 if (Config.simulators == NULL) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
997 Config.simulators = simulator;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
998 } else {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
999 for (tmps = Config.simulators; tmps; tmps = tmps->next) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1000 if (tmps->next == NULL) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1001 tmps->next = simulator;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1002 break;
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1003 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1004 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1005 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1006
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1007 syslog(LOG_NOTICE, "Simulator %s added", simulator->uuid);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1008 srv_send(s, (char *)"211 Simulator %s added", simulator->uuid);
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1009 return 1;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1010 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1011
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1012 if (strcmp(opt, (char *)"DEL") == 0) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1013 rc = delete_Simulator(param);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1014 if (rc) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1015 syslog(LOG_NOTICE, "Simulator %s deleted", param);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1016 srv_send(s, (char *)"211 Simulator %s deleted", param);
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1017 return 1;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1018 } else {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1019 srv_send(s, (char *)"440 No such simulator");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1020 return 0;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1021 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1022 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1023
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1024 if (strcmp(opt, (char *)"GET") == 0) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1025 for (simulator = Config.simulators; simulator; simulator = simulator->next) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1026 if (strcmp(simulator->uuid, param) == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1027 srv_send(s, (char *)"213 Simulator record follows:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1028 srv_send(s, (char *)"NAME,%s", simulator->name);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1029 srv_send(s, (char *)"VOLUME_AIR,%d", simulator->volume_air);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1030 srv_send(s, (char *)"VOLUME_BEER,%d", simulator->volume_beer);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1031 srv_send(s, (char *)"ROOM_TEMPERATURE,%.1f", simulator->room_temperature);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1032 srv_send(s, (char *)"ROOM_HUMIDITY,%.1f", simulator->room_humidity);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1033 srv_send(s, (char *)"AIR_TEMPERATURE,%.3f", simulator->air_temperature);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1034 srv_send(s, (char *)"BEER_TEMPERATURE,%.3f", simulator->beer_temperature);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1035 srv_send(s, (char *)"CHILLER_TEMPERATURE,%.3f", simulator->chiller_temperature);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1036 srv_send(s, (char *)"COOLER_TEMP,%.1f", simulator->cooler_temp);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1037 srv_send(s, (char *)"COOLER_TIME,%d", simulator->cooler_time);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1038 srv_send(s, (char *)"COOLER_SIZE,%.3f", simulator->cooler_size);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1039 srv_send(s, (char *)"HEATER_TEMP,%.1f", simulator->heater_temp);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1040 srv_send(s, (char *)"HEATER_TIME,%d", simulator->heater_time);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1041 srv_send(s, (char *)"HEATER_SIZE,%.3f", simulator->heater_size);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1042 srv_send(s, (char *)"HEATER_STATE,%d", simulator->heater_state);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1043 srv_send(s, (char *)"COOLER_STATE,%d", simulator->cooler_state);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1044 srv_send(s, (char *)"FRIGO_ISOLATION,%.3f", simulator->frigo_isolation);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1045 srv_send(s, (char *)".");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1046 return 0;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1047 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1048 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1049 srv_send(s, (char *)"440 No such simulator");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1050 return 0;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1051 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1052
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1053 if (strcmp(opt, (char *)"PUT") == 0) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1054 for (simulator = Config.simulators; simulator; simulator = simulator->next) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1055 if (strcmp(simulator->uuid, param) == 0) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1056 while (1) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1057 rlen = srv_recv(s, ibuf);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1058 if (rlen == -1) {
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1059 return 0;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1060 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1061 if (strlen(ibuf)) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1062 if (strcmp(ibuf, (char *)".") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1063 srv_send(s, (char *)"219 Accepted Simulator record");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1064 return 1;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1065 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1066 kwd = strtok(ibuf, ",\0");
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1067 val = strtok(NULL, "\0");
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1068 if (kwd && val) {
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1069
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1070 if (strcmp(kwd, (char *)"NAME") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1071 if (simulator->name) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1072 if (strcmp(simulator->name, val))
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1073 syslog(LOG_NOTICE, "Simulator %s name `%s' to `%s'", simulator->uuid, simulator->name, val);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1074 free(simulator->name);
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1075 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1076 simulator->name = xstrcpy(val);
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1077
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1078 } else if (strcmp(kwd, (char *)"VOLUME_AIR") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1079 if (sscanf(val, "%d", &ival) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1080 if (simulator->volume_air != ival)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1081 syslog(LOG_NOTICE, "Simulator %s volume air %d to %d", simulator->uuid, simulator->volume_air, ival);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1082 simulator->volume_air = ival;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1083 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1084
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1085 } else if (strcmp(kwd, (char *)"VOLUME_BEER") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1086 if (sscanf(val, "%d", &ival) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1087 if (simulator->volume_beer != ival)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1088 syslog(LOG_NOTICE, "Simulator %s volume beer %d to %d", simulator->uuid, simulator->volume_beer, ival);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1089 simulator->volume_beer = ival;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1090 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1091
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1092 } else if (strcmp(kwd, (char *)"ROOM_TEMPERATURE") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1093 if (sscanf(val, "%f", &fval) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1094 if (simulator->room_temperature != fval)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1095 syslog(LOG_NOTICE, "Simulator %s room temperature %.1f to %.1f", simulator->uuid, simulator->room_temperature, fval);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1096 simulator->room_temperature = fval;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1097 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1098
553
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1099 } else if (strcmp(kwd, (char *)"ROOM_HUMIDITY") == 0) {
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1100 if (sscanf(val, "%f", &fval) == 1) {
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1101 if (simulator->room_humidity != fval)
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1102 syslog(LOG_NOTICE, "Simulator %s room hunidity %.1f to %.1f", simulator->uuid, simulator->room_humidity, fval);
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1103 simulator->room_humidity = fval;
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1104 }
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1105
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1106 } else if (strcmp(kwd, (char *)"AIR_TEMPERATURE") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1107 if (sscanf(val, "%f", &fval) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1108 if (simulator->air_temperature != fval)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1109 syslog(LOG_NOTICE, "Simulator %s air temperature %.1f to %.1f", simulator->uuid, simulator->air_temperature, fval);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1110 simulator->air_temperature = fval;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1111 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1112
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1113 } else if (strcmp(kwd, (char *)"BEER_TEMPERATURE") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1114 if (sscanf(val, "%f", &fval) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1115 if (simulator->beer_temperature != fval)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1116 syslog(LOG_NOTICE, "Simulator %s beer temperature %.1f to %.1f", simulator->uuid, simulator->beer_temperature, fval);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1117 simulator->beer_temperature = fval;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1118 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1119
553
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1120 } else if (strcmp(kwd, (char *)"CHILLER_TEMPERATURE") == 0) {
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1121 if (sscanf(val, "%f", &fval) == 1) {
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1122 if (simulator->chiller_temperature != fval)
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1123 syslog(LOG_NOTICE, "Simulator %s chiller temperature %.1f to %.1f", simulator->uuid, simulator->chiller_temperature, fval);
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1124 simulator->chiller_temperature = fval;
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1125 }
4091d4fe217f Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents: 545
diff changeset
1126
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1127 } else if (strcmp(kwd, (char *)"COOLER_TEMP") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1128 if (sscanf(val, "%f", &fval) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1129 if (simulator->cooler_temp != fval)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1130 syslog(LOG_NOTICE, "Simulator %s cooler temperature %.1f to %.1f", simulator->uuid, simulator->cooler_temp, fval);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1131 simulator->cooler_temp = fval;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1132 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1133
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1134 } else if (strcmp(kwd, (char *)"COOLER_TIME") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1135 if (sscanf(val, "%d", &ival) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1136 if (simulator->cooler_time != ival)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1137 syslog(LOG_NOTICE, "Simulator %s cooler time %d to %d", simulator->uuid, simulator->cooler_time, ival);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1138 simulator->cooler_time = ival;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1139 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1140
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1141 } else if (strcmp(kwd, (char *)"COOLER_SIZE") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1142 if (sscanf(val, "%f", &fval) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1143 if (simulator->cooler_size != fval)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1144 syslog(LOG_NOTICE, "Simulator %s cooler size %.1f to %.1f", simulator->uuid, simulator->cooler_size, fval);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1145 simulator->cooler_size = fval;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1146 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1147
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1148 } else if (strcmp(kwd, (char *)"HEATER_TEMP") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1149 if (sscanf(val, "%f", &fval) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1150 if (simulator->heater_temp != fval)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1151 syslog(LOG_NOTICE, "Simulator %s heater temperature %.1f to %.1f", simulator->uuid, simulator->heater_temp, fval);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1152 simulator->heater_temp = fval;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1153 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1154
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1155 } else if (strcmp(kwd, (char *)"HEATER_TIME") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1156 if (sscanf(val, "%d", &ival) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1157 if (simulator->heater_time != ival)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1158 syslog(LOG_NOTICE, "Simulator %s heater time %d to %d", simulator->uuid, simulator->heater_time, ival);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1159 simulator->heater_time = ival;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1160 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1161
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1162 } else if (strcmp(kwd, (char *)"HEATER_SIZE") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1163 if (sscanf(val, "%f", &fval) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1164 if (simulator->heater_size != fval)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1165 syslog(LOG_NOTICE, "Simulator %s heater size %.1f to %.1f", simulator->uuid, simulator->heater_size, fval);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1166 simulator->heater_size = fval;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1167 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1168
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1169 } else if (strcmp(kwd, (char *)"HEATER_STATE") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1170 if (sscanf(val, "%d", &ival) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1171 if (simulator->heater_state != ival)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1172 syslog(LOG_NOTICE, "Simulator %s heater state %d to %d", simulator->uuid, simulator->heater_state, ival);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1173 simulator->heater_state = ival;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1174 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1175
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1176 } else if (strcmp(kwd, (char *)"COOLER_STATE") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1177 if (sscanf(val, "%d", &ival) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1178 if (simulator->cooler_state != ival)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1179 syslog(LOG_NOTICE, "Simulator %s cooler state %d to %d", simulator->uuid, simulator->cooler_state, ival);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1180 simulator->cooler_state = ival;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1181 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1182
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1183 } else if (strcmp(kwd, (char *)"FRIGO_ISOLATION") == 0) {
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1184 if (sscanf(val, "%f", &fval) == 1) {
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1185 if (simulator->frigo_isolation != fval)
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1186 syslog(LOG_NOTICE, "Simulator %s frigo isolation %.1f to %.1f", simulator->uuid, simulator->frigo_isolation, fval);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1187 simulator->frigo_isolation = fval;
281
12a5dbbfd0e3 SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
1188 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1189
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1190 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1191 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1192 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1193 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1194 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1195 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1196 srv_send(s, (char *)"440 No such simulator");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1197 return 0;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1198 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1199
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1200 srv_send(s, (char *)"504 Subcommand error");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1201 return 0;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1202 }
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1203 #endif
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1204
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1205
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
1206
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1207 int delete_Unit(char *uuid)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1208 {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1209 units_list *current = Config.units;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1210 units_list *previous = NULL;
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: 566
diff changeset
1211 prof_step *step, *olds;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1212
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1213 while (current) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1214 if (strcmp(current->uuid, uuid) == 0) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1215 if (previous == NULL) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1216 Config.units = current->next;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1217 free(current->uuid);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1218 current->uuid = NULL;
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: 553
diff changeset
1219 if (current->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: 553
diff changeset
1220 free(current->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: 553
diff changeset
1221 current->product_uuid = 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: 553
diff changeset
1222 if (current->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: 553
diff changeset
1223 free(current->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: 553
diff changeset
1224 current->product_code = 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: 553
diff changeset
1225 if (current->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: 553
diff changeset
1226 free(current->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: 553
diff changeset
1227 current->product_name = NULL;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1228 if (current->air_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1229 free(current->air_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1230 current->air_address = NULL;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1231 if (current->beer_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1232 free(current->beer_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1233 current->beer_address = NULL;
614
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1234 if (current->beer_address2)
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1235 free(current->beer_address2);
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1236 current->beer_address2 = NULL;
518
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1237 if (current->chiller_address)
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1238 free(current->chiller_address);
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1239 current->chiller_address = NULL;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1240 if (current->heater_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1241 free(current->heater_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1242 current->heater_address = NULL;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1243 if (current->cooler_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1244 free(current->cooler_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1245 current->cooler_address = NULL;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1246 if (current->fan_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1247 free(current->fan_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1248 current->fan_address = NULL;
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1249 if (current->light_address)
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1250 free(current->light_address);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1251 current->light_address = NULL;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1252 if (current->door_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1253 free(current->door_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1254 current->door_address = NULL;
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1255 if (current->psu_address)
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1256 free(current->psu_address);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1257 current->psu_address = NULL;
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: 566
diff changeset
1258 if (current->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: 566
diff changeset
1259 free(current->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: 566
diff changeset
1260 current->profile_uuid = 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: 566
diff changeset
1261 if (current->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: 566
diff changeset
1262 free(current->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: 566
diff changeset
1263 current->profile_name = NULL;
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1264 if (current->PID_cool)
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1265 free(current->PID_cool);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1266 current->PID_cool = NULL;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1267 if (current->PID_heat)
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1268 free(current->PID_heat);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1269 current->PID_heat = NULL;
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: 566
diff changeset
1270 if (current->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: 566
diff changeset
1271 for (step = current->profile_steps; step; step = olds) {
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: 566
diff changeset
1272 olds = 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: 566
diff changeset
1273 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: 566
diff changeset
1274 }
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: 566
diff changeset
1275 current->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: 566
diff changeset
1276 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1277 free(current);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1278 return 1;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1279 } else {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1280 free(current->uuid);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1281 current->uuid = NULL;
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: 553
diff changeset
1282 if (current->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: 553
diff changeset
1283 free(current->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: 553
diff changeset
1284 current->product_uuid = 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: 553
diff changeset
1285 if (current->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: 553
diff changeset
1286 free(current->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: 553
diff changeset
1287 current->product_code = 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: 553
diff changeset
1288 if (current->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: 553
diff changeset
1289 free(current->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: 553
diff changeset
1290 current->product_name = NULL;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1291 if (current->air_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1292 free(current->air_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1293 current->air_address = NULL;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1294 if (current->beer_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1295 free(current->beer_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1296 current->beer_address = NULL;
614
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1297 if (current->beer_address2)
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1298 free(current->beer_address2);
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1299 current->beer_address2 = NULL;
518
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1300 if (current->chiller_address)
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1301 free(current->chiller_address);
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1302 current->chiller_address = NULL;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1303 if (current->heater_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1304 free(current->heater_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1305 current->heater_address = NULL;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1306 if (current->cooler_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1307 free(current->cooler_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1308 current->cooler_address = NULL;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1309 if (current->fan_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1310 free(current->fan_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1311 current->fan_address = NULL;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1312 if (current->door_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1313 free(current->door_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1314 current->door_address = NULL;
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1315 if (current->light_address)
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1316 free(current->light_address);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1317 current->light_address = NULL;
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1318 if (current->psu_address)
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1319 free(current->psu_address);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1320 current->psu_address = NULL;
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: 566
diff changeset
1321 if (current->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: 566
diff changeset
1322 free(current->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: 566
diff changeset
1323 current->profile_uuid = 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: 566
diff changeset
1324 if (current->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: 566
diff changeset
1325 free(current->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: 566
diff changeset
1326 current->profile_name = NULL;
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1327 if (current->PID_cool)
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1328 free(current->PID_cool);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1329 current->PID_cool = NULL;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1330 if (current->PID_heat)
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1331 free(current->PID_heat);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1332 current->PID_heat = NULL;
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: 566
diff changeset
1333 if (current->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: 566
diff changeset
1334 for (step = current->profile_steps; step; step = olds) {
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: 566
diff changeset
1335 olds = 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: 566
diff changeset
1336 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: 566
diff changeset
1337 }
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: 566
diff changeset
1338 current->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: 566
diff changeset
1339 }
245
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1340 previous->next = current->next;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1341 free(current);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1342 current = previous->next;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1343 return 1;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1344 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1345 } else {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1346 previous = current;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1347 current = current->next;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1348 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1349 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1350 return 0;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1351 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1352
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1353
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1354
88
12259362595b Added SET commands
Michiel Broek <mbroek@mbse.eu>
parents: 87
diff changeset
1355 /*
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1356 * UNIT ADD name
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1357 * UNIT DEL uuid
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1358 * UNIT LIST
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1359 * UNIT GET uuid
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1360 * UNIT PUT uuid
87
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1361 */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1362 int cmd_unit(int s, char *buf)
87
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1363 {
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1364 char *opt, *param = NULL, *kwd, *val, ibuf[SS_BUFSIZE];
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1365 units_list *unit, *tmpu;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1366 uuid_t uu;
245
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1367 int ival, i, rc, rlen;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1368 float fval;
87
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1369
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1370 opt = strtok(buf, " \0");
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1371 opt = strtok(NULL, " \0");
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1372
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1373 if (opt == NULL) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1374 srv_send(s, (char *)"501 Subcommand missing");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1375 return 0;
87
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1376 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1377 param = strtok(NULL, "\0");
87
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1378
380
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
1379 if (strcmp(opt, (char *)"HELP") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1380 srv_send(s, (char *)"100 Help text follows:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1381 srv_send(s, (char *)"Recognized commands:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1382 srv_send(s, (char *)"UNIT ADD name Add a new Unit with name");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1383 srv_send(s, (char *)"UNIT DEL uuid Delete Unit by uuid");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1384 srv_send(s, (char *)"UNIT LIST List all Units");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1385 srv_send(s, (char *)"UNIT GET uuid Get Unit record by uuid");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1386 srv_send(s, (char *)"UNIT PUT uuid Put Unit record by uuid");
677
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1387 srv_send(s, (char *)"UNIT JSON uuid Get Unit record in json");
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1388 srv_send(s, (char *)".");
380
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
1389 return 0;
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
1390 }
75afd21885f2 Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
1391
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1392 if ((strcmp(opt, (char *)"LIST") == 0) && (param == NULL)) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1393 srv_send(s, (char *)"212 Fermenter list follows:");
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1394 for (unit = Config.units; unit; unit = unit->next) {
566
776a605befa5 Added Carbonation stage.
Michiel Broek <mbroek@mbse.eu>
parents: 564
diff changeset
1395 if (strlen(unit->product_code) && strlen(unit->product_name)) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1396 srv_send(s, (char *)"%s,%s %s,%s", unit->uuid, unit->product_code, unit->product_name, UNITMODE[unit->mode]);
566
776a605befa5 Added Carbonation stage.
Michiel Broek <mbroek@mbse.eu>
parents: 564
diff changeset
1397 } else {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1398 srv_send(s, (char *)"%s,%s,%s", unit->uuid, unit->alias, UNITMODE[unit->mode]);
566
776a605befa5 Added Carbonation stage.
Michiel Broek <mbroek@mbse.eu>
parents: 564
diff changeset
1399 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1400 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1401 srv_send(s, (char *)".");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1402 return 0;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1403 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1404
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1405 if (param == NULL) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1406 srv_send(s, (char *)"502 Parameter missing");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1407 return 0;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1408 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1409
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1410 if (strcmp(opt, (char *)"ADD") == 0) {
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
1411 char an[128];
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
1412
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
1413 sprintf(an, "unit%d", Config.next_unit);
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
1414 Config.next_unit++;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1415 unit = (units_list *)malloc(sizeof(units_list));
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1416 unit->next = NULL;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1417 unit->uuid = malloc(37);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1418 uuid_generate(uu);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1419 uuid_unparse(uu, unit->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: 553
diff changeset
1420 unit->product_uuid = 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: 553
diff changeset
1421 unit->product_code = xstrcpy((char *)"FAKE0000");
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: 553
diff changeset
1422 unit->product_name = xstrcpy(param);
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
1423 unit->alias = xstrcpy(an);
614
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1424 unit->air_address = unit->beer_address = unit->beer_address2 = unit->chiller_address = unit->heater_address = unit->cooler_address = \
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1425 unit->fan_address = unit->door_address = unit->light_address = \
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: 566
diff changeset
1426 unit->psu_address = unit->profile_uuid = unit->profile_name = NULL;
518
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1427 unit->air_idx = unit->beer_idx = unit->chiller_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \
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: 566
diff changeset
1428 unit->door_idx = unit->light_idx = unit->psu_idx = 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: 566
diff changeset
1429 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: 566
diff changeset
1430 unit->profile_steps = NULL;
289
d810df0df36a Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
1431 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
518
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1432 unit->air_state = unit->beer_state = unit->chiller_state = 1;
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1433 unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = 20000;
578
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
1434 unit->beer_set_lo = unit->beer_set_hi = unit->fridge_set_lo = unit->fridge_set_hi = unit->profile_inittemp_lo = unit->profile_inittemp_hi =20.0;
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1435 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = \
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: 578
diff changeset
1436 unit->light_state = unit->light_timer = unit->psu_state = unit->prof_state = unit->stage = 0;
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1437 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1438 unit->light_delay = 1; /* 15 seconds delay */
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1439 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1440 unit->heater_usage = unit->cooler_usage = unit->fan_usage = unit->light_usage = 0;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1441 unit->temp_set_min = 1.0;
604
e2766e538d0e Version 0.9.7. Increased the maximum fermentation temperature to 45 degrees to allow Kveik fermentations.
Michiel Broek <mbroek@mbse.eu>
parents: 599
diff changeset
1442 unit->temp_set_max = 45.0;
289
d810df0df36a Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
1443 unit->prof_started = unit->prof_paused = unit->prof_primary_done = (time_t)0;
284
9e6fb5aed618 Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
1444 unit->prof_percent = 0;
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1445 unit->PID_cool = (pid_var *)malloc(sizeof(pid_var));
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1446 unit->PID_heat = (pid_var *)malloc(sizeof(pid_var));
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1447 InitPID(unit->PID_cool, PID_TYPE_COOL);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1448 InitPID(unit->PID_heat, PID_TYPE_HEAT);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1449
245
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1450 /*
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1451 * Block main process
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1452 */
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1453 run_pause = TRUE;
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1454 for (;;) {
652
16d3d4b58b5b Moved all delay functions into a new general file.
Michiel Broek <mbroek@mbse.eu>
parents: 646
diff changeset
1455 mDelay(100);
245
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1456 if (run_hold)
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1457 break;
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1458 }
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1459
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1460 if (Config.units == NULL) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1461 Config.units = unit;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1462 } else {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1463 for (tmpu = Config.units; tmpu; tmpu = tmpu->next) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1464 if (tmpu->next == NULL) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1465 tmpu->next = unit;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1466 break;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1467 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1468 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1469 }
245
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1470 lcd_buf_reset();
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1471 run_pause = FALSE;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1472
213
2317b8d644fa Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents: 209
diff changeset
1473 syslog(LOG_NOTICE, "Unit %s added", unit->uuid);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1474 srv_send(s, (char *)"211 Unit %s added", unit->uuid);
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1475 return 1;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1476 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1477
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1478 if (strcmp(opt, (char *)"DEL") == 0) {
245
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1479 /*
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1480 * Block main process.
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1481 */
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1482 run_pause = TRUE;
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1483 for (;;) {
652
16d3d4b58b5b Moved all delay functions into a new general file.
Michiel Broek <mbroek@mbse.eu>
parents: 646
diff changeset
1484 mDelay(100);
245
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1485 if (run_hold)
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1486 break;
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1487 }
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1488
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1489 rc = delete_Unit(param);
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1490 lcd_buf_reset();
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1491 run_pause = FALSE;
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1492
b01b6238eb67 You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents: 240
diff changeset
1493 if (rc) {
213
2317b8d644fa Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents: 209
diff changeset
1494 syslog(LOG_NOTICE, "Unit %s deleted", param);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1495 srv_send(s, (char *)"211 Unit %s deleted", param);
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1496 return 1;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1497 } else {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1498 srv_send(s, (char *)"440 No such unit");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1499 return 0;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1500 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1501 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1502
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1503 if (strcmp(opt, (char *)"GET") == 0) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1504 for (unit = Config.units; unit; unit = unit->next) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1505 if (strcmp(param, unit->uuid) == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1506 srv_send(s, (char *)"213 Unit listing follows:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1507 srv_send(s, (char *)"UUID,%s", unit->uuid);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1508 srv_send(s, (char *)"ALIAS,%s", unit->alias);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1509 srv_send(s, (char *)"PRODUCT_NAME,%s", unit->product_name);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1510 srv_send(s, (char *)"PRODUCT_CODE,%s", unit->product_code);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1511 srv_send(s, (char *)"MODE,%s", UNITMODE[unit->mode]);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1512 srv_send(s, (char *)"STAGE,%s", UNITSTAGE[unit->stage]);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1513 srv_send(s, (char *)"VOLUME,%2f", unit->volume);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1514 srv_send(s, (char *)"AIR_ADDRESS,%s", unit->air_address);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1515 srv_send(s, (char *)"AIR_STATE,%s", TEMPSTATE[unit->air_state]);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1516 srv_send(s, (char *)"AIR_TEMPERATURE,%.3f", unit->air_temperature / 1000.0);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1517 srv_send(s, (char *)"AIR_IDX,%d", unit->air_idx);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1518 srv_send(s, (char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address));
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1519 srv_send(s, (char *)"BEER_ADDRESS2,%s", MBSE_SS(unit->beer_address2));
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1520 srv_send(s, (char *)"BEER_STATE,%s", TEMPSTATE[unit->beer_state]);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1521 srv_send(s, (char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1522 srv_send(s, (char *)"BEER_IDX,%d", unit->beer_idx);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1523 srv_send(s, (char *)"CHILLER_ADDRESS,%s", MBSE_SS(unit->chiller_address));
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1524 srv_send(s, (char *)"CHILLER_STATE,%s", TEMPSTATE[unit->chiller_state]);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1525 srv_send(s, (char *)"CHILLER_TEMPERATURE,%.3f", unit->chiller_temperature / 1000.0);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1526 srv_send(s, (char *)"CHILLER_IDX,%d", unit->chiller_idx);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1527 srv_send(s, (char *)"HEATER_ADDRESS,%s", unit->heater_address);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1528 srv_send(s, (char *)"HEATER_STATE,%d", unit->heater_state);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1529 srv_send(s, (char *)"HEATER_DELAY,%d", unit->heater_delay);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1530 srv_send(s, (char *)"HEATER_USAGE,%d", unit->heater_usage);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1531 srv_send(s, (char *)"HEATER_IDX,%d", unit->heater_idx);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1532 if (unit->PID_heat) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1533 srv_send(s, (char *)"PIDH_IMAX,%.1f", unit->PID_heat->iMax);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1534 srv_send(s, (char *)"PIDH_IDLERANGE,%.2f", unit->PID_heat->idleRange);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1535 srv_send(s, (char *)"PIDH_PGAIN,%.3f", unit->PID_heat->pGain);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1536 srv_send(s, (char *)"PIDH_IGAIN,%.3f", unit->PID_heat->iGain);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1537 srv_send(s, (char *)"PIDH_DGAIN,%.3f", unit->PID_heat->dGain);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1538 srv_send(s, (char *)"PIDH_SV,%.2f", unit->PID_heat->SetP);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1539 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1540 srv_send(s, (char *)"COOLER_ADDRESS,%s", unit->cooler_address);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1541 srv_send(s, (char *)"COOLER_STATE,%d", unit->cooler_state);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1542 srv_send(s, (char *)"COOLER_DELAY,%d", unit->cooler_delay);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1543 srv_send(s, (char *)"COOLER_USAGE,%d", unit->cooler_usage);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1544 srv_send(s, (char *)"COOLER_IDX,%d", unit->cooler_idx);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1545 if (unit->PID_cool) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1546 srv_send(s, (char *)"PIDC_IMAX,%.1f", unit->PID_cool->iMax);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1547 srv_send(s, (char *)"PIDC_IDLERANGE,%.2f", unit->PID_cool->idleRange);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1548 srv_send(s, (char *)"PIDC_PGAIN,%.3f", unit->PID_cool->pGain);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1549 srv_send(s, (char *)"PIDC_IGAIN,%.3f", unit->PID_cool->iGain);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1550 srv_send(s, (char *)"PIDC_DGAIN,%.3f", unit->PID_cool->dGain);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1551 srv_send(s, (char *)"PIDC_SV,%.2f", unit->PID_cool->SetP);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1552 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1553 srv_send(s, (char *)"FAN_ADDRESS,%s", unit->fan_address);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1554 srv_send(s, (char *)"FAN_STATE,%d", unit->fan_state);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1555 srv_send(s, (char *)"FAN_DELAY,%d", unit->fan_delay);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1556 srv_send(s, (char *)"FAN_USAGE,%d", unit->fan_usage);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1557 srv_send(s, (char *)"FAN_IDX,%d", unit->fan_idx);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1558 srv_send(s, (char *)"LIGHT_ADDRESS,%s", unit->light_address);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1559 srv_send(s, (char *)"LIGHT_STATE,%d", unit->light_state);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1560 srv_send(s, (char *)"LIGHT_DELAY,%d", unit->light_delay);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1561 srv_send(s, (char *)"LIGHT_USAGE,%d", unit->light_usage);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1562 srv_send(s, (char *)"LIGHT_IDX,%d", unit->light_idx);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1563 srv_send(s, (char *)"DOOR_ADDRESS,%s", unit->door_address);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1564 srv_send(s, (char *)"DOOR_STATE,%d", unit->door_state);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1565 srv_send(s, (char *)"DOOR_IDX,%d", unit->door_idx);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1566 srv_send(s, (char *)"PSU_ADDRESS,%s", unit->psu_address);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1567 srv_send(s, (char *)"PSU_STATE,%d", unit->psu_state);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1568 srv_send(s, (char *)"PSU_IDX,%d", unit->psu_idx);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1569 srv_send(s, (char *)"FRIDGE_SET_LO,%.1f", unit->fridge_set_lo);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1570 srv_send(s, (char *)"FRIDGE_SET_HI,%.1f", unit->fridge_set_hi);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1571 srv_send(s, (char *)"BEER_SET_LO,%.1f", unit->beer_set_lo);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1572 srv_send(s, (char *)"BEER_SET_HI,%.1f", unit->beer_set_hi);
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: 566
diff changeset
1573 if (unit->profile_uuid) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1574 srv_send(s, (char *)"PROFILE_UUID,%s", unit->profile_uuid);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1575 srv_send(s, (char *)"PROFILE_NAME,%s", unit->profile_name);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1576 srv_send(s, (char *)"PROFILE_INITTEMP_LO,%.1f", unit->profile_inittemp_lo);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1577 srv_send(s, (char *)"PROFILE_INITTEMP_HI,%.1f", unit->profile_inittemp_hi);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1578 srv_send(s, (char *)"PROFILE_FRIDGE_MODE,%d", unit->profile_fridge_mode);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1579 srv_send(s, (char *)"PROFILE_DURATION,%d", unit->profile_duration);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1580 srv_send(s, (char *)"PROFILE_TOTALSTEPS,%d", unit->profile_totalsteps);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1581 srv_send(s, (char *)"PROF_STARTED,%d", (int)unit->prof_started);
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: 566
diff changeset
1582 if (unit->prof_state == PROFILE_RUN) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1583 srv_send(s, (char *)"PROF_STATE,%s %d%%", PROFSTATE[unit->prof_state], unit->prof_percent);
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: 566
diff changeset
1584 } else {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1585 srv_send(s, (char *)"PROF_STATE,%s", PROFSTATE[unit->prof_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: 566
diff changeset
1586 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1587 srv_send(s, (char *)"PROF_TARGET_LO,%.3f", unit->prof_target_lo);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1588 srv_send(s, (char *)"PROF_TARGET_HI,%.3f", unit->prof_target_hi);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1589 srv_send(s, (char *)"PROF_FRIDGE_MODE,%d", unit->prof_fridge_mode);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1590 srv_send(s, (char *)"PROF_PEAK_ABS,%.3f", unit->prof_peak_abs);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1591 srv_send(s, (char *)"PROF_PEAK_REL,%.3f", unit->prof_peak_rel);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1592 srv_send(s, (char *)"PROF_PRIMARY_DONE,%d", (int)unit->prof_primary_done);
284
9e6fb5aed618 Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
1593 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1594 srv_send(s, (char *)"TEMP_SET_MIN,%.1f", unit->temp_set_min);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1595 srv_send(s, (char *)"TEMP_SET_MAX,%.1f", unit->temp_set_max);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1596 srv_send(s, (char *)"ALARM,%d", unit->alarm_flag);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1597 srv_send(s, (char *)".");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1598 return 0;
87
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1599 }
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1600 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1601 srv_send(s, (char *)"440 No such unit");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1602 return 0;
87
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1603 }
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
1604
677
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1605 if (strcmp(opt, (char *)"JSON") == 0) {
678
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
1606 syslog(LOG_NOTICE, "UNIT JSON %s", param);
677
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1607 for (unit = Config.units; unit; unit = unit->next) {
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1608 if (strcmp(param, unit->uuid) == 0) {
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1609 char *payload, *payloadu;
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1610
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1611 srv_send(s, (char *)"213 Unit json data follows:");
678
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
1612
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
1613 payload = xstrcpy((char *)"{\"type\":\"fermenter\",\"unit\":\"");
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
1614 payload = xstrcat(payload, unit->alias);
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
1615 payload = xstrcat(payload, (char *)"\",\"metric\":");
cc49115e769e Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents: 677
diff changeset
1616 payloadu = unit_data(unit, false);
677
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1617 payload = xstrcat(payload, payloadu);
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1618 payload = xstrcat(payload, (char *)"}");
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1619 srv_send(s, payload);
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1620 free(payload);
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1621 free(payloadu);
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1622 payload = payloadu = NULL;
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1623 srv_send(s, (char *)".");
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1624 return 0;
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1625 }
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1626 }
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1627 srv_send(s, (char *)"440 No such unit");
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1628 return 0;
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1629 }
c867eb3f7fc1 Server json unit data list added
Michiel Broek <mbroek@mbse.eu>
parents: 676
diff changeset
1630
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1631 if (strcmp(opt, (char *)"PUT") == 0) {
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1632 /*
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1633 * Block main process
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1634 */
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1635 run_pause = TRUE;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1636 for (;;) {
652
16d3d4b58b5b Moved all delay functions into a new general file.
Michiel Broek <mbroek@mbse.eu>
parents: 646
diff changeset
1637 mDelay(100);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1638 if (run_hold)
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1639 break;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1640 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1641
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1642 for (unit = Config.units ; unit; unit = unit->next) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1643 if (strcmp(unit->uuid, param) == 0) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1644 while (1) {
506
cdcd07bbee30 New MQTT protocol
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
1645 unit->mqtt_flag = 0;
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1646 rlen = srv_recv(s, ibuf);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1647 if (rlen == -1) {
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1648 run_pause = FALSE;
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1649 return 0;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1650 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1651 if (strlen(ibuf)) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1652 if (strcmp(ibuf, (char *)".") == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
1653 srv_send(s, (char *)"219 Accepted Unit record");
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1654 run_pause = FALSE;
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
1655 return 1;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1656 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1657 kwd = strtok(ibuf, ",\0");
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1658 val = strtok(NULL, "\0");
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1659 if (kwd) {
506
cdcd07bbee30 New MQTT protocol
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
1660 unit->mqtt_flag = 0;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1661 /*
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1662 * Accept writable data. The client can sent just one line,
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1663 * but may also sent everything. Simply ignore things we
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1664 * don't understand.
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1665 */
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: 553
diff changeset
1666 if (val && (strcmp(kwd, (char *)"PRODUCT_CODE") == 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: 553
diff changeset
1667 if (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: 553
diff changeset
1668 if (strcmp(unit->product_code, val)) {
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: 553
diff changeset
1669 syslog(LOG_NOTICE, "Fermenter unit %s name `%s' to `%s'", unit->uuid, unit->product_code, val);
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: 493
diff changeset
1670 }
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: 553
diff changeset
1671 free(unit->product_code);
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1672 }
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: 553
diff changeset
1673 unit->product_code = xstrcpy(val);
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: 553
diff changeset
1674 unit->mqtt_flag |= MQTT_FLAG_DATA;
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: 553
diff changeset
1675
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: 553
diff changeset
1676 } else if (val && (strcmp(kwd, (char *)"PRODUCT_NAME") == 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: 553
diff changeset
1677 if (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: 553
diff changeset
1678 if (strcmp(unit->product_name, val)) {
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: 553
diff changeset
1679 syslog(LOG_NOTICE, "Fermenter unit %s name `%s' to `%s'", unit->uuid, unit->product_name, val);
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: 553
diff changeset
1680 }
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: 553
diff changeset
1681 free(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: 553
diff changeset
1682 }
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: 553
diff changeset
1683 unit->product_name = xstrcpy(val);
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: 506
diff changeset
1684 unit->mqtt_flag |= MQTT_FLAG_DATA;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1685
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1686 } else if (val && (strcmp(kwd, (char *)"VOLUME") == 0)) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1687 if (sscanf(val, "%f", &fval) == 1) {
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1688 if (unit->volume != fval)
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1689 syslog(LOG_NOTICE, "Fermenter unit %s volume %.3f to %.3f", unit->uuid, unit->volume, fval);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1690 unit->volume = fval;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1691 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1692
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1693 } else if (strcmp(kwd, (char *)"AIR_ADDRESS") == 0) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1694 if (val && unit->air_address && (strcmp(val, unit->air_address)))
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1695 syslog(LOG_NOTICE, "Fermenter unit %s air address `%s' to `%s'", unit->uuid, unit->air_address, val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1696 if (unit->air_address) {
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1697 device_count(FALSE, unit->air_address);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1698 free(unit->air_address);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1699 }
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1700 if (val) {
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1701 unit->air_address = xstrcpy(val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1702 device_count(TRUE, unit->air_address);
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1703 } else
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1704 unit->air_address = 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: 506
diff changeset
1705 unit->mqtt_flag |= MQTT_FLAG_DATA;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1706
513
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1707 } else if (val && (strcmp(kwd, (char *)"AIR_IDX") == 0)) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1708 if (sscanf(val, "%d", &ival) == 1) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1709 if (unit->air_idx != ival)
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1710 syslog(LOG_NOTICE, "Fermenter unit %s air idx %d to %d", unit->uuid, unit->air_idx, ival);
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1711 unit->air_idx = ival;
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1712 }
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1713
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1714 } else if (strcmp(kwd, (char *)"BEER_ADDRESS") == 0) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1715 if (val && unit->beer_address && (strcmp(val, unit->beer_address)))
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1716 syslog(LOG_NOTICE, "Fermenter unit %s beer address `%s' to `%s'", unit->uuid, unit->beer_address, val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1717 if (unit->beer_address) {
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1718 device_count(FALSE, unit->beer_address);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1719 free(unit->beer_address);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1720 }
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1721 if (val) {
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1722 unit->beer_address = xstrcpy(val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1723 device_count(TRUE, unit->beer_address);
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1724 } else
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1725 unit->beer_address = 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: 506
diff changeset
1726 unit->mqtt_flag |= MQTT_FLAG_DATA;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1727
614
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1728 } else if (strcmp(kwd, (char *)"BEER_ADDRESS2") == 0) {
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1729 if (val && unit->beer_address2 && (strcmp(val, unit->beer_address2)))
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1730 syslog(LOG_NOTICE, "Fermenter unit %s beer address alt `%s' to `%s'", unit->uuid, unit->beer_address2, val);
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1731 if (unit->beer_address2) {
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1732 device_count(FALSE, unit->beer_address2);
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1733 free(unit->beer_address2);
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1734 }
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1735 if (val) {
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1736 unit->beer_address2 = xstrcpy(val);
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1737 device_count(TRUE, unit->beer_address2);
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1738 } else
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1739 unit->beer_address2 = NULL;
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1740 unit->mqtt_flag |= MQTT_FLAG_DATA;
389097dc665d Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.
Michiel Broek <mbroek@mbse.eu>
parents: 606
diff changeset
1741
513
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1742 } else if (val && (strcmp(kwd, (char *)"BEER_IDX") == 0)) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1743 if (sscanf(val, "%d", &ival) == 1) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1744 if (unit->beer_idx != ival)
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1745 syslog(LOG_NOTICE, "Fermenter unit %s beer idx %d to %d", unit->uuid, unit->beer_idx, ival);
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1746 unit->beer_idx = ival;
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1747 }
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1748
518
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1749 } else if (strcmp(kwd, (char *)"CHILLER_ADDRESS") == 0) {
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1750 if (val && unit->chiller_address && (strcmp(val, unit->chiller_address)))
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1751 syslog(LOG_NOTICE, "Fermenter unit %s chiller address `%s' to `%s'", unit->uuid, unit->chiller_address, val);
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1752 if (unit->chiller_address) {
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1753 device_count(FALSE, unit->chiller_address);
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1754 free(unit->chiller_address);
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1755 }
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1756 if (val) {
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1757 unit->chiller_address = xstrcpy(val);
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1758 device_count(TRUE, unit->chiller_address);
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1759 } else
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1760 unit->chiller_address = NULL;
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1761 unit->mqtt_flag |= MQTT_FLAG_DATA;
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1762
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1763 } else if (val && (strcmp(kwd, (char *)"CHILLER_IDX") == 0)) {
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1764 if (sscanf(val, "%d", &ival) == 1) {
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1765 if (unit->chiller_idx != ival)
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1766 syslog(LOG_NOTICE, "Fermenter unit %s chiller idx %d to %d", unit->uuid, unit->chiller_idx, ival);
520
32bf084df5af Fix storing beer_idx value
Michiel Broek <mbroek@mbse.eu>
parents: 518
diff changeset
1767 unit->chiller_idx = ival;
518
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1768 }
fd36bedab944 Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents: 513
diff changeset
1769
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1770 } else if (strcmp(kwd, (char *)"HEATER_ADDRESS") == 0) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1771 if (val && unit->heater_address && (strcmp(val, unit->heater_address)))
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1772 syslog(LOG_NOTICE, "Fermenter unit %s heater address `%s' to `%s'", unit->uuid, unit->heater_address, val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1773 if (unit->heater_address) {
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1774 device_count(FALSE, unit->heater_address);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1775 free(unit->heater_address);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1776 }
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1777 if (val) {
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1778 unit->heater_address = xstrcpy(val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1779 device_count(TRUE, unit->heater_address);
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1780 } else
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1781 unit->heater_address = 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: 506
diff changeset
1782 unit->mqtt_flag |= MQTT_FLAG_DATA;
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1783
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1784 } else if (val && (strcmp(kwd, (char *)"HEATER_STATE") == 0)) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1785 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) {
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1786 if (unit->heater_state != ival)
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1787 syslog(LOG_NOTICE, "Fermenter unit %s heater state %d to %d", unit->uuid, unit->heater_state, ival);
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1788 unit->heater_state = ival;
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: 506
diff changeset
1789 unit->mqtt_flag |= MQTT_FLAG_DATA;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1790 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1791
513
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1792 } else if (val && (strcmp(kwd, (char *)"HEATER_IDX") == 0)) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1793 if (sscanf(val, "%d", &ival) == 1) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1794 if (unit->heater_idx != ival)
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1795 syslog(LOG_NOTICE, "Fermenter unit %s heater idx %d to %d", unit->uuid, unit->heater_idx, ival);
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1796 unit->heater_idx = ival;
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1797 }
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1798
270
df81d583c2c3 The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
1799 } else if (val && (strcmp(kwd, (char *)"HEATER_DELAY") == 0)) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1800 if (sscanf(val, "%d", &ival) == 1) {
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1801 if (unit->heater_delay != ival)
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1802 syslog(LOG_NOTICE, "Fermenter unit %s heater delay %d to %d", unit->uuid, unit->heater_delay, ival);
270
df81d583c2c3 The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
1803 unit->heater_delay = ival;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1804 }
270
df81d583c2c3 The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
1805
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1806 } else if (strcmp(kwd, (char *)"COOLER_ADDRESS") == 0) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1807 if (val && unit->cooler_address && (strcmp(val, unit->cooler_address)))
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1808 syslog(LOG_NOTICE, "Fermenter unit %s cooler address `%s' to `%s'", unit->uuid, unit->cooler_address, val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1809 if (unit->cooler_address) {
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1810 device_count(FALSE, unit->cooler_address);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1811 free(unit->cooler_address);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1812 }
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1813 if (val) {
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1814 unit->cooler_address = xstrcpy(val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1815 device_count(TRUE, unit->cooler_address);
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1816 } else
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1817 unit->cooler_address = 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: 506
diff changeset
1818 unit->mqtt_flag |= MQTT_FLAG_DATA;
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1819
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1820 } else if (val && (strcmp(kwd, (char *)"COOLER_STATE") == 0)) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1821 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) {
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1822 if (unit->cooler_state != ival)
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1823 syslog(LOG_NOTICE, "Fermenter unit %s cooler state %d to %d", unit->uuid, unit->cooler_state, ival);
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1824 unit->cooler_state = ival;
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: 506
diff changeset
1825 unit->mqtt_flag |= MQTT_FLAG_DATA;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1826 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1827
270
df81d583c2c3 The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
1828 } else if (val && (strcmp(kwd, (char *)"COOLER_DELAY") == 0)) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1829 if (sscanf(val, "%d", &ival) == 1) {
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1830 if (unit->cooler_delay != ival)
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1831 syslog(LOG_NOTICE, "Fermenter unit %s cooler delay %d to %d", unit->uuid, unit->cooler_delay, ival);
270
df81d583c2c3 The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
1832 unit->cooler_delay = ival;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1833 }
270
df81d583c2c3 The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
1834
513
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1835 } else if (val && (strcmp(kwd, (char *)"COOLER_IDX") == 0)) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1836 if (sscanf(val, "%d", &ival) == 1) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1837 if (unit->cooler_idx != ival)
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1838 syslog(LOG_NOTICE, "Fermenter unit %s cooler idx %d to %d", unit->uuid, unit->cooler_idx, ival);
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1839 unit->cooler_idx = ival;
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1840 }
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1841
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1842 } else if (strcmp(kwd, (char *)"FAN_ADDRESS") == 0) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1843 if (val && unit->fan_address && (strcmp(val, unit->fan_address)))
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1844 syslog(LOG_NOTICE, "Fermenter unit %s fan address `%s' to `%s'", unit->uuid, unit->fan_address, val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1845 if (unit->fan_address) {
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1846 device_count(FALSE, unit->fan_address);
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1847 free(unit->fan_address);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1848 }
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1849 if (val) {
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1850 unit->fan_address = xstrcpy(val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1851 device_count(TRUE, unit->fan_address);
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1852 } else
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1853 unit->fan_address = 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: 506
diff changeset
1854 unit->mqtt_flag |= MQTT_FLAG_DATA;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1855
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1856 } else if (val && (strcmp(kwd, (char *)"FAN_STATE") == 0)) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1857 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) {
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1858 if (unit->fan_state != ival)
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1859 syslog(LOG_NOTICE, "Fermenter unit %s fan state %d to %d", unit->uuid, unit->fan_state, ival);
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1860 unit->fan_state = ival;
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: 506
diff changeset
1861 unit->mqtt_flag |= MQTT_FLAG_DATA;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1862 }
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1863
270
df81d583c2c3 The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
1864 } else if (val && (strcmp(kwd, (char *)"FAN_DELAY") == 0)) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1865 if (sscanf(val, "%d", &ival) == 1) {
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1866 if (unit->fan_delay != ival)
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1867 syslog(LOG_NOTICE, "Fermenter unit %s fan delay %d to %d", unit->uuid, unit->fan_delay, ival);
270
df81d583c2c3 The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
1868 unit->fan_delay = ival;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1869 }
270
df81d583c2c3 The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
1870
513
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1871 } else if (val && (strcmp(kwd, (char *)"FAN_IDX") == 0)) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1872 if (sscanf(val, "%d", &ival) == 1) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1873 if (unit->fan_idx != ival)
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1874 syslog(LOG_NOTICE, "Fermenter unit %s fan idx %d to %d", unit->uuid, unit->fan_idx, ival);
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1875 unit->fan_idx = ival;
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1876 }
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1877
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1878 } else if (strcmp(kwd, (char *)"LIGHT_ADDRESS") == 0) {
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1879 if (val && unit->light_address && (strcmp(val, unit->light_address)))
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1880 syslog(LOG_NOTICE, "Fermenter unit %s light address `%s' to `%s'", unit->uuid, unit->light_address, val);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1881 if (unit->light_address) {
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1882 device_count(FALSE, unit->light_address);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1883 free(unit->light_address);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1884 }
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1885 if (val) {
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1886 unit->light_address = xstrcpy(val);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1887 device_count(TRUE, unit->light_address);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1888 } else
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1889 unit->light_address = 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: 506
diff changeset
1890 unit->mqtt_flag |= MQTT_FLAG_DATA;
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1891
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1892 } else if (val && (strcmp(kwd, (char *)"LIGHT_STATE") == 0)) {
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1893 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) {
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1894 if (unit->light_state != ival)
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1895 syslog(LOG_NOTICE, "Fermenter unit %s light state %d to %d", unit->uuid, unit->light_state, ival);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1896 unit->light_state = ival;
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: 506
diff changeset
1897 unit->mqtt_flag |= MQTT_FLAG_DATA;
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1898 }
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1899
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1900 } else if (val && (strcmp(kwd, (char *)"LIGHT_DELAY") == 0)) {
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1901 if (sscanf(val, "%d", &ival) == 1) {
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1902 if (unit->light_delay != ival)
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1903 syslog(LOG_NOTICE, "Fermenter unit %s light delay %d to %d", unit->uuid, unit->light_delay, ival);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1904 unit->light_delay = ival;
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1905 }
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1906
513
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1907 } else if (val && (strcmp(kwd, (char *)"LIGHT_IDX") == 0)) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1908 if (sscanf(val, "%d", &ival) == 1) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1909 if (unit->light_idx != ival)
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1910 syslog(LOG_NOTICE, "Fermenter unit %s light idx %d to %d", unit->uuid, unit->light_idx, ival);
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1911 unit->light_idx = ival;
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1912 }
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1913
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1914 } else if (strcmp(kwd, (char *)"DOOR_ADDRESS") == 0) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1915 if (val && unit->door_address && (strcmp(val, unit->door_address)))
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1916 syslog(LOG_NOTICE, "Fermenter unit %s door address `%s' to `%s'", unit->uuid, unit->door_address, val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1917 if (unit->door_address) {
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1918 device_count(FALSE, unit->door_address);
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1919 free(unit->door_address);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1920 }
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1921 if (val) {
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1922 unit->door_address = xstrcpy(val);
179
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1923 device_count(TRUE, unit->door_address);
417ee898fb02 Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
1924 } else
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1925 unit->door_address = NULL;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1926
513
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1927 } else if (val && (strcmp(kwd, (char *)"DOOR_IDX") == 0)) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1928 if (sscanf(val, "%d", &ival) == 1) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1929 if (unit->door_idx != ival)
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1930 syslog(LOG_NOTICE, "Fermenter unit %s door idx %d to %d", unit->uuid, unit->door_idx, ival);
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1931 unit->door_idx = ival;
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1932 }
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1933
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1934 } else if (strcmp(kwd, (char *)"PSU_ADDRESS") == 0) {
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1935 if (val && unit->psu_address && (strcmp(val, unit->psu_address)))
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1936 syslog(LOG_NOTICE, "Fermenter unit %s psu address `%s' to `%s'", unit->uuid, unit->psu_address, val);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1937 if (unit->psu_address) {
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1938 device_count(FALSE, unit->psu_address);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1939 free(unit->psu_address);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1940 }
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1941 if (val) {
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1942 unit->psu_address = xstrcpy(val);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1943 device_count(TRUE, unit->psu_address);
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1944 } else
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1945 unit->psu_address = 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: 506
diff changeset
1946 unit->mqtt_flag |= MQTT_FLAG_DATA;
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1947
513
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1948 } else if (val && (strcmp(kwd, (char *)"PSU_IDX") == 0)) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1949 if (sscanf(val, "%d", &ival) == 1) {
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1950 if (unit->psu_idx != ival)
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1951 syslog(LOG_NOTICE, "Fermenter unit %s psu idx %d to %d", unit->uuid, unit->psu_idx, ival);
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1952 unit->psu_idx = ival;
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1953 }
a2732027afb3 Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 510
diff changeset
1954
564
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1955 } else if (val && (strcmp(kwd, (char *)"STAGE") == 0)) {
566
776a605befa5 Added Carbonation stage.
Michiel Broek <mbroek@mbse.eu>
parents: 564
diff changeset
1956 for (i = 0; i < 4; i++) {
564
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1957 if (strcmp(val, UNITSTAGE[i]) == 0) {
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1958 if (i != unit->stage) {
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1959 syslog(LOG_NOTICE, "Fermenter unit %s stage %s to %s", unit->uuid, UNITSTAGE[unit->stage], UNITSTAGE[i]);
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1960 unit->mqtt_flag |= MQTT_FLAG_DATA;
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1961 }
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1962 unit->stage = i;
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1963 break;
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1964 }
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1965 }
3fc61dd28656 Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents: 562
diff changeset
1966
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1967 } else if (val && (strcmp(kwd, (char *)"MODE") == 0)) {
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1968 for (i = 0; i < 5; i++) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1969 if (strcmp(val, UNITMODE[i]) == 0) {
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: 529
diff changeset
1970 unit->mqtt_flag |= MQTT_FLAG_DATA;
189
cc2b04d4db99 Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
1971 /* Initialize log if the unit is turned on */
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: 529
diff changeset
1972 if ((unit->mode == UNITMODE_OFF) && (i != UNITMODE_OFF)) {
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: 529
diff changeset
1973 unit->mqtt_flag |= MQTT_FLAG_BIRTH;
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: 529
diff changeset
1974 }
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
1975 syslog(LOG_NOTICE, "Fermenter unit %s mode %s to %s", unit->uuid, UNITMODE[unit->mode], UNITMODE[i]);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1976 unit->mode = i;
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
1977 /* Allways turn everything off after a mode change */
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1978 unit->PID_cool->OutP = unit->PID_heat->OutP = 0.0;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1979 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: 578
diff changeset
1980 unit->heater_state = unit->cooler_state = unit->fan_state = unit->light_state = unit->light_timer = 0;
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1981 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
184
db997a04fde3 Fixed switching problems
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
1982 device_out(unit->heater_address, unit->heater_state);
db997a04fde3 Fixed switching problems
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
1983 device_out(unit->cooler_address, unit->cooler_state);
db997a04fde3 Fixed switching problems
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
1984 device_out(unit->fan_address, unit->fan_state);
306
97602274eb58 Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents: 303
diff changeset
1985 device_out(unit->light_address, unit->light_state);
237
51a294d683cd Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents: 235
diff changeset
1986 if (unit->mode == UNITMODE_PROFILE) {
51a294d683cd Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents: 235
diff changeset
1987 /*
51a294d683cd Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents: 235
diff changeset
1988 * Set a sane default until it will be overruled by the
51a294d683cd Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents: 235
diff changeset
1989 * main processing loop.
51a294d683cd Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents: 235
diff changeset
1990 */
397
00ca08f5a6f8 Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
1991 unit->prof_target_lo = unit->prof_target_hi = 20.0;
00ca08f5a6f8 Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
1992 unit->prof_fridge_mode = 0;
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: 566
diff changeset
1993 if (unit->profile_uuid) {
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: 506
diff changeset
1994 unit->mqtt_flag |= MQTT_FLAG_DATA;
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: 493
diff changeset
1995 }
237
51a294d683cd Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents: 235
diff changeset
1996 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1997 break;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1998 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
1999 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2000
578
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2001 } else if (val && (strcmp(kwd, (char *)"FRIDGE_SET_LO") == 0)) {
246
6df404da3537 Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents: 245
diff changeset
2002 if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) {
578
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2003 if (unit->fridge_set_lo != fval)
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2004 syslog(LOG_NOTICE, "Fermenter unit %s fridge temp low %.1f to %.1f", unit->uuid, unit->fridge_set_lo, fval);
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2005 unit->fridge_set_lo = fval;
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: 506
diff changeset
2006 unit->mqtt_flag |= MQTT_FLAG_DATA;
246
6df404da3537 Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents: 245
diff changeset
2007 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2008
578
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2009 } else if (val && (strcmp(kwd, (char *)"FRIDGE_SET_HI") == 0)) {
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2010 if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) {
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2011 if (unit->fridge_set_hi != fval)
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2012 syslog(LOG_NOTICE, "Fermenter unit %s fridge temp high %.1f to %.1f", unit->uuid, unit->fridge_set_hi, fval);
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2013 unit->fridge_set_hi = fval;
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2014 unit->mqtt_flag |= MQTT_FLAG_DATA;
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2015 }
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2016
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2017 } else if (val && (strcmp(kwd, (char *)"BEER_SET_LO") == 0)) {
246
6df404da3537 Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents: 245
diff changeset
2018 if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) {
578
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2019 if (unit->beer_set_lo != fval)
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2020 syslog(LOG_NOTICE, "Fermenter unit %s beer temp low %.1f to %.1f", unit->uuid, unit->beer_set_lo, fval);
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2021 unit->beer_set_lo = fval;
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2022 unit->mqtt_flag |= MQTT_FLAG_DATA;
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2023 }
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2024
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2025 } else if (val && (strcmp(kwd, (char *)"BEER_SET_HI") == 0)) {
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2026 if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) {
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2027 if (unit->beer_set_hi != fval)
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2028 syslog(LOG_NOTICE, "Fermenter unit %s beer temp high %.1f to %.1f", unit->uuid, unit->beer_set_hi, fval);
d694abd9d809 Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents: 575
diff changeset
2029 unit->beer_set_hi = fval;
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: 506
diff changeset
2030 unit->mqtt_flag |= MQTT_FLAG_DATA;
246
6df404da3537 Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents: 245
diff changeset
2031 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2032
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2033 } else if (val && (strcmp(kwd, (char *)"PIDC_IMAX") == 0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2034 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2035 if (unit->PID_cool->iMax != fval)
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2036 syslog(LOG_NOTICE, "Fermenter unit %s PID_cool iGain %.1f to %.1f", unit->uuid, unit->PID_cool->iMax, fval);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2037 unit->PID_cool->iMax = fval;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2038 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2039
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2040 } else if (val && (strcmp(kwd, (char *)"PIDC_PGAIN") == 0)) {
310
53774295e14a Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents: 306
diff changeset
2041 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2042 if (unit->PID_cool->pGain != fval)
493
04d726035afe Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents: 492
diff changeset
2043 syslog(LOG_NOTICE, "Fermenter unit %s PID_cool pGain %.3f to %.3f", unit->uuid, unit->PID_cool->pGain, fval);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2044 unit->PID_cool->pGain = fval;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2045 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2046
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2047 } else if (val && (strcmp(kwd, (char *)"PIDC_DGAIN") == 0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2048 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2049 if (unit->PID_cool->dGain != fval)
493
04d726035afe Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents: 492
diff changeset
2050 syslog(LOG_NOTICE, "Fermenter unit %s PID_cool dGain %.3f to %.3f", unit->uuid, unit->PID_cool->dGain, fval);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2051 unit->PID_cool->dGain = fval;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2052 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2053
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2054 } else if (val && (strcmp(kwd, (char *)"PIDC_IGAIN") == 0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2055 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2056 if (unit->PID_cool->iGain != fval)
493
04d726035afe Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents: 492
diff changeset
2057 syslog(LOG_NOTICE, "Fermenter unit %s PID_cool iGain %.3f to %.3f", unit->uuid, unit->PID_cool->iGain, fval);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2058 unit->PID_cool->iGain = fval;
310
53774295e14a Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents: 306
diff changeset
2059 }
53774295e14a Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents: 306
diff changeset
2060
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2061 } else if (val && (strcmp(kwd, (char *)"PIDC_IDLERANGE") == 0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2062 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2063 if (unit->PID_cool->idleRange != fval)
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2064 syslog(LOG_NOTICE, "Fermenter unit %s PID_cool idleRange %.2f to %.2f", unit->uuid, unit->PID_cool->idleRange, fval);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2065 unit->PID_cool->idleRange = fval;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2066 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2067
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2068 } else if (val && (strcmp(kwd, (char *)"PIDH_IMAX") == 0)) {
310
53774295e14a Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents: 306
diff changeset
2069 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2070 if (unit->PID_heat->iMax != fval)
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2071 syslog(LOG_NOTICE, "Fermenter unit %s PID_heat iGain %.1f to %.1f", unit->uuid, unit->PID_heat->iMax, fval);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2072 unit->PID_heat->iMax = fval;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2073 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2074
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2075 } else if (val && (strcmp(kwd, (char *)"PIDH_PGAIN") == 0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2076 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2077 if (unit->PID_heat->pGain != fval)
493
04d726035afe Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents: 492
diff changeset
2078 syslog(LOG_NOTICE, "Fermenter unit %s PID_heat pGain %.3f to %.3f", unit->uuid, unit->PID_heat->pGain, fval);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2079 unit->PID_heat->pGain = fval;
310
53774295e14a Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents: 306
diff changeset
2080 }
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2081
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2082 } else if (val && (strcmp(kwd, (char *)"PIDH_DGAIN") == 0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2083 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2084 if (unit->PID_heat->dGain != fval)
493
04d726035afe Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents: 492
diff changeset
2085 syslog(LOG_NOTICE, "Fermenter unit %s PID_heat dGain %.3f to %.3f", unit->uuid, unit->PID_heat->dGain, fval);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2086 unit->PID_heat->dGain = fval;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2087 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2088
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2089 } else if (val && (strcmp(kwd, (char *)"PIDH_IGAIN") == 0)) {
310
53774295e14a Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents: 306
diff changeset
2090 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2091 if (unit->PID_heat->iGain != fval)
493
04d726035afe Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents: 492
diff changeset
2092 syslog(LOG_NOTICE, "Fermenter unit %s PIH_heat iGain %.3f to %.3f", unit->uuid, unit->PID_heat->iGain, fval);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2093 unit->PID_heat->iGain = fval;
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2094 }
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2095
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2096 } else if (val && (strcmp(kwd, (char *)"PIDH_IDLERANGE") == 0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2097 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2098 if (unit->PID_heat->idleRange != fval)
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2099 syslog(LOG_NOTICE, "Fermenter unit %s PID_heat idleRange %.2f to %.2f", unit->uuid, unit->PID_heat->idleRange, fval);
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2100 unit->PID_heat->idleRange = fval;
310
53774295e14a Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents: 306
diff changeset
2101 }
53774295e14a Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents: 306
diff changeset
2102
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: 566
diff changeset
2103 } else if (val && (strcmp(kwd, (char *)"PROF_STATE") == 0) && unit->profile_uuid) {
217
2922d439ff63 Added profile state ABORT
Michiel Broek <mbroek@mbse.eu>
parents: 213
diff changeset
2104 for (i = 0; i < 5; i++) {
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2105 if (strcmp(val, PROFSTATE[i]) == 0) {
219
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2106 switch (i) {
274
111b0e9663dc Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
2107 case PROFILE_OFF: if (unit->prof_state == PROFILE_DONE) {
219
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2108 unit->prof_state = PROFILE_OFF;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2109 syslog(LOG_NOTICE, "Fermenter unit %s profile to OFF", unit->uuid);
274
111b0e9663dc Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
2110 }
219
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2111 break;
274
111b0e9663dc Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
2112 case PROFILE_PAUSE: if (unit->prof_state == PROFILE_RUN) {
219
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2113 unit->prof_state = PROFILE_PAUSE;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2114 syslog(LOG_NOTICE, "Fermenter unit %s profile PAUSE", unit->uuid);
274
111b0e9663dc Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
2115 } else if (unit->prof_state == PROFILE_PAUSE) {
219
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2116 unit->prof_state = PROFILE_RUN;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2117 syslog(LOG_NOTICE, "Fermenter unit %s profile RESUME", unit->uuid);
274
111b0e9663dc Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.
Michiel Broek <mbroek@mbse.eu>
parents: 273
diff changeset
2118 }
219
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2119 break;
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2120 case PROFILE_RUN: if (unit->prof_state == PROFILE_OFF) {
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2121 unit->prof_state = PROFILE_RUN;
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2122 unit->prof_started = time(NULL);
289
d810df0df36a Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
2123 unit->prof_paused = unit->prof_primary_done = 0;
d810df0df36a Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents: 285
diff changeset
2124 unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2125 syslog(LOG_NOTICE, "Fermenter unit %s profile to RUN", unit->uuid);
219
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2126 }
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2127 break;
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2128 case PROFILE_DONE: break; /* Command is illegal */
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2129 case PROFILE_ABORT: if ((unit->prof_state == PROFILE_RUN) || (unit->prof_state == PROFILE_PAUSE)) {
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2130 unit->prof_state = PROFILE_OFF;
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: 566
diff changeset
2131 unit->prof_started = unit->prof_paused = unit->prof_primary_done = 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: 566
diff changeset
2132 unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2133 syslog(LOG_NOTICE, "Fermenter unit %s profile ABORT", unit->uuid);
219
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2134 }
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2135 break;
ae720212accc Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
2136 }
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: 506
diff changeset
2137 unit->mqtt_flag |= MQTT_FLAG_DATA;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2138 break;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2139 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2140 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2141
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
2142 } else if (val && (strcmp(kwd, (char *)"TEMP_SET_MIN") == 0)) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2143 if (sscanf(val, "%f", &fval) == 1) {
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2144 if (unit->temp_set_min != fval)
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2145 syslog(LOG_NOTICE, "Fermenter unit %s temperature set minimum %.1f to %.1f", unit->uuid, unit->temp_set_min, fval);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2146 unit->temp_set_min = fval;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2147 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2148
178
988a898974f3 Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
2149 } else if (val && (strcmp(kwd, (char *)"TEMP_SET_MAX") == 0)) {
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2150 if (sscanf(val, "%f", &fval) == 1) {
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2151 if (unit->temp_set_max != fval)
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2152 syslog(LOG_NOTICE, "Fermenter unit %s temperature set maximum %.1f to %.1f", unit->uuid, unit->temp_set_max, fval);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2153 unit->temp_set_max = fval;
282
885e5243bb50 UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents: 281
diff changeset
2154 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2155
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2156 }
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: 529
diff changeset
2157 if (unit->mqtt_flag) {
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: 529
diff changeset
2158 if (unit->mqtt_flag & MQTT_FLAG_BIRTH) {
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: 529
diff changeset
2159 publishDBirth(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: 529
diff changeset
2160 } else {
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: 529
diff changeset
2161 publishDData(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: 529
diff changeset
2162 }
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: 529
diff changeset
2163 if (unit->mqtt_flag & MQTT_FLAG_DEATH) {
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: 529
diff changeset
2164 publishDDeath(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: 529
diff changeset
2165 }
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: 529
diff changeset
2166 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2167 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2168 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2169 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2170 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2171 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2172 srv_send(s, (char *)"440 No such unit");
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2173 run_pause = FALSE;
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
2174 return 0;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2175 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2176
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2177 srv_send(s, (char *)"504 Subcommand error");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
2178 return 0;
87
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
2179 }
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
2180
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
2181
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
2182
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2183 void cmd_server(int s)
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2184 {
132
8bd209d1c020 Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
2185 char buf[SS_BUFSIZE];
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2186 int rlen;
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2187
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2188 rlen = srv_recv(s, buf);
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
2189 if (rlen != -1) {
48
d8c64f81b192 Single client server works
Michiel Broek <mbroek@mbse.eu>
parents: 46
diff changeset
2190 if (strlen(buf)) {
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2191 /*
48
d8c64f81b192 Single client server works
Michiel Broek <mbroek@mbse.eu>
parents: 46
diff changeset
2192 * Process commands from the client
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2193 */
592
ff30227c0903 Removed ARCHIVER commands and web pages.
Michiel Broek <mbroek@mbse.eu>
parents: 591
diff changeset
2194 if (strncmp(buf, "DEVICE", 6) == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2195 if (cmd_device(s, buf))
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 170
diff changeset
2196 wrconfig();
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
2197
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
2198 } else if (strncmp(buf, "GLOBAL", 6) == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2199 if (cmd_global(s, buf))
206
78fb6f99e473 Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
2200 wrconfig();
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
2201
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 79
diff changeset
2202 } else if (strncmp(buf, "HELP", 4) == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2203 srv_send(s, (char *)"100 Help text follows");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2204 srv_send(s, (char *)"Recognized commands:");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2205 srv_send(s, (char *)"");
132
8bd209d1c020 Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
2206 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2207 srv_send(s, (char *)"DEVICE <CMD> [parameters] Device commands");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2208 srv_send(s, (char *)"DEVICE HELP Device help screen");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2209 srv_send(s, (char *)"GLOBAL <CMD> [parameters] Global commands");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2210 srv_send(s, (char *)"GLOBAL HELP Global help screen");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2211 srv_send(s, (char *)"LIST <CMD> [parameters] List commands");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2212 srv_send(s, (char *)"LIST HELP List help screen");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2213 srv_send(s, (char *)"PING Check if server is alive");
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
2214 #ifdef USE_SIMULATOR
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2215 srv_send(s, (char *)"SIMULATOR <CMD> [parameters] Simulator commands");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2216 srv_send(s, (char *)"SIMULATOR HELP Simulator help screen");
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
2217 #endif
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2218 srv_send(s, (char *)"UNIT <CMD> [parameters] Unit commands");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2219 srv_send(s, (char *)"UNIT HELP Unit help screen");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2220 srv_send(s, (char *)".");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
2221
81
547bbe344886 Added list command
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
2222 } else if (strncmp(buf, "LIST", 4) == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2223 cmd_list(s, buf);
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
2224
303
19a9a3912d03 Added PING/PONG command to the server. Bumped to version 0.2.7
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
2225 } else if (strncmp(buf, "PING", 4) == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2226 srv_send(s, (char *)"101 PONG");
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
2227
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
2228 #ifdef USE_SIMULATOR
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
2229 } else if (strncmp(buf, "SIMULATOR", 9) == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2230 if (cmd_simulator(s, buf))
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
2231 wrconfig();
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
2232
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
2233 #endif
87
55f1315c94f1 Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
2234 } else if (strncmp(buf, "UNIT", 4) == 0) {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2235 if (cmd_unit(s, buf))
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
2236 wrconfig();
381
b22f8bf63b17 Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
2237
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2238 } else {
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2239 srv_send(s, (char *)"500 Unknown command");
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2240 }
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2241 }
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2242 }
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2243
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2244 close(s);
42
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2245 }
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2246
01b96a24ae7c Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2247
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2248 static void cleanup_handler(void *arg)
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2249 {
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2250 syslog(LOG_NOTICE, "Thread my_server_loop stopped (cleanup_handler)");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2251 close(ls);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2252 my_server_state = 0;
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2253 }
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2254
132
8bd209d1c020 Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
2255
74
879bd09e2b96 Reinstalled threads
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
2256 void *my_server_loop(void *threadid)
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2257 {
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2258 socklen_t addrlen;
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2259 int s, optval = 1;
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2260
646
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 645
diff changeset
2261 my_server_state = 1;
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2262 syslog(LOG_NOTICE, "Thread my_server_loop started");
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2263
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2264 /*
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2265 * Prepare thread to stop in blocking accept() call.
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2266 */
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2267 pthread_cleanup_push(cleanup_handler, NULL);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2268 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2269 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2270
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2271 memset((char *)&myaddr_in, 0, sizeof(struct sockaddr_in));
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2272 memset((char *)&peeraddr_in, 0, sizeof(struct sockaddr_in));
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2273 myaddr_in.sin_family = AF_INET;
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2274 myaddr_in.sin_addr.s_addr = INADDR_ANY;
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2275 myaddr_in.sin_port = htons(Config.my_port);
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2276
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2277 ls = socket(AF_INET, SOCK_STREAM, 0);
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2278 if (ls == -1) {
268
dda91dfa4aa8 All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
2279 syslog(LOG_NOTICE, "Can't create listen socket: %s", strerror(errno));
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2280 fprintf(stderr, "Can't create listen socket: %s\n", strerror(errno));
646
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 645
diff changeset
2281 my_server_state = 0;
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2282 return 0;
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2283 }
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2284
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2285 if (setsockopt(ls, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) == -1) {
268
dda91dfa4aa8 All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
2286 syslog(LOG_NOTICE, "Can't setsockopt SO_KEEPALIVE socket: %s", strerror(errno));
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2287 close(ls);
646
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 645
diff changeset
2288 my_server_state = 0;
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2289 return 0;
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2290 }
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2291
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2292 // if (setsockopt(ls, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) == -1) {
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2293 // syslog(LOG_NOTICE, "Can't setsockopt SO_REUSEADDR socket: %s", strerror(errno));
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2294 // close(ls);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2295 // my_server_state = 0;
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2296 // return 0;
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2297 // }
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2298
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2299 if (bind(ls, (struct sockaddr *)&myaddr_in, sizeof(struct sockaddr_in)) == -1) {
268
dda91dfa4aa8 All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
2300 syslog(LOG_NOTICE, "Can't bind to listen socket: %s", strerror(errno));
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2301 close(ls);
646
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 645
diff changeset
2302 my_server_state = 0;
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 62
diff changeset
2303 return 0;
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2304 }
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2305
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2306 if (listen(ls, 5) == -1) {
268
dda91dfa4aa8 All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
2307 syslog(LOG_NOTICE, "Can't listen on listen socket: %s", strerror(errno));
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2308 close(ls);
646
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 645
diff changeset
2309 my_server_state = 0;
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 62
diff changeset
2310 return 0;
44
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2311 }
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2312
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2313 syslog(LOG_NOTICE, "listen socket created %d", ls);
f37d73940699 Server communication works
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
2314
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2315 /*
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2316 * Loop forever until the external shutdown variable is set.
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2317 */
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2318 for (;;) {
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2319
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2320 addrlen = sizeof(struct sockaddr_in);
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2321 /*
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2322 * This call will block until a new connection
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2323 * arrives. Then it will return the address of
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2324 * the connecting peer, and a new socket
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2325 * descriptor, s, for that connection.
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2326 */
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2327 s = accept(ls, (struct sockaddr *)&peeraddr_in, &addrlen);
665
66fae54fa7ba Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
2328 // syslog(LOG_NOTICE, "my_server_loop accept socket %d", s);
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2329 if (s == -1) {
268
dda91dfa4aa8 All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents: 266
diff changeset
2330 syslog(LOG_NOTICE, "my_server_loop accept failed %s", strerror(errno));
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2331 break;
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2332 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2333 if (my_server_shutdown)
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2334 break;
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2335
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2336 cmd_server(s);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2337
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2338 if (my_server_shutdown)
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2339 break;
652
16d3d4b58b5b Moved all delay functions into a new general file.
Michiel Broek <mbroek@mbse.eu>
parents: 646
diff changeset
2340 mDelay(100);
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2341 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2342
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2343 close(ls);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2344 pthread_cleanup_pop(my_server_state);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2345 syslog(LOG_NOTICE, "Thread my_server_loop stopped");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2346 my_server_state = 0;
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 652
diff changeset
2347 return 0;
43
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2348 }
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2349
24e731bb2e08 Initial server code added
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
2350

mercurial