From 87d0db0b5cbda0a88de52bf09df870d67f15b0a9 Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 28 Sep 2022 20:27:48 +0200 Subject: [PATCH] auto formatting --- interface/package-lock.json | 132 +++--- interface/package.json | 8 +- lib/framework/APSettingsService.cpp | 6 +- lib/framework/NTPSettingsService.h | 3 +- lib/framework/NetworkSettingsService.cpp | 6 +- lib/uuid-console/src/shell.cpp | 26 +- lib/uuid-console/src/uuid/console.h | 32 +- lib/uuid-log/src/uuid/log.h | 4 +- lib/uuid-telnet/src/stream.cpp | 487 ++++++++++----------- lib/uuid-telnet/src/uuid/telnet.h | 279 ++++++------ lib_standalone/AsyncMqttClient.h | 10 +- lib_standalone/HttpEndpoint.h | 189 ++++---- lib_standalone/Network.h | 42 +- lib_standalone/SecuritySettingsService.cpp | 173 ++++---- lib_standalone/StatefulService.h | 6 +- src/analogsensor.cpp | 2 +- src/command.cpp | 2 +- src/console.cpp | 56 +-- src/dallassensor.cpp | 12 +- src/devices/boiler.cpp | 16 +- src/devices/thermostat.cpp | 8 +- src/emsdevice.cpp | 26 +- src/emsesp.cpp | 40 +- src/mqtt.cpp | 24 +- src/shower.cpp | 6 +- src/system.cpp | 72 +-- src/telegram.cpp | 6 +- src/test/test.cpp | 118 ++--- src/version.h | 2 +- src/web/WebAPIService.cpp | 2 +- src/web/WebDataService.cpp | 2 +- src/web/WebStatusService.cpp | 12 +- 32 files changed, 893 insertions(+), 916 deletions(-) diff --git a/interface/package-lock.json b/interface/package-lock.json index 03ebd707e..96f64bf37 100644 --- a/interface/package-lock.json +++ b/interface/package-lock.json @@ -12,10 +12,10 @@ "@emotion/styled": "^11.10.4", "@msgpack/msgpack": "^2.8.0", "@mui/icons-material": "^5.10.6", - "@mui/material": "^5.10.6", + "@mui/material": "^5.10.7", "@table-library/react-table-library": "4.0.18", "@types/lodash": "^4.14.185", - "@types/node": "^18.7.20", + "@types/node": "^18.7.23", "@types/react": "^18.0.21", "@types/react-dom": "^18.0.6", "@types/react-router-dom": "^5.3.3", @@ -34,8 +34,8 @@ "react-router-dom": "^6.4.1", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typesafe-i18n": "^5.13.0", - "typescript": "^4.8.3" + "typesafe-i18n": "^5.13.1", + "typescript": "^4.8.4" }, "devDependencies": { "nodemon": "^2.0.20", @@ -3103,9 +3103,9 @@ } }, "node_modules/@mui/base": { - "version": "5.0.0-alpha.98", - "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.98.tgz", - "integrity": "sha512-c0U51+K2m57MASpRrmNs6qTXSvktDbVcSjD8zCRPbfuwYWERGGwNxwM3/jsBa4dSojTSmLPnOBFDypl74Ds6yQ==", + "version": "5.0.0-alpha.99", + "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.99.tgz", + "integrity": "sha512-D04H6O1c0Jv561yI0SVbpa8MpqpW3G43CwJxV2o6ALfI0DMJ45w07dGafmDchb6aCWTRTdggd3rjgmuzyNwPiQ==", "dependencies": { "@babel/runtime": "^7.19.0", "@emotion/is-prop-valid": "^1.2.0", @@ -3135,9 +3135,9 @@ } }, "node_modules/@mui/core-downloads-tracker": { - "version": "5.10.6", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.6.tgz", - "integrity": "sha512-dmyQBqrKmVU6yCSM4GGal5qNXpViXX+/V1t0GA1A5i9QF5Gx6noV/cw0hrSS2ffLT8L2oScq1oTdA6NVIiQ8lg==", + "version": "5.10.7", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.7.tgz", + "integrity": "sha512-3N0UYVy3MbrHzM3j6f7fIUCZ+bQ1/sSZq143tLxwSssW3Z4AqE83brpr5flEY1Lx+Aowv/cPyQMmZxzRlFCGqw==", "funding": { "type": "opencollective", "url": "https://opencollective.com/mui" @@ -3169,19 +3169,19 @@ } }, "node_modules/@mui/material": { - "version": "5.10.6", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.6.tgz", - "integrity": "sha512-QilW5PAAGSQdN7Cpp4rwSQ1doJAt3ca1a2PHZtr8RLVlpHnXb+qQ8CeDo9+9V2fK5CDNdtTN1F+iJKO43aFBpQ==", + "version": "5.10.7", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.7.tgz", + "integrity": "sha512-o1jcQGii+q7ORrXhBiMmGzFDaboc1qTgOOC3zDW+NR9ryVzWzL7qEeqoORbgDB5zk9OBsXCjB91fUH/ls5xMwg==", "dependencies": { "@babel/runtime": "^7.19.0", - "@mui/base": "5.0.0-alpha.98", - "@mui/core-downloads-tracker": "^5.10.6", - "@mui/system": "^5.10.6", + "@mui/base": "5.0.0-alpha.99", + "@mui/core-downloads-tracker": "^5.10.7", + "@mui/system": "^5.10.7", "@mui/types": "^7.2.0", "@mui/utils": "^5.10.6", "@types/react-transition-group": "^4.4.5", "clsx": "^1.2.1", - "csstype": "^3.1.0", + "csstype": "^3.1.1", "prop-types": "^15.8.1", "react-is": "^18.2.0", "react-transition-group": "^4.4.5" @@ -3239,13 +3239,13 @@ } }, "node_modules/@mui/styled-engine": { - "version": "5.10.6", - "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.10.6.tgz", - "integrity": "sha512-OnVw5xnO4l0XzlJFhKif/RlLenBNhyEQQlSTwB9ApSWB05UAU5ZSbjNsRfyEKvgmQ/fPa+MqPD/dzxbIRCwyeg==", + "version": "5.10.7", + "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.10.7.tgz", + "integrity": "sha512-CCrtW+vvCKEm6pOE/QcutQ+ORC/iE6D1ghscN4l7LE2JXPvTXO/z0yu8Wxug1JEDlWm4r1Qa0PzJe1P9bjKzNA==", "dependencies": { "@babel/runtime": "^7.19.0", "@emotion/cache": "^11.10.3", - "csstype": "^3.1.0", + "csstype": "^3.1.1", "prop-types": "^15.8.1" }, "engines": { @@ -3270,17 +3270,17 @@ } }, "node_modules/@mui/system": { - "version": "5.10.6", - "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.6.tgz", - "integrity": "sha512-HfQVX7e2xpQ3jtdB/WwtkFVtozMOozyN575/63u8ILHkE8wGDhblmCieAsnyJPFbm7WBW5PCMyzmfr4QyKLaYg==", + "version": "5.10.7", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.7.tgz", + "integrity": "sha512-kwyhjjKGsgtBRFl6vSqidDZcNKU5S1juTgm4Xi2fyWxaEbIQb9Sh9y0iVP2bNCJzgDr0alLaENOZOEaDWHISAQ==", "dependencies": { "@babel/runtime": "^7.19.0", "@mui/private-theming": "^5.10.6", - "@mui/styled-engine": "^5.10.6", + "@mui/styled-engine": "^5.10.7", "@mui/types": "^7.2.0", "@mui/utils": "^5.10.6", "clsx": "^1.2.1", - "csstype": "^3.1.0", + "csstype": "^3.1.1", "prop-types": "^15.8.1" }, "engines": { @@ -4029,9 +4029,9 @@ "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" }, "node_modules/@types/node": { - "version": "18.7.20", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.20.tgz", - "integrity": "sha512-adzY4vLLr5Uivmx8+zfSJ5fbdgKxX8UMtjtl+17n0B1q1Nz8JEmE151vefMdpD+1gyh+77weN4qEhej/O7budQ==" + "version": "18.7.23", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz", + "integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg==" }, "node_modules/@types/parse-json": { "version": "4.0.0", @@ -16420,9 +16420,9 @@ } }, "node_modules/typesafe-i18n": { - "version": "5.13.0", - "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.13.0.tgz", - "integrity": "sha512-Q72l+LqB37kNT2R39mkTwQy1tuQ7URAahD1QXbR84itO864xvVgdoS8xaRAatp0y2/oU7f+2EzpAK3YGp0g+eA==", + "version": "5.13.1", + "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.13.1.tgz", + "integrity": "sha512-9Cgikxcj+2LAWQGZ8pOQAf14P+aOOcOel/G1kSAXAObA4Htj8R+qgCx9DqUnxjRfugWzM/19ZqGss7dl8Dw7Gg==", "bin": { "typesafe-i18n": "cli/typesafe-i18n.mjs" }, @@ -16435,9 +16435,9 @@ } }, "node_modules/typescript": { - "version": "4.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", - "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -19643,9 +19643,9 @@ "integrity": "sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ==" }, "@mui/base": { - "version": "5.0.0-alpha.98", - "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.98.tgz", - "integrity": "sha512-c0U51+K2m57MASpRrmNs6qTXSvktDbVcSjD8zCRPbfuwYWERGGwNxwM3/jsBa4dSojTSmLPnOBFDypl74Ds6yQ==", + "version": "5.0.0-alpha.99", + "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.99.tgz", + "integrity": "sha512-D04H6O1c0Jv561yI0SVbpa8MpqpW3G43CwJxV2o6ALfI0DMJ45w07dGafmDchb6aCWTRTdggd3rjgmuzyNwPiQ==", "requires": { "@babel/runtime": "^7.19.0", "@emotion/is-prop-valid": "^1.2.0", @@ -19658,9 +19658,9 @@ } }, "@mui/core-downloads-tracker": { - "version": "5.10.6", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.6.tgz", - "integrity": "sha512-dmyQBqrKmVU6yCSM4GGal5qNXpViXX+/V1t0GA1A5i9QF5Gx6noV/cw0hrSS2ffLT8L2oScq1oTdA6NVIiQ8lg==" + "version": "5.10.7", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.7.tgz", + "integrity": "sha512-3N0UYVy3MbrHzM3j6f7fIUCZ+bQ1/sSZq143tLxwSssW3Z4AqE83brpr5flEY1Lx+Aowv/cPyQMmZxzRlFCGqw==" }, "@mui/icons-material": { "version": "5.10.6", @@ -19671,19 +19671,19 @@ } }, "@mui/material": { - "version": "5.10.6", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.6.tgz", - "integrity": "sha512-QilW5PAAGSQdN7Cpp4rwSQ1doJAt3ca1a2PHZtr8RLVlpHnXb+qQ8CeDo9+9V2fK5CDNdtTN1F+iJKO43aFBpQ==", + "version": "5.10.7", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.7.tgz", + "integrity": "sha512-o1jcQGii+q7ORrXhBiMmGzFDaboc1qTgOOC3zDW+NR9ryVzWzL7qEeqoORbgDB5zk9OBsXCjB91fUH/ls5xMwg==", "requires": { "@babel/runtime": "^7.19.0", - "@mui/base": "5.0.0-alpha.98", - "@mui/core-downloads-tracker": "^5.10.6", - "@mui/system": "^5.10.6", + "@mui/base": "5.0.0-alpha.99", + "@mui/core-downloads-tracker": "^5.10.7", + "@mui/system": "^5.10.7", "@mui/types": "^7.2.0", "@mui/utils": "^5.10.6", "@types/react-transition-group": "^4.4.5", "clsx": "^1.2.1", - "csstype": "^3.1.0", + "csstype": "^3.1.1", "prop-types": "^15.8.1", "react-is": "^18.2.0", "react-transition-group": "^4.4.5" @@ -19700,28 +19700,28 @@ } }, "@mui/styled-engine": { - "version": "5.10.6", - "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.10.6.tgz", - "integrity": "sha512-OnVw5xnO4l0XzlJFhKif/RlLenBNhyEQQlSTwB9ApSWB05UAU5ZSbjNsRfyEKvgmQ/fPa+MqPD/dzxbIRCwyeg==", + "version": "5.10.7", + "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.10.7.tgz", + "integrity": "sha512-CCrtW+vvCKEm6pOE/QcutQ+ORC/iE6D1ghscN4l7LE2JXPvTXO/z0yu8Wxug1JEDlWm4r1Qa0PzJe1P9bjKzNA==", "requires": { "@babel/runtime": "^7.19.0", "@emotion/cache": "^11.10.3", - "csstype": "^3.1.0", + "csstype": "^3.1.1", "prop-types": "^15.8.1" } }, "@mui/system": { - "version": "5.10.6", - "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.6.tgz", - "integrity": "sha512-HfQVX7e2xpQ3jtdB/WwtkFVtozMOozyN575/63u8ILHkE8wGDhblmCieAsnyJPFbm7WBW5PCMyzmfr4QyKLaYg==", + "version": "5.10.7", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.7.tgz", + "integrity": "sha512-kwyhjjKGsgtBRFl6vSqidDZcNKU5S1juTgm4Xi2fyWxaEbIQb9Sh9y0iVP2bNCJzgDr0alLaENOZOEaDWHISAQ==", "requires": { "@babel/runtime": "^7.19.0", "@mui/private-theming": "^5.10.6", - "@mui/styled-engine": "^5.10.6", + "@mui/styled-engine": "^5.10.7", "@mui/types": "^7.2.0", "@mui/utils": "^5.10.6", "clsx": "^1.2.1", - "csstype": "^3.1.0", + "csstype": "^3.1.1", "prop-types": "^15.8.1" } }, @@ -20233,9 +20233,9 @@ "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" }, "@types/node": { - "version": "18.7.20", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.20.tgz", - "integrity": "sha512-adzY4vLLr5Uivmx8+zfSJ5fbdgKxX8UMtjtl+17n0B1q1Nz8JEmE151vefMdpD+1gyh+77weN4qEhej/O7budQ==" + "version": "18.7.23", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz", + "integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg==" }, "@types/parse-json": { "version": "4.0.0", @@ -29096,15 +29096,15 @@ } }, "typesafe-i18n": { - "version": "5.13.0", - "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.13.0.tgz", - "integrity": "sha512-Q72l+LqB37kNT2R39mkTwQy1tuQ7URAahD1QXbR84itO864xvVgdoS8xaRAatp0y2/oU7f+2EzpAK3YGp0g+eA==", + "version": "5.13.1", + "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.13.1.tgz", + "integrity": "sha512-9Cgikxcj+2LAWQGZ8pOQAf14P+aOOcOel/G1kSAXAObA4Htj8R+qgCx9DqUnxjRfugWzM/19ZqGss7dl8Dw7Gg==", "requires": {} }, "typescript": { - "version": "4.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", - "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==" + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==" }, "unbox-primitive": { "version": "1.0.2", diff --git a/interface/package.json b/interface/package.json index 80fa0fc84..ee3976892 100644 --- a/interface/package.json +++ b/interface/package.json @@ -8,10 +8,10 @@ "@emotion/styled": "^11.10.4", "@msgpack/msgpack": "^2.8.0", "@mui/icons-material": "^5.10.6", - "@mui/material": "^5.10.6", + "@mui/material": "^5.10.7", "@table-library/react-table-library": "4.0.18", "@types/lodash": "^4.14.185", - "@types/node": "^18.7.20", + "@types/node": "^18.7.23", "@types/react": "^18.0.21", "@types/react-dom": "^18.0.6", "@types/react-router-dom": "^5.3.3", @@ -30,8 +30,8 @@ "react-router-dom": "^6.4.1", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typesafe-i18n": "^5.13.0", - "typescript": "^4.8.3" + "typesafe-i18n": "^5.13.1", + "typescript": "^4.8.4" }, "scripts": { "start": "react-app-rewired start", diff --git a/lib/framework/APSettingsService.cpp b/lib/framework/APSettingsService.cpp index 0f9967aff..065f10bd2 100644 --- a/lib/framework/APSettingsService.cpp +++ b/lib/framework/APSettingsService.cpp @@ -49,9 +49,9 @@ void APSettingsService::startAP() { WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask); esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_AP, WIFI_BW_HT20); WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), _state.channel, _state.ssidHidden, _state.maxClients); - #ifdef ARDUINO_LOLIN_C3_MINI - WiFi.setTxPower(WIFI_POWER_8_5dBm); //https://www.wemos.cc/en/latest/c3/c3_mini.html#about-wifi - #endif +#ifdef ARDUINO_LOLIN_C3_MINI + WiFi.setTxPower(WIFI_POWER_8_5dBm); //https://www.wemos.cc/en/latest/c3/c3_mini.html#about-wifi +#endif if (!_dnsServer) { IPAddress apIp = WiFi.softAPIP(); emsesp::EMSESP::logger().info(F("Starting Access Point with captive portal on %s"), apIp.toString().c_str()); diff --git a/lib/framework/NTPSettingsService.h b/lib/framework/NTPSettingsService.h index 69125628a..6871ac053 100644 --- a/lib/framework/NTPSettingsService.h +++ b/lib/framework/NTPSettingsService.h @@ -56,7 +56,7 @@ class NTPSettingsService : public StatefulService { public: NTPSettingsService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager); - void begin(); + void begin(); static void ntp_received(struct timeval * tv); private: @@ -68,7 +68,6 @@ class NTPSettingsService : public StatefulService { void WiFiEvent(WiFiEvent_t event); void configureNTP(); void configureTime(AsyncWebServerRequest * request, JsonVariant & json); - }; #endif diff --git a/lib/framework/NetworkSettingsService.cpp b/lib/framework/NetworkSettingsService.cpp index 814bd5dde..075857a14 100644 --- a/lib/framework/NetworkSettingsService.cpp +++ b/lib/framework/NetworkSettingsService.cpp @@ -75,9 +75,9 @@ void NetworkSettingsService::manageSTA() { }); WiFi.begin(_state.ssid.c_str(), _state.password.c_str()); // attempt to connect to the network - #ifdef ARDUINO_LOLIN_C3_MINI - WiFi.setTxPower(WIFI_POWER_8_5dBm); //https://www.wemos.cc/en/latest/c3/c3_mini.html#about-wifi - #endif +#ifdef ARDUINO_LOLIN_C3_MINI + WiFi.setTxPower(WIFI_POWER_8_5dBm); //https://www.wemos.cc/en/latest/c3/c3_mini.html#about-wifi +#endif } } diff --git a/lib/uuid-console/src/shell.cpp b/lib/uuid-console/src/shell.cpp index 54d2f2079..489ea69f3 100644 --- a/lib/uuid-console/src/shell.cpp +++ b/lib/uuid-console/src/shell.cpp @@ -262,32 +262,30 @@ void Shell::loop_normal() { } else if (esc_ == 1) { // pos1 cursor_ = line_buffer_.length(); } else if (esc_ == 11) { // F1 - - // TODO use flash here? - set_command_str(("help")); + set_command_str("help"); } else if (esc_ == 12) { // F2 - set_command_str(("show")); + set_command_str("show"); } else if (esc_ == 13) { // F3 - set_command_str(("log notice")); + set_command_str("log notice"); } else if (esc_ == 14) { // F4 - set_command_str(("log info")); + set_command_str("log info"); } else if (esc_ == 15) { // F5 - set_command_str(("log debug")); + set_command_str("log debug"); } else if (esc_ == 17) { // F6 - set_command_str(("watch off")); + set_command_str("watch off"); } else if (esc_ == 18) { // F7 - set_command_str(("watch on")); + set_command_str("watch on"); } else if (esc_ == 19) { // F8 - set_command_str(("watch raw")); + set_command_str("watch raw"); } else if (esc_ == 20) { // F9 - set_command_str(("call system info")); + set_command_str("call system info"); } else if (esc_ == 21) { // F10 - set_command_str(("call system settings")); + set_command_str("call system settings"); } else if (esc_ == 23) { // F11 - line_buffer_ = (("call send \"0B \"")); + line_buffer_ = ("call send \"0B \""); cursor_ = 1; } else if (esc_ == 24) { // F12 - set_command_str(("log debug; watch raw")); + set_command_str("log debug; watch raw"); } esc_ = 0; } else if (c >= '0' && (c <= '9')) { // numbers diff --git a/lib/uuid-console/src/uuid/console.h b/lib/uuid-console/src/uuid/console.h index d2c8a3727..fc15563d7 100644 --- a/lib/uuid-console/src/uuid/console.h +++ b/lib/uuid-console/src/uuid/console.h @@ -685,8 +685,8 @@ class Shell : public std::enable_shared_from_this, public uuid::log::Hand PasswordData(const char * password_prompt, password_function && password_function); ~PasswordData() override = default; - const char * password_prompt_; /*!< Prompt requesting password input. @since 0.1.0 */ - password_function password_function_; /*!< Function to execute after password entry. @since 0.1.0 */ + const char * password_prompt_; /*!< Prompt requesting password input. @since 0.1.0 */ + password_function password_function_; /*!< Function to execute after password entry. @since 0.1.0 */ }; /** @@ -761,7 +761,7 @@ class Shell : public std::enable_shared_from_this, public uuid::log::Hand const std::shared_ptr content_; /*!< Log message content. @since 0.1.0 */ }; - Shell(const Shell &) = delete; + Shell(const Shell &) = delete; Shell & operator=(const Shell &) = delete; /** @@ -906,7 +906,7 @@ class Shell : public std::enable_shared_from_this, public uuid::log::Hand size_t maximum_log_messages_ = MAX_LOG_MESSAGES; /*!< Maximum command line length in bytes. @since 0.6.0 */ std::string line_buffer_; /*!< Command line buffer. Limited to maximum_command_line_length() bytes. @since 0.1.0 */ std::string line_old_[MAX_LINES]; /*!< old Command line buffer.*/ - uint8_t line_no_ = 0; + uint8_t line_no_ = 0; size_t maximum_command_line_length_ = MAX_COMMAND_LINE_LENGTH; /*!< Maximum command line length in bytes. @since 0.6.0 */ unsigned char previous_ = 0; /*!< Previous character that was entered on the command line. Used to detect CRLF line endings. @since 0.1.0 */ uint8_t cursor_ = 0; /*!< cursor position from end of line */ @@ -955,9 +955,9 @@ class CommandLine { ~CommandLine() = default; #ifdef UNIT_TEST - CommandLine(CommandLine &&) = default; - CommandLine & operator=(CommandLine &&) = default; - CommandLine(const CommandLine &) __attribute__((deprecated)) = default; + CommandLine(CommandLine &&) = default; + CommandLine & operator=(CommandLine &&) = default; + CommandLine(const CommandLine &) __attribute__((deprecated)) = default; CommandLine & operator=(const CommandLine &) __attribute__((deprecated)) = default; #endif @@ -1279,8 +1279,8 @@ class Commands { */ void add_command(unsigned int context, unsigned int flags, - const string_vector & name, - const string_vector & arguments, + const string_vector & name, + const string_vector & arguments, command_function function, argument_completion_function arg_function); @@ -1344,11 +1344,7 @@ class Commands { * completions for this command. * @since 0.1.0 */ - Command(unsigned int flags, - const string_vector name, - const string_vector arguments, - command_function function, - argument_completion_function arg_function); + Command(unsigned int flags, const string_vector name, const string_vector arguments, command_function function, argument_completion_function arg_function); ~Command(); /** @@ -1372,13 +1368,13 @@ class Commands { } unsigned int flags_; /*!< Shell flags that must be set for this command to be available. @since 0.1.0 */ - const string_vector name_; /*!< Name of the command as a std::vector of flash strings. @since 0.1.0 */ - const string_vector arguments_; /*!< Help text for arguments that the command accepts as a std::vector of flash strings. @since 0.1.0 */ + const string_vector name_; /*!< Name of the command as a std::vector of flash strings. @since 0.1.0 */ + const string_vector arguments_; /*!< Help text for arguments that the command accepts as a std::vector of flash strings. @since 0.1.0 */ command_function function_; /*!< Function to be used when the command is executed. @since 0.1.0 */ argument_completion_function arg_function_; /*!< Function to be used to perform argument completions for this command. @since 0.1.0 */ private: - Command(const Command &) = delete; + Command(const Command &) = delete; Command & operator=(const Command &) = delete; }; @@ -1487,7 +1483,7 @@ class StreamConsole : virtual public Shell { explicit StreamConsole(Stream & stream); private: - StreamConsole(const StreamConsole &) = delete; + StreamConsole(const StreamConsole &) = delete; StreamConsole & operator=(const StreamConsole &) = delete; /** diff --git a/lib/uuid-log/src/uuid/log.h b/lib/uuid-log/src/uuid/log.h index 956e4615f..615bc7577 100644 --- a/lib/uuid-log/src/uuid/log.h +++ b/lib/uuid-log/src/uuid/log.h @@ -626,8 +626,8 @@ class Logger { static std::map handlers_; /*!< Registered log handlers. @since 1.0.0 */ static Level level_; /*!< Minimum global log level across all handlers. @since 1.0.0 */ - const char * name_; /*!< Logger name (flash string). @since 1.0.0 */ - const Facility facility_; /*!< Default logging facility for messages. @since 1.0.0 */ + const char * name_; /*!< Logger name (flash string). @since 1.0.0 */ + const Facility facility_; /*!< Default logging facility for messages. @since 1.0.0 */ }; } // namespace log diff --git a/lib/uuid-telnet/src/stream.cpp b/lib/uuid-telnet/src/stream.cpp index bafe3e392..adf5f16ec 100644 --- a/lib/uuid-telnet/src/stream.cpp +++ b/lib/uuid-telnet/src/stream.cpp @@ -28,329 +28,322 @@ namespace uuid { namespace telnet { -TelnetStream::TelnetStream(WiFiClient &client) - : client_(client) { - output_buffer_.reserve(BUFFER_SIZE); +TelnetStream::TelnetStream(WiFiClient & client) + : client_(client) { + output_buffer_.reserve(BUFFER_SIZE); } void TelnetStream::start() { - raw_write({ - IAC, WILL, OPT_ECHO, - IAC, WILL, OPT_BINARY, - IAC, WILL, OPT_SGA, - IAC, DONT, OPT_ECHO, - IAC, DO, OPT_BINARY, - IAC, DO, OPT_SGA - }); + raw_write({IAC, WILL, OPT_ECHO, IAC, WILL, OPT_BINARY, IAC, WILL, OPT_SGA, IAC, DONT, OPT_ECHO, IAC, DO, OPT_BINARY, IAC, DO, OPT_SGA}); } int TelnetStream::available() { - if (peek() == -1) { - return 0; - } else { - return 1; - } + if (peek() == -1) { + return 0; + } else { + return 1; + } } int TelnetStream::read() { - if (peek_ != -1) { - int data = peek_; - peek_ = -1; - return data; - } + if (peek_ != -1) { + int data = peek_; + peek_ = -1; + return data; + } - buffer_flush(); + buffer_flush(); restart: - int data = raw_read(); + int data = raw_read(); - if (data == -1) { - return -1; - } + if (data == -1) { + return -1; + } - unsigned char c = data; + unsigned char c = data; - if (sub_negotiation_) { - if (previous_raw_in_ == IAC) { - switch (c) { - case SE: - sub_negotiation_ = false; - previous_raw_in_ = 0; - goto restart; + if (sub_negotiation_) { + if (previous_raw_in_ == IAC) { + switch (c) { + case SE: + sub_negotiation_ = false; + previous_raw_in_ = 0; + goto restart; - case IAC: - previous_raw_in_ = 0; - goto restart; - } - } else { - switch (c) { - case IAC: - previous_raw_in_ = c; - goto restart; + case IAC: + previous_raw_in_ = 0; + goto restart; + } + } else { + switch (c) { + case IAC: + previous_raw_in_ = c; + goto restart; - default: - previous_raw_in_ = 0; - goto restart; - } - } - } else { - if (previous_raw_in_ == IAC) { - switch (c) { - case IP: - // Interrupt (^C) - previous_raw_in_ = 0; - c = '\x03'; - break; + default: + previous_raw_in_ = 0; + goto restart; + } + } + } else { + if (previous_raw_in_ == IAC) { + switch (c) { + case IP: + // Interrupt (^C) + previous_raw_in_ = 0; + c = '\x03'; + break; - case EC: - // Backspace (^H) - previous_raw_in_ = 0; - c = '\x08'; - break; + case EC: + // Backspace (^H) + previous_raw_in_ = 0; + c = '\x08'; + break; - case EL: - // Delete line (^U) - previous_raw_in_ = 0; - c = '\x15'; - break; + case EL: + // Delete line (^U) + previous_raw_in_ = 0; + c = '\x15'; + break; - case IAC: - previous_raw_in_ = 0; - break; + case IAC: + previous_raw_in_ = 0; + break; - case SB: - case WILL: - case WONT: - case DO: - case DONT: - previous_raw_in_ = c; - goto restart; + case SB: + case WILL: + case WONT: + case DO: + case DONT: + previous_raw_in_ = c; + goto restart; - case SE: - case DM: - case BRK: - case AO: - case AYT: - case GA: - case NOP: - default: - previous_raw_in_ = 0; - goto restart; - } - } else if (previous_raw_in_ == SB) { - sub_negotiation_ = true; - previous_raw_in_ = 0; - goto restart; - } else if (previous_raw_in_ == WILL || previous_raw_in_ == WONT) { - switch (c) { - case OPT_ECHO: - // Don't do these - raw_write({IAC, DONT, c}); - break; + case SE: + case DM: + case BRK: + case AO: + case AYT: + case GA: + case NOP: + default: + previous_raw_in_ = 0; + goto restart; + } + } else if (previous_raw_in_ == SB) { + sub_negotiation_ = true; + previous_raw_in_ = 0; + goto restart; + } else if (previous_raw_in_ == WILL || previous_raw_in_ == WONT) { + switch (c) { + case OPT_ECHO: + // Don't do these + raw_write({IAC, DONT, c}); + break; - case OPT_BINARY: - case OPT_SGA: - // Do these - raw_write({IAC, DO, c}); - break; + case OPT_BINARY: + case OPT_SGA: + // Do these + raw_write({IAC, DO, c}); + break; - default: - // Don't do anything else - raw_write({IAC, DONT, c}); - break; - } + default: + // Don't do anything else + raw_write({IAC, DONT, c}); + break; + } - previous_raw_in_ = 0; - goto restart; - } else if (previous_raw_in_ == DO) { - switch (c) { - case OPT_ECHO: - case OPT_BINARY: - case OPT_SGA: - // These are always enabled - break; + previous_raw_in_ = 0; + goto restart; + } else if (previous_raw_in_ == DO) { + switch (c) { + case OPT_ECHO: + case OPT_BINARY: + case OPT_SGA: + // These are always enabled + break; - default: - // Refuse to do anything else - raw_write({IAC, WONT, c}); - break; - } + default: + // Refuse to do anything else + raw_write({IAC, WONT, c}); + break; + } - previous_raw_in_ = 0; - goto restart; - } else if (previous_raw_in_ == DONT) { - switch (c) { - case OPT_ECHO: - case OPT_BINARY: - case OPT_SGA: - // Insist that we do these - raw_write({IAC, WILL, c}); - break; + previous_raw_in_ = 0; + goto restart; + } else if (previous_raw_in_ == DONT) { + switch (c) { + case OPT_ECHO: + case OPT_BINARY: + case OPT_SGA: + // Insist that we do these + raw_write({IAC, WILL, c}); + break; - default: - // Everything else is always disabled - break; - } + default: + // Everything else is always disabled + break; + } - previous_raw_in_ = 0; - goto restart; - } else { - switch (c) { - case IAC: - previous_raw_in_ = c; - goto restart; + previous_raw_in_ = 0; + goto restart; + } else { + switch (c) { + case IAC: + previous_raw_in_ = c; + goto restart; - default: - previous_raw_in_ = 0; - break; - } - } - } + default: + previous_raw_in_ = 0; + break; + } + } + } - if (previous_in_ == CR) { - if (c == NUL) { - previous_in_ = 0; - goto restart; - } - } + if (previous_in_ == CR) { + if (c == NUL) { + previous_in_ = 0; + goto restart; + } + } - previous_in_ = c; - return c; + previous_in_ = c; + return c; } int TelnetStream::peek() { - buffer_flush(); + buffer_flush(); - // It's too complicated to implement this by calling peek() - // on the original stream, especially if the original stream - // doesn't actually support peeking. - if (peek_ == -1) { - peek_ = read(); - } + // It's too complicated to implement this by calling peek() + // on the original stream, especially if the original stream + // doesn't actually support peeking. + if (peek_ == -1) { + peek_ = read(); + } - return peek_; + return peek_; } size_t TelnetStream::write(uint8_t data) { - if (previous_out_ == CR && data != LF) { - previous_out_ = data; + if (previous_out_ == CR && data != LF) { + previous_out_ = data; - if (raw_write({NUL, data}) != 2) { - return 0; - } - } else { - previous_out_ = data; - } + if (raw_write({NUL, data}) != 2) { + return 0; + } + } else { + previous_out_ = data; + } - if (data == IAC) { - if (raw_write({IAC, IAC}) != 2) { - return 0; - } - } else { - if (raw_write(data) != 1) { - return 0; - } - } + if (data == IAC) { + if (raw_write({IAC, IAC}) != 2) { + return 0; + } + } else { + if (raw_write(data) != 1) { + return 0; + } + } - return 1; + return 1; } -size_t TelnetStream::write(const uint8_t *buffer, size_t size) { - std::vector data; - data.reserve(size); +size_t TelnetStream::write(const uint8_t * buffer, size_t size) { + std::vector data; + data.reserve(size); - while (size-- > 0) { - unsigned char c = *buffer++; + while (size-- > 0) { + unsigned char c = *buffer++; - if (previous_out_ == CR && c != LF) { - data.push_back((unsigned char)NUL); - } + if (previous_out_ == CR && c != LF) { + data.push_back((unsigned char)NUL); + } - if (c == IAC) { - data.push_back((unsigned char)IAC); - } + if (c == IAC) { + data.push_back((unsigned char)IAC); + } - previous_out_ = c; - data.push_back(c); - } + previous_out_ = c; + data.push_back(c); + } - size_t len = raw_write(data); - if (len < size) { - len = 0; - } - return len; + size_t len = raw_write(data); + if (len < size) { + len = 0; + } + return len; } void TelnetStream::flush() { - // This is a pure virtual function in Arduino's Stream class, which - // makes no sense because that class is for input and this is an - // output function. Later versions move it to Print as an empty - // virtual function so this is here for backward compatibility. + // This is a pure virtual function in Arduino's Stream class, which + // makes no sense because that class is for input and this is an + // output function. Later versions move it to Print as an empty + // virtual function so this is here for backward compatibility. } int TelnetStream::raw_available() { - return client_.available(); + return client_.available(); } int TelnetStream::raw_read() { - return client_.read(); + return client_.read(); } void TelnetStream::buffer_flush() { - if (!output_buffer_.empty()) { - size_t len = client_.write(reinterpret_cast(output_buffer_.data()), output_buffer_.size()); - if (len != output_buffer_.size()) { - client_.stop(); - } - output_buffer_.clear(); - output_buffer_.shrink_to_fit(); - } + if (!output_buffer_.empty()) { + size_t len = client_.write(reinterpret_cast(output_buffer_.data()), output_buffer_.size()); + if (len != output_buffer_.size()) { + client_.stop(); + } + output_buffer_.clear(); + output_buffer_.shrink_to_fit(); + } } size_t TelnetStream::raw_write(unsigned char data) { - output_buffer_.push_back(data); + output_buffer_.push_back(data); - if (output_buffer_.size() >= BUFFER_SIZE) { - buffer_flush(); - } + if (output_buffer_.size() >= BUFFER_SIZE) { + buffer_flush(); + } - return 1; + return 1; } -size_t TelnetStream::raw_write(const std::vector &data) { - return raw_write(reinterpret_cast(data.data()), data.size()); +size_t TelnetStream::raw_write(const std::vector & data) { + return raw_write(reinterpret_cast(data.data()), data.size()); } -size_t TelnetStream::raw_write(const uint8_t *buffer, size_t size) { - size_t offset = 0; - size_t remaining = size; +size_t TelnetStream::raw_write(const uint8_t * buffer, size_t size) { + size_t offset = 0; + size_t remaining = size; - if (!output_buffer_.empty()) { - // Fill the rest of the buffer - size_t block = std::min(remaining, BUFFER_SIZE - output_buffer_.size()); + if (!output_buffer_.empty()) { + // Fill the rest of the buffer + size_t block = std::min(remaining, BUFFER_SIZE - output_buffer_.size()); - output_buffer_.insert(output_buffer_.end(), buffer, buffer + block); - offset += block; - remaining -= block; + output_buffer_.insert(output_buffer_.end(), buffer, buffer + block); + offset += block; + remaining -= block; - if (output_buffer_.size() >= BUFFER_SIZE) { - buffer_flush(); - } - } + if (output_buffer_.size() >= BUFFER_SIZE) { + buffer_flush(); + } + } - if (remaining >= BUFFER_SIZE) { - // Output directly if it won't fit in the buffer - size_t len = client_.write(buffer + offset, remaining); - if (len != remaining) { - client_.stop(); - return offset + len; - } - } else if (remaining > 0) { - // Put the rest in the buffer - output_buffer_.insert(output_buffer_.end(), buffer + offset, buffer + offset + remaining); - } + if (remaining >= BUFFER_SIZE) { + // Output directly if it won't fit in the buffer + size_t len = client_.write(buffer + offset, remaining); + if (len != remaining) { + client_.stop(); + return offset + len; + } + } else if (remaining > 0) { + // Put the rest in the buffer + output_buffer_.insert(output_buffer_.end(), buffer + offset, buffer + offset + remaining); + } - return size; + return size; } } // namespace telnet diff --git a/lib/uuid-telnet/src/uuid/telnet.h b/lib/uuid-telnet/src/uuid/telnet.h index 1338ae590..46ece1d01 100644 --- a/lib/uuid-telnet/src/uuid/telnet.h +++ b/lib/uuid-telnet/src/uuid/telnet.h @@ -21,9 +21,9 @@ #include #ifdef ARDUINO_ARCH_ESP8266 -# include +#include #else -# include +#include #endif #include @@ -51,47 +51,47 @@ namespace telnet { * * @since 0.1.0 */ -class TelnetStream: public ::Stream { -public: - /** +class TelnetStream : public ::Stream { + public: + /** * Create a new telnet stream wrapper. * * @param[in] client Client connection. * @since 0.1.0 */ - explicit TelnetStream(WiFiClient &client); - virtual ~TelnetStream() = default; + explicit TelnetStream(WiFiClient & client); + virtual ~TelnetStream() = default; - /** + /** * Perform initial negotiation. * * @since 0.1.0 */ - void start(); + void start(); - /** + /** * Check for available input. * * @return The number of bytes available to read. * @since 0.1.0 */ - int available() override; - /** + int available() override; + /** * Read one byte from the available input. * * @return An unsigned char if input is available, otherwise -1. * @since 0.1.0 */ - int read() override; - /** + int read() override; + /** * Read one byte from the available input without advancing to the * next one. * * @return An unsigned char if input is available, otherwise -1. * @since 0.1.0 */ - int peek() override; - /** + int peek() override; + /** * Write one byte to the output stream. * * Disconnect the client if the socket buffer is full. @@ -100,8 +100,8 @@ public: * @return The number of bytes that were output. * @since 0.1.0 */ - size_t write(uint8_t data) override; - /** + size_t write(uint8_t data) override; + /** * Write an array of bytes to the output stream. * * Disconnect the client if the socket buffer is full. @@ -111,8 +111,8 @@ public: * @return The number of bytes that were output. * @since 0.1.0 */ - size_t write(const uint8_t *buffer, size_t size) override; - /** + size_t write(const uint8_t * buffer, size_t size) override; + /** * Does nothing. * * This is a pure virtual function in Arduino's Stream class, which @@ -122,66 +122,69 @@ public: * * @since 0.1.0 */ - void flush() override; + void flush() override; -private: - static constexpr const unsigned char NUL = 0; /*!< No operation. @since 0.1.0 */ - static constexpr const unsigned char BEL = 7; /*!< Produces an audible or visible signal. @since 0.1.0 */ - static constexpr const unsigned char BS = 8; /*!< Moves the print head one character position towards the left margin. @since 0.1.0 */ - static constexpr const unsigned char HT = 9; /*!< Moves the printer to the next horizontal tab stop. @since 0.1.0 */ - static constexpr const unsigned char LF = 10; /*!< Line Feed. @since 0.1.0 */ - static constexpr const unsigned char VT = 11; /*!< Moves the printer to the next vertical tab stop. @since 0.1.0 */ - static constexpr const unsigned char FF = 12; /*!< Moves the printer to the top of the next page, keeping the same horizontal position. @since 0.1.0 */ - static constexpr const unsigned char CR = 13; /*!< Carriage Return. @since 0.1.0 */ - static constexpr const unsigned char SE = 240; /*!< End of sub-negotiation parameters. @since 0.1.0 */ - static constexpr const unsigned char NOP = 241; /*!< No operation. @since 0.1.0 */ - static constexpr const unsigned char DM = 242; /*!< The data stream portion of a Synch. @since 0.1.0 */ - static constexpr const unsigned char BRK = 243; /*!< NVT character BRK. @since 0.1.0 */ - static constexpr const unsigned char IP = 244; /*!< Interrupt Process function. @since 0.1.0 */ - static constexpr const unsigned char AO = 245; /*!< Abort Output function. @since 0.1.0 */ - static constexpr const unsigned char AYT = 246; /*!< Are You There function. @since 0.1.0 */ - static constexpr const unsigned char EC = 247; /*!< Erase Character function. @since 0.1.0 */ - static constexpr const unsigned char EL = 248; /*!< Erase Line function. @since 0.1.0 */ - static constexpr const unsigned char GA = 249; /*!< Go Ahead signal. @since 0.1.0 */ - static constexpr const unsigned char SB = 250; /*!< Sub-negotiation of the indicated option. @since 0.1.0 */ - static constexpr const unsigned char WILL = 251; /*!< Indicates the desire to begin performing, or confirmation that you are now performing, the indicated option. @since 0.1.0 */ - static constexpr const unsigned char WONT = 252; /*!< Indicates the refusal to perform, or continue performing, the indicated option. @since 0.1.0 */ - static constexpr const unsigned char DO = 253; /*!< Indicates the request that the other party perform, or confirmation that you are expecting the other party to perform, the indicated option. @since 0.1.0 */ - static constexpr const unsigned char DONT = 254; /*!< Indicates the demand that the other party stop performing, or confirmation that you are no longer expecting the other party to perform, the indicated option. @since 0.1.0 */ - static constexpr const unsigned char IAC = 255; /*!< Interpret As Command escape character. @since 0.1.0 */ + private: + static constexpr const unsigned char NUL = 0; /*!< No operation. @since 0.1.0 */ + static constexpr const unsigned char BEL = 7; /*!< Produces an audible or visible signal. @since 0.1.0 */ + static constexpr const unsigned char BS = 8; /*!< Moves the print head one character position towards the left margin. @since 0.1.0 */ + static constexpr const unsigned char HT = 9; /*!< Moves the printer to the next horizontal tab stop. @since 0.1.0 */ + static constexpr const unsigned char LF = 10; /*!< Line Feed. @since 0.1.0 */ + static constexpr const unsigned char VT = 11; /*!< Moves the printer to the next vertical tab stop. @since 0.1.0 */ + static constexpr const unsigned char FF = 12; /*!< Moves the printer to the top of the next page, keeping the same horizontal position. @since 0.1.0 */ + static constexpr const unsigned char CR = 13; /*!< Carriage Return. @since 0.1.0 */ + static constexpr const unsigned char SE = 240; /*!< End of sub-negotiation parameters. @since 0.1.0 */ + static constexpr const unsigned char NOP = 241; /*!< No operation. @since 0.1.0 */ + static constexpr const unsigned char DM = 242; /*!< The data stream portion of a Synch. @since 0.1.0 */ + static constexpr const unsigned char BRK = 243; /*!< NVT character BRK. @since 0.1.0 */ + static constexpr const unsigned char IP = 244; /*!< Interrupt Process function. @since 0.1.0 */ + static constexpr const unsigned char AO = 245; /*!< Abort Output function. @since 0.1.0 */ + static constexpr const unsigned char AYT = 246; /*!< Are You There function. @since 0.1.0 */ + static constexpr const unsigned char EC = 247; /*!< Erase Character function. @since 0.1.0 */ + static constexpr const unsigned char EL = 248; /*!< Erase Line function. @since 0.1.0 */ + static constexpr const unsigned char GA = 249; /*!< Go Ahead signal. @since 0.1.0 */ + static constexpr const unsigned char SB = 250; /*!< Sub-negotiation of the indicated option. @since 0.1.0 */ + static constexpr const unsigned char WILL = + 251; /*!< Indicates the desire to begin performing, or confirmation that you are now performing, the indicated option. @since 0.1.0 */ + static constexpr const unsigned char WONT = 252; /*!< Indicates the refusal to perform, or continue performing, the indicated option. @since 0.1.0 */ + static constexpr const unsigned char DO = + 253; /*!< Indicates the request that the other party perform, or confirmation that you are expecting the other party to perform, the indicated option. @since 0.1.0 */ + static constexpr const unsigned char DONT = + 254; /*!< Indicates the demand that the other party stop performing, or confirmation that you are no longer expecting the other party to perform, the indicated option. @since 0.1.0 */ + static constexpr const unsigned char IAC = 255; /*!< Interpret As Command escape character. @since 0.1.0 */ - static constexpr const unsigned char OPT_BINARY = 0; /*!< Binary (8-bit) transmission mode. (RFC 856). @since 0.1.0 */ - static constexpr const unsigned char OPT_ECHO = 1; /*!< Remote Echo (RFC 857). @since 0.1.0 */ - static constexpr const unsigned char OPT_SGA = 3; /*!< Suppress Go Ahead (RFC 858). @since 0.1.0 */ + static constexpr const unsigned char OPT_BINARY = 0; /*!< Binary (8-bit) transmission mode. (RFC 856). @since 0.1.0 */ + static constexpr const unsigned char OPT_ECHO = 1; /*!< Remote Echo (RFC 857). @since 0.1.0 */ + static constexpr const unsigned char OPT_SGA = 3; /*!< Suppress Go Ahead (RFC 858). @since 0.1.0 */ - static constexpr const size_t BUFFER_SIZE = 536; /*!< Output buffer size. @since 0.1.0 */ + static constexpr const size_t BUFFER_SIZE = 536; /*!< Output buffer size. @since 0.1.0 */ - TelnetStream(const TelnetStream&) = delete; - TelnetStream& operator=(const TelnetStream&) = delete; + TelnetStream(const TelnetStream &) = delete; + TelnetStream & operator=(const TelnetStream &) = delete; - /** + /** * Directly check for available input. * * @return The number of bytes available to read. * @since 0.1.0 */ - int raw_available(); - /** + int raw_available(); + /** * Read one byte directly from the available input. * * @return An unsigned char if input is available, otherwise -1. * @since 0.1.0 */ - int raw_read(); - /** + int raw_read(); + /** * Flush output stream buffer. * * Disconnect the client if the socket buffer is full. * * @since 0.1.0 */ - void buffer_flush(); - /** + void buffer_flush(); + /** * Write one byte directly to the output stream. * * Disconnect the client if the socket buffer is full. @@ -190,8 +193,8 @@ private: * @return The number of bytes that were output. * @since 0.1.0 */ - size_t raw_write(unsigned char data); - /** + size_t raw_write(unsigned char data); + /** * Write a vector of bytes directly to the output stream. * * Disconnect the client if the socket buffer is full. @@ -200,8 +203,8 @@ private: * @return The number of bytes that were output. * @since 0.1.0 */ - size_t raw_write(const std::vector &data); - /** + size_t raw_write(const std::vector & data); + /** * Write an array of bytes directly to the output stream. * * Disconnect the client if the socket buffer is full. @@ -211,15 +214,15 @@ private: * @return The number of bytes that were output. * @since 0.1.0 */ - size_t raw_write(const uint8_t *buffer, size_t size); + size_t raw_write(const uint8_t * buffer, size_t size); - WiFiClient &client_; /*!< Client connection. @since 0.1.0 */ - unsigned char previous_raw_in_ = 0; /*!< Previous raw character that was received. Used to detect commands. @since 0.1.0 */ - bool sub_negotiation_ = false; /*!< Sub-negotiation mode. @since 0.1.0 */ - unsigned char previous_in_ = 0; /*!< Previous character that was received. Used to detect CR NUL. @since 0.1.0 */ - unsigned char previous_out_ = 0; /*!< Previous character that was sent. Used to insert NUL after CR without LF. @since 0.1.0 */ - int peek_ = -1; /*!< Previously read data cached by peek(). @since 0.1.0 */ - std::vector output_buffer_; /*!< Buffer data to be output until a read function is called. @since 0.1.0 */ + WiFiClient & client_; /*!< Client connection. @since 0.1.0 */ + unsigned char previous_raw_in_ = 0; /*!< Previous raw character that was received. Used to detect commands. @since 0.1.0 */ + bool sub_negotiation_ = false; /*!< Sub-negotiation mode. @since 0.1.0 */ + unsigned char previous_in_ = 0; /*!< Previous character that was received. Used to detect CR NUL. @since 0.1.0 */ + unsigned char previous_out_ = 0; /*!< Previous character that was sent. Used to insert NUL after CR without LF. @since 0.1.0 */ + int peek_ = -1; /*!< Previously read data cached by peek(). @since 0.1.0 */ + std::vector output_buffer_; /*!< Buffer data to be output until a read function is called. @since 0.1.0 */ }; /** @@ -228,13 +231,13 @@ private: * @since 0.1.0 */ class TelnetService { -public: - static constexpr size_t MAX_CONNECTIONS = 3; /*!< Maximum number of concurrent open connections. @since 0.1.0 */ - static constexpr uint16_t DEFAULT_PORT = 23; /*!< Default TCP port to listen on. @since 0.1.0 */ - static constexpr unsigned long DEFAULT_IDLE_TIMEOUT = 600; /*!< Default initial idle timeout (in seconds). @since 0.1.0 */ - static constexpr unsigned long DEFAULT_WRITE_TIMEOUT = 0; /*!< Default write timeout (in milliseconds). @ since 0.1.0 */ + public: + static constexpr size_t MAX_CONNECTIONS = 3; /*!< Maximum number of concurrent open connections. @since 0.1.0 */ + static constexpr uint16_t DEFAULT_PORT = 23; /*!< Default TCP port to listen on. @since 0.1.0 */ + static constexpr unsigned long DEFAULT_IDLE_TIMEOUT = 600; /*!< Default initial idle timeout (in seconds). @since 0.1.0 */ + static constexpr unsigned long DEFAULT_WRITE_TIMEOUT = 0; /*!< Default write timeout (in milliseconds). @ since 0.1.0 */ - /** + /** * Function to handle the creation of a shell. * * @param[in] stream Stream for the telnet connection. @@ -242,9 +245,9 @@ public: * @param[in] port Remote port. * @since 0.1.0 */ - using shell_factory_function = std::function(Stream &stream, const IPAddress &addr, uint16_t port)>; + using shell_factory_function = std::function(Stream & stream, const IPAddress & addr, uint16_t port)>; - /** + /** * Create a new telnet service listening on the default port. * * @param[in] commands Commands available for execution in shells. @@ -252,9 +255,9 @@ public: * @param[in] flags Initial flags for shells. * @since 0.1.0 */ - TelnetService(std::shared_ptr commands, unsigned int context = 0, unsigned int flags = 0); + TelnetService(std::shared_ptr commands, unsigned int context = 0, unsigned int flags = 0); - /** + /** * Create a new telnet service listening on a specific port. * * @param[in] port TCP listening port. @@ -263,74 +266,74 @@ public: * @param[in] flags Initial flags for shells. * @since 0.1.0 */ - TelnetService(uint16_t port, std::shared_ptr commands, unsigned int context = 0, unsigned int flags = 0); + TelnetService(uint16_t port, std::shared_ptr commands, unsigned int context = 0, unsigned int flags = 0); - /** + /** * Create a new telnet service listening on the default port. * * @param[in] shell_factory Function to create a shell for new connections. * @since 0.1.0 */ - explicit TelnetService(shell_factory_function shell_factory); + explicit TelnetService(shell_factory_function shell_factory); - /** + /** * Create a new telnet service listening on a specific port. * * @param[in] port TCP listening port. * @param[in] shell_factory Function to create a shell for new connections. * @since 0.1.0 */ - TelnetService(uint16_t port, shell_factory_function shell_factory); + TelnetService(uint16_t port, shell_factory_function shell_factory); - ~TelnetService() = default; + ~TelnetService() = default; - /** + /** * Start listening for connections on the configured port. * * @since 0.1.0 */ - void start(); - /** + void start(); + /** * Close all connections. * * The listening status is not affected. * * @since 0.1.0 */ - void close_all(); - /** + void close_all(); + /** * Stop listening for connections. * * Existing connections are not affected. * * @since 0.1.0 */ - void stop(); + void stop(); - /** + /** * Get the maximum number of concurrent open connections. * * @return The maximum number of concurrent open connections. * @since 0.1.0 */ - size_t maximum_connections() const; - /** + size_t maximum_connections() const; + /** * Set the maximum number of concurrent open connections. * * Defaults to TelnetService::MAX_CONNECTIONS. * * @since 0.1.0 */ - void maximum_connections(size_t count); + void maximum_connections(size_t count); - /** + /** * Get the initial idle timeout for new connections. * * @return The initial idle timeout in seconds (or 0 for disabled). * @since 0.1.0 */ - unsigned long initial_idle_timeout() const; - /** + unsigned long initial_idle_timeout() const; + /** * Set the initial idle timeout for new connections. * * Defaults to TelnetService::DEFAULT_IDLE_TIMEOUT. @@ -338,17 +341,17 @@ public: * @param[in] timeout Idle timeout in seconds (or 0 to disable). * @since 0.1.0 */ - void initial_idle_timeout(unsigned long timeout); + void initial_idle_timeout(unsigned long timeout); - /** + /** * Get the default socket write timeout for new connections. * * @return The default socket write timeout in seconds (or 0 for * platform default). * @since 0.1.0 */ - unsigned long default_write_timeout() const; - /** + unsigned long default_write_timeout() const; + /** * Set the default socket write timeout for new connections. * * Defaults to TelnetService::DEFAULT_WRITE_TIMEOUT (platform @@ -358,26 +361,26 @@ public: * platform default). * @since 0.1.0 */ - void default_write_timeout(unsigned long timeout); + void default_write_timeout(unsigned long timeout); - /** + /** * Accept new connections. * * @since 0.1.0 */ - void loop(); + void loop(); -private: - /** + private: + /** * Telnet connection. * * Holds the client and stream instance for the lifetime of the shell. * * @since 0.1.0 */ - class Connection { - public: - /** + class Connection { + public: + /** * Create a telnet connection shell. * * @param[in] shell_factory Function to create a shell for new connections. @@ -386,52 +389,52 @@ private: * @param[in] write_timeout Idle timeout in milliseconds. * @since 0.1.0 */ - Connection(shell_factory_function &shell_factory, WiFiClient &&client, unsigned long idle_timeout, unsigned long write_timeout); - ~Connection() = default; + Connection(shell_factory_function & shell_factory, WiFiClient && client, unsigned long idle_timeout, unsigned long write_timeout); + ~Connection() = default; - /** + /** * Check if the shell is still active. * * @return Active status of the shell. * @since 0.1.0 */ - bool active(); - /** + bool active(); + /** * Stop the shell if the client is not connected. * * @return Active status of the shell. * @since 0.1.0 */ - bool loop(); - /** + bool loop(); + /** * Stop the shell. * * @since 0.1.0 */ - void stop(); + void stop(); - private: - Connection(const Connection&) = delete; - Connection& operator=(const Connection&) = delete; + private: + Connection(const Connection &) = delete; + Connection & operator=(const Connection &) = delete; - WiFiClient client_; /*!< Client connection. @since 0.1.0 */ - TelnetStream stream_; /*!< Telnet stream for the connection. @since 0.1.0 */ - std::shared_ptr shell_; /*!< Shell for connection. @since 0.1.0 */ - IPAddress addr_; /*!< Remote address of connection. @since 0.1.0 */ - uint16_t port_; /*!< Remote port of connection. @since 0.1.0 */ - }; + WiFiClient client_; /*!< Client connection. @since 0.1.0 */ + TelnetStream stream_; /*!< Telnet stream for the connection. @since 0.1.0 */ + std::shared_ptr shell_; /*!< Shell for connection. @since 0.1.0 */ + IPAddress addr_; /*!< Remote address of connection. @since 0.1.0 */ + uint16_t port_; /*!< Remote port of connection. @since 0.1.0 */ + }; - TelnetService(const TelnetService&) = delete; - TelnetService& operator=(const TelnetService&) = delete; + TelnetService(const TelnetService &) = delete; + TelnetService & operator=(const TelnetService &) = delete; - static uuid::log::Logger logger_; /*!< uuid::log::Logger instance for telnet services. @since 0.1.0 */ + static uuid::log::Logger logger_; /*!< uuid::log::Logger instance for telnet services. @since 0.1.0 */ - WiFiServer server_; /*!< TCP server. @since 0.1.0 */ - size_t maximum_connections_ = MAX_CONNECTIONS; /*!< Maximum number of concurrent open connections. @since 0.1.0 */ - std::list connections_; /*!< Open connections. @since 0.1.0 */ - shell_factory_function shell_factory_; /*!< Function to create a shell. @since 0.1.0 */ - unsigned long initial_idle_timeout_ = DEFAULT_IDLE_TIMEOUT; /*!< Initial idle timeout (in seconds). @since 0.1.0 */ - unsigned long write_timeout_ = DEFAULT_WRITE_TIMEOUT; /*!< Write timeout (in milliseconds). @since 0.1.0 */ + WiFiServer server_; /*!< TCP server. @since 0.1.0 */ + size_t maximum_connections_ = MAX_CONNECTIONS; /*!< Maximum number of concurrent open connections. @since 0.1.0 */ + std::list connections_; /*!< Open connections. @since 0.1.0 */ + shell_factory_function shell_factory_; /*!< Function to create a shell. @since 0.1.0 */ + unsigned long initial_idle_timeout_ = DEFAULT_IDLE_TIMEOUT; /*!< Initial idle timeout (in seconds). @since 0.1.0 */ + unsigned long write_timeout_ = DEFAULT_WRITE_TIMEOUT; /*!< Write timeout (in milliseconds). @since 0.1.0 */ }; } // namespace telnet diff --git a/lib_standalone/AsyncMqttClient.h b/lib_standalone/AsyncMqttClient.h index 1a7e6d29f..770480242 100644 --- a/lib_standalone/AsyncMqttClient.h +++ b/lib_standalone/AsyncMqttClient.h @@ -26,12 +26,12 @@ struct AsyncMqttClientMessageProperties { namespace AsyncMqttClientInternals { -typedef std::function OnConnectUserCallback; -typedef std::function OnDisconnectUserCallback; -typedef std::function OnSubscribeUserCallback; -typedef std::function OnUnsubscribeUserCallback; +typedef std::function OnConnectUserCallback; +typedef std::function OnDisconnectUserCallback; +typedef std::function OnSubscribeUserCallback; +typedef std::function OnUnsubscribeUserCallback; typedef std::function OnMessageUserCallback; -typedef std::function OnPublishUserCallback; +typedef std::function OnPublishUserCallback; }; // namespace AsyncMqttClientInternals class AsyncMqttClient { diff --git a/lib_standalone/HttpEndpoint.h b/lib_standalone/HttpEndpoint.h index 10442d03f..f06662702 100644 --- a/lib_standalone/HttpEndpoint.h +++ b/lib_standalone/HttpEndpoint.h @@ -13,120 +13,111 @@ template class HttpGetEndpoint { - public: - HttpGetEndpoint(JsonStateReader stateReader, - StatefulService* statefulService, - AsyncWebServer* server, - const String& servicePath, - SecurityManager* securityManager, - AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, - size_t bufferSize = DEFAULT_BUFFER_SIZE) : - _stateReader(stateReader), _statefulService(statefulService), _bufferSize(bufferSize) { - } + public: + HttpGetEndpoint(JsonStateReader stateReader, + StatefulService * statefulService, + AsyncWebServer * server, + const String & servicePath, + SecurityManager * securityManager, + AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, + size_t bufferSize = DEFAULT_BUFFER_SIZE) + : _stateReader(stateReader) + , _statefulService(statefulService) + , _bufferSize(bufferSize) { + } - HttpGetEndpoint(JsonStateReader stateReader, - StatefulService* statefulService, - AsyncWebServer* server, - const String& servicePath, - size_t bufferSize = DEFAULT_BUFFER_SIZE) : - _stateReader(stateReader), _statefulService(statefulService), _bufferSize(bufferSize) { - } + HttpGetEndpoint(JsonStateReader stateReader, + StatefulService * statefulService, + AsyncWebServer * server, + const String & servicePath, + size_t bufferSize = DEFAULT_BUFFER_SIZE) + : _stateReader(stateReader) + , _statefulService(statefulService) + , _bufferSize(bufferSize) { + } - protected: - JsonStateReader _stateReader; - StatefulService* _statefulService; - size_t _bufferSize; + protected: + JsonStateReader _stateReader; + StatefulService * _statefulService; + size_t _bufferSize; - void fetchSettings(AsyncWebServerRequest* request) { - } + void fetchSettings(AsyncWebServerRequest * request) { + } }; template class HttpPostEndpoint { - public: - HttpPostEndpoint(JsonStateReader stateReader, - JsonStateUpdater stateUpdater, - StatefulService* statefulService, - AsyncWebServer* server, - const String& servicePath, - SecurityManager* securityManager, - AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, - size_t bufferSize = DEFAULT_BUFFER_SIZE) : - _stateReader(stateReader), - _stateUpdater(stateUpdater), - _statefulService(statefulService), - _bufferSize(bufferSize) { - } - - HttpPostEndpoint(JsonStateReader stateReader, - JsonStateUpdater stateUpdater, - StatefulService* statefulService, - AsyncWebServer* server, - const String& servicePath, - size_t bufferSize = DEFAULT_BUFFER_SIZE) : - _stateReader(stateReader), - _stateUpdater(stateUpdater), - _statefulService(statefulService), - _bufferSize(bufferSize) { - } - - protected: - JsonStateReader _stateReader; - JsonStateUpdater _stateUpdater; - StatefulService* _statefulService; - size_t _bufferSize; - - void updateSettings(AsyncWebServerRequest* request, JsonVariant& json) { - if (!json.is()) { - return; + public: + HttpPostEndpoint(JsonStateReader stateReader, + JsonStateUpdater stateUpdater, + StatefulService * statefulService, + AsyncWebServer * server, + const String & servicePath, + SecurityManager * securityManager, + AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, + size_t bufferSize = DEFAULT_BUFFER_SIZE) + : _stateReader(stateReader) + , _stateUpdater(stateUpdater) + , _statefulService(statefulService) + , _bufferSize(bufferSize) { } - JsonObject jsonObject = json.as(); - StateUpdateResult outcome = _statefulService->updateWithoutPropagation(jsonObject, _stateUpdater); - if (outcome == StateUpdateResult::ERROR) { - return; + + HttpPostEndpoint(JsonStateReader stateReader, + JsonStateUpdater stateUpdater, + StatefulService * statefulService, + AsyncWebServer * server, + const String & servicePath, + size_t bufferSize = DEFAULT_BUFFER_SIZE) + : _stateReader(stateReader) + , _stateUpdater(stateUpdater) + , _statefulService(statefulService) + , _bufferSize(bufferSize) { } - if (outcome == StateUpdateResult::CHANGED) { + + protected: + JsonStateReader _stateReader; + JsonStateUpdater _stateUpdater; + StatefulService * _statefulService; + size_t _bufferSize; + + void updateSettings(AsyncWebServerRequest * request, JsonVariant & json) { + if (!json.is()) { + return; + } + JsonObject jsonObject = json.as(); + StateUpdateResult outcome = _statefulService->updateWithoutPropagation(jsonObject, _stateUpdater); + if (outcome == StateUpdateResult::ERROR) { + return; + } + if (outcome == StateUpdateResult::CHANGED) { + } } - } }; template class HttpEndpoint : public HttpGetEndpoint, public HttpPostEndpoint { - public: - HttpEndpoint(JsonStateReader stateReader, - JsonStateUpdater stateUpdater, - StatefulService* statefulService, - AsyncWebServer* server, - const String& servicePath, - SecurityManager* securityManager, - AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, - size_t bufferSize = DEFAULT_BUFFER_SIZE) : - HttpGetEndpoint(stateReader, - statefulService, - server, - servicePath, - securityManager, - authenticationPredicate, - bufferSize), - HttpPostEndpoint(stateReader, - stateUpdater, - statefulService, - server, - servicePath, - securityManager, - authenticationPredicate, - bufferSize) { - } + public: + HttpEndpoint(JsonStateReader stateReader, + JsonStateUpdater stateUpdater, + StatefulService * statefulService, + AsyncWebServer * server, + const String & servicePath, + SecurityManager * securityManager, + AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, + size_t bufferSize = DEFAULT_BUFFER_SIZE) + : HttpGetEndpoint(stateReader, statefulService, server, servicePath, securityManager, authenticationPredicate, bufferSize) + , HttpPostEndpoint(stateReader, stateUpdater, statefulService, server, servicePath, securityManager, authenticationPredicate, bufferSize) { + } - HttpEndpoint(JsonStateReader stateReader, - JsonStateUpdater stateUpdater, - StatefulService* statefulService, - AsyncWebServer* server, - const String& servicePath, - size_t bufferSize = DEFAULT_BUFFER_SIZE) : - HttpGetEndpoint(stateReader, statefulService, server, servicePath, bufferSize), - HttpPostEndpoint(stateReader, stateUpdater, statefulService, server, servicePath, bufferSize) { - } + HttpEndpoint(JsonStateReader stateReader, + JsonStateUpdater stateUpdater, + StatefulService * statefulService, + AsyncWebServer * server, + const String & servicePath, + size_t bufferSize = DEFAULT_BUFFER_SIZE) + : HttpGetEndpoint(stateReader, statefulService, server, servicePath, bufferSize) + , HttpPostEndpoint(stateReader, stateUpdater, statefulService, server, servicePath, bufferSize) { + } }; #endif diff --git a/lib_standalone/Network.h b/lib_standalone/Network.h index 857ff4a0e..836167df5 100644 --- a/lib_standalone/Network.h +++ b/lib_standalone/Network.h @@ -61,51 +61,51 @@ typedef enum { } wifi_auth_mode_t; typedef struct { - uint32_t status; /**< status of scanning APs: 0 — success, 1 - failure */ - uint8_t number; /**< number of scan results */ - uint8_t scan_id; /**< scan sequence number, used for block scan */ + uint32_t status; /**< status of scanning APs: 0 — success, 1 - failure */ + uint8_t number; /**< number of scan results */ + uint8_t scan_id; /**< scan sequence number, used for block scan */ } wifi_event_sta_scan_done_t; /** Argument structure for WIFI_EVENT_STA_CONNECTED event */ typedef struct { - uint8_t ssid[32]; /**< SSID of connected AP */ - uint8_t ssid_len; /**< SSID length of connected AP */ - uint8_t bssid[6]; /**< BSSID of connected AP*/ - uint8_t channel; /**< channel of connected AP*/ - wifi_auth_mode_t authmode;/**< authentication mode used by AP*/ + uint8_t ssid[32]; /**< SSID of connected AP */ + uint8_t ssid_len; /**< SSID length of connected AP */ + uint8_t bssid[6]; /**< BSSID of connected AP*/ + uint8_t channel; /**< channel of connected AP*/ + wifi_auth_mode_t authmode; /**< authentication mode used by AP*/ } wifi_event_sta_connected_t; /** Argument structure for WIFI_EVENT_STA_DISCONNECTED event */ typedef struct { - uint8_t ssid[32]; /**< SSID of disconnected AP */ - uint8_t ssid_len; /**< SSID length of disconnected AP */ - uint8_t bssid[6]; /**< BSSID of disconnected AP */ - uint8_t reason; /**< reason of disconnection */ + uint8_t ssid[32]; /**< SSID of disconnected AP */ + uint8_t ssid_len; /**< SSID length of disconnected AP */ + uint8_t bssid[6]; /**< BSSID of disconnected AP */ + uint8_t reason; /**< reason of disconnection */ } wifi_event_sta_disconnected_t; /** Argument structure for WIFI_EVENT_STA_AUTHMODE_CHANGE event */ typedef struct { - wifi_auth_mode_t old_mode; /**< the old auth mode of AP */ - wifi_auth_mode_t new_mode; /**< the new auth mode of AP */ + wifi_auth_mode_t old_mode; /**< the old auth mode of AP */ + wifi_auth_mode_t new_mode; /**< the new auth mode of AP */ } wifi_event_sta_authmode_change_t; /** Argument structure for WIFI_EVENT_STA_WPS_ER_PIN event */ typedef struct { - uint8_t pin_code[8]; /**< PIN code of station in enrollee mode */ + uint8_t pin_code[8]; /**< PIN code of station in enrollee mode */ } wifi_event_sta_wps_er_pin_t; /** Argument structure for WIFI_EVENT_STA_WPS_ER_FAILED event */ typedef enum { - WPS_FAIL_REASON_NORMAL = 0, /**< ESP32 WPS normal fail reason */ - WPS_FAIL_REASON_RECV_M2D, /**< ESP32 WPS receive M2D frame */ + WPS_FAIL_REASON_NORMAL = 0, /**< ESP32 WPS normal fail reason */ + WPS_FAIL_REASON_RECV_M2D, /**< ESP32 WPS receive M2D frame */ WPS_FAIL_REASON_MAX } wifi_event_sta_wps_fail_reason_t; typedef union { - wifi_event_sta_scan_done_t wifi_scan_done; - wifi_event_sta_authmode_change_t wifi_sta_authmode_change; - wifi_event_sta_connected_t wifi_sta_connected; - wifi_event_sta_disconnected_t wifi_sta_disconnected; + wifi_event_sta_scan_done_t wifi_scan_done; + wifi_event_sta_authmode_change_t wifi_sta_authmode_change; + wifi_event_sta_connected_t wifi_sta_connected; + wifi_event_sta_disconnected_t wifi_sta_disconnected; } arduino_event_info_t; typedef struct { diff --git a/lib_standalone/SecuritySettingsService.cpp b/lib_standalone/SecuritySettingsService.cpp index bfdc0a211..fbe83bf7f 100644 --- a/lib_standalone/SecuritySettingsService.cpp +++ b/lib_standalone/SecuritySettingsService.cpp @@ -4,139 +4,136 @@ #include "../../src/emsesp_stub.h" // proddy added -SecuritySettingsService::SecuritySettingsService(AsyncWebServer* server, FS* fs) : - _httpEndpoint(SecuritySettings::read, SecuritySettings::update, this, server, SECURITY_SETTINGS_PATH, this), - _fsPersistence(SecuritySettings::read, SecuritySettings::update, this, fs, SECURITY_SETTINGS_FILE), - _jwtHandler(FACTORY_JWT_SECRET) { - addUpdateHandler([&](const String& originId) { configureJWTHandler(); }, false); +SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs) + : _httpEndpoint(SecuritySettings::read, SecuritySettings::update, this, server, SECURITY_SETTINGS_PATH, this) + , _fsPersistence(SecuritySettings::read, SecuritySettings::update, this, fs, SECURITY_SETTINGS_FILE) + , _jwtHandler(FACTORY_JWT_SECRET) { + addUpdateHandler([&](const String & originId) { configureJWTHandler(); }, false); } void SecuritySettingsService::begin() { - _fsPersistence.readFromFS(); - configureJWTHandler(); + _fsPersistence.readFromFS(); + configureJWTHandler(); } -Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest* request) { - AsyncWebHeader* authorizationHeader = request->getHeader(AUTHORIZATION_HEADER); - if (authorizationHeader) { - String value = authorizationHeader->value(); - if (value.startsWith(AUTHORIZATION_HEADER_PREFIX)) { - value = value.substring(AUTHORIZATION_HEADER_PREFIX_LEN); - return authenticateJWT(value); +Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest * request) { + AsyncWebHeader * authorizationHeader = request->getHeader(AUTHORIZATION_HEADER); + if (authorizationHeader) { + String value = authorizationHeader->value(); + if (value.startsWith(AUTHORIZATION_HEADER_PREFIX)) { + value = value.substring(AUTHORIZATION_HEADER_PREFIX_LEN); + return authenticateJWT(value); + } + } else if (request->hasParam(ACCESS_TOKEN_PARAMATER)) { + AsyncWebParameter * tokenParamater = request->getParam(ACCESS_TOKEN_PARAMATER); + String value = tokenParamater->value(); + return authenticateJWT(value); } - } else if (request->hasParam(ACCESS_TOKEN_PARAMATER)) { - AsyncWebParameter* tokenParamater = request->getParam(ACCESS_TOKEN_PARAMATER); - String value = tokenParamater->value(); - return authenticateJWT(value); - } - return Authentication(); + return Authentication(); } void SecuritySettingsService::configureJWTHandler() { - _jwtHandler.setSecret(_state.jwtSecret); + _jwtHandler.setSecret(_state.jwtSecret); } -Authentication SecuritySettingsService::authenticateJWT(String& jwt) { - DynamicJsonDocument payloadDocument(MAX_JWT_SIZE); - _jwtHandler.parseJWT(jwt, payloadDocument); - if (payloadDocument.is()) { - JsonObject parsedPayload = payloadDocument.as(); - String username = parsedPayload["username"]; +Authentication SecuritySettingsService::authenticateJWT(String & jwt) { + DynamicJsonDocument payloadDocument(MAX_JWT_SIZE); + _jwtHandler.parseJWT(jwt, payloadDocument); + if (payloadDocument.is()) { + JsonObject parsedPayload = payloadDocument.as(); + String username = parsedPayload["username"]; + for (User _user : _state.users) { + if (_user.username == username && validatePayload(parsedPayload, &_user)) { + return Authentication(_user); + } + } + } + return Authentication(); +} + +Authentication SecuritySettingsService::authenticate(const String & username, const String & password) { for (User _user : _state.users) { - if (_user.username == username && validatePayload(parsedPayload, &_user)) { - return Authentication(_user); - } + if (_user.username == username && _user.password == password) { + return Authentication(_user); + } } - } - return Authentication(); + return Authentication(); } -Authentication SecuritySettingsService::authenticate(const String& username, const String& password) { - for (User _user : _state.users) { - if (_user.username == username && _user.password == password) { - return Authentication(_user); - } - } - return Authentication(); +inline void populateJWTPayload(JsonObject & payload, User * user) { + payload["username"] = user->username; + payload["admin"] = user->admin; } -inline void populateJWTPayload(JsonObject& payload, User* user) { - payload["username"] = user->username; - payload["admin"] = user->admin; +boolean SecuritySettingsService::validatePayload(JsonObject & parsedPayload, User * user) { + DynamicJsonDocument jsonDocument(MAX_JWT_SIZE); + JsonObject payload = jsonDocument.to(); + populateJWTPayload(payload, user); + return payload == parsedPayload; } -boolean SecuritySettingsService::validatePayload(JsonObject& parsedPayload, User* user) { - DynamicJsonDocument jsonDocument(MAX_JWT_SIZE); - JsonObject payload = jsonDocument.to(); - populateJWTPayload(payload, user); - return payload == parsedPayload; -} - -String SecuritySettingsService::generateJWT(User* user) { - DynamicJsonDocument jsonDocument(MAX_JWT_SIZE); - JsonObject payload = jsonDocument.to(); - populateJWTPayload(payload, user); - return _jwtHandler.buildJWT(payload); +String SecuritySettingsService::generateJWT(User * user) { + DynamicJsonDocument jsonDocument(MAX_JWT_SIZE); + JsonObject payload = jsonDocument.to(); + populateJWTPayload(payload, user); + return _jwtHandler.buildJWT(payload); } ArRequestFilterFunction SecuritySettingsService::filterRequest(AuthenticationPredicate predicate) { - return [this, predicate](AsyncWebServerRequest* request) { - Authentication authentication = authenticateRequest(request); - return predicate(authentication); - }; + return [this, predicate](AsyncWebServerRequest * request) { + Authentication authentication = authenticateRequest(request); + return predicate(authentication); + }; } -ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, - AuthenticationPredicate predicate) { - return [this, onRequest, predicate](AsyncWebServerRequest* request) { - Authentication authentication = authenticateRequest(request); - if (!predicate(authentication)) { - request->send(401); - return; - } - onRequest(request); - }; +ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { + return [this, onRequest, predicate](AsyncWebServerRequest * request) { + Authentication authentication = authenticateRequest(request); + if (!predicate(authentication)) { + request->send(401); + return; + } + onRequest(request); + }; } -ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, - AuthenticationPredicate predicate) { - return [this, onRequest, predicate](AsyncWebServerRequest* request, JsonVariant& json) { - Authentication authentication = authenticateRequest(request); - if (!predicate(authentication)) { - request->send(401); - return; - } - onRequest(request, json); - }; +ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { + return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant & json) { + Authentication authentication = authenticateRequest(request); + if (!predicate(authentication)) { + request->send(401); + return; + } + onRequest(request, json); + }; } #else User ADMIN_USER = User(FACTORY_ADMIN_USERNAME, FACTORY_ADMIN_PASSWORD, true); -SecuritySettingsService::SecuritySettingsService(AsyncWebServer* server, FS* fs) : SecurityManager() { +SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs) + : SecurityManager() { } SecuritySettingsService::~SecuritySettingsService() { } ArRequestFilterFunction SecuritySettingsService::filterRequest(AuthenticationPredicate predicate) { - return [this, predicate](AsyncWebServerRequest* request) { return true; }; + return [this, predicate](AsyncWebServerRequest * request) { return true; }; } // Return the admin user on all request - disabling security features -Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest* request) { - return Authentication(ADMIN_USER); +Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest * request) { + return Authentication(ADMIN_USER); } // Return the function unwrapped -ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, - AuthenticationPredicate predicate) { - return onRequest; +ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { + return onRequest; } -ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, - AuthenticationPredicate predicate) { - return onRequest; +ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { + return onRequest; } #endif diff --git a/lib_standalone/StatefulService.h b/lib_standalone/StatefulService.h index 4b9d8dea1..d45195cc2 100644 --- a/lib_standalone/StatefulService.h +++ b/lib_standalone/StatefulService.h @@ -16,10 +16,10 @@ #endif enum class StateUpdateResult { - CHANGED = 0, // The update changed the state and propagation should take place if required + CHANGED = 0, // The update changed the state and propagation should take place if required CHANGED_RESTART, // The update changed the state and the service should be restarted - UNCHANGED, // The state was unchanged, propagation should not take place - ERROR // There was a problem updating the state, propagation should not take place + UNCHANGED, // The state was unchanged, propagation should not take place + ERROR // There was a problem updating the state, propagation should not take place }; template diff --git a/src/analogsensor.cpp b/src/analogsensor.cpp index 531e7a339..2070d8e95 100644 --- a/src/analogsensor.cpp +++ b/src/analogsensor.cpp @@ -32,7 +32,7 @@ void AnalogSensor::start() { analogSetAttenuation(ADC_2_5db); // for all channels 1.5V - LOG_INFO(("Starting Analog sensor service")); + LOG_INFO("Starting Analog sensor service"); // Add API call for /info Command::add( diff --git a/src/command.cpp b/src/command.cpp index 277c6135e..e7446c215 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -376,7 +376,7 @@ bool Command::list(const uint8_t device_type, JsonObject & output) { // output list of all commands to console for a specific DeviceType void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbose) { if (cmdfunctions_.empty()) { - shell.println(("No commands available")); + shell.println("No commands available"); return; } diff --git a/src/console.cpp b/src/console.cpp index 18880809e..f76bfb71e 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -59,12 +59,12 @@ void EMSESPShell::stopped() { // this is one of the first functions called when the shell is started void EMSESPShell::display_banner() { println(); - printfln(("┌──────────────────────────────────────┐")); + printfln("┌──────────────────────────────────────┐"); printfln(("│ %sEMS-ESP version %-10s%s │"), COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_BOLD_OFF); printfln(("│ %s%shttps://github.com/emsesp/EMS-ESP32%s │"), COLOR_BRIGHT_GREEN, COLOR_UNDERLINE, COLOR_RESET); - printfln(("│ │")); + printfln("│ │"); printfln(("│ type %shelp%s to show available commands │"), COLOR_UNDERLINE, COLOR_RESET); - printfln(("└──────────────────────────────────────┘")); + printfln("└──────────────────────────────────────┘"); println(); // set console name @@ -151,16 +151,16 @@ void EMSESPShell::add_console_commands() { }, "local"); } else { - shell.println(("Must be 0B, 0D, 0A, 0F or 12")); + shell.println("Must be 0B, 0D, 0A, 0F or 12"); } }, [](Shell & shell __attribute__((unused)), const std::vector & arguments __attribute__((unused))) -> const std::vector { return std::vector{ - (("0B")), - (("0D")), - (("0A")), - (("0F")), - (("12")), + ("0B"), + ("0D"), + ("0A"), + ("0F"), + ("12"), }; }); @@ -189,7 +189,7 @@ void EMSESPShell::add_console_commands() { if (arguments.size() == 0) { EMSESP::scan_devices(); } else { - shell.printfln(("Performing a deep scan...")); + shell.printfln("Performing a deep scan..."); EMSESP::clear_all_devices(); std::vector Device_Ids; @@ -240,7 +240,7 @@ void EMSESPShell::add_console_commands() { uint8_t device_id = Helpers::hextoint(arguments.front().c_str()); if (!EMSESP::valid_device(device_id)) { - shell.printfln(("Invalid deviceID")); + shell.printfln("Invalid deviceID"); return; } @@ -305,28 +305,28 @@ void EMSESPShell::add_console_commands() { EMSESP::watch_id(watch_id); } else { - shell.printfln(("Invalid: use watch raw|on|off|unknown|id [id]")); + shell.printfln("Invalid: use watch raw|on|off|unknown|id [id]"); return; } uint8_t watch = EMSESP::watch(); if (watch == EMSESP::WATCH_OFF) { - shell.printfln(("Watching telegrams is off")); + shell.printfln("Watching telegrams is off"); return; } // if logging is off, the watch won't show anything, show force it back to NOTICE if (shell.log_level() < Level::NOTICE) { shell.log_level(Level::NOTICE); - shell.printfln(("Setting log level to Notice")); + shell.printfln("Setting log level to Notice"); } if (watch == EMSESP::WATCH_ON) { - shell.printfln(("Watching incoming telegrams, displayed in decoded format")); + shell.printfln("Watching incoming telegrams, displayed in decoded format"); } else if (watch == EMSESP::WATCH_RAW) { - shell.printfln(("Watching incoming telegrams, displayed as raw bytes")); // WATCH_RAW + shell.printfln("Watching incoming telegrams, displayed as raw bytes"); // WATCH_RAW } else { - shell.printfln(("Watching unknown telegrams")); // WATCH_UNKNOWN + shell.printfln("Watching unknown telegrams"); // WATCH_UNKNOWN } watch_id = EMSESP::watch_id(); @@ -351,7 +351,7 @@ void EMSESPShell::add_console_commands() { // validate the device_type uint8_t device_type = EMSdevice::device_name_2_device_type(arguments[0].c_str()); if (!Command::device_has_commands(device_type)) { - shell.print(("Invalid device. Available devices are: ")); + shell.print("Invalid device. Available devices are: "); Command::show_devices(shell); return; } @@ -359,7 +359,7 @@ void EMSESPShell::add_console_commands() { // validate that a command is present if (arguments.size() < 2) { - shell.print(("Missing command. Available commands are: ")); + shell.print("Missing command. Available commands are: "); Command::show(shell, device_type, false); // non-verbose mode return; } @@ -399,8 +399,8 @@ void EMSESPShell::add_console_commands() { } if (return_code == CommandRet::NOT_FOUND) { - shell.println(("Unknown command")); - shell.print(("Available commands are: ")); + shell.println("Unknown command"); + shell.print("Available commands are: "); Command::show(shell, device_type, false); // non-verbose mode } else if (return_code != CommandRet::OK) { shell.printfln(("Bad syntax (error code %d)"), return_code); @@ -494,7 +494,7 @@ void Console::load_standard_commands(unsigned int context) { return; } } else { - shell.print(("levels: ")); + shell.print("levels: "); std::vector v = uuid::log::levels_lowercase(); size_t i = v.size(); while (i--) { @@ -543,7 +543,7 @@ void Console::load_standard_commands(unsigned int context) { } else { shell.delay_until(now + INVALID_PASSWORD_DELAY_MS, [](Shell & shell) { shell.logger().log(LogLevel::NOTICE, LogFacility::AUTH, ("Invalid su password on console")); - shell.println(("su: incorrect password")); + shell.println("su: incorrect password"); }); } }); @@ -579,7 +579,7 @@ void Console::load_system_commands(unsigned int context) { if (securitySettings.jwtSecret.equals(password.c_str())) { EMSESP::system_.format(shell); } else { - shell.println(("incorrect password")); + shell.println("incorrect password"); } }); } @@ -602,9 +602,9 @@ void Console::load_system_commands(unsigned int context) { return StateUpdateResult::CHANGED; }, "local"); - shell.println(("su password updated")); + shell.println("su password updated"); } else { - shell.println(("Passwords do not match")); + shell.println("Passwords do not match"); } } }); @@ -675,7 +675,7 @@ void Console::load_system_commands(unsigned int context) { }); shell.println("Use `wifi reconnect` to save and apply the new settings"); } else { - shell.println(("Passwords do not match")); + shell.println("Passwords do not match"); } } }); @@ -737,7 +737,7 @@ EMSESPStreamConsole::EMSESPStreamConsole(Stream & stream, bool local) : uuid::console::Shell(commands, ShellContext::MAIN, local ? (CommandFlags::USER | CommandFlags::LOCAL) : CommandFlags::USER) , uuid::console::StreamConsole(stream) , EMSESPShell() - , name_((("Serial"))) + , name_(("Serial")) , pty_(SIZE_MAX) , addr_() , port_(0) { diff --git a/src/dallassensor.cpp b/src/dallassensor.cpp index 32635c748..1c2d211bb 100644 --- a/src/dallassensor.cpp +++ b/src/dallassensor.cpp @@ -42,7 +42,7 @@ void DallasSensor::start() { #ifndef EMSESP_STANDALONE bus_.begin(dallas_gpio_); - LOG_INFO(("Starting Dallas sensor service")); + LOG_INFO("Starting Dallas sensor service"); #endif // Add API calls @@ -84,7 +84,7 @@ void DallasSensor::loop() { if (state_ == State::IDLE) { if (time_now - last_activity_ >= READ_INTERVAL_MS) { #ifdef EMSESP_DEBUG_SENSOR - LOG_DEBUG(("[DEBUG] Read sensor temperature")); + LOG_DEBUG("[DEBUG] Read sensor temperature"); #endif if (bus_.reset() || parasite_) { YIELD; @@ -99,7 +99,7 @@ void DallasSensor::loop() { if (++scanretry_ > SCAN_MAX) { // every 30 sec scanretry_ = 0; #ifdef EMSESP_DEBUG_SENSOR - LOG_ERROR(("Bus reset failed")); + LOG_ERROR("Bus reset failed"); #endif for (auto & sensor : sensors_) { sensor.temperature_c = EMS_VALUE_SHORT_NOTSET; @@ -112,13 +112,13 @@ void DallasSensor::loop() { } else if (state_ == State::READING) { if (temperature_convert_complete() && (time_now - last_activity_ > CONVERSION_MS)) { #ifdef EMSESP_DEBUG_SENSOR - LOG_DEBUG(("Scanning for sensors")); + LOG_DEBUG("Scanning for sensors"); #endif bus_.reset_search(); state_ = State::SCANNING; } else if (time_now - last_activity_ > READ_TIMEOUT_MS) { #ifdef EMSESP_DEBUG_SENSOR - LOG_WARNING(("Dallas sensor read timeout")); + LOG_WARNING("Dallas sensor read timeout"); #endif state_ = State::IDLE; sensorfails_++; @@ -126,7 +126,7 @@ void DallasSensor::loop() { } else if (state_ == State::SCANNING) { if (time_now - last_activity_ > SCAN_TIMEOUT_MS) { #ifdef EMSESP_DEBUG_SENSOR - LOG_ERROR(("Dallas sensor scan timeout")); + LOG_ERROR("Dallas sensor scan timeout"); #endif state_ = State::IDLE; sensorfails_++; diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index def57f8c4..281f3f8dc 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -2083,9 +2083,9 @@ bool Boiler::set_ww_circulation_mode(const char * value, const int8_t id) { if (v < 7) { // LOG_INFO(("Setting dhw circulation mode %dx3min"), v); } else if (v == 7) { - // LOG_INFO(("Setting dhw circulation mode continuous")); + // LOG_INFO("Setting dhw circulation mode continuous"); } else { - // LOG_WARNING(("Set dhw circulation mode: Invalid value")); + // LOG_WARNING("Set dhw circulation mode: Invalid value"); return false; } @@ -2109,12 +2109,12 @@ bool Boiler::set_reset(const char * value, const int8_t id) { } if (num == 1) { - // LOG_INFO(("Reset boiler maintenance message")); + // LOG_INFO("Reset boiler maintenance message"); write_command(0x05, 0x08, 0xFF, 0x1C); has_update(&reset_); return true; } else if (num == 2) { - // LOG_INFO(("Reset boiler error message")); + // LOG_INFO("Reset boiler error message"); write_command(0x05, 0x00, 0x5A); // error reset has_update(&reset_); return true; @@ -2131,7 +2131,7 @@ bool Boiler::set_maintenance(const char * value, const int8_t id) { std::string s; if (Helpers::value2string(value, s)) { if (s == Helpers::translated_word(FL_(reset))) { - // LOG_INFO(("Reset boiler maintenance message")); + // LOG_INFO("Reset boiler maintenance message"); write_command(0x05, 0x08, 0xFF, 0x1C); return true; } @@ -2169,7 +2169,7 @@ bool Boiler::set_maintenance(const char * value, const int8_t id) { return true; } - LOG_WARNING(("Setting maintenance: wrong format")); + LOG_WARNING("Setting maintenance: wrong format"); return false; } //maintenance @@ -2183,7 +2183,7 @@ bool Boiler::set_maintenancetime(const char * value, const int8_t id) { return true; } } - LOG_WARNING(("Setting maintenance: wrong format")); + LOG_WARNING("Setting maintenance: wrong format"); return false; } @@ -2204,7 +2204,7 @@ bool Boiler::set_maintenancedate(const char * value, const int8_t id) { return true; } - LOG_WARNING(("Setting maintenance: wrong format")); + LOG_WARNING("Setting maintenance: wrong format"); return false; } diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index b67926910..4486e09bb 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -1369,7 +1369,7 @@ void Thermostat::process_RCTime(std::shared_ptr telegram) { double difference = difftime(now, ttime); if (difference > 15 || difference < -15) { set_datetime("ntp", -1); // set from NTP - LOG_INFO(("thermostat time correction from ntp")); + LOG_INFO("thermostat time correction from ntp"); } } #ifndef EMSESP_STANDALONE @@ -1380,7 +1380,7 @@ void Thermostat::process_RCTime(std::shared_ptr telegram) { } struct timeval newnow = {.tv_sec = ttime}; settimeofday(&newnow, nullptr); - LOG_INFO(("ems-esp time set from thermostat")); + LOG_INFO("ems-esp time set from thermostat"); } #endif } @@ -2132,7 +2132,7 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) { return false; } if (!EMSESP::system_.ntp_connected()) { - LOG_WARNING(("Set date: no valid NTP data, setting from ESP Clock")); + LOG_WARNING("Set date: no valid NTP data, setting from ESP Clock"); } data[0] = tm_->tm_year - 100; // Bosch counts from 2000 @@ -2153,7 +2153,7 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) { data[6] = (dt[20] - '0'); // day of week, Mo:0 data[7] = (dt[22] - '0') + 2; // DST and flag } else { - LOG_WARNING(("Set date: invalid data, wrong length")); + LOG_WARNING("Set date: invalid data, wrong length"); return false; } if (data[1] == 0 || data[1] > 12 || data[2] > 23 || data[3] == 0 || data[3] > 31 || data[4] > 59 || data[5] > 59 || data[6] > 6 || data[7] > 3) { diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index d0f259d8d..093f18dec 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -62,19 +62,19 @@ std::string EMSdevice::uom_to_string(uint8_t uom) { std::string EMSdevice::brand_to_string() const { switch (brand_) { case EMSdevice::Brand::BOSCH: - return (("Bosch")); + return ("Bosch"); case EMSdevice::Brand::JUNKERS: - return (("Junkers")); + return ("Junkers"); case EMSdevice::Brand::BUDERUS: - return (("Buderus")); + return ("Buderus"); case EMSdevice::Brand::NEFIT: - return (("Nefit")); + return ("Nefit"); case EMSdevice::Brand::SIEGER: - return (("Sieger")); + return ("Sieger"); case EMSdevice::Brand::WORCESTER: - return (("Worcester")); + return ("Worcester"); case EMSdevice::Brand::IVT: - return (("IVT")); + return ("IVT"); default: return (("")); } @@ -302,28 +302,28 @@ void EMSdevice::show_telegram_handlers(uuid::console::Shell & shell) const { } shell.printf(COLOR_RESET); */ - shell.printf((" Received telegram type IDs: ")); + shell.printf(" Received telegram type IDs: "); for (const auto & tf : telegram_functions_) { if (tf.received_ && !tf.fetch_) { shell.printf(("0x%02X "), tf.telegram_type_id_); } } shell.println(); - shell.printf((" Fetched telegram type IDs: ")); + shell.printf(" Fetched telegram type IDs: "); for (const auto & tf : telegram_functions_) { if (tf.fetch_) { shell.printf(("0x%02X "), tf.telegram_type_id_); } } shell.println(); - shell.printf((" Pending telegram type IDs: ")); + shell.printf(" Pending telegram type IDs: "); for (const auto & tf : telegram_functions_) { if (!tf.received_ && !tf.fetch_) { shell.printf(("0x%02X "), tf.telegram_type_id_); } } shell.println(); - shell.printf((" Ignored telegram type IDs: ")); + shell.printf(" Ignored telegram type IDs: "); for (auto handlers : handlers_ignored_) { shell.printf(("0x%02X "), handlers); } @@ -1467,9 +1467,9 @@ bool EMSdevice::has_telegram_id(uint16_t id) const { std::string EMSdevice::telegram_type_name(std::shared_ptr telegram) const { // see if it's one of the common ones, like Version if (telegram->type_id == EMS_TYPE_VERSION) { - return (("Version")); + return ("Version"); } else if (telegram->type_id == EMS_TYPE_UBADevices) { - return (("UBADevices")); + return ("UBADevices"); } for (const auto & tf : telegram_functions_) { diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 95b9a1bce..0582a7384 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -190,7 +190,7 @@ void EMSESP::uart_init() { if (System::is_valid_gpio(rx_gpio) && System::is_valid_gpio(tx_gpio)) { EMSuart::start(tx_mode, rx_gpio, tx_gpio); // start UART } else { - LOG_WARNING(("Invalid UART Rx/Tx GPIOs. Check config.")); + LOG_WARNING("Invalid UART Rx/Tx GPIOs. Check config."); } txservice_.start(); // sends out request to EMS bus for all devices @@ -234,20 +234,20 @@ void EMSESP::show_ems(uuid::console::Shell & shell) { // EMS bus information switch (bus_status()) { case BUS_STATUS_OFFLINE: - shell.printfln(("EMS Bus is disconnected.")); + shell.printfln("EMS Bus is disconnected."); break; case BUS_STATUS_TX_ERRORS: - shell.printfln(("EMS Bus is connected, but Tx is not stable.")); + shell.printfln("EMS Bus is connected, but Tx is not stable."); break; default: - shell.printfln(("EMS Bus is connected.")); + shell.printfln("EMS Bus is connected."); break; } shell.println(); if (bus_status() != BUS_STATUS_OFFLINE) { - shell.printfln(("EMS Bus info:")); + shell.printfln("EMS Bus info:"); EMSESP::webSettingsService.read([&](WebSettings & settings) { shell.printfln((" Tx mode: %d"), settings.tx_mode); }); shell.printfln((" Bus protocol: %s"), EMSbus::is_ht3() ? ("HT3") : ("Buderus")); shell.printfln((" #recognized EMS devices: %d"), EMSESP::emsdevices.size()); @@ -265,7 +265,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) { // Rx queue auto rx_telegrams = rxservice_.queue(); if (rx_telegrams.empty()) { - shell.printfln(("Rx Queue is empty")); + shell.printfln("Rx Queue is empty"); } else { shell.printfln(("Rx Queue (%ld telegram%s):"), rx_telegrams.size(), rx_telegrams.size() == 1 ? "" : "s"); for (const auto & it : rx_telegrams) { @@ -278,7 +278,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) { // Tx queue auto tx_telegrams = txservice_.queue(); if (tx_telegrams.empty()) { - shell.printfln(("Tx Queue is empty")); + shell.printfln("Tx Queue is empty"); } else { shell.printfln(("Tx Queue (%ld telegram%s):"), tx_telegrams.size(), tx_telegrams.size() == 1 ? "" : "s"); @@ -301,7 +301,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) { // show EMS device values to the shell console void EMSESP::show_device_values(uuid::console::Shell & shell) { if (emsdevices.empty()) { - shell.printfln(("No EMS devices detected.")); + shell.printfln("No EMS devices detected."); shell.println(); return; } @@ -359,7 +359,7 @@ void EMSESP::show_device_values(uuid::console::Shell & shell) { // show Dallas temperature sensors and Analog sensors void EMSESP::show_sensor_values(uuid::console::Shell & shell) { if (dallassensor_.have_sensors()) { - shell.printfln(("Temperature sensors:")); + shell.printfln("Temperature sensors:"); char s[10]; char s2[10]; uint8_t fahrenheit = EMSESP::system_.fahrenheit() ? 2 : 0; @@ -384,7 +384,7 @@ void EMSESP::show_sensor_values(uuid::console::Shell & shell) { if (analogsensor_.have_sensors()) { char s[10]; char s2[10]; - shell.printfln(("Analog sensors:")); + shell.printfln("Analog sensors:"); for (const auto & sensor : analogsensor_.sensors()) { switch (sensor.type()) { case AnalogSensor::AnalogType::ADC: @@ -537,7 +537,7 @@ void EMSESP::publish_device_values(uint8_t device_type) { } if (need_publish) { if (doc.overflowed()) { - LOG_WARNING(("MQTT buffer overflow, please use individual topics")); + LOG_WARNING("MQTT buffer overflow, please use individual topics"); } Mqtt::publish(Mqtt::tag_to_topic(device_type, DeviceValueTAG::TAG_NONE), json); } @@ -808,7 +808,7 @@ bool EMSESP::process_telegram(std::shared_ptr telegram) { // only process broadcast telegrams or ones sent to us on request // if ((telegram->dest != 0x00) && (telegram->dest != rxservice_.ems_bus_id())) { if (telegram->operation == Telegram::Operation::RX_READ) { - // LOG_DEBUG(("read telegram received, not processing")); + // LOG_DEBUG("read telegram received, not processing"); return false; } @@ -884,12 +884,12 @@ bool EMSESP::device_exists(const uint8_t device_id) { // for each associated EMS device go and get its system information void EMSESP::show_devices(uuid::console::Shell & shell) { if (emsdevices.empty()) { - shell.printfln(("No EMS devices detected. Try using 'scan devices' from the ems menu.")); + shell.printfln("No EMS devices detected. Try using 'scan devices' from the ems menu."); shell.println(); return; } - shell.printfln(("These EMS devices are currently active:")); + shell.printfln("These EMS devices are currently active:"); shell.println(); // count the number of thermostats @@ -1018,7 +1018,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const name = "generic boiler"; device_type = DeviceType::BOILER; flags = DeviceFlags::EMS_DEVICE_FLAG_HEATPUMP; - LOG_WARNING(("Unknown EMS boiler. Using generic profile. Please report on GitHub.")); + LOG_WARNING("Unknown EMS boiler. Using generic profile. Please report on GitHub."); } else { LOG_WARNING(("Unrecognized EMS device (device ID 0x%02X, no product ID). Please report on GitHub."), device_id); return false; @@ -1190,14 +1190,14 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) { // if we're waiting on a Write operation, we want a single byte 1 or 4 if ((tx_state == Telegram::Operation::TX_WRITE) && (length == 1)) { if (first_value == TxService::TX_WRITE_SUCCESS) { - LOG_DEBUG(("Last Tx write successful")); + LOG_DEBUG("Last Tx write successful"); txservice_.increment_telegram_write_count(); // last tx/write was confirmed ok txservice_.send_poll(); // close the bus publish_id_ = txservice_.post_send_query(); // follow up with any post-read if set txservice_.reset_retry_count(); tx_successful = true; } else if (first_value == TxService::TX_WRITE_FAIL) { - LOG_ERROR(("Last Tx write rejected by host")); + LOG_ERROR("Last Tx write rejected by host"); txservice_.send_poll(); // close the bus txservice_.reset_retry_count(); } @@ -1206,7 +1206,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) { uint8_t src = data[0]; uint8_t dest = data[1]; if (txservice_.is_last_tx(src, dest)) { - LOG_DEBUG(("Last Tx read successful")); + LOG_DEBUG("Last Tx read successful"); txservice_.increment_telegram_read_count(); txservice_.send_poll(); // close the bus txservice_.reset_retry_count(); @@ -1289,14 +1289,14 @@ void EMSESP::start() { webLogService.begin(); // start web log service. now we can start capturing logs to the web log #ifdef EMSESP_DEBUG - LOG_NOTICE(("System is running in Debug mode")); + LOG_NOTICE("System is running in Debug mode"); #endif LOG_INFO(("Last system reset reason Core0: %s, Core1: %s"), system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str()); // do any system upgrades if (system_.check_upgrade()) { - LOG_INFO(("System needs a restart to apply new settings. Please wait.")); + LOG_INFO("System needs a restart to apply new settings. Please wait."); system_.system_restart(); }; diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 1b17f41ae..83a405129 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -192,7 +192,7 @@ void Mqtt::show_mqtt(uuid::console::Shell & shell) { shell.println(); // show subscriptions - shell.printfln(("MQTT topic subscriptions:")); + shell.printfln("MQTT topic subscriptions:"); for (const auto & mqtt_subfunction : mqtt_subfunctions_) { shell.printfln((" %s/%s"), mqtt_base_.c_str(), mqtt_subfunction.topic_.c_str()); } @@ -200,7 +200,7 @@ void Mqtt::show_mqtt(uuid::console::Shell & shell) { // show queues if (mqtt_messages_.empty()) { - shell.printfln(("MQTT queue is empty")); + shell.printfln("MQTT queue is empty"); shell.println(); return; } @@ -341,7 +341,7 @@ void Mqtt::show_topic_handlers(uuid::console::Shell & shell, const uint8_t devic return; } - // shell.print((" Subscribed MQTT topics: ")); + // shell.print(" Subscribed MQTT topics: "); // for (const auto & mqtt_subfunction : mqtt_subfunctions_) { // if (mqtt_subfunction.device_type_ == device_type) { // shell.printf(("%s "), mqtt_subfunction.topic_.c_str()); @@ -368,7 +368,7 @@ void Mqtt::on_publish(uint16_t packetId) const { // if the last published failed, don't bother checking it. wait for the next retry if (mqtt_message.packet_id_ == 0) { #if defined(EMSESP_DEBUG) - LOG_DEBUG(("[DEBUG] ACK for failed message pid 0")); + LOG_DEBUG("[DEBUG] ACK for failed message pid 0"); #endif return; } @@ -450,15 +450,15 @@ void Mqtt::start() { } connecting_ = false; if (reason == AsyncMqttClientDisconnectReason::TCP_DISCONNECTED) { - LOG_WARNING(("MQTT disconnected: TCP")); + LOG_WARNING("MQTT disconnected: TCP"); } else if (reason == AsyncMqttClientDisconnectReason::MQTT_IDENTIFIER_REJECTED) { - LOG_WARNING(("MQTT disconnected: Identifier Rejected")); + LOG_WARNING("MQTT disconnected: Identifier Rejected"); } else if (reason == AsyncMqttClientDisconnectReason::MQTT_SERVER_UNAVAILABLE) { - LOG_WARNING(("MQTT disconnected: Server unavailable")); + LOG_WARNING("MQTT disconnected: Server unavailable"); } else if (reason == AsyncMqttClientDisconnectReason::MQTT_MALFORMED_CREDENTIALS) { - LOG_WARNING(("MQTT disconnected: Malformed credentials")); + LOG_WARNING("MQTT disconnected: Malformed credentials"); } else if (reason == AsyncMqttClientDisconnectReason::MQTT_NOT_AUTHORIZED) { - LOG_WARNING(("MQTT disconnected: Not authorized")); + LOG_WARNING("MQTT disconnected: Not authorized"); } else { LOG_WARNING(("MQTT disconnected: code %d"), reason); } @@ -535,7 +535,7 @@ void Mqtt::on_connect() { return; } - LOG_INFO(("MQTT connected")); + LOG_INFO("MQTT connected"); connecting_ = true; connectcount_++; @@ -686,7 +686,7 @@ std::shared_ptr Mqtt::queue_message(const uint8_t operation, // if the queue is full, make room but removing the last one if (mqtt_messages_.size() >= MAX_MQTT_MESSAGES) { mqtt_messages_.pop_front(); - LOG_WARNING(("Queue overflow, removing one message")); + LOG_WARNING("Queue overflow, removing one message"); mqtt_publish_fails_++; } mqtt_messages_.emplace_back(mqtt_message_id_++, std::move(message)); @@ -815,7 +815,7 @@ void Mqtt::process_queue() { // it will have a real packet ID if (mqtt_message.packet_id_ > 0) { #if defined(EMSESP_DEBUG) - LOG_DEBUG(("[DEBUG] Waiting for QOS-ACK")); + LOG_DEBUG("[DEBUG] Waiting for QOS-ACK"); #endif // if we don't get the ack within 10 minutes, republish with new packet_id if (uuid::get_uptime_sec() - last_publish_queue_ < 600) { diff --git a/src/shower.cpp b/src/shower.cpp index 56a98a8d3..bf4937649 100644 --- a/src/shower.cpp +++ b/src/shower.cpp @@ -57,7 +57,7 @@ void Shower::loop() { // first check to see if hot water has been on long enough to be recognized as a Shower/Bath if (!shower_state_ && (time_now - timer_start_) > SHOWER_MIN_DURATION) { set_shower_state(true); - LOG_DEBUG(("[Shower] hot water still running, starting shower timer")); + LOG_DEBUG("[Shower] hot water still running, starting shower timer"); } // check if the shower has been on too long else if ((time_now - timer_start_) > shower_alert_trigger_) { @@ -109,7 +109,7 @@ void Shower::loop() { // turn back on the hot water for the shower void Shower::shower_alert_stop() { if (doing_cold_shot_) { - LOG_DEBUG(("Shower Alert stopped")); + LOG_DEBUG("Shower Alert stopped"); (void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "true"); doing_cold_shot_ = false; } @@ -117,7 +117,7 @@ void Shower::shower_alert_stop() { // turn off hot water to send a shot of cold void Shower::shower_alert_start() { if (shower_alert_) { - LOG_DEBUG(("Shower Alert started")); + LOG_DEBUG("Shower Alert started"); (void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false"); doing_cold_shot_ = true; alert_timer_start_ = uuid::get_uptime(); // timer starts now diff --git a/src/system.cpp b/src/system.cpp index a78044a21..0bad8d687 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -77,7 +77,7 @@ bool System::command_fetch(const char * value, const int8_t id) { std::string value_s; if (Helpers::value2string(value, value_s)) { if (value_s == "all") { - LOG_INFO(("Requesting data from EMS devices")); + LOG_INFO("Requesting data from EMS devices"); EMSESP::fetch_device_values(); return true; } else if (value_s == (F_(boiler))) { @@ -105,7 +105,7 @@ bool System::command_publish(const char * value, const int8_t id) { if (Helpers::value2string(value, value_s)) { if (value_s == "ha") { EMSESP::publish_all(true); // includes HA - LOG_INFO(("Publishing all data to MQTT, including HA configs")); + LOG_INFO("Publishing all data to MQTT, including HA configs"); return true; } else if (value_s == (F_(boiler))) { EMSESP::publish_device_values(EMSdevice::DeviceType::BOILER); @@ -129,7 +129,7 @@ bool System::command_publish(const char * value, const int8_t id) { } EMSESP::publish_all(); - LOG_INFO(("Publishing all data to MQTT")); + LOG_INFO("Publishing all data to MQTT"); return true; } @@ -192,7 +192,7 @@ bool System::command_watch(const char * value, const int8_t id) { // restart EMS-ESP void System::system_restart() { - LOG_INFO(("Restarting EMS-ESP...")); + LOG_INFO("Restarting EMS-ESP..."); Shell::loop_all(); delay(1000); // wait a second #ifndef EMSESP_STANDALONE @@ -202,7 +202,7 @@ void System::system_restart() { // saves all settings void System::wifi_reconnect() { - LOG_INFO(("WiFi reconnecting...")); + LOG_INFO("WiFi reconnecting..."); Shell::loop_all(); EMSESP::console_.loop(); delay(1000); // wait a second @@ -241,7 +241,7 @@ void System::syslog_init() { // start & configure syslog if (!was_enabled) { syslog_.start(); - EMSESP::logger().info(("Starting Syslog")); + EMSESP::logger().info("Starting Syslog"); } syslog_.log_level((uuid::log::Level)syslog_level_); syslog_.mark_interval(syslog_mark_interval_); @@ -255,7 +255,7 @@ void System::syslog_init() { } else if (was_enabled) { // in case service is still running, this flushes the queue // https://github.com/emsesp/EMS-ESP/issues/496 - EMSESP::logger().info(("Stopping Syslog")); + EMSESP::logger().info("Stopping Syslog"); syslog_.log_level((uuid::log::Level)-1); syslog_.mark_interval(0); syslog_.destination(""); @@ -399,7 +399,7 @@ void System::start() { // button single click void System::button_OnClick(PButton & b) { - LOG_DEBUG(("Button pressed - single click")); + LOG_DEBUG("Button pressed - single click"); #ifdef EMSESP_DEBUG #ifndef EMSESP_STANDALONE @@ -410,20 +410,20 @@ void System::button_OnClick(PButton & b) { // button double click void System::button_OnDblClick(PButton & b) { - LOG_DEBUG(("Button pressed - double click - reconnect")); + LOG_DEBUG("Button pressed - double click - reconnect"); EMSESP::system_.wifi_reconnect(); } // button long press void System::button_OnLongPress(PButton & b) { - LOG_DEBUG(("Button pressed - long press")); + LOG_DEBUG("Button pressed - long press"); } // button indefinite press void System::button_OnVLongPress(PButton & b) { - LOG_DEBUG(("Button pressed - very long press")); + LOG_DEBUG("Button pressed - very long press"); #ifndef EMSESP_STANDALONE - LOG_WARNING(("Performing factory reset...")); + LOG_WARNING("Performing factory reset..."); EMSESP::console_.loop(); EMSESP::esp8266React.factoryReset(); #endif @@ -437,12 +437,12 @@ void System::button_init(bool refresh) { if (is_valid_gpio(pbutton_gpio_)) { if (!myPButton_.init(pbutton_gpio_, HIGH)) { - LOG_DEBUG(("Multi-functional button not detected")); + LOG_DEBUG("Multi-functional button not detected"); } else { - LOG_DEBUG(("Multi-functional button enabled")); + LOG_DEBUG("Multi-functional button enabled"); } } else { - LOG_WARNING(("Invalid button GPIO. Check config.")); + LOG_WARNING("Invalid button GPIO. Check config."); } myPButton_.onClick(BUTTON_Debounce, button_OnClick); @@ -772,7 +772,7 @@ int8_t System::wifi_quality(int8_t dBm) { // print users to console void System::show_users(uuid::console::Shell & shell) { - shell.printfln(("Users:")); + shell.printfln("Users:"); #ifndef EMSESP_STANDALONE EMSESP::esp8266React.getSecuritySettingsService()->read([&](SecuritySettings & securitySettings) { @@ -801,19 +801,19 @@ void System::show_system(uuid::console::Shell & shell) { shell.println("Network:"); switch (WiFi.status()) { case WL_IDLE_STATUS: - shell.printfln((" Network: Idle")); + shell.printfln(" Network: Idle"); break; case WL_NO_SSID_AVAIL: - shell.printfln((" Network: Network not found")); + shell.printfln(" Network: Network not found"); break; case WL_SCAN_COMPLETED: - shell.printfln((" Network: Network scan complete")); + shell.printfln(" Network: Network scan complete"); break; case WL_CONNECTED: - shell.printfln((" Network: connected")); + shell.printfln(" Network: connected"); shell.printfln((" SSID: %s"), WiFi.SSID().c_str()); shell.printfln((" BSSID: %s"), WiFi.BSSIDstr().c_str()); shell.printfln((" RSSI: %d dBm (%d %%)"), WiFi.RSSI(), wifi_quality(WiFi.RSSI())); @@ -828,27 +828,27 @@ void System::show_system(uuid::console::Shell & shell) { break; case WL_CONNECT_FAILED: - shell.printfln((" WiFi Network: Connection failed")); + shell.printfln(" WiFi Network: Connection failed"); break; case WL_CONNECTION_LOST: - shell.printfln((" WiFi Network: Connection lost")); + shell.printfln(" WiFi Network: Connection lost"); break; case WL_DISCONNECTED: - shell.printfln((" WiFi Network: Disconnected")); + shell.printfln(" WiFi Network: Disconnected"); break; case WL_NO_SHIELD: default: - shell.printfln((" WiFi Network: Unknown")); + shell.printfln(" WiFi Network: Unknown"); break; } // show Ethernet if connected if (ethernet_connected_) { shell.println(); - shell.printfln((" Ethernet Network: connected")); + shell.printfln(" Ethernet Network: connected"); shell.printfln((" MAC address: %s"), ETH.macAddress().c_str()); shell.printfln((" Hostname: %s"), ETH.getHostname()); shell.printfln((" IPv4 address: %s/%s"), uuid::printable_to_string(ETH.localIP()).c_str(), uuid::printable_to_string(ETH.subnetMask()).c_str()); @@ -862,17 +862,17 @@ void System::show_system(uuid::console::Shell & shell) { shell.println("Syslog:"); if (!syslog_enabled_) { - shell.printfln((" Syslog: disabled")); + shell.printfln(" Syslog: disabled"); } else { shell.printfln((" Syslog: %s"), syslog_.started() ? "started" : "stopped"); - shell.print((" ")); + shell.print(" "); shell.printfln(F_(host_fmt), !syslog_host_.isEmpty() ? syslog_host_.c_str() : (F_(unset))); shell.printfln((" IP: %s"), uuid::printable_to_string(syslog_.ip()).c_str()); - shell.print((" ")); + shell.print(" "); shell.printfln(F_(port_fmt), syslog_port_); - shell.print((" ")); + shell.print(" "); shell.printfln(F_(log_level_fmt), uuid::log::format_level_lowercase(static_cast(syslog_level_))); - shell.print((" ")); + shell.print(" "); shell.printfln(F_(mark_interval_fmt), syslog_mark_interval_); shell.printfln((" Queued: %d"), syslog_.queued()); } @@ -908,10 +908,10 @@ bool System::check_upgrade() { // it's a customization file, just replace it and there's no need to reboot saveSettings(EMSESP_CUSTOMIZATION_FILE, "Customizations", input); } else { - LOG_ERROR(("Unrecognized file uploaded")); + LOG_ERROR("Unrecognized file uploaded"); } } else { - LOG_ERROR(("Unrecognized file uploaded, not json")); + LOG_ERROR("Unrecognized file uploaded, not json"); } // close (just in case) and remove the temp file @@ -1111,16 +1111,16 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp node = output.createNestedObject("Bus Status"); switch (EMSESP::bus_status()) { case EMSESP::BUS_STATUS_OFFLINE: - node["bus status"] = (("disconnected")); + node["bus status"] = ("disconnected"); break; case EMSESP::BUS_STATUS_TX_ERRORS: - node["bus status"] = (("connected, tx issues - try a different Tx Mode")); + node["bus status"] = ("connected, tx issues - try a different Tx Mode"); break; case EMSESP::BUS_STATUS_CONNECTED: - node["bus status"] = (("connected")); + node["bus status"] = ("connected"); break; default: - node["bus status"] = (("unknown")); + node["bus status"] = ("unknown"); break; } if (EMSESP::bus_status() != EMSESP::BUS_STATUS_OFFLINE) { diff --git a/src/telegram.cpp b/src/telegram.cpp index eb02f3b6d..c1a57a9a3 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -120,7 +120,7 @@ std::string Telegram::to_string() const { // returns telegram's message body only, in hex std::string Telegram::to_string_message() const { if (this->message_length == 0) { - return (("")); + return (""); } return Helpers::data_to_hex(this->message_data, this->message_length); @@ -381,7 +381,7 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) { uint16_t status = EMSuart::transmit(telegram_raw, length); if (status == EMS_TX_STATUS_ERR) { - LOG_ERROR(("Failed to transmit Tx via UART.")); + LOG_ERROR("Failed to transmit Tx via UART."); if (telegram->operation == Telegram::Operation::TX_READ) { increment_telegram_read_fail_count(); // another Tx fail } else { @@ -412,7 +412,7 @@ void TxService::send_telegram(const uint8_t * data, const uint8_t length) { uint16_t status = EMSuart::transmit(telegram_raw, length); if (status == EMS_TX_STATUS_ERR) { - LOG_ERROR(("Failed to transmit Tx via UART.")); + LOG_ERROR("Failed to transmit Tx via UART."); increment_telegram_fail_count(); // another Tx fail } } diff --git a/src/test/test.cpp b/src/test/test.cpp index 092a12ca0..3476a85b2 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -30,7 +30,7 @@ bool Test::run_test(const char * command, int8_t id) { } if (strcmp(command, "general") == 0) { - EMSESP::logger().info(("Testing general. Adding a Boiler and Thermostat")); + EMSESP::logger().info("Testing general. Adding a Boiler and Thermostat"); add_device(0x08, 123); // Nefit Trendline add_device(0x18, 157); // Bosch CR100 @@ -54,7 +54,7 @@ bool Test::run_test(const char * command, int8_t id) { } if (strcmp(command, "2thermostats") == 0) { - EMSESP::logger().info(("Testing with multiple thermostats...")); + EMSESP::logger().info("Testing with multiple thermostats..."); add_device(0x08, 123); // GB072 add_device(0x10, 158); // RC310 @@ -86,7 +86,7 @@ bool Test::run_test(const char * command, int8_t id) { } if (strcmp(command, "310") == 0) { - EMSESP::logger().info(("Adding a GB072/RC310 combo...")); + EMSESP::logger().info("Adding a GB072/RC310 combo..."); add_device(0x08, 123); // GB072 add_device(0x10, 158); // RC310 @@ -113,7 +113,7 @@ bool Test::run_test(const char * command, int8_t id) { } if (strcmp(command, "gateway") == 0) { - EMSESP::logger().info(("Adding a Gateway...")); + EMSESP::logger().info("Adding a Gateway..."); // add 0x48 KM200, via a version command rx_telegram({0x48, 0x0B, 0x02, 0x00, 0xBD, 0x04, 0x06, 00, 00, 00, 00, 00, 00, 00}); @@ -133,7 +133,7 @@ bool Test::run_test(const char * command, int8_t id) { } if (strcmp(command, "mixer") == 0) { - EMSESP::logger().info(("Adding a mixer...")); + EMSESP::logger().info("Adding a mixer..."); // add controller add_device(0x09, 114); @@ -155,7 +155,7 @@ bool Test::run_test(const char * command, int8_t id) { } if (strcmp(command, "boiler") == 0) { - EMSESP::logger().info(("Adding boiler...")); + EMSESP::logger().info("Adding boiler..."); add_device(0x08, 123); // Nefit Trendline // UBAuptime @@ -172,7 +172,7 @@ bool Test::run_test(const char * command, int8_t id) { } if (strcmp(command, "thermostat") == 0) { - EMSESP::logger().info(("Adding thermostat...")); + EMSESP::logger().info("Adding thermostat..."); add_device(0x10, 192); // FW120 @@ -185,7 +185,7 @@ bool Test::run_test(const char * command, int8_t id) { } if (strcmp(command, "solar") == 0) { - EMSESP::logger().info(("Adding solar...")); + EMSESP::logger().info("Adding solar..."); add_device(0x30, 163); // SM100 @@ -204,7 +204,7 @@ bool Test::run_test(const char * command, int8_t id) { } if (strcmp(command, "heatpump") == 0) { - EMSESP::logger().info(("Adding heatpump...")); + EMSESP::logger().info("Adding heatpump..."); add_device(0x38, 200); // Enviline module add_device(0x10, 192); // FW120 thermostat @@ -238,7 +238,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "general") { - shell.printfln(("Testing adding a general boiler & thermostat...")); + shell.printfln("Testing adding a general boiler & thermostat..."); run_test("general"); shell.invoke_command("show devices"); shell.invoke_command("show"); @@ -247,7 +247,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "render") { - shell.printfln(("Testing render...")); + shell.printfln("Testing render..."); // check read_value to make sure it handles all the data type correctly uint8_t message_data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; // message_length is 9 @@ -315,7 +315,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "devices") { - shell.printfln(("Testing devices...")); + shell.printfln("Testing devices..."); // A fake response - UBADevices(0x07) rx_telegram({0x08, 0x00, 0x07, 0x00, 0x0B, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); @@ -323,7 +323,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const // check for boiler and controller on same product_id if (command == "double") { - shell.printfln(("Testing double...")); + shell.printfln("Testing double..."); add_device(0x08, 206); // Nefit Excellent HR30 add_device(0x09, 206); // Nefit Excellent HR30 Controller @@ -333,7 +333,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "620") { - EMSESP::logger().info(("Testing 620...")); + EMSESP::logger().info("Testing 620..."); // Version Controller uart_telegram({0x09, 0x0B, 0x02, 0x00, 0x5F, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); @@ -344,7 +344,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const // unknown device if (command == "unknown") { - shell.printfln(("Testing unknown...")); + shell.printfln("Testing unknown..."); // add boiler add_device(0x08, 84); @@ -361,19 +361,19 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "unknown2") { - shell.printfln(("Testing unknown2...")); + shell.printfln("Testing unknown2..."); // simulate getting version information back from an unknown device rx_telegram({0x09, 0x0B, 0x02, 0x00, 0x5A, 0x01, 0x02}); // productID is 90 which doesn't exist } if (command == "gateway") { - shell.printfln(("Testing Gateway...")); + shell.printfln("Testing Gateway..."); run_test("gateway"); } if (command == "310") { - shell.printfln(("Testing RC310...")); + shell.printfln("Testing RC310..."); run_test("310"); shell.invoke_command("show devices"); shell.invoke_command("show"); @@ -382,14 +382,14 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "2thermostats") { - shell.printfln(("Testing multiple thermostats...")); + shell.printfln("Testing multiple thermostats..."); run_test("2thermostats"); shell.invoke_command("show"); shell.invoke_command("show devices"); } if (command == "web") { - shell.printfln(("Testing Web...")); + shell.printfln("Testing Web..."); Mqtt::enabled(false); // turn off mqtt Mqtt::ha_enabled(false); // turn off ha @@ -438,7 +438,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "board_profile") { - shell.printfln(("Testing board profile...")); + shell.printfln("Testing board profile..."); shell.invoke_command("system"); shell.invoke_command("set board_profile wemos"); @@ -447,7 +447,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "boiler") { - shell.printfln(("Testing boiler...")); + shell.printfln("Testing boiler..."); // Mqtt::ha_enabled(false); Mqtt::ha_enabled(true); Mqtt::nested_format(1); @@ -475,7 +475,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "shower_alert") { - shell.printfln(("Testing Shower Alert...")); + shell.printfln("Testing Shower Alert..."); run_test("boiler"); @@ -484,7 +484,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "fr120") { - shell.printfln(("Testing adding a thermostat FR120...")); + shell.printfln("Testing adding a thermostat FR120..."); add_device(0x10, 191); // FR120 thermostat @@ -496,7 +496,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "ha") { - shell.printfln(("Testing HA mqtt discovery")); + shell.printfln("Testing HA mqtt discovery"); Mqtt::ha_enabled(true); // Mqtt::ha_enabled(false); @@ -518,7 +518,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "lastcode") { - shell.printfln(("Testing lastcode")); + shell.printfln("Testing lastcode"); Mqtt::ha_enabled(false); Mqtt::nested_format(1); @@ -536,7 +536,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "dv") { - shell.printfln(("Testing device value rendering")); + shell.printfln("Testing device value rendering"); Mqtt::ha_enabled(true); Mqtt::nested_format(1); @@ -550,12 +550,12 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "dallas") { - shell.printfln(("Testing adding Dallas sensor")); + shell.printfln("Testing adding Dallas sensor"); emsesp::EMSESP::dallassensor_.test(); } if (command == "dallas_full") { - shell.printfln(("Testing adding and changing Dallas sensor")); + shell.printfln("Testing adding and changing Dallas sensor"); Mqtt::ha_enabled(true); Mqtt::nested_format(1); // Mqtt::nested_format(0); @@ -571,7 +571,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "analog") { - shell.printfln(("Testing adding Analog sensor")); + shell.printfln("Testing adding Analog sensor"); Mqtt::ha_enabled(true); // Mqtt::ha_enabled(false); Mqtt::nested_format(1); @@ -602,7 +602,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "masked") { - shell.printfln(("Testing masked entities")); + shell.printfln("Testing masked entities"); Mqtt::ha_enabled(true); Mqtt::send_response(false); @@ -626,7 +626,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "dv2") { - shell.printfln(("Testing device value lost")); + shell.printfln("Testing device value lost"); Mqtt::ha_enabled(true); Mqtt::send_response(false); @@ -647,7 +647,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const if (command == "api_values") { #if defined(EMSESP_STANDALONE) - shell.printfln(("Testing API getting values")); + shell.printfln("Testing API getting values"); Mqtt::ha_enabled(false); Mqtt::nested_format(1); Mqtt::send_response(false); @@ -680,7 +680,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "mqtt_post") { - shell.printfln(("Testing MQTT incoming changes")); + shell.printfln("Testing MQTT incoming changes"); Mqtt::ha_enabled(false); Mqtt::nested_format(1); Mqtt::send_response(false); @@ -696,7 +696,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const #if defined(EMSESP_STANDALONE) // https://github.com/emsesp/EMS-ESP32/issues/541 if (command == "api_wwmode") { - shell.printfln(("Testing API wwmode")); + shell.printfln("Testing API wwmode"); Mqtt::ha_enabled(false); Mqtt::nested_format(1); run_test("310"); @@ -715,7 +715,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const #endif if (command == "api") { - shell.printfln(("Testing API with MQTT and REST, standalone")); + shell.printfln("Testing API with MQTT and REST, standalone"); Mqtt::ha_enabled(true); // Mqtt::ha_enabled(false); @@ -990,7 +990,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "mqtt_nested") { - shell.printfln(("Testing nested MQTT")); + shell.printfln("Testing nested MQTT"); Mqtt::ha_enabled(false); // turn off HA Discovery to stop the chatter run_test("boiler"); @@ -1010,7 +1010,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "thermostat") { - shell.printfln(("Testing adding a thermostat FW120...")); + shell.printfln("Testing adding a thermostat FW120..."); run_test("thermostat"); shell.invoke_command("show"); @@ -1026,7 +1026,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "tc100") { - shell.printfln(("Testing adding a TC100 thermostat to the EMS bus...")); + shell.printfln("Testing adding a TC100 thermostat to the EMS bus..."); // add a thermostat add_device(0x18, 202); // Bosch TC100 - https://github.com/emsesp/EMS-ESP/issues/474 @@ -1037,7 +1037,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "solar") { - shell.printfln(("Testing Solar")); + shell.printfln("Testing Solar"); run_test("solar"); uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on (1)sh @@ -1050,14 +1050,14 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "heatpump") { - shell.printfln(("Testing Heat Pump")); + shell.printfln("Testing Heat Pump"); run_test("heatpump"); shell.invoke_command("call"); shell.invoke_command("call heatpump info"); } if (command == "solar200") { - shell.printfln(("Testing Solar SM200")); + shell.printfln("Testing Solar SM200"); add_device(0x30, 164); // SM200 @@ -1082,7 +1082,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "km") { - shell.printfln(("Testing KM200 Gateway")); + shell.printfln("Testing KM200 Gateway"); add_device(0x10, 158); // RC300 add_device(0x48, 189); // KM200 @@ -1140,7 +1140,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "cr100") { - shell.printfln(("Testing CR100")); + shell.printfln("Testing CR100"); add_device(0x18, 157); // Bosch CR100 - https://github.com/emsesp/EMS-ESP/issues/355 @@ -1165,14 +1165,14 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "rx2") { - shell.printfln(("Testing Rx2...")); + shell.printfln("Testing Rx2..."); for (uint8_t i = 0; i < 30; i++) { uart_telegram({0x08, 0x0B, 0x33, 0x00, 0x08, 0xFF, 0x34, 0xFB, 0x00, 0x28, 0x00, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0x00}); } } if (command == "rx") { - shell.printfln(("Testing Rx...")); + shell.printfln("Testing Rx..."); // fake telegrams. length includes CRC // Boiler -> Me, UBAMonitorFast(0x18), telegram: 08 00 18 00 00 02 5A 73 3D 0A 10 65 40 02 1A 80 00 01 E1 01 76 0E 3D 48 00 C9 44 02 00 (#data=25) @@ -1229,7 +1229,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "tx") { - shell.printfln(("Testing Tx...")); + shell.printfln("Testing Tx..."); // TX queue example - Me -> Thermostat, (0x91), telegram: 0B 17 91 05 44 45 46 47 (#data=4) uint8_t t11[] = {0x44, 0x45, 0x46, 0x47}; @@ -1266,7 +1266,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "poll") { - shell.printfln(("Testing Poll...")); + shell.printfln("Testing Poll..."); // simulate sending a read request // uint8_t t16[] = {0x44, 0x45, 0x46, 0x47}; // Me -> Thermostat, (0x91), telegram: 0B 17 91 05 44 45 46 47 (#data=4) @@ -1291,7 +1291,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "cmd") { - shell.printfln(("Testing Commands...")); + shell.printfln("Testing Commands..."); // add a thermostat with 3 HCs add_device(0x10, 192); // FW120 @@ -1318,13 +1318,13 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "pin") { - shell.printfln(("Testing pin...")); + shell.printfln("Testing pin..."); shell.invoke_command("call system pin"); shell.invoke_command("call system pin 1 true"); } if (command == "mqtt2") { - shell.printfln(("Testing MQTT large payloads...")); + shell.printfln("Testing MQTT large payloads..."); DynamicJsonDocument doc(EMSESP_JSON_SIZE_XXLARGE_DYN); @@ -1347,7 +1347,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "mqtt") { - shell.printfln(("Testing MQTT...")); + shell.printfln("Testing MQTT..."); Mqtt::ha_enabled(false); Mqtt::enabled(true); @@ -1422,7 +1422,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "poll2") { - shell.printfln(("Testing Tx Sending last message on queue...")); + shell.printfln("Testing Tx Sending last message on queue..."); EMSESP::show_ems(shell); @@ -1433,7 +1433,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "rx2") { - shell.printfln(("Testing rx2...")); + shell.printfln("Testing rx2..."); uart_telegram({0x1B, 0x5B, 0xFD, 0x2D, 0x9E, 0x3A, 0xB6, 0xE5, 0x02, 0x20, 0x33, 0x30, 0x32, 0x3A, 0x20, 0x5B, 0x73, 0xFF, 0xFF, 0xCB, 0xDF, 0xB7, 0xA7, 0xB5, 0x67, 0x77, 0x77, 0xE4, 0xFF, 0xFD, 0x77, 0xFF}); @@ -1441,14 +1441,14 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const // https://github.com/emsesp/EMS-ESP/issues/380#issuecomment-633663007 if (command == "rx3") { - shell.printfln(("Testing rx3...")); + shell.printfln("Testing rx3..."); uart_telegram({0x21, 0x0B, 0xFF, 0x00}); } // testing the UART tx command, without a queue if (command == "tx2") { - shell.printfln(("Testing tx2...")); + shell.printfln("Testing tx2..."); uint8_t t[] = {0x0B, 0x88, 0x18, 0x00, 0x20, 0xD4}; // including CRC EMSuart::transmit(t, sizeof(t)); @@ -1456,14 +1456,14 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const // send read request with offset if (command == "offset") { - shell.printfln(("Testing offset...")); + shell.printfln("Testing offset..."); // send_read_request(0x18, 0x08); EMSESP::txservice_.read_request(0x18, 0x08, 27); // no offset } if (command == "mixer") { - shell.printfln(("Testing Mixer...")); + shell.printfln("Testing Mixer..."); run_test("mixer"); @@ -1477,7 +1477,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const } if (command == "crash") { - shell.printfln(("Forcing a crash...")); + shell.printfln("Forcing a crash..."); #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdiv-by-zero" diff --git a/src/version.h b/src/version.h index 69c779d31..393fcb0b5 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.5.0b3" +#define EMSESP_APP_VERSION "3.5.0b3_o" diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index b0e48b233..e6cdbb2a5 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -117,7 +117,7 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) { emsesp::EMSESP::logger().err(error); api_fails_++; } else { - // emsesp::EMSESP::logger().debug(("API command called successfully")); + // emsesp::EMSESP::logger().debug("API command called successfully"); // if there was no json output from the call, default to the output message 'OK'. if (!output.size()) { output["message"] = "OK"; diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index 38c1146d7..8eddfbc03 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -238,7 +238,7 @@ void WebDataService::write_value(AsyncWebServerRequest * request, JsonVariant & if (return_code != CommandRet::OK) { EMSESP::logger().err(("Write command failed %s (%s)"), (const char *)output["message"], Command::return_code_string(return_code).c_str()); } else { - EMSESP::logger().debug(("Write command successful")); + EMSESP::logger().debug("Write command successful"); } response->setCode((return_code == CommandRet::OK) ? 200 : 204); diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index 4a1ae6352..21619f490 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -48,7 +48,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { break; case ARDUINO_EVENT_ETH_START: - // EMSESP::logger().info(("Ethernet initialized")); + // EMSESP::logger().info("Ethernet initialized"); ETH.setHostname(EMSESP::system_.hostname().c_str()); // configure for static IP @@ -74,12 +74,12 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { break; case ARDUINO_EVENT_ETH_DISCONNECTED: - EMSESP::logger().warning(("Ethernet disconnected")); + EMSESP::logger().warning("Ethernet disconnected"); EMSESP::system_.ethernet_connected(false); break; case ARDUINO_EVENT_ETH_STOP: - EMSESP::logger().info(("Ethernet stopped")); + EMSESP::logger().info("Ethernet stopped"); EMSESP::system_.ethernet_connected(false); break; @@ -202,7 +202,7 @@ void WebStatusService::mDNS_start() const { EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) { if (networkSettings.enableMDNS) { if (!MDNS.begin(EMSESP::system_.hostname().c_str())) { - EMSESP::logger().warning(("Failed to start mDNS responder service")); + EMSESP::logger().warning("Failed to start mDNS responder service"); return; } @@ -214,13 +214,13 @@ void WebStatusService::mDNS_start() const { MDNS.addServiceTxt("http", "tcp", "version", EMSESP_APP_VERSION); MDNS.addServiceTxt("http", "tcp", "address", address_s.c_str()); - EMSESP::logger().info(("mDNS responder service started")); + EMSESP::logger().info("mDNS responder service started"); } }); #else EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) { if (networkSettings.enableMDNS) { - EMSESP::logger().info(("mDNS responder service started")); + EMSESP::logger().info("mDNS responder service started"); } }); #endif