# HG changeset patch # User Michiel Broek # Date 1713091562 -7200 # Node ID 09b5efe0c633e95245ee631066587564ad1366f3 # Parent 825210ba27076f2b881e0d3e06a1767d7333178b Add stylesheet, about page. Add menu for fermenters. Add websocket port setup to the config server. diff -r 825210ba2707 -r 09b5efe0c633 thermferm/server.c --- a/thermferm/server.c Sat Apr 13 16:50:26 2024 +0200 +++ b/thermferm/server.c Sun Apr 14 12:46:02 2024 +0200 @@ -613,6 +613,7 @@ srv_send(s, (char *)"MQTT_PORT,%d", Config.mqtt_port); srv_send(s, (char *)"MQTT_USER,%s", Config.mqtt_username); srv_send(s, (char *)"MQTT_PASS,%s", Config.mqtt_password); + srv_send(s, (char *)"WEBSOCKET_PORT,%d", Config.websocket_port); srv_send(s, (char *)"."); return 0; } @@ -751,6 +752,14 @@ else Config.mqtt_password = NULL; + } else if (val && (strcmp(kwd, (char *)"WEBSOCKET_PORT") == 0)) { + if (sscanf(val, "%d", &ival) == 1) { + if (Config.websocket_port != ival) { + syslog(LOG_NOTICE, "Global Websocket port %d to %d", Config.websocket_port, ival); + Config.websocket_port = ival; + } + } + } } } diff -r 825210ba2707 -r 09b5efe0c633 thermferm/websocket.c --- a/thermferm/websocket.c Sat Apr 13 16:50:26 2024 +0200 +++ b/thermferm/websocket.c Sun Apr 14 12:46:02 2024 +0200 @@ -75,6 +75,7 @@ ws_clients++; pss->ringbuffer_tail = ringbuffer_head; pss->wsi = wsi; + syslog(LOG_NOTICE, "Websocket: new client, now %d", ws_clients); break; } @@ -115,7 +116,7 @@ memcpy(buf, in, len); buf[len] = '\0'; - // syslog(LOG_NOTICE, "ws: reveived %ld bytes %s", len, buf); + syslog(LOG_NOTICE, "ws: reveived %ld bytes %s", len, buf); /* * These are send by bmsapp to bmsd. Then bmsd resends these via MQTT. * Do we want to change that? Or use it for the new web pages. @@ -136,6 +137,7 @@ case LWS_CALLBACK_CLOSED: ws_clients--; + syslog(LOG_NOTICE, "Websocket: del client, now %d", ws_clients); break; default: diff -r 825210ba2707 -r 09b5efe0c633 www/css/style.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/css/style.css Sun Apr 14 12:46:02 2024 +0200 @@ -0,0 +1,31 @@ +/* local style for thermferm web + */ + +body { + background: #ccc; + font-family: Verdana, Arial, sans-serif; + margin: 0px; +} + + +#MainPanel, +#fermenter { + width: 1278px; + height: 628px; + border: 2px solid #4297d7; + background: #252526; + float: left; + color: #eeeeee; +} + + +#about_table { + width: 960px; + background: #353536; + margin: 150px; + border: 2px solid; + border-color: #59b4d4; + border-radius: 5px 5px 5px 5px; +} + + diff -r 825210ba2707 -r 09b5efe0c633 www/gen_about.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/gen_about.php Sun Apr 14 12:46:02 2024 +0200 @@ -0,0 +1,21 @@ + + +
+
+
+ + + + + + +
About ThermFerm
Version:
Written by:M. Broek
Widgets and style:jQWidgets
+
+
+ + diff -r 825210ba2707 -r 09b5efe0c633 www/images/fridge.png Binary file www/images/fridge.png has changed diff -r 825210ba2707 -r 09b5efe0c633 www/includes/global.inc.php --- a/www/includes/global.inc.php Sat Apr 13 16:50:26 2024 +0200 +++ b/www/includes/global.inc.php Sun Apr 14 12:46:02 2024 +0200 @@ -24,25 +24,72 @@ /* * Look for the style names in the jqwidgets/styles directory. */ -$my_style = 'ui-redmond'; -//$my_style = 'ui-mbse'; +//$my_style = 'ui-redmond'; +$my_style = 'ui-mbse'; require_once($_SERVER['DOCUMENT_ROOT'].'/version.php'); +function open_socket() +{ + $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + + if (!($sock === false)) { + if (socket_connect($sock, "localhost", 6554)) { + socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 15, 'usec' => 0)); + } else { + socket_close($sock); + } + } + return $sock; +} + + +/** + * @param string $command to send to the server. + * @return string with the complete reply from the + * server. This can be a multiline reply. + */ +function send_cmd($command) +{ + $sock = open_socket(); + if ($sock == false) { + return ""; + } + socket_write($sock, $command . "\r\n", 4096); + + $answer = ""; + while (1) { + $line = socket_read($sock, 4096); + if ($line === '') + break; + $answer .= $line; + } + socket_close($sock); + + return $answer; +} + + +function startsWith($haystack, $needle) +{ + return !strncmp($haystack, $needle, strlen($needle)); +} + + function page_header($title, $loadjs) { global $my_style; global $my_version; ?> - + - + ThermFerm v<?php echo $my_version;?> - <?php echo $title;?> - + - + @@ -72,6 +119,28 @@