Fri, 29 May 2020 09:17:52 +0200
Added websocket_port to the bms.conf file. Log the used port number.
bmsd/bms.h | file | annotate | diff | comparison | revisions | |
bmsd/rdconfig.c | file | annotate | diff | comparison | revisions | |
bmsd/websocket.c | file | annotate | diff | comparison | revisions |
--- 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;
--- 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 </path/to/webroot>\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(); }
--- 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.