# HG changeset patch # User Michiel Broek # Date 1590736672 -7200 # Node ID f4de55f587c1f316fa5ce8d6027237f1d76829d1 # Parent cfe2327100274ba9030cb9bb2898f758644b25ff Added websocket_port to the bms.conf file. Log the used port number. diff -r cfe232710027 -r f4de55f587c1 bmsd/bms.h --- a/bmsd/bms.h Thu May 28 14:23:14 2020 +0200 +++ b/bmsd/bms.h Fri May 29 09:17:52 2020 +0200 @@ -78,6 +78,7 @@ char *mqtt_user; ///< MQTT username of NULL char *mqtt_pass; ///< MQTT password of NULL char *web_root; ///< WWW root directory + int websocket_port; ///< Websocket port } sys_config; diff -r cfe232710027 -r f4de55f587c1 bmsd/rdconfig.c --- a/bmsd/rdconfig.c Thu May 28 14:23:14 2020 +0200 +++ b/bmsd/rdconfig.c Fri May 29 09:17:52 2020 +0200 @@ -54,6 +54,7 @@ {(char *)"mqtt_user", getstr, (char **)&Config.mqtt_user}, {(char *)"mqtt_pass", getstr, (char **)&Config.mqtt_pass}, {(char *)"web_root", getstr, (char **)&Config.web_root}, + {(char *)"websocket_port", getint, (char **)&Config.websocket_port}, {NULL, NULL, NULL} }; @@ -99,6 +100,7 @@ if (Config.web_root) free(Config.web_root); Config.web_root = NULL; + Config.websocket_port = 8010; } @@ -161,6 +163,7 @@ fprintf(fp, "web_root %s\n", Config.web_root); else fprintf(fp, "#web_root \n"); + fprintf(fp, "websocket_port %d\n", Config.websocket_port); fprintf(fp, "#\n"); fprintf(fp, "# End of generated configuration\n"); fclose(fp); @@ -198,6 +201,7 @@ Config.mysql_host = xstrcpy((char *)"localhost"); Config.mqtt_port = 1883; Config.mqtt_host = xstrcpy((char *)"localhost"); + Config.websocket_port = 8010; return wrconfig(); } diff -r cfe232710027 -r f4de55f587c1 bmsd/websocket.c --- a/bmsd/websocket.c Thu May 28 14:23:14 2020 +0200 +++ b/bmsd/websocket.c Fri May 29 09:17:52 2020 +0200 @@ -210,10 +210,8 @@ struct lws_context_creation_info info; int n = 0; - syslog(LOG_NOTICE, "Thread ws_loop started"); - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = 8010; + info.port = Config.websocket_port; info.protocols = protocols; info.gid = -1; info.uid = -1; @@ -225,6 +223,7 @@ if (context == NULL) { syslog(LOG_NOTICE, "libwebsocket_create_context() failed"); } + syslog(LOG_NOTICE, "Websocket server port %d started", info.port); /* * Loop forever until external shutdown variable is set.