# HG changeset patch # User Michiel Broek # Date 1562500503 -7200 # Node ID 44d41db09466353b829ced09fdbc00a158c063e4 # Parent 1ff1a95a761457fcaff5517888a8d743f1f0076e# Parent af2383e3f110b12089fde145eaec8cb64c6f1c6c Merged with default diff -r 1ff1a95a7614 -r 44d41db09466 configure --- a/configure Thu May 09 15:17:30 2019 +0200 +++ b/configure Sun Jul 07 13:55:03 2019 +0200 @@ -2047,7 +2047,7 @@ PACKAGE="mbsePi-apps" -VERSION="0.9.5" +VERSION="0.9.6" COPYRIGHT="Copyright (C) 2014-2019 Michiel Broek, All Rights Reserved" CYEARS="2014-2019" diff -r 1ff1a95a7614 -r 44d41db09466 configure.ac --- a/configure.ac Thu May 09 15:17:30 2019 +0200 +++ b/configure.ac Sun Jul 07 13:55:03 2019 +0200 @@ -8,7 +8,7 @@ dnl General settings dnl After changeing the version number, run autoconf! PACKAGE="mbsePi-apps" -VERSION="0.9.5" +VERSION="0.9.6" COPYRIGHT="Copyright (C) 2014-2019 Michiel Broek, All Rights Reserved" CYEARS="2014-2019" AC_SUBST(PACKAGE) diff -r 1ff1a95a7614 -r 44d41db09466 thermferm/Makefile --- a/thermferm/Makefile Thu May 09 15:17:30 2019 +0200 +++ b/thermferm/Makefile Sun Jul 07 13:55:03 2019 +0200 @@ -54,20 +54,19 @@ # DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT # Dependencies generated by make depend +mqtt.o: thermferm.h rdconfig.h devices.h xutil.h mqtt.h rc-switch.o: thermferm.h xutil.h rc-switch.h -mqtt.o: thermferm.h rdconfig.h logger.h devices.h xutil.h mqtt.h slcd.o: thermferm.h slcd.h futil.h xutil.h panel.o: thermferm.h lcd-pcf8574.h slcd.h panel.h devices.o: thermferm.h devices.h rc-switch.h panel.h xutil.h lcd-buffer.o: thermferm.h lcd-buffer.h lcd-pcf8574.h slcd.h panel.h futil.o: thermferm.h futil.h -thermferm.o: lock.h logger.h rdconfig.h devices.h server.h thermferm.h simulator.h lcd-pcf8574.h lcd-buffer.h slcd.h panel.h futil.h xutil.h pid.h mqtt.h +thermferm.o: lock.h rdconfig.h devices.h server.h thermferm.h simulator.h lcd-pcf8574.h lcd-buffer.h slcd.h panel.h futil.h xutil.h pid.h mqtt.h lock.o: lock.h thermferm.h -logger.o: logger.h thermferm.h futil.h xutil.h lcd-pcf8574.o: thermferm.h lcd-pcf8574.h slcd.h pid.o: thermferm.h pid.h xutil.o: thermferm.h xutil.h -server.o: rdconfig.h thermferm.h logger.h devices.h server.h lcd-buffer.h xutil.h mqtt.h +server.o: rdconfig.h thermferm.h devices.h server.h lcd-buffer.h xutil.h mqtt.h simulator.o: thermferm.h simulator.h rdconfig.o: rdconfig.h thermferm.h pid.h futil.h xutil.h # End of generated dependencies diff -r 1ff1a95a7614 -r 44d41db09466 thermferm/devices.c --- a/thermferm/devices.c Thu May 09 15:17:30 2019 +0200 +++ b/thermferm/devices.c Sun Jul 07 13:55:03 2019 +0200 @@ -27,7 +27,6 @@ #include "xutil.h" -extern int debug; extern sys_config Config; extern int my_shutdown; @@ -313,8 +312,6 @@ disableTransmit(); piLock(LOCK_DEVICES); syslog(LOG_NOTICE, "RC433 command %s rc=%d", buf, rc); - if (debug) - fprintf(stdout, "RC433 command %s rc=%d\n", buf, rc); device->value = value; device->timestamp = time(NULL); piUnlock(LOCK_DEVICES); @@ -350,8 +347,6 @@ if ((write_w1(device->address, (char *)"output", output)) == 0) { syslog(LOG_NOTICE, "DS2413 PIO%c value=%d (%s)", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1, device->comment); - if (debug) - fprintf(stdout, "DS2413 PIO%c value=%d (%s)\n", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1, device->comment); device->value = (value == 0) ? 0 : 1; device->timestamp = time(NULL); } @@ -365,8 +360,6 @@ (strcmp((char *)"SimFan" , device->address) == 0) || (strcmp((char *)"SimLight" , device->address) == 0)) { if (value != device->value) { syslog(LOG_NOTICE, "SIM %s value=%d", device->address, value); - if (debug) - fprintf(stdout, "SIM %s value=%d\n", device->address, value); } device->value = value; device->timestamp = time(NULL); diff -r 1ff1a95a7614 -r 44d41db09466 thermferm/logger.c --- a/thermferm/logger.c Thu May 09 15:17:30 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2014-2019 - * - * Michiel Broek - * - * This file is part of the mbsePi-apps - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * mbsePi-apps is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ThermFerm; see the file COPYING. If not, write to the Free - * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - *****************************************************************************/ - -#include "logger.h" -#include "thermferm.h" -#include "futil.h" -#include "xutil.h" - - -void initlog(char *code, char *name) -{ - char buf[128], *filename; - - snprintf(buf, 127, "Mode,Air,Beer,Target_L,S_Heater,S_Cooler,S_Fan,S_Door,U_Heater,U_Cooler,U_Fan,Room,Target_H,Chiller,Event"); - filename = xstrcpy(code); - filename = xstrcat(filename, (char *)" "); - filename = xstrcat(filename, name); - filename = xstrcat(filename, (char *)".log"); - logger(filename, buf); - free(filename); - filename = NULL; -} - - - -void logger(char *filename, char *data) -{ - struct timeval now; - struct tm ptm; - char *outstr = NULL, *name = NULL; - FILE *logfile; - - if (getenv((char *)"USER") == NULL) { - name = xstrcpy((char *)"/root"); - } else { - name = xstrcpy(getenv((char *)"HOME")); - } - name = xstrcat(name, (char *)"/.thermferm/log/"); - mkdirs(name, 0755); - name = xstrcat(name, filename); - - gettimeofday(&now, NULL); - localtime_r(&now.tv_sec, &ptm); - outstr = calloc(10240, sizeof(char)); - snprintf(outstr, 10239, "%04d-%02d-%02d %02d:%02d,%s\n", ptm.tm_year + 1900, ptm.tm_mon + 1, ptm.tm_mday, ptm.tm_hour, ptm.tm_min, data); - - if ((logfile = fopen(name, "a+"))) { - fprintf(logfile, outstr); - fclose(logfile); - } else { - syslog(LOG_NOTICE, "logger: cannot open %s for writing", name); - } - - free(outstr); - outstr = NULL; - free(name); - name = NULL; -} - - diff -r 1ff1a95a7614 -r 44d41db09466 thermferm/logger.h --- a/thermferm/logger.h Thu May 09 15:17:30 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#ifndef LOGGER_H -#define LOGGER_H - - -void logger(char *, char *); -void initlog(char *, char *); - - -#endif diff -r 1ff1a95a7614 -r 44d41db09466 thermferm/mqtt.c --- a/thermferm/mqtt.c Thu May 09 15:17:30 2019 +0200 +++ b/thermferm/mqtt.c Sun Jul 07 13:55:03 2019 +0200 @@ -22,7 +22,6 @@ #include "thermferm.h" #include "rdconfig.h" -#include "logger.h" #include "devices.h" #include "xutil.h" #include "mqtt.h" @@ -59,6 +58,224 @@ char my_hostname[256]; +#ifndef HAVE_WIRINGPI_H + +/* + * Code from wiringPi written by Gordon Henderson. + * Copied here to have some sort of hardware detection without wiringPi. + */ +const char *piModelNames [20] = +{ + "Model A", // 0 + "Model B", // 1 + "Model A+", // 2 + "Model B+", // 3 + "Pi 2", // 4 + "Alpha", // 5 + "CM", // 6 + "Unknown07", // 07 + "Pi 3", // 08 + "Pi Zero", // 09 + "CM3", // 10 + "Unknown11", // 11 + "Pi Zero-W", // 12 + "Pi 3B+", // 13 + "Pi 3A+", // 14 + "Unknown15", // 15 + "CM3+", // 16 + "Unknown17", // 17 + "Unknown18", // 18 + "Unknown19", // 19 +}; +const char *piRevisionNames [16] = +{ + "00", + "01", + "02", + "03", + "04", + "05", + "06", + "07", + "08", + "09", + "10", + "11", + "12", + "13", + "14", + "15", +} ; +const char *piMakerNames [16] = +{ + "Sony", // 0 + "Egoman", // 1 + "Embest", // 2 + "Unknown", // 3 + "Embest", // 4 + "Unknown05", // 5 + "Unknown06", // 6 + "Unknown07", // 7 + "Unknown08", // 8 + "Unknown09", // 9 + "Unknown10", // 10 + "Unknown11", // 11 + "Unknown12", // 12 + "Unknown13", // 13 + "Unknown14", // 14 + "Unknown15", // 15 +} ; +const int piMemorySize [8] = +{ + 256, // 0 + 512, // 1 + 1024, // 2 + 0, // 3 + 0, // 4 + 0, // 5 + 0, // 6 + 0, // 7 +} ; + +void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty) +{ + FILE *cpuFd ; + char line [120] ; + char *c ; + unsigned int revision ; + int bRev, bType, bProc, bMfg, bMem, bWarranty ; + + *model = -1; // Mark no info + if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL) { + syslog(LOG_NOTICE, "Unable to open /proc/cpuinfo") ; + return; + } + + while (fgets (line, 120, cpuFd) != NULL) + if (strncmp (line, "Revision", 8) == 0) + break ; + + fclose (cpuFd) ; + + if (strncmp (line, "Revision", 8) != 0) { + syslog(LOG_NOTICE, "No \"Revision\" line"); + return; + } + +// Chomp trailing CR/NL + + for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c) + *c = 0 ; + + if (debug) + fprintf(stdout, "piBoardId: Revision string: %s\n", line) ; + +// Need to work out if it's using the new or old encoding scheme: + +// Scan to the first character of the revision number + + for (c = line ; *c ; ++c) + if (*c == ':') + break ; + + if (*c != ':') { + syslog(LOG_NOTICE, "Bogus \"Revision\" line (no colon)") ; + return; + } + +// Chomp spaces + + ++c ; + while (isspace (*c)) + ++c ; + + if (!isxdigit (*c)) + syslog(LOG_NOTICE, "Bogus \"Revision\" line (no hex digit at start of revision)") ; + + revision = (unsigned int)strtol (c, NULL, 16) ; // Hex number with no leading 0x + +// Check for new way: + + if ((revision & (1 << 23)) != 0) { // New way + if (debug) + fprintf(stdout, "piBoardId: New Way: revision is: %08X\n", revision) ; + + bRev = (revision & (0x0F << 0)) >> 0 ; + bType = (revision & (0xFF << 4)) >> 4 ; + bProc = (revision & (0x0F << 12)) >> 12 ; // Not used for now. + bMfg = (revision & (0x0F << 16)) >> 16 ; + bMem = (revision & (0x07 << 20)) >> 20 ; + bWarranty = (revision & (0x03 << 24)) != 0 ; + + *model = bType ; + *rev = bRev ; + *mem = bMem ; + *maker = bMfg ; + *warranty = bWarranty ; + + if (debug) + fprintf(stdout, "piBoardId: rev: %d, type: %d, proc: %d, mfg: %d, mem: %d, warranty: %d\n", bRev, bType, bProc, bMfg, bMem, bWarranty) ; + } else { // Old way + if (debug) + fprintf(stdout, "piBoardId: Old Way: revision is: %s\n", c) ; + + if (!isdigit (*c)) { + syslog(LOG_NOTICE, "Bogus \"Revision\" line (no digit at start of revision)") ; + return; + } + +// Make sure its long enough + + if (strlen (c) < 4) { + syslog(LOG_NOTICE, "Bogus \"Revision\" line (not long enough)") ; + return; + } + +// If longer than 4, we'll assume it's been overvolted + + *warranty = strlen (c) > 4 ; + +// Extract last 4 characters: + + c = c + strlen (c) - 4 ; + +// Fill out the replys as appropriate + + /**/ if (strcmp (c, "0002") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "0003") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_1 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } + + else if (strcmp (c, "0004") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "0005") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "0006") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } + + else if (strcmp (c, "0007") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "0008") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_SONY ; ; } + else if (strcmp (c, "0009") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } + + else if (strcmp (c, "000d") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "000e") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "000f") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; } + + else if (strcmp (c, "0010") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "0013") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_EMBEST ; } + else if (strcmp (c, "0016") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "0019") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "0011") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_1 ; *mem = 1 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "0014") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_1 ; *mem = 1 ; *maker = PI_MAKER_EMBEST ; } + else if (strcmp (c, "0017") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_1 ; *mem = 1 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "001a") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_1 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; } + + else if (strcmp (c, "0012") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_1 ; *mem = 0 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "0015") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_1 ; *mem = 1 ; *maker = PI_MAKER_EMBEST ; } + else if (strcmp (c, "0018") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_1 ; *mem = 0 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "001b") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_1 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; } + + else { *model = 0 ; *rev = 0 ; *mem = 0 ; *maker = 0 ; } + } +} +#endif + + char *payload_header(void) { @@ -153,9 +370,8 @@ void my_log_callback(struct mosquitto *my_mosq, void *obj, int level, const char *str) { -// syslog(LOG_NOTICE, "MQTT: %s", str); - if (debug) - fprintf(stdout, "MQTT: %s\n", str); +// if (debug) +// fprintf(stdout, "MQTT: %s\n", str); } @@ -238,7 +454,6 @@ unit->mqtt_flag |= MQTT_FLAG_DATA; /* Initialize log if the unit is turned on */ if ((unit->mode == UNITMODE_OFF) && (i != UNITMODE_OFF)) { - initlog(unit->product_code, unit->product_name); unit->mqtt_flag |= MQTT_FLAG_BIRTH; } else if ((unit->mode != UNITMODE_OFF) && (i == UNITMODE_OFF)) { unit->mqtt_flag |= MQTT_FLAG_DEATH; @@ -442,7 +657,6 @@ cmd = NULL; } } else if (json_object_object_get_ex(profile, "uuid", &profile1)) { -// syslog(LOG_NOTICE, "profile new profile"); if ((unit->prof_state == PROFILE_OFF) || (unit->prof_state == PROFILE_DONE) || (unit->prof_state == PROFILE_ABORT)) { if (unit->profile_uuid) free(unit->profile_uuid); @@ -458,8 +672,6 @@ } unit->profile_steps = NULL; unit->profile_duration = unit->profile_totalsteps = 0; -// syslog(LOG_NOTICE, "profile new profile: old cleared"); - unit->profile_uuid = xstrcpy((char *)json_object_get_string(profile1)); if (json_object_object_get_ex(profile, "name", &val)) { unit->profile_name = xstrcpy((char *)json_object_get_string(val)); @@ -1174,6 +1386,7 @@ char *topic = NULL, *payload = NULL, sidx[10], buf[64]; struct utsname ubuf; bool comma = false; + int model, rev, mem, maker, warranty; payload = payload_header(); payload = xstrcat(payload, (char *)"{"); @@ -1186,7 +1399,6 @@ /* * Get the info from the WiringPi libary */ - int model, rev, mem, maker, warranty; piBoardId (&model, &rev, &mem, &maker, &warranty); payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\"Raspberry Pi "); payload = xstrcat(payload, (char *)piMakerNames[maker]); @@ -1196,7 +1408,19 @@ payload = xstrcat(payload, (char *)piRevisionNames[rev]); payload = xstrcat(payload, (char *)"\""); #else - if (uname(&ubuf) == 0) { + /* + * Get the info from the internal function + */ + piBoardId (&model, &rev, &mem, &maker, &warranty); + if (model != -1) { + payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\"Raspberry Pi "); + payload = xstrcat(payload, (char *)piMakerNames[maker]); + payload = xstrcat(payload, (char *)"\",\"hardwaremodel\":\""); + payload = xstrcat(payload, (char *)piModelNames[model]); + payload = xstrcat(payload, (char *)" rev "); + payload = xstrcat(payload, (char *)piRevisionNames[rev]); + payload = xstrcat(payload, (char *)"\""); + } else if (uname(&ubuf) == 0) { payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\""); payload = xstrcat(payload, ubuf.machine); payload = xstrcat(payload, (char *)"\",\"hardwaremodel\":\"Unknown\""); diff -r 1ff1a95a7614 -r 44d41db09466 thermferm/mqtt.h --- a/thermferm/mqtt.h Thu May 09 15:17:30 2019 +0200 +++ b/thermferm/mqtt.h Sun Jul 07 13:55:03 2019 +0200 @@ -6,6 +6,40 @@ #define STATUS_CONNACK_RECVD 1 #define STATUS_WAITING 2 +#ifndef HAVE_WIRINGPI_H + +// Pi model types and version numbers +// Intended for the GPIO program Use at your own risk. + +#define PI_MODEL_A 0 +#define PI_MODEL_B 1 +#define PI_MODEL_AP 2 +#define PI_MODEL_BP 3 +#define PI_MODEL_2 4 +#define PI_ALPHA 5 +#define PI_MODEL_CM 6 +#define PI_MODEL_07 7 +#define PI_MODEL_3B 8 +#define PI_MODEL_ZERO 9 +#define PI_MODEL_CM3 10 +#define PI_MODEL_ZERO_W 12 +#define PI_MODEL_3BP 13 +#define PI_MODEL_3AP 14 +#define PI_MODEL_CM3P 16 + +#define PI_VERSION_1 0 +#define PI_VERSION_1_1 1 +#define PI_VERSION_1_2 2 +#define PI_VERSION_2 3 + +#define PI_MAKER_SONY 0 +#define PI_MAKER_EGOMAN 1 +#define PI_MAKER_EMBEST 2 +#define PI_MAKER_UNKNOWN 3 + + +#endif + /* * Public functions diff -r 1ff1a95a7614 -r 44d41db09466 thermferm/server.c --- a/thermferm/server.c Thu May 09 15:17:30 2019 +0200 +++ b/thermferm/server.c Sun Jul 07 13:55:03 2019 +0200 @@ -22,7 +22,6 @@ #include "rdconfig.h" #include "thermferm.h" -#include "logger.h" #include "devices.h" #include "server.h" #include "lcd-buffer.h" @@ -206,7 +205,7 @@ *tmp = (ls_list *)malloc(sizeof(ls_list)); (*tmp)->next = NULL; - strncpy((*tmp)->d_name, name, 256); + strncpy((*tmp)->d_name, name, 255); (*tmp)->mode = mode; (*tmp)->size = size; (*tmp)->mtime = mtime; @@ -256,299 +255,6 @@ -/* - * ARCHIVE DIR - * ARCHIVE GET filename - * ARCHIVE LOG filename - * ARCHIVE HELP - */ -int cmd_archive(char *buf) -{ - char *opt, *param, *name = NULL, *filename = NULL, *logname = NULL, mbits[11], tstr[24]; - DIR *dd; - FILE *fp; - struct dirent *result; - ls_list *lsx = NULL, *tmp; - struct stat sbuf; - struct tm *tbuf; - time_t ftime; - int found; - units_list *unit; - - - opt = strtok(buf, " \0"); - opt = strtok(NULL, " \0"); - - if (opt == NULL) { - srv_send((char *)"501 Subcommand missing"); - return 0; - } - param = strtok(NULL, "\0"); - - if (strcmp(opt, (char *)"HELP") == 0) { - srv_send((char *)"100 Help text follows:"); - srv_send((char *)"Recognized commands:"); - srv_send((char *)"ARCHIVE DIR Archived logfiles directory"); - srv_send((char *)"ARCHIVE GET filename Archived logfile download"); - srv_send((char *)"ARCHIVE LOG filename Archived logfile data in graphsteps"); - srv_send((char *)"."); - return 0; - } - - if (strcmp(opt, (char *)"DIR") == 0) { - - if (getenv((char *)"USER") == NULL) { - name = xstrcpy((char *)"/root"); - } else { - name = xstrcpy(getenv((char *)"HOME")); - } - name = xstrcat(name, (char *)"/.thermferm/log/"); - - if ((dd = opendir(name))) { - for (;;) { - if (! (result = readdir(dd))) { - syslog(LOG_NOTICE, "readdir: error=%d", errno); - break; - } - if (result->d_name[0] != '.') { - filename = xstrcpy(name); - filename = xstrcat(filename, result->d_name); - /* - * Remove files from the list when they are in use - */ - found = 0; - for (unit = Config.units; unit; unit = unit->next) { - if (unit->mode != UNITMODE_OFF) { - logname = xstrcpy(unit->product_code); - logname = xstrcat(logname, (char *)" "); - logname = xstrcat(logname, unit->product_name); - logname = xstrcat(logname, (char *)".log"); - if (! strcmp(result->d_name, logname)) - found = 1; - free(logname); - logname = NULL; - } - } - if ((found == 0) && ((stat(filename, &sbuf)) == 0)) { - fill_list(&lsx, result->d_name, sbuf.st_mode, sbuf.st_size, sbuf.st_mtime); - } - free(filename); - filename = NULL; - } - } - closedir(dd); - } else { - syslog(LOG_NOTICE, "opendir: \"%s\" error=%d", name, errno); - } - - sort_list(&lsx); - - srv_send((char *)"212 Archive directory follows:"); - for (tmp = lsx; tmp; tmp = tmp->next) { - sprintf(mbits, "----------"); - if (tmp->mode & S_IRUSR) - mbits[1] = 'r'; - if (tmp->mode & S_IWUSR) - mbits[2] = 'w'; - if (tmp->mode & S_IXUSR) - mbits[3] = 'x'; - if (tmp->mode & S_IRGRP) - mbits[4] = 'r'; - if (tmp->mode & S_IWGRP) - mbits[5] = 'w'; - if (tmp->mode & S_IXGRP) - mbits[6] = 'x'; - if (tmp->mode & S_IROTH) - mbits[7] = 'r'; - if (tmp->mode & S_IWOTH) - mbits[8] = 'w'; - if (tmp->mode & S_IXOTH) - mbits[9] = 'x'; - ftime = tmp->mtime; - tbuf = localtime(&ftime); - sprintf(tstr, "%02d %s %04d %02d:%02d", tbuf->tm_mday, MONTH[tbuf->tm_mon], tbuf->tm_year+1900, tbuf->tm_hour, tbuf->tm_min); - srv_send((char *)"%s,%s,%d,%s", tmp->d_name, mbits, tmp->size, tstr); - } - srv_send((char *)"."); - tidy_lslist(&lsx); - - free(name); - name = NULL; - return 0; - } - - if (param == NULL) { - srv_send((char *)"502 Parameter missing"); - return 0; - } - - if (strcmp(opt, (char *)"GET") == 0) { - if (getenv((char *)"USER") == NULL) { - name = xstrcpy((char *)"/root"); - } else { - name = xstrcpy(getenv((char *)"HOME")); - } - name = xstrcat(name, (char *)"/.thermferm/log/"); - name = xstrcat(name, param); - - if ((fp = fopen(name, "r"))) { - char buffer[256]; - - srv_send((char *)"212 Archive file follows:"); - while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { - int i; - - for (i = 0; i < strlen(buffer); i++) { - if (buffer[i] == '\n') - buffer[i] = '\0'; - if (buffer[i] == '\r') - buffer[i] = '\0'; - } - srv_send(buffer); - } - srv_send((char *)"."); - fclose(fp); - } else { - srv_send((char *)"440 No such file"); - } - - free(name); - name = NULL; - return 0; - } - - if (strcmp(opt, (char *)"LOG") == 0) { - if (getenv((char *)"USER") == NULL) { - name = xstrcpy((char *)"/root"); - } else { - name = xstrcpy(getenv((char *)"HOME")); - } - name = xstrcat(name, (char *)"/.thermferm/log/"); - name = xstrcat(name, param); - - if ((fp = fopen(name, "r"))) { - char buffer[256], outbuf[256], q[5], hr[3]; - char *date_n, *mode_n, *air_n, *beer_n, *target_lo_n, *target_hi_n, *heater_n, *cooler_n, *room_n, *chiller_n; - char *heater_u, *cooler_u; - int lines = 0, heater_l = 0, cooler_l = 0, h = 0, c = 0, heat_used = 0, cool_used = 0, graphstep = 0; - float room_t = 0.0; - - srv_send((char *)"212 Logfile list follows:"); - while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { - lines++; - } - fseek(fp, 0L, SEEK_SET); - /* - * We have counted the lines in the logfile including the header lines. - * The header lines should be ignored but there are so few of them, we - * just include them in the total. - * Now find a reasonable interval of lines to sent to the client. - */ - for (graphstep = 1; graphstep <= MAX_INTERVALS; graphstep++) { - if (lines < GRAPH_DATALINES[graphstep]) { - break; - } - } - if (graphstep > MAX_INTERVALS) - graphstep = MAX_INTERVALS; - syslog(LOG_NOTICE, "ARCHIVE LOG %s: lines=%d, interval=%d, graphstep=%d", param, lines, GRAPH_INTERVAL[graphstep], graphstep); - - while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { - /* - * 2014-11-15 18:39,BEER,20.312,19.750,20.0,0,NA,NA,NA,78105,NA,NA,18.000,20.1,5.312 - * | | | | | | | | | | | | | | | - * date_n | | | | | | | | | | | | | | - * mode_n ----------+ | | | | | | | | | | | | | - * air_n -----------------+ | | | | | | | | | | | | - * beer_n -----------------------+ | | | | | | | | | | | - * target_lo_n ------------------------+ | | | | | | | | | | - * heater_n -------------------------------+ | | | | | | | | | - * cooler_n ---------------------------------+ | | | | | | | | - * not used ------------------------------------+ | | | | | | | - * not used ---------------------------------------+ | | | | | | - * heater_u --------------------------------------------+ | | | | | - * cooler_u ------------------------------------------------+ | | | | - * not used ---------------------------------------------------+ | | | - * room_n ----------------------------------------------------------+ | | - * target_hi_n -----------------------------------------------------------+ | - * chiller_n ------------------------------------------------------------------+ - */ - hr[0] = q[0] = buffer[11]; - hr[1] = q[1] = buffer[12]; - q[2] = buffer[14]; - q[3] = buffer[15]; - hr[2] = '\0'; - buffer[strlen(buffer) -1] = '\0'; - date_n = strtok(buffer, ",\0"); /* timestamp */ - mode_n = strtok(NULL, ",\0"); /* unit mode */ - air_n = strtok(NULL, ",\0"); /* air temp */ - beer_n = strtok(NULL, ",\0"); /* beer temp */ - target_lo_n = strtok(NULL, ",\0"); /* target low temp */ - heater_n = strtok(NULL, ",\0"); /* current heater state */ - cooler_n = strtok(NULL, ",\0"); /* current cooler state */ - heater_u = strtok(NULL, ",\0"); /* current fan state */ - heater_u = strtok(NULL, ",\0"); /* current door state */ - heater_u = strtok(NULL, ",\0"); /* heater use counter */ - cooler_u = strtok(NULL, ",\0"); /* cooler use counter */ - room_n = strtok(NULL, ",\0"); /* fan use counter */ - room_n = strtok(NULL, ",\0"); /* room temperature */ - target_hi_n = strtok(NULL, ",\0"); /* target high temp */ - chiller_n = strtok(NULL, ",\0"); /* chiller temp */ - - if (strncmp(mode_n, (char *)"Mode", 4)) { - /* - * Output a line at the right intervals - */ - int hour = atoi(hr); - if (((graphstep == 1)) || - ((graphstep == 2) && (q[3] == '0' || q[3] == '5')) || - ((graphstep == 3) && ((q[2] == '0' && q[3] == '0') || (q[2] == '1' && q[3] == '5') || (q[2] == '3' && q[3] == '0') || (q[2] == '4' && q[3] == '5'))) || - ((graphstep == 4) && ((q[2] == '0' && q[3] == '0') || (q[2] == '3' && q[3] == '0'))) || - ((graphstep == 5) && (q[2] == '0' && q[3] == '0')) || - ((graphstep == 6) && (hour % 2 == 0) && (q[2] == '0' && q[3] == '0')) || /* 120 minutes */ - ((graphstep == 7) && (hour % 4 == 0) && (q[2] == '0' && q[3] == '0')) || /* 240 minutes */ - ((graphstep >= 8) && (hour % 8 == 0) && (q[2] == '0' && q[3] == '0')) ) { /* 480 minutes */ - heat_used = cool_used = 0; - if (heater_u && strcmp(heater_u, "NA") && (sscanf(heater_u, "%d", &h) == 1)) { - if (h && heater_l) { - heat_used = ((h - heater_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); - } - } - if (cooler_u && strcmp(cooler_u, "NA") && (sscanf(cooler_u, "%d", &c) == 1)) { - if (c && cooler_l) { - cool_used = ((c - cooler_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); - } - } - if (room_n) - sscanf(room_n, "%f", &room_t); - if (target_hi_n == NULL) - target_hi_n = target_lo_n; - snprintf(outbuf, 255, "%s,%s,%s,%s,%s,%s,%s,%d,%d,%.1f,%s,%s", - date_n, mode_n, air_n, beer_n, target_lo_n, heater_n, cooler_n, heat_used, cool_used, room_t,target_hi_n, chiller_n); - srv_send(outbuf); - if (heater_u && h && strcmp(heater_u, "NA")) - heater_l = h; - if (cooler_u && c & strcmp(cooler_u, "NA")) - cooler_l = c; - } - } - } - - srv_send((char *)"."); - fclose(fp); - } else { - srv_send((char *)"440 No such file"); - } - - free(name); - name = NULL; - } - - return 0; -} - - - int delete_Device(char *uuid) { devices_list *current = Config.devices; @@ -2195,7 +1901,6 @@ unit->mqtt_flag |= MQTT_FLAG_DATA; /* Initialize log if the unit is turned on */ if ((unit->mode == UNITMODE_OFF) && (i != UNITMODE_OFF)) { - initlog(unit->product_code, unit->product_name); unit->mqtt_flag |= MQTT_FLAG_BIRTH; } else if ((unit->mode != UNITMODE_OFF) && (i == UNITMODE_OFF)) { unit->mqtt_flag |= MQTT_FLAG_DEATH; @@ -2383,8 +2088,6 @@ } if (unit->mqtt_flag) { - if (debug) - fprintf(stdout, "flag value %d\n", unit->mqtt_flag); if (unit->mqtt_flag & MQTT_FLAG_BIRTH) { publishDBirth(unit); } else { @@ -2421,10 +2124,7 @@ /* * Process commands from the client */ - if (strncmp(buf, "ARCHIVE", 7) == 0) { - cmd_archive(buf); - - } else if (strncmp(buf, "DEVICE", 6) == 0) { + if (strncmp(buf, "DEVICE", 6) == 0) { if (cmd_device(buf)) wrconfig(); @@ -2437,8 +2137,6 @@ srv_send((char *)"Recognized commands:"); srv_send((char *)""); // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 - srv_send((char *)"ARCHIVE [parameters] Archive commands"); - srv_send((char *)"ARCHIVE HELP Archive help screen"); srv_send((char *)"DEVICE [parameters] Device commands"); srv_send((char *)"DEVICE HELP Device help screen"); srv_send((char *)"GLOBAL [parameters] Global commands"); diff -r 1ff1a95a7614 -r 44d41db09466 thermferm/simulator.c --- a/thermferm/simulator.c Thu May 09 15:17:30 2019 +0200 +++ b/thermferm/simulator.c Sun Jul 07 13:55:03 2019 +0200 @@ -26,7 +26,6 @@ #ifdef USE_SIMULATOR extern int my_shutdown; -extern int debug; extern sys_config Config; int SIMcooling = 0; @@ -125,14 +124,6 @@ simulator->beer_temperature += ((simulator->air_temperature - simulator->beer_temperature) / 500.0); simulator->air_temperature += ((simulator->beer_temperature - simulator->air_temperature) / 2500.0); simulator->chiller_temperature = simulator->cooler_temp; // Libk these - -// if ((seconds % 15) == 0) -// syslog(LOG_NOTICE, "air=%.3f beer=%.3f heater=%.3f cooler=%.3f", simulator->air_temperature, simulator->beer_temperature, -// simulator->s_heat_temp, simulator->s_cool_temp); - -// if (debug) -// fprintf(stdout, "sqm_room_air=%f air=%f air_heat_transfer=%f air_change=%f beer=%f\n", -// sqm_room_air, simulator->air_temperature, air_heat_transfer, air_change, simulator->beer_temperature); } usleep(100000); } diff -r 1ff1a95a7614 -r 44d41db09466 thermferm/thermferm.c --- a/thermferm/thermferm.c Thu May 09 15:17:30 2019 +0200 +++ b/thermferm/thermferm.c Sun Jul 07 13:55:03 2019 +0200 @@ -21,7 +21,6 @@ *****************************************************************************/ #include "lock.h" -#include "logger.h" #include "rdconfig.h" #include "devices.h" #include "server.h" @@ -405,7 +404,6 @@ { current_unit->mqtt_flag |= MQTT_FLAG_DATA; if ((current_unit->mode == UNITMODE_OFF) && (mode != UNITMODE_OFF)) { - initlog(current_unit->product_code, current_unit->product_name); current_unit->mqtt_flag |= MQTT_FLAG_BIRTH; } else if ((current_unit->mode != UNITMODE_OFF) && (mode == UNITMODE_OFF)) { current_unit->mqtt_flag |= MQTT_FLAG_DEATH; @@ -1001,6 +999,8 @@ killconfig(); syslog(LOG_NOTICE, "Finished, rc=%d", rc); + if (debug) + fprintf(stdout, "Finished, rc=%d\n", rc); return rc; } @@ -1008,12 +1008,10 @@ int server(void) { - char buf[1024], *filename, target_lo[40], target_hi[40], heater[40], cooler[40], fan[40], door[40]; - char use_heater[40], use_cooler[40], use_fan[40], room_temp[40]; time_t now, last = (time_t)0, ndata = (time_t)0;; units_list *unit; prof_step *step; - int row, rc, run = 1, seconds = 0, minutes = 0, temp, deviation; + int row, rc, run = 1, seconds = 0, minutes = 0, temp; int run_seconds, run_minutes, run_hours, tot_minutes, key; struct tm *tm; #ifndef HAVE_WIRINGPI_H @@ -1122,17 +1120,8 @@ } else { syslog(LOG_NOTICE, "Starting unit `%s' in off state", unit->alias); } - - /* - * Initialize logfile - */ - if (unit->mode != UNITMODE_OFF) { - initlog(unit->product_code, unit->product_name); - } } - printf("Units started\n"); publishDBirthAll(); - printf("Birth all done\n"); for (unit = Config.units; unit; unit = unit->next) { if (unit->mode != UNITMODE_OFF) { @@ -1282,26 +1271,12 @@ if (unit->air_address) { rc = device_in(unit->air_address, &temp); if (rc == DEVPRESENT_YES) { - /* - * It is possible to have read errors or extreme values. - * This can happen with bad connections so we compare the - * value with the previous one. If the difference is too - * much, we don't send that value. That also means that if - * the next value is ok again, it will be marked invalid too. - * Maximum error is 40 degrees for now. - */ - deviation = 40000; - if ((unit->air_temperature == 0) || - (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) { - if (unit->air_temperature != temp) { - unit->mqtt_flag |= MQTT_FLAG_DATA; - pub_domoticz_temp(unit->air_idx, temp); - } - unit->air_temperature = temp; - unit->air_state = 0; - } else { - syslog(LOG_NOTICE, "deviation error air deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp); + if (unit->air_temperature != temp) { + unit->mqtt_flag |= MQTT_FLAG_DATA; + pub_domoticz_temp(unit->air_idx, temp); } + unit->air_temperature = temp; + unit->air_state = 0; } else if (rc == DEVPRESENT_ERROR) { unit->air_state = 1; } else { @@ -1312,18 +1287,12 @@ if (unit->beer_address) { rc = device_in(unit->beer_address, &temp); if (rc == DEVPRESENT_YES) { - deviation = 40000; - if ((unit->beer_temperature == 0) || - (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) { - if (unit->beer_temperature != temp) { - unit->mqtt_flag |= MQTT_FLAG_DATA; - pub_domoticz_temp(unit->beer_idx, temp); - } - unit->beer_temperature = temp; - unit->beer_state = 0; - } else { - syslog(LOG_NOTICE, "deviation error beer deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp); + if (unit->beer_temperature != temp) { + unit->mqtt_flag |= MQTT_FLAG_DATA; + pub_domoticz_temp(unit->beer_idx, temp); } + unit->beer_temperature = temp; + unit->beer_state = 0; } else if (rc == DEVPRESENT_ERROR) { unit->beer_state = 1; } else { @@ -1334,18 +1303,12 @@ if (unit->chiller_address) { rc = device_in(unit->chiller_address, &temp); if (rc == DEVPRESENT_YES) { - deviation = 40000; - if ((unit->chiller_temperature == 0) || - (unit->chiller_temperature && (temp > (int)unit->chiller_temperature - deviation) && (temp < ((int)unit->chiller_temperature + deviation)))) { - if (unit->chiller_temperature != temp) { - unit->mqtt_flag |= MQTT_FLAG_DATA; - pub_domoticz_temp(unit->chiller_idx, temp); - } - unit->chiller_temperature = temp; - unit->chiller_state = 0; - } else { - syslog(LOG_NOTICE, "deviation error chiller deviation=%d, old=%d new=%d", deviation, unit->chiller_temperature, temp); + if (unit->chiller_temperature != temp) { + unit->mqtt_flag |= MQTT_FLAG_DATA; + pub_domoticz_temp(unit->chiller_idx, temp); } + unit->chiller_temperature = temp; + unit->chiller_state = 0; } else if (rc == DEVPRESENT_ERROR) { unit->chiller_state = 1; } else { @@ -1524,10 +1487,6 @@ * This is our current step */ valid_step = TRUE; - // if (debug) - // fprintf(stdout, "step=%d step_pos=%d step=%d/%d target=%.1f..%.1f ", - // current_step, run_hours - time_until_now, - // step->steptime, step->resttime, step->target_lo, step->target_hi); if ((run_hours - time_until_now) < step->steptime) { unit->prof_target_lo = previous_target_lo + (((run_minutes - (time_until_now * 60.0)) / (step->steptime * 60.0)) * (step->target_lo - previous_target_lo)); unit->prof_target_hi = previous_target_hi + (((run_minutes - (time_until_now * 60.0)) / (step->steptime * 60.0)) * (step->target_hi - previous_target_hi)); @@ -1541,18 +1500,10 @@ if (debug) fprintf(stdout, "prof_fridge_mode=%d run_minutes=%d steptime=%d time_until_now=%d\n", unit->prof_fridge_mode, run_minutes, step->steptime, time_until_now); - // if (debug) - // fprintf(stdout, "tempshift=%.1f..%.1f minutes=%d duration=%d temp_move=%.3f..%.3f ", - // step->target_lo - previous_target_lo, - // step->target_hi - previous_target_hi, - // run_minutes - (time_until_now * 60), - // step->steptime * 60, unit->prof_target_lo, unit->prof_target_hi); } else { unit->prof_target_lo = step->target_lo; unit->prof_target_hi = step->target_hi; unit->prof_fridge_mode = step->fridge_mode; - // if (debug) - // fprintf(stdout, "resting target=%.1f..%.1f ", step->target_lo, step->target_hi); } break; } @@ -1561,8 +1512,6 @@ previous_target_hi = step->target_hi; previous_fridge_mode = step->fridge_mode; } - // if (debug) - // fprintf(stdout, " %s %02d:%02d\n", valid_step ? "TRUE":"FALSE", minutes, seconds); if (valid_step == TRUE) { unit->prof_percent = (100 * run_minutes) / tot_minutes; @@ -1688,9 +1637,6 @@ */ usetemp = ((unit->prof_fridge_mode * (unit->air_temperature / 1000.0)) + ((100 - unit->prof_fridge_mode) * (unit->beer_temperature / 1000.0))) / 100.0; - if (debug) - fprintf(stdout, " fridge_mode=%d measured=%.3f %.3f => %.3f\n", unit->prof_fridge_mode, - unit->air_temperature / 1000.0, unit->beer_temperature / 1000.0, usetemp); unit->PID_cool->Input = unit->PID_heat->Input = usetemp; unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_AUTO; } @@ -1963,60 +1909,10 @@ seconds = 0; /* - * Log temperature and status every minute if unit is active. + * Publish data every minute if unit is active. */ for (unit = Config.units; unit; unit = unit->next) { if (unit->mode != UNITMODE_OFF) { - - snprintf(target_lo, 39, "NA"); - snprintf(target_hi, 39, "NA"); - snprintf(heater, 39, "NA"); - snprintf(cooler, 39, "NA"); - snprintf(fan, 39, "NA"); - snprintf(door, 39, "NA"); - snprintf(use_heater, 39, "NA"); - snprintf(use_cooler, 39, "NA"); - snprintf(use_fan, 39, "NA"); - snprintf(room_temp, 39, "NA"); - - if ((unit->mode == UNITMODE_BEER) || (unit->mode == UNITMODE_FRIDGE) || (unit->mode == UNITMODE_PROFILE)) { - snprintf(target_lo, 39, "%.1f", unit->PID_heat->SetP); - snprintf(target_hi, 39, "%.1f", unit->PID_cool->SetP); - } - - if (unit->heater_address) { - snprintf(heater, 39, "%d", unit->heater_state); - snprintf(use_heater, 39, "%d", unit->heater_usage); - } - if (unit->cooler_address) { - snprintf(cooler, 39, "%d", unit->cooler_state); - snprintf(use_cooler, 39, "%d", unit->cooler_usage); - } - if (unit->fan_address) { - snprintf(fan, 39, "%d", unit->fan_state); - snprintf(use_fan, 39, "%d", unit->fan_usage); - } - if (unit->door_address) { - snprintf(door, 39, "%d", unit->door_state); - } - if (Config.temp_address) { - snprintf(room_temp, 39, "%.3f", Config.temp_value / 1000.0); - } - - snprintf(buf, 1023, "%s,%.3f,%.3f,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%.3f,%s", - UNITMODE[unit->mode], unit->air_temperature / 1000.0, - unit->beer_temperature / 1000.0, - target_lo, heater, cooler, fan, door, use_heater, use_cooler, use_fan, room_temp, target_hi, - unit->chiller_temperature / 1000.0, - (unit->event_msg) ? unit->event_msg : (char *)""); - filename = xstrcpy(unit->product_code); - filename = xstrcat(filename, (char *)" "); - filename = xstrcat(filename, unit->product_name); - filename = xstrcat(filename, (char *)".log"); - logger(filename, buf); - free(filename); - filename = NULL; - publishDLog(unit); if (unit->event_msg) free(unit->event_msg); diff -r 1ff1a95a7614 -r 44d41db09466 www-thermferm/archives.php --- a/www-thermferm/archives.php Thu May 09 15:17:30 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,328 +0,0 @@ - - * - * Copyright (C) 2015-2018 - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * ThermFerm is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ThermFerm; see the file COPYING. If not, write to the Free - * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - - -require_once('utilities.php'); -$my_style = 'ui-redmond'; - -if (isset($_GET['action'])) { - switch ($_GET['action']) { - case 'dl': archive_dl(); - break; - case 'view': archive_view(); - break; - default: break; - } -} else { - archive_dir(); -} - -exit; - -/**************************************************************************** - * - */ - -/* - * View an archived file in graph format - */ -function archive_view() { - - global $my_style; - - $name = urldecode($_GET['name']); - $return = urldecode($_GET['return']); - - $answer = send_cmd('GLOBAL GET'); - $arr = explode("\r\n", $answer); - $version = "?"; - - if (startsWith($arr[0], "213")) { - $j = 1; - while (1) { - if (strcmp($arr[$j], ".") == 0) - break; - $f = explode(",", $arr[$j]); - - if ($f[0] == "RELEASE") - $version = $f[1]; - $j++; - } - } - - $outstr = ''.PHP_EOL; - $outstr .= ''.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' Archive View '.$name.''.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - - $outstr .= ' '.PHP_EOL; - $outstr .= build_footer(); - echo $outstr; -} - - - -/* - * Download popup. The file contents is dynamic generated from - * the thermferm server. - */ -function archive_dl() { - - $name = urldecode($_GET['name']) . ".log"; - - header('Content-Type: text/plain'); - header('Content-Disposition: attachment; filename="'.$name.'"'); - - $answer = send_cmd('ARCHIVE GET '.$name); - $arr = explode("\r\n", $answer); - - $outstr = ''; - if (startsWith($arr[0], "212")) { - $j = 1; - while (1) { - if (strcmp($arr[$j], ".") == 0) - break; - $outstr .= $arr[$j].PHP_EOL; - $j++; - } - } - echo $outstr; - exit(); -} - - - -/* - * Show directory - */ -function archive_dir() { - - $answer = send_cmd("ARCHIVE DIR"); - $reply = explode("\r\n", $answer); - - $outstr = build_header("Archived logfiles"); - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - - if (startsWith($reply[0], "212")) { - $j = 1; - while (1) { - if (strcmp($reply[$j], ".") == 0) - break; - $f = explode(",", $reply[$j]); - $name = urlencode(basename($f[0], ".log")); - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $j++; - } - } - - $outstr .= '
File nameModeSizeDateAction
'.$f[0].''.$f[1].''.$f[2].''.$f[3].'Download'; - $outstr .= ' View
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= build_footer(); - echo $outstr; -} - - - diff -r 1ff1a95a7614 -r 44d41db09466 www-thermferm/css/style.css --- a/www-thermferm/css/style.css Thu May 09 15:17:30 2019 +0200 +++ b/www-thermferm/css/style.css Sun Jul 07 13:55:03 2019 +0200 @@ -193,8 +193,6 @@ * |+----------++----------++----------+| * || switch1 || switch2 || switch3 || * |+----------++----------++----------+| - * +------------------------------------+ - * +----------pannel_buttons------------+ * | | * +------------------------------------+ */ @@ -295,7 +293,7 @@ #fermentor_panel_control { width: 236px; - height: 100px; + height: 136px; float: right; background-color: #eee; border: 2px solid; @@ -370,16 +368,6 @@ margin-top: 10px; } -#fermentor_panel_buttons { - width: 236px; - height: 30px; - float: right; - background-color: #eee; - border: 2px solid; - border-color: #888; - border-radius: 5px 5px 5px 5px; -} - #menu { width: 600px; height: 300px; diff -r 1ff1a95a7614 -r 44d41db09466 www-thermferm/liveview.php --- a/www-thermferm/liveview.php Thu May 09 15:17:30 2019 +0200 +++ b/www-thermferm/liveview.php Sun Jul 07 13:55:03 2019 +0200 @@ -381,17 +381,6 @@ $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; } diff -r 1ff1a95a7614 -r 44d41db09466 www-thermferm/maintenance.php --- a/www-thermferm/maintenance.php Thu May 09 15:17:30 2019 +0200 +++ b/www-thermferm/maintenance.php Sun Jul 07 13:55:03 2019 +0200 @@ -79,9 +79,6 @@ $outstr .= '
'.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= '
'.PHP_EOL; -$outstr .= '
'.PHP_EOL; -$outstr .= ' '.PHP_EOL; -$outstr .= '
'.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= '