auto formatting

This commit is contained in:
Proddy
2022-09-28 20:27:48 +02:00
parent 777c9db0f6
commit 87d0db0b5c
32 changed files with 893 additions and 916 deletions

View File

@@ -12,10 +12,10 @@
"@emotion/styled": "^11.10.4", "@emotion/styled": "^11.10.4",
"@msgpack/msgpack": "^2.8.0", "@msgpack/msgpack": "^2.8.0",
"@mui/icons-material": "^5.10.6", "@mui/icons-material": "^5.10.6",
"@mui/material": "^5.10.6", "@mui/material": "^5.10.7",
"@table-library/react-table-library": "4.0.18", "@table-library/react-table-library": "4.0.18",
"@types/lodash": "^4.14.185", "@types/lodash": "^4.14.185",
"@types/node": "^18.7.20", "@types/node": "^18.7.23",
"@types/react": "^18.0.21", "@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6", "@types/react-dom": "^18.0.6",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
@@ -34,8 +34,8 @@
"react-router-dom": "^6.4.1", "react-router-dom": "^6.4.1",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
"sockette": "^2.0.6", "sockette": "^2.0.6",
"typesafe-i18n": "^5.13.0", "typesafe-i18n": "^5.13.1",
"typescript": "^4.8.3" "typescript": "^4.8.4"
}, },
"devDependencies": { "devDependencies": {
"nodemon": "^2.0.20", "nodemon": "^2.0.20",
@@ -3103,9 +3103,9 @@
} }
}, },
"node_modules/@mui/base": { "node_modules/@mui/base": {
"version": "5.0.0-alpha.98", "version": "5.0.0-alpha.99",
"resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.98.tgz", "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.99.tgz",
"integrity": "sha512-c0U51+K2m57MASpRrmNs6qTXSvktDbVcSjD8zCRPbfuwYWERGGwNxwM3/jsBa4dSojTSmLPnOBFDypl74Ds6yQ==", "integrity": "sha512-D04H6O1c0Jv561yI0SVbpa8MpqpW3G43CwJxV2o6ALfI0DMJ45w07dGafmDchb6aCWTRTdggd3rjgmuzyNwPiQ==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@emotion/is-prop-valid": "^1.2.0", "@emotion/is-prop-valid": "^1.2.0",
@@ -3135,9 +3135,9 @@
} }
}, },
"node_modules/@mui/core-downloads-tracker": { "node_modules/@mui/core-downloads-tracker": {
"version": "5.10.6", "version": "5.10.7",
"resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.6.tgz", "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.7.tgz",
"integrity": "sha512-dmyQBqrKmVU6yCSM4GGal5qNXpViXX+/V1t0GA1A5i9QF5Gx6noV/cw0hrSS2ffLT8L2oScq1oTdA6NVIiQ8lg==", "integrity": "sha512-3N0UYVy3MbrHzM3j6f7fIUCZ+bQ1/sSZq143tLxwSssW3Z4AqE83brpr5flEY1Lx+Aowv/cPyQMmZxzRlFCGqw==",
"funding": { "funding": {
"type": "opencollective", "type": "opencollective",
"url": "https://opencollective.com/mui" "url": "https://opencollective.com/mui"
@@ -3169,19 +3169,19 @@
} }
}, },
"node_modules/@mui/material": { "node_modules/@mui/material": {
"version": "5.10.6", "version": "5.10.7",
"resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.6.tgz", "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.7.tgz",
"integrity": "sha512-QilW5PAAGSQdN7Cpp4rwSQ1doJAt3ca1a2PHZtr8RLVlpHnXb+qQ8CeDo9+9V2fK5CDNdtTN1F+iJKO43aFBpQ==", "integrity": "sha512-o1jcQGii+q7ORrXhBiMmGzFDaboc1qTgOOC3zDW+NR9ryVzWzL7qEeqoORbgDB5zk9OBsXCjB91fUH/ls5xMwg==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@mui/base": "5.0.0-alpha.98", "@mui/base": "5.0.0-alpha.99",
"@mui/core-downloads-tracker": "^5.10.6", "@mui/core-downloads-tracker": "^5.10.7",
"@mui/system": "^5.10.6", "@mui/system": "^5.10.7",
"@mui/types": "^7.2.0", "@mui/types": "^7.2.0",
"@mui/utils": "^5.10.6", "@mui/utils": "^5.10.6",
"@types/react-transition-group": "^4.4.5", "@types/react-transition-group": "^4.4.5",
"clsx": "^1.2.1", "clsx": "^1.2.1",
"csstype": "^3.1.0", "csstype": "^3.1.1",
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"react-is": "^18.2.0", "react-is": "^18.2.0",
"react-transition-group": "^4.4.5" "react-transition-group": "^4.4.5"
@@ -3239,13 +3239,13 @@
} }
}, },
"node_modules/@mui/styled-engine": { "node_modules/@mui/styled-engine": {
"version": "5.10.6", "version": "5.10.7",
"resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.10.6.tgz", "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.10.7.tgz",
"integrity": "sha512-OnVw5xnO4l0XzlJFhKif/RlLenBNhyEQQlSTwB9ApSWB05UAU5ZSbjNsRfyEKvgmQ/fPa+MqPD/dzxbIRCwyeg==", "integrity": "sha512-CCrtW+vvCKEm6pOE/QcutQ+ORC/iE6D1ghscN4l7LE2JXPvTXO/z0yu8Wxug1JEDlWm4r1Qa0PzJe1P9bjKzNA==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@emotion/cache": "^11.10.3", "@emotion/cache": "^11.10.3",
"csstype": "^3.1.0", "csstype": "^3.1.1",
"prop-types": "^15.8.1" "prop-types": "^15.8.1"
}, },
"engines": { "engines": {
@@ -3270,17 +3270,17 @@
} }
}, },
"node_modules/@mui/system": { "node_modules/@mui/system": {
"version": "5.10.6", "version": "5.10.7",
"resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.6.tgz", "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.7.tgz",
"integrity": "sha512-HfQVX7e2xpQ3jtdB/WwtkFVtozMOozyN575/63u8ILHkE8wGDhblmCieAsnyJPFbm7WBW5PCMyzmfr4QyKLaYg==", "integrity": "sha512-kwyhjjKGsgtBRFl6vSqidDZcNKU5S1juTgm4Xi2fyWxaEbIQb9Sh9y0iVP2bNCJzgDr0alLaENOZOEaDWHISAQ==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@mui/private-theming": "^5.10.6", "@mui/private-theming": "^5.10.6",
"@mui/styled-engine": "^5.10.6", "@mui/styled-engine": "^5.10.7",
"@mui/types": "^7.2.0", "@mui/types": "^7.2.0",
"@mui/utils": "^5.10.6", "@mui/utils": "^5.10.6",
"clsx": "^1.2.1", "clsx": "^1.2.1",
"csstype": "^3.1.0", "csstype": "^3.1.1",
"prop-types": "^15.8.1" "prop-types": "^15.8.1"
}, },
"engines": { "engines": {
@@ -4029,9 +4029,9 @@
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA=="
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.7.20", "version": "18.7.23",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.20.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz",
"integrity": "sha512-adzY4vLLr5Uivmx8+zfSJ5fbdgKxX8UMtjtl+17n0B1q1Nz8JEmE151vefMdpD+1gyh+77weN4qEhej/O7budQ==" "integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg=="
}, },
"node_modules/@types/parse-json": { "node_modules/@types/parse-json": {
"version": "4.0.0", "version": "4.0.0",
@@ -16420,9 +16420,9 @@
} }
}, },
"node_modules/typesafe-i18n": { "node_modules/typesafe-i18n": {
"version": "5.13.0", "version": "5.13.1",
"resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.13.0.tgz", "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.13.1.tgz",
"integrity": "sha512-Q72l+LqB37kNT2R39mkTwQy1tuQ7URAahD1QXbR84itO864xvVgdoS8xaRAatp0y2/oU7f+2EzpAK3YGp0g+eA==", "integrity": "sha512-9Cgikxcj+2LAWQGZ8pOQAf14P+aOOcOel/G1kSAXAObA4Htj8R+qgCx9DqUnxjRfugWzM/19ZqGss7dl8Dw7Gg==",
"bin": { "bin": {
"typesafe-i18n": "cli/typesafe-i18n.mjs" "typesafe-i18n": "cli/typesafe-i18n.mjs"
}, },
@@ -16435,9 +16435,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "4.8.3", "version": "4.8.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz",
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==",
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@@ -19643,9 +19643,9 @@
"integrity": "sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ==" "integrity": "sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ=="
}, },
"@mui/base": { "@mui/base": {
"version": "5.0.0-alpha.98", "version": "5.0.0-alpha.99",
"resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.98.tgz", "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.99.tgz",
"integrity": "sha512-c0U51+K2m57MASpRrmNs6qTXSvktDbVcSjD8zCRPbfuwYWERGGwNxwM3/jsBa4dSojTSmLPnOBFDypl74Ds6yQ==", "integrity": "sha512-D04H6O1c0Jv561yI0SVbpa8MpqpW3G43CwJxV2o6ALfI0DMJ45w07dGafmDchb6aCWTRTdggd3rjgmuzyNwPiQ==",
"requires": { "requires": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@emotion/is-prop-valid": "^1.2.0", "@emotion/is-prop-valid": "^1.2.0",
@@ -19658,9 +19658,9 @@
} }
}, },
"@mui/core-downloads-tracker": { "@mui/core-downloads-tracker": {
"version": "5.10.6", "version": "5.10.7",
"resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.6.tgz", "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.7.tgz",
"integrity": "sha512-dmyQBqrKmVU6yCSM4GGal5qNXpViXX+/V1t0GA1A5i9QF5Gx6noV/cw0hrSS2ffLT8L2oScq1oTdA6NVIiQ8lg==" "integrity": "sha512-3N0UYVy3MbrHzM3j6f7fIUCZ+bQ1/sSZq143tLxwSssW3Z4AqE83brpr5flEY1Lx+Aowv/cPyQMmZxzRlFCGqw=="
}, },
"@mui/icons-material": { "@mui/icons-material": {
"version": "5.10.6", "version": "5.10.6",
@@ -19671,19 +19671,19 @@
} }
}, },
"@mui/material": { "@mui/material": {
"version": "5.10.6", "version": "5.10.7",
"resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.6.tgz", "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.7.tgz",
"integrity": "sha512-QilW5PAAGSQdN7Cpp4rwSQ1doJAt3ca1a2PHZtr8RLVlpHnXb+qQ8CeDo9+9V2fK5CDNdtTN1F+iJKO43aFBpQ==", "integrity": "sha512-o1jcQGii+q7ORrXhBiMmGzFDaboc1qTgOOC3zDW+NR9ryVzWzL7qEeqoORbgDB5zk9OBsXCjB91fUH/ls5xMwg==",
"requires": { "requires": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@mui/base": "5.0.0-alpha.98", "@mui/base": "5.0.0-alpha.99",
"@mui/core-downloads-tracker": "^5.10.6", "@mui/core-downloads-tracker": "^5.10.7",
"@mui/system": "^5.10.6", "@mui/system": "^5.10.7",
"@mui/types": "^7.2.0", "@mui/types": "^7.2.0",
"@mui/utils": "^5.10.6", "@mui/utils": "^5.10.6",
"@types/react-transition-group": "^4.4.5", "@types/react-transition-group": "^4.4.5",
"clsx": "^1.2.1", "clsx": "^1.2.1",
"csstype": "^3.1.0", "csstype": "^3.1.1",
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"react-is": "^18.2.0", "react-is": "^18.2.0",
"react-transition-group": "^4.4.5" "react-transition-group": "^4.4.5"
@@ -19700,28 +19700,28 @@
} }
}, },
"@mui/styled-engine": { "@mui/styled-engine": {
"version": "5.10.6", "version": "5.10.7",
"resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.10.6.tgz", "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.10.7.tgz",
"integrity": "sha512-OnVw5xnO4l0XzlJFhKif/RlLenBNhyEQQlSTwB9ApSWB05UAU5ZSbjNsRfyEKvgmQ/fPa+MqPD/dzxbIRCwyeg==", "integrity": "sha512-CCrtW+vvCKEm6pOE/QcutQ+ORC/iE6D1ghscN4l7LE2JXPvTXO/z0yu8Wxug1JEDlWm4r1Qa0PzJe1P9bjKzNA==",
"requires": { "requires": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@emotion/cache": "^11.10.3", "@emotion/cache": "^11.10.3",
"csstype": "^3.1.0", "csstype": "^3.1.1",
"prop-types": "^15.8.1" "prop-types": "^15.8.1"
} }
}, },
"@mui/system": { "@mui/system": {
"version": "5.10.6", "version": "5.10.7",
"resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.6.tgz", "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.7.tgz",
"integrity": "sha512-HfQVX7e2xpQ3jtdB/WwtkFVtozMOozyN575/63u8ILHkE8wGDhblmCieAsnyJPFbm7WBW5PCMyzmfr4QyKLaYg==", "integrity": "sha512-kwyhjjKGsgtBRFl6vSqidDZcNKU5S1juTgm4Xi2fyWxaEbIQb9Sh9y0iVP2bNCJzgDr0alLaENOZOEaDWHISAQ==",
"requires": { "requires": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@mui/private-theming": "^5.10.6", "@mui/private-theming": "^5.10.6",
"@mui/styled-engine": "^5.10.6", "@mui/styled-engine": "^5.10.7",
"@mui/types": "^7.2.0", "@mui/types": "^7.2.0",
"@mui/utils": "^5.10.6", "@mui/utils": "^5.10.6",
"clsx": "^1.2.1", "clsx": "^1.2.1",
"csstype": "^3.1.0", "csstype": "^3.1.1",
"prop-types": "^15.8.1" "prop-types": "^15.8.1"
} }
}, },
@@ -20233,9 +20233,9 @@
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA=="
}, },
"@types/node": { "@types/node": {
"version": "18.7.20", "version": "18.7.23",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.20.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz",
"integrity": "sha512-adzY4vLLr5Uivmx8+zfSJ5fbdgKxX8UMtjtl+17n0B1q1Nz8JEmE151vefMdpD+1gyh+77weN4qEhej/O7budQ==" "integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg=="
}, },
"@types/parse-json": { "@types/parse-json": {
"version": "4.0.0", "version": "4.0.0",
@@ -29096,15 +29096,15 @@
} }
}, },
"typesafe-i18n": { "typesafe-i18n": {
"version": "5.13.0", "version": "5.13.1",
"resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.13.0.tgz", "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.13.1.tgz",
"integrity": "sha512-Q72l+LqB37kNT2R39mkTwQy1tuQ7URAahD1QXbR84itO864xvVgdoS8xaRAatp0y2/oU7f+2EzpAK3YGp0g+eA==", "integrity": "sha512-9Cgikxcj+2LAWQGZ8pOQAf14P+aOOcOel/G1kSAXAObA4Htj8R+qgCx9DqUnxjRfugWzM/19ZqGss7dl8Dw7Gg==",
"requires": {} "requires": {}
}, },
"typescript": { "typescript": {
"version": "4.8.3", "version": "4.8.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz",
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==" "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ=="
}, },
"unbox-primitive": { "unbox-primitive": {
"version": "1.0.2", "version": "1.0.2",

View File

@@ -8,10 +8,10 @@
"@emotion/styled": "^11.10.4", "@emotion/styled": "^11.10.4",
"@msgpack/msgpack": "^2.8.0", "@msgpack/msgpack": "^2.8.0",
"@mui/icons-material": "^5.10.6", "@mui/icons-material": "^5.10.6",
"@mui/material": "^5.10.6", "@mui/material": "^5.10.7",
"@table-library/react-table-library": "4.0.18", "@table-library/react-table-library": "4.0.18",
"@types/lodash": "^4.14.185", "@types/lodash": "^4.14.185",
"@types/node": "^18.7.20", "@types/node": "^18.7.23",
"@types/react": "^18.0.21", "@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6", "@types/react-dom": "^18.0.6",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
@@ -30,8 +30,8 @@
"react-router-dom": "^6.4.1", "react-router-dom": "^6.4.1",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
"sockette": "^2.0.6", "sockette": "^2.0.6",
"typesafe-i18n": "^5.13.0", "typesafe-i18n": "^5.13.1",
"typescript": "^4.8.3" "typescript": "^4.8.4"
}, },
"scripts": { "scripts": {
"start": "react-app-rewired start", "start": "react-app-rewired start",

View File

@@ -49,9 +49,9 @@ void APSettingsService::startAP() {
WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask); WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask);
esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_AP, WIFI_BW_HT20); 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); WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), _state.channel, _state.ssidHidden, _state.maxClients);
#ifdef ARDUINO_LOLIN_C3_MINI #ifdef ARDUINO_LOLIN_C3_MINI
WiFi.setTxPower(WIFI_POWER_8_5dBm); //https://www.wemos.cc/en/latest/c3/c3_mini.html#about-wifi WiFi.setTxPower(WIFI_POWER_8_5dBm); //https://www.wemos.cc/en/latest/c3/c3_mini.html#about-wifi
#endif #endif
if (!_dnsServer) { if (!_dnsServer) {
IPAddress apIp = WiFi.softAPIP(); IPAddress apIp = WiFi.softAPIP();
emsesp::EMSESP::logger().info(F("Starting Access Point with captive portal on %s"), apIp.toString().c_str()); emsesp::EMSESP::logger().info(F("Starting Access Point with captive portal on %s"), apIp.toString().c_str());

View File

@@ -56,7 +56,7 @@ class NTPSettingsService : public StatefulService<NTPSettings> {
public: public:
NTPSettingsService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager); NTPSettingsService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager);
void begin(); void begin();
static void ntp_received(struct timeval * tv); static void ntp_received(struct timeval * tv);
private: private:
@@ -68,7 +68,6 @@ class NTPSettingsService : public StatefulService<NTPSettings> {
void WiFiEvent(WiFiEvent_t event); void WiFiEvent(WiFiEvent_t event);
void configureNTP(); void configureNTP();
void configureTime(AsyncWebServerRequest * request, JsonVariant & json); void configureTime(AsyncWebServerRequest * request, JsonVariant & json);
}; };
#endif #endif

View File

@@ -75,9 +75,9 @@ void NetworkSettingsService::manageSTA() {
}); });
WiFi.begin(_state.ssid.c_str(), _state.password.c_str()); // attempt to connect to the network WiFi.begin(_state.ssid.c_str(), _state.password.c_str()); // attempt to connect to the network
#ifdef ARDUINO_LOLIN_C3_MINI #ifdef ARDUINO_LOLIN_C3_MINI
WiFi.setTxPower(WIFI_POWER_8_5dBm); //https://www.wemos.cc/en/latest/c3/c3_mini.html#about-wifi WiFi.setTxPower(WIFI_POWER_8_5dBm); //https://www.wemos.cc/en/latest/c3/c3_mini.html#about-wifi
#endif #endif
} }
} }

View File

@@ -262,32 +262,30 @@ void Shell::loop_normal() {
} else if (esc_ == 1) { // pos1 } else if (esc_ == 1) { // pos1
cursor_ = line_buffer_.length(); cursor_ = line_buffer_.length();
} else if (esc_ == 11) { // F1 } else if (esc_ == 11) { // F1
set_command_str("help");
// TODO use flash here?
set_command_str(("help"));
} else if (esc_ == 12) { // F2 } else if (esc_ == 12) { // F2
set_command_str(("show")); set_command_str("show");
} else if (esc_ == 13) { // F3 } else if (esc_ == 13) { // F3
set_command_str(("log notice")); set_command_str("log notice");
} else if (esc_ == 14) { // F4 } else if (esc_ == 14) { // F4
set_command_str(("log info")); set_command_str("log info");
} else if (esc_ == 15) { // F5 } else if (esc_ == 15) { // F5
set_command_str(("log debug")); set_command_str("log debug");
} else if (esc_ == 17) { // F6 } else if (esc_ == 17) { // F6
set_command_str(("watch off")); set_command_str("watch off");
} else if (esc_ == 18) { // F7 } else if (esc_ == 18) { // F7
set_command_str(("watch on")); set_command_str("watch on");
} else if (esc_ == 19) { // F8 } else if (esc_ == 19) { // F8
set_command_str(("watch raw")); set_command_str("watch raw");
} else if (esc_ == 20) { // F9 } else if (esc_ == 20) { // F9
set_command_str(("call system info")); set_command_str("call system info");
} else if (esc_ == 21) { // F10 } else if (esc_ == 21) { // F10
set_command_str(("call system settings")); set_command_str("call system settings");
} else if (esc_ == 23) { // F11 } else if (esc_ == 23) { // F11
line_buffer_ = (("call send \"0B \"")); line_buffer_ = ("call send \"0B \"");
cursor_ = 1; cursor_ = 1;
} else if (esc_ == 24) { // F12 } else if (esc_ == 24) { // F12
set_command_str(("log debug; watch raw")); set_command_str("log debug; watch raw");
} }
esc_ = 0; esc_ = 0;
} else if (c >= '0' && (c <= '9')) { // numbers } else if (c >= '0' && (c <= '9')) { // numbers

View File

@@ -685,8 +685,8 @@ class Shell : public std::enable_shared_from_this<Shell>, public uuid::log::Hand
PasswordData(const char * password_prompt, password_function && password_function); PasswordData(const char * password_prompt, password_function && password_function);
~PasswordData() override = default; ~PasswordData() override = default;
const char * password_prompt_; /*!< Prompt requesting password input. @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 */ 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<Shell>, public uuid::log::Hand
const std::shared_ptr<const uuid::log::Message> content_; /*!< Log message content. @since 0.1.0 */ const std::shared_ptr<const uuid::log::Message> content_; /*!< Log message content. @since 0.1.0 */
}; };
Shell(const Shell &) = delete; Shell(const Shell &) = delete;
Shell & operator=(const Shell &) = delete; Shell & operator=(const Shell &) = delete;
/** /**
@@ -906,7 +906,7 @@ class Shell : public std::enable_shared_from_this<Shell>, public uuid::log::Hand
size_t maximum_log_messages_ = MAX_LOG_MESSAGES; /*!< Maximum command line length in bytes. @since 0.6.0 */ 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_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.*/ 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 */ 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 */ 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 */ uint8_t cursor_ = 0; /*!< cursor position from end of line */
@@ -955,9 +955,9 @@ class CommandLine {
~CommandLine() = default; ~CommandLine() = default;
#ifdef UNIT_TEST #ifdef UNIT_TEST
CommandLine(CommandLine &&) = default; CommandLine(CommandLine &&) = default;
CommandLine & operator=(CommandLine &&) = default; CommandLine & operator=(CommandLine &&) = default;
CommandLine(const CommandLine &) __attribute__((deprecated)) = default; CommandLine(const CommandLine &) __attribute__((deprecated)) = default;
CommandLine & operator=(const CommandLine &) __attribute__((deprecated)) = default; CommandLine & operator=(const CommandLine &) __attribute__((deprecated)) = default;
#endif #endif
@@ -1279,8 +1279,8 @@ class Commands {
*/ */
void add_command(unsigned int context, void add_command(unsigned int context,
unsigned int flags, unsigned int flags,
const string_vector & name, const string_vector & name,
const string_vector & arguments, const string_vector & arguments,
command_function function, command_function function,
argument_completion_function arg_function); argument_completion_function arg_function);
@@ -1344,11 +1344,7 @@ class Commands {
* completions for this command. * completions for this command.
* @since 0.1.0 * @since 0.1.0
*/ */
Command(unsigned int flags, Command(unsigned int flags, const string_vector name, const string_vector arguments, command_function function, argument_completion_function arg_function);
const string_vector name,
const string_vector arguments,
command_function function,
argument_completion_function arg_function);
~Command(); ~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 */ 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 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 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 */ 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 */ argument_completion_function arg_function_; /*!< Function to be used to perform argument completions for this command. @since 0.1.0 */
private: private:
Command(const Command &) = delete; Command(const Command &) = delete;
Command & operator=(const Command &) = delete; Command & operator=(const Command &) = delete;
}; };
@@ -1487,7 +1483,7 @@ class StreamConsole : virtual public Shell {
explicit StreamConsole(Stream & stream); explicit StreamConsole(Stream & stream);
private: private:
StreamConsole(const StreamConsole &) = delete; StreamConsole(const StreamConsole &) = delete;
StreamConsole & operator=(const StreamConsole &) = delete; StreamConsole & operator=(const StreamConsole &) = delete;
/** /**

View File

@@ -626,8 +626,8 @@ class Logger {
static std::map<Handler *, Level> handlers_; /*!< Registered log handlers. @since 1.0.0 */ static std::map<Handler *, Level> handlers_; /*!< Registered log handlers. @since 1.0.0 */
static Level level_; /*!< Minimum global log level across all 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 char * name_; /*!< Logger name (flash string). @since 1.0.0 */
const Facility facility_; /*!< Default logging facility for messages. @since 1.0.0 */ const Facility facility_; /*!< Default logging facility for messages. @since 1.0.0 */
}; };
} // namespace log } // namespace log

View File

@@ -28,329 +28,322 @@ namespace uuid {
namespace telnet { namespace telnet {
TelnetStream::TelnetStream(WiFiClient &client) TelnetStream::TelnetStream(WiFiClient & client)
: client_(client) { : client_(client) {
output_buffer_.reserve(BUFFER_SIZE); output_buffer_.reserve(BUFFER_SIZE);
} }
void TelnetStream::start() { void TelnetStream::start() {
raw_write({ 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});
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() { int TelnetStream::available() {
if (peek() == -1) { if (peek() == -1) {
return 0; return 0;
} else { } else {
return 1; return 1;
} }
} }
int TelnetStream::read() { int TelnetStream::read() {
if (peek_ != -1) { if (peek_ != -1) {
int data = peek_; int data = peek_;
peek_ = -1; peek_ = -1;
return data; return data;
} }
buffer_flush(); buffer_flush();
restart: restart:
int data = raw_read(); int data = raw_read();
if (data == -1) { if (data == -1) {
return -1; return -1;
} }
unsigned char c = data; unsigned char c = data;
if (sub_negotiation_) { if (sub_negotiation_) {
if (previous_raw_in_ == IAC) { if (previous_raw_in_ == IAC) {
switch (c) { switch (c) {
case SE: case SE:
sub_negotiation_ = false; sub_negotiation_ = false;
previous_raw_in_ = 0; previous_raw_in_ = 0;
goto restart; goto restart;
case IAC: case IAC:
previous_raw_in_ = 0; previous_raw_in_ = 0;
goto restart; goto restart;
} }
} else { } else {
switch (c) { switch (c) {
case IAC: case IAC:
previous_raw_in_ = c; previous_raw_in_ = c;
goto restart; goto restart;
default: default:
previous_raw_in_ = 0; previous_raw_in_ = 0;
goto restart; goto restart;
} }
} }
} else { } else {
if (previous_raw_in_ == IAC) { if (previous_raw_in_ == IAC) {
switch (c) { switch (c) {
case IP: case IP:
// Interrupt (^C) // Interrupt (^C)
previous_raw_in_ = 0; previous_raw_in_ = 0;
c = '\x03'; c = '\x03';
break; break;
case EC: case EC:
// Backspace (^H) // Backspace (^H)
previous_raw_in_ = 0; previous_raw_in_ = 0;
c = '\x08'; c = '\x08';
break; break;
case EL: case EL:
// Delete line (^U) // Delete line (^U)
previous_raw_in_ = 0; previous_raw_in_ = 0;
c = '\x15'; c = '\x15';
break; break;
case IAC: case IAC:
previous_raw_in_ = 0; previous_raw_in_ = 0;
break; break;
case SB: case SB:
case WILL: case WILL:
case WONT: case WONT:
case DO: case DO:
case DONT: case DONT:
previous_raw_in_ = c; previous_raw_in_ = c;
goto restart; goto restart;
case SE: case SE:
case DM: case DM:
case BRK: case BRK:
case AO: case AO:
case AYT: case AYT:
case GA: case GA:
case NOP: case NOP:
default: default:
previous_raw_in_ = 0; previous_raw_in_ = 0;
goto restart; goto restart;
} }
} else if (previous_raw_in_ == SB) { } else if (previous_raw_in_ == SB) {
sub_negotiation_ = true; sub_negotiation_ = true;
previous_raw_in_ = 0; previous_raw_in_ = 0;
goto restart; goto restart;
} else if (previous_raw_in_ == WILL || previous_raw_in_ == WONT) { } else if (previous_raw_in_ == WILL || previous_raw_in_ == WONT) {
switch (c) { switch (c) {
case OPT_ECHO: case OPT_ECHO:
// Don't do these // Don't do these
raw_write({IAC, DONT, c}); raw_write({IAC, DONT, c});
break; break;
case OPT_BINARY: case OPT_BINARY:
case OPT_SGA: case OPT_SGA:
// Do these // Do these
raw_write({IAC, DO, c}); raw_write({IAC, DO, c});
break; break;
default: default:
// Don't do anything else // Don't do anything else
raw_write({IAC, DONT, c}); raw_write({IAC, DONT, c});
break; break;
} }
previous_raw_in_ = 0; previous_raw_in_ = 0;
goto restart; goto restart;
} else if (previous_raw_in_ == DO) { } else if (previous_raw_in_ == DO) {
switch (c) { switch (c) {
case OPT_ECHO: case OPT_ECHO:
case OPT_BINARY: case OPT_BINARY:
case OPT_SGA: case OPT_SGA:
// These are always enabled // These are always enabled
break; break;
default: default:
// Refuse to do anything else // Refuse to do anything else
raw_write({IAC, WONT, c}); raw_write({IAC, WONT, c});
break; break;
} }
previous_raw_in_ = 0; previous_raw_in_ = 0;
goto restart; goto restart;
} else if (previous_raw_in_ == DONT) { } else if (previous_raw_in_ == DONT) {
switch (c) { switch (c) {
case OPT_ECHO: case OPT_ECHO:
case OPT_BINARY: case OPT_BINARY:
case OPT_SGA: case OPT_SGA:
// Insist that we do these // Insist that we do these
raw_write({IAC, WILL, c}); raw_write({IAC, WILL, c});
break; break;
default: default:
// Everything else is always disabled // Everything else is always disabled
break; break;
} }
previous_raw_in_ = 0; previous_raw_in_ = 0;
goto restart; goto restart;
} else { } else {
switch (c) { switch (c) {
case IAC: case IAC:
previous_raw_in_ = c; previous_raw_in_ = c;
goto restart; goto restart;
default: default:
previous_raw_in_ = 0; previous_raw_in_ = 0;
break; break;
} }
} }
} }
if (previous_in_ == CR) { if (previous_in_ == CR) {
if (c == NUL) { if (c == NUL) {
previous_in_ = 0; previous_in_ = 0;
goto restart; goto restart;
} }
} }
previous_in_ = c; previous_in_ = c;
return c; return c;
} }
int TelnetStream::peek() { int TelnetStream::peek() {
buffer_flush(); buffer_flush();
// It's too complicated to implement this by calling peek() // It's too complicated to implement this by calling peek()
// on the original stream, especially if the original stream // on the original stream, especially if the original stream
// doesn't actually support peeking. // doesn't actually support peeking.
if (peek_ == -1) { if (peek_ == -1) {
peek_ = read(); peek_ = read();
} }
return peek_; return peek_;
} }
size_t TelnetStream::write(uint8_t data) { size_t TelnetStream::write(uint8_t data) {
if (previous_out_ == CR && data != LF) { if (previous_out_ == CR && data != LF) {
previous_out_ = data; previous_out_ = data;
if (raw_write({NUL, data}) != 2) { if (raw_write({NUL, data}) != 2) {
return 0; return 0;
} }
} else { } else {
previous_out_ = data; previous_out_ = data;
} }
if (data == IAC) { if (data == IAC) {
if (raw_write({IAC, IAC}) != 2) { if (raw_write({IAC, IAC}) != 2) {
return 0; return 0;
} }
} else { } else {
if (raw_write(data) != 1) { if (raw_write(data) != 1) {
return 0; return 0;
} }
} }
return 1; return 1;
} }
size_t TelnetStream::write(const uint8_t *buffer, size_t size) { size_t TelnetStream::write(const uint8_t * buffer, size_t size) {
std::vector<unsigned char> data; std::vector<unsigned char> data;
data.reserve(size); data.reserve(size);
while (size-- > 0) { while (size-- > 0) {
unsigned char c = *buffer++; unsigned char c = *buffer++;
if (previous_out_ == CR && c != LF) { if (previous_out_ == CR && c != LF) {
data.push_back((unsigned char)NUL); data.push_back((unsigned char)NUL);
} }
if (c == IAC) { if (c == IAC) {
data.push_back((unsigned char)IAC); data.push_back((unsigned char)IAC);
} }
previous_out_ = c; previous_out_ = c;
data.push_back(c); data.push_back(c);
} }
size_t len = raw_write(data); size_t len = raw_write(data);
if (len < size) { if (len < size) {
len = 0; len = 0;
} }
return len; return len;
} }
void TelnetStream::flush() { void TelnetStream::flush() {
// This is a pure virtual function in Arduino's Stream class, which // 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 // makes no sense because that class is for input and this is an
// output function. Later versions move it to Print as an empty // output function. Later versions move it to Print as an empty
// virtual function so this is here for backward compatibility. // virtual function so this is here for backward compatibility.
} }
int TelnetStream::raw_available() { int TelnetStream::raw_available() {
return client_.available(); return client_.available();
} }
int TelnetStream::raw_read() { int TelnetStream::raw_read() {
return client_.read(); return client_.read();
} }
void TelnetStream::buffer_flush() { void TelnetStream::buffer_flush() {
if (!output_buffer_.empty()) { if (!output_buffer_.empty()) {
size_t len = client_.write(reinterpret_cast<const unsigned char*>(output_buffer_.data()), output_buffer_.size()); size_t len = client_.write(reinterpret_cast<const unsigned char *>(output_buffer_.data()), output_buffer_.size());
if (len != output_buffer_.size()) { if (len != output_buffer_.size()) {
client_.stop(); client_.stop();
} }
output_buffer_.clear(); output_buffer_.clear();
output_buffer_.shrink_to_fit(); output_buffer_.shrink_to_fit();
} }
} }
size_t TelnetStream::raw_write(unsigned char data) { size_t TelnetStream::raw_write(unsigned char data) {
output_buffer_.push_back(data); output_buffer_.push_back(data);
if (output_buffer_.size() >= BUFFER_SIZE) { if (output_buffer_.size() >= BUFFER_SIZE) {
buffer_flush(); buffer_flush();
} }
return 1; return 1;
} }
size_t TelnetStream::raw_write(const std::vector<unsigned char> &data) { size_t TelnetStream::raw_write(const std::vector<unsigned char> & data) {
return raw_write(reinterpret_cast<const unsigned char*>(data.data()), data.size()); return raw_write(reinterpret_cast<const unsigned char *>(data.data()), data.size());
} }
size_t TelnetStream::raw_write(const uint8_t *buffer, size_t size) { size_t TelnetStream::raw_write(const uint8_t * buffer, size_t size) {
size_t offset = 0; size_t offset = 0;
size_t remaining = size; size_t remaining = size;
if (!output_buffer_.empty()) { if (!output_buffer_.empty()) {
// Fill the rest of the buffer // Fill the rest of the buffer
size_t block = std::min(remaining, BUFFER_SIZE - output_buffer_.size()); size_t block = std::min(remaining, BUFFER_SIZE - output_buffer_.size());
output_buffer_.insert(output_buffer_.end(), buffer, buffer + block); output_buffer_.insert(output_buffer_.end(), buffer, buffer + block);
offset += block; offset += block;
remaining -= block; remaining -= block;
if (output_buffer_.size() >= BUFFER_SIZE) { if (output_buffer_.size() >= BUFFER_SIZE) {
buffer_flush(); buffer_flush();
} }
} }
if (remaining >= BUFFER_SIZE) { if (remaining >= BUFFER_SIZE) {
// Output directly if it won't fit in the buffer // Output directly if it won't fit in the buffer
size_t len = client_.write(buffer + offset, remaining); size_t len = client_.write(buffer + offset, remaining);
if (len != remaining) { if (len != remaining) {
client_.stop(); client_.stop();
return offset + len; return offset + len;
} }
} else if (remaining > 0) { } else if (remaining > 0) {
// Put the rest in the buffer // Put the rest in the buffer
output_buffer_.insert(output_buffer_.end(), buffer + offset, buffer + offset + remaining); output_buffer_.insert(output_buffer_.end(), buffer + offset, buffer + offset + remaining);
} }
return size; return size;
} }
} // namespace telnet } // namespace telnet

View File

@@ -21,9 +21,9 @@
#include <Arduino.h> #include <Arduino.h>
#ifdef ARDUINO_ARCH_ESP8266 #ifdef ARDUINO_ARCH_ESP8266
# include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#else #else
# include <WiFi.h> #include <WiFi.h>
#endif #endif
#include <WiFiUdp.h> #include <WiFiUdp.h>
@@ -51,47 +51,47 @@ namespace telnet {
* *
* @since 0.1.0 * @since 0.1.0
*/ */
class TelnetStream: public ::Stream { class TelnetStream : public ::Stream {
public: public:
/** /**
* Create a new telnet stream wrapper. * Create a new telnet stream wrapper.
* *
* @param[in] client Client connection. * @param[in] client Client connection.
* @since 0.1.0 * @since 0.1.0
*/ */
explicit TelnetStream(WiFiClient &client); explicit TelnetStream(WiFiClient & client);
virtual ~TelnetStream() = default; virtual ~TelnetStream() = default;
/** /**
* Perform initial negotiation. * Perform initial negotiation.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
void start(); void start();
/** /**
* Check for available input. * Check for available input.
* *
* @return The number of bytes available to read. * @return The number of bytes available to read.
* @since 0.1.0 * @since 0.1.0
*/ */
int available() override; int available() override;
/** /**
* Read one byte from the available input. * Read one byte from the available input.
* *
* @return An unsigned char if input is available, otherwise -1. * @return An unsigned char if input is available, otherwise -1.
* @since 0.1.0 * @since 0.1.0
*/ */
int read() override; int read() override;
/** /**
* Read one byte from the available input without advancing to the * Read one byte from the available input without advancing to the
* next one. * next one.
* *
* @return An unsigned char if input is available, otherwise -1. * @return An unsigned char if input is available, otherwise -1.
* @since 0.1.0 * @since 0.1.0
*/ */
int peek() override; int peek() override;
/** /**
* Write one byte to the output stream. * Write one byte to the output stream.
* *
* Disconnect the client if the socket buffer is full. * Disconnect the client if the socket buffer is full.
@@ -100,8 +100,8 @@ public:
* @return The number of bytes that were output. * @return The number of bytes that were output.
* @since 0.1.0 * @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. * Write an array of bytes to the output stream.
* *
* Disconnect the client if the socket buffer is full. * Disconnect the client if the socket buffer is full.
@@ -111,8 +111,8 @@ public:
* @return The number of bytes that were output. * @return The number of bytes that were output.
* @since 0.1.0 * @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. * Does nothing.
* *
* This is a pure virtual function in Arduino's Stream class, which * This is a pure virtual function in Arduino's Stream class, which
@@ -122,66 +122,69 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
void flush() override; void flush() override;
private: private:
static constexpr const unsigned char NUL = 0; /*!< No operation. @since 0.1.0 */ 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 WILL =
static constexpr const unsigned char WONT = 252; /*!< Indicates the refusal to perform, or continue performing, the indicated option. @since 0.1.0 */ 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 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 WONT = 252; /*!< Indicates the refusal to perform, or continue performing, 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 DO =
static constexpr const unsigned char IAC = 255; /*!< Interpret As Command escape character. @since 0.1.0 */ 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_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_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_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(const TelnetStream &) = delete;
TelnetStream& operator=(const TelnetStream&) = delete; TelnetStream & operator=(const TelnetStream &) = delete;
/** /**
* Directly check for available input. * Directly check for available input.
* *
* @return The number of bytes available to read. * @return The number of bytes available to read.
* @since 0.1.0 * @since 0.1.0
*/ */
int raw_available(); int raw_available();
/** /**
* Read one byte directly from the available input. * Read one byte directly from the available input.
* *
* @return An unsigned char if input is available, otherwise -1. * @return An unsigned char if input is available, otherwise -1.
* @since 0.1.0 * @since 0.1.0
*/ */
int raw_read(); int raw_read();
/** /**
* Flush output stream buffer. * Flush output stream buffer.
* *
* Disconnect the client if the socket buffer is full. * Disconnect the client if the socket buffer is full.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
void buffer_flush(); void buffer_flush();
/** /**
* Write one byte directly to the output stream. * Write one byte directly to the output stream.
* *
* Disconnect the client if the socket buffer is full. * Disconnect the client if the socket buffer is full.
@@ -190,8 +193,8 @@ private:
* @return The number of bytes that were output. * @return The number of bytes that were output.
* @since 0.1.0 * @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. * Write a vector of bytes directly to the output stream.
* *
* Disconnect the client if the socket buffer is full. * Disconnect the client if the socket buffer is full.
@@ -200,8 +203,8 @@ private:
* @return The number of bytes that were output. * @return The number of bytes that were output.
* @since 0.1.0 * @since 0.1.0
*/ */
size_t raw_write(const std::vector<unsigned char> &data); size_t raw_write(const std::vector<unsigned char> & data);
/** /**
* Write an array of bytes directly to the output stream. * Write an array of bytes directly to the output stream.
* *
* Disconnect the client if the socket buffer is full. * Disconnect the client if the socket buffer is full.
@@ -211,15 +214,15 @@ private:
* @return The number of bytes that were output. * @return The number of bytes that were output.
* @since 0.1.0 * @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 */ 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 */ 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 */ 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_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 */ 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 */ int peek_ = -1; /*!< Previously read data cached by peek(). @since 0.1.0 */
std::vector<char> output_buffer_; /*!< Buffer data to be output until a read function is called. @since 0.1.0 */ std::vector<char> 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 * @since 0.1.0
*/ */
class TelnetService { class TelnetService {
public: public:
static constexpr size_t MAX_CONNECTIONS = 3; /*!< Maximum number of concurrent open connections. @since 0.1.0 */ 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 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_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 */ 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. * Function to handle the creation of a shell.
* *
* @param[in] stream Stream for the telnet connection. * @param[in] stream Stream for the telnet connection.
@@ -242,9 +245,9 @@ public:
* @param[in] port Remote port. * @param[in] port Remote port.
* @since 0.1.0 * @since 0.1.0
*/ */
using shell_factory_function = std::function<std::shared_ptr<uuid::console::Shell>(Stream &stream, const IPAddress &addr, uint16_t port)>; using shell_factory_function = std::function<std::shared_ptr<uuid::console::Shell>(Stream & stream, const IPAddress & addr, uint16_t port)>;
/** /**
* Create a new telnet service listening on the default port. * Create a new telnet service listening on the default port.
* *
* @param[in] commands Commands available for execution in shells. * @param[in] commands Commands available for execution in shells.
@@ -252,9 +255,9 @@ public:
* @param[in] flags Initial flags for shells. * @param[in] flags Initial flags for shells.
* @since 0.1.0 * @since 0.1.0
*/ */
TelnetService(std::shared_ptr<uuid::console::Commands> commands, unsigned int context = 0, unsigned int flags = 0); TelnetService(std::shared_ptr<uuid::console::Commands> commands, unsigned int context = 0, unsigned int flags = 0);
/** /**
* Create a new telnet service listening on a specific port. * Create a new telnet service listening on a specific port.
* *
* @param[in] port TCP listening port. * @param[in] port TCP listening port.
@@ -263,74 +266,74 @@ public:
* @param[in] flags Initial flags for shells. * @param[in] flags Initial flags for shells.
* @since 0.1.0 * @since 0.1.0
*/ */
TelnetService(uint16_t port, std::shared_ptr<uuid::console::Commands> commands, unsigned int context = 0, unsigned int flags = 0); TelnetService(uint16_t port, std::shared_ptr<uuid::console::Commands> commands, unsigned int context = 0, unsigned int flags = 0);
/** /**
* Create a new telnet service listening on the default port. * Create a new telnet service listening on the default port.
* *
* @param[in] shell_factory Function to create a shell for new connections. * @param[in] shell_factory Function to create a shell for new connections.
* @since 0.1.0 * @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. * Create a new telnet service listening on a specific port.
* *
* @param[in] port TCP listening port. * @param[in] port TCP listening port.
* @param[in] shell_factory Function to create a shell for new connections. * @param[in] shell_factory Function to create a shell for new connections.
* @since 0.1.0 * @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. * Start listening for connections on the configured port.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
void start(); void start();
/** /**
* Close all connections. * Close all connections.
* *
* The listening status is not affected. * The listening status is not affected.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
void close_all(); void close_all();
/** /**
* Stop listening for connections. * Stop listening for connections.
* *
* Existing connections are not affected. * Existing connections are not affected.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
void stop(); void stop();
/** /**
* Get the maximum number of concurrent open connections. * Get the maximum number of concurrent open connections.
* *
* @return The maximum number of concurrent open connections. * @return The maximum number of concurrent open connections.
* @since 0.1.0 * @since 0.1.0
*/ */
size_t maximum_connections() const; size_t maximum_connections() const;
/** /**
* Set the maximum number of concurrent open connections. * Set the maximum number of concurrent open connections.
* *
* Defaults to TelnetService::MAX_CONNECTIONS. * Defaults to TelnetService::MAX_CONNECTIONS.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
void maximum_connections(size_t count); void maximum_connections(size_t count);
/** /**
* Get the initial idle timeout for new connections. * Get the initial idle timeout for new connections.
* *
* @return The initial idle timeout in seconds (or 0 for disabled). * @return The initial idle timeout in seconds (or 0 for disabled).
* @since 0.1.0 * @since 0.1.0
*/ */
unsigned long initial_idle_timeout() const; unsigned long initial_idle_timeout() const;
/** /**
* Set the initial idle timeout for new connections. * Set the initial idle timeout for new connections.
* *
* Defaults to TelnetService::DEFAULT_IDLE_TIMEOUT. * Defaults to TelnetService::DEFAULT_IDLE_TIMEOUT.
@@ -338,17 +341,17 @@ public:
* @param[in] timeout Idle timeout in seconds (or 0 to disable). * @param[in] timeout Idle timeout in seconds (or 0 to disable).
* @since 0.1.0 * @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. * Get the default socket write timeout for new connections.
* *
* @return The default socket write timeout in seconds (or 0 for * @return The default socket write timeout in seconds (or 0 for
* platform default). * platform default).
* @since 0.1.0 * @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. * Set the default socket write timeout for new connections.
* *
* Defaults to TelnetService::DEFAULT_WRITE_TIMEOUT (platform * Defaults to TelnetService::DEFAULT_WRITE_TIMEOUT (platform
@@ -358,26 +361,26 @@ public:
* platform default). * platform default).
* @since 0.1.0 * @since 0.1.0
*/ */
void default_write_timeout(unsigned long timeout); void default_write_timeout(unsigned long timeout);
/** /**
* Accept new connections. * Accept new connections.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
void loop(); void loop();
private: private:
/** /**
* Telnet connection. * Telnet connection.
* *
* Holds the client and stream instance for the lifetime of the shell. * Holds the client and stream instance for the lifetime of the shell.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
class Connection { class Connection {
public: public:
/** /**
* Create a telnet connection shell. * Create a telnet connection shell.
* *
* @param[in] shell_factory Function to create a shell for new connections. * @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. * @param[in] write_timeout Idle timeout in milliseconds.
* @since 0.1.0 * @since 0.1.0
*/ */
Connection(shell_factory_function &shell_factory, WiFiClient &&client, unsigned long idle_timeout, unsigned long write_timeout); Connection(shell_factory_function & shell_factory, WiFiClient && client, unsigned long idle_timeout, unsigned long write_timeout);
~Connection() = default; ~Connection() = default;
/** /**
* Check if the shell is still active. * Check if the shell is still active.
* *
* @return Active status of the shell. * @return Active status of the shell.
* @since 0.1.0 * @since 0.1.0
*/ */
bool active(); bool active();
/** /**
* Stop the shell if the client is not connected. * Stop the shell if the client is not connected.
* *
* @return Active status of the shell. * @return Active status of the shell.
* @since 0.1.0 * @since 0.1.0
*/ */
bool loop(); bool loop();
/** /**
* Stop the shell. * Stop the shell.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
void stop(); void stop();
private: private:
Connection(const Connection&) = delete; Connection(const Connection &) = delete;
Connection& operator=(const Connection&) = delete; Connection & operator=(const Connection &) = delete;
WiFiClient client_; /*!< Client connection. @since 0.1.0 */ WiFiClient client_; /*!< Client connection. @since 0.1.0 */
TelnetStream stream_; /*!< Telnet stream for the connection. @since 0.1.0 */ TelnetStream stream_; /*!< Telnet stream for the connection. @since 0.1.0 */
std::shared_ptr<uuid::console::Shell> shell_; /*!< Shell for connection. @since 0.1.0 */ std::shared_ptr<uuid::console::Shell> shell_; /*!< Shell for connection. @since 0.1.0 */
IPAddress addr_; /*!< Remote address of 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 */ uint16_t port_; /*!< Remote port of connection. @since 0.1.0 */
}; };
TelnetService(const TelnetService&) = delete; TelnetService(const TelnetService &) = delete;
TelnetService& operator=(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 */ WiFiServer server_; /*!< TCP server. @since 0.1.0 */
size_t maximum_connections_ = MAX_CONNECTIONS; /*!< Maximum number of concurrent open connections. @since 0.1.0 */ size_t maximum_connections_ = MAX_CONNECTIONS; /*!< Maximum number of concurrent open connections. @since 0.1.0 */
std::list<Connection> connections_; /*!< Open connections. @since 0.1.0 */ std::list<Connection> connections_; /*!< Open connections. @since 0.1.0 */
shell_factory_function shell_factory_; /*!< Function to create a shell. @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 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 */ unsigned long write_timeout_ = DEFAULT_WRITE_TIMEOUT; /*!< Write timeout (in milliseconds). @since 0.1.0 */
}; };
} // namespace telnet } // namespace telnet

View File

@@ -26,12 +26,12 @@ struct AsyncMqttClientMessageProperties {
namespace AsyncMqttClientInternals { namespace AsyncMqttClientInternals {
typedef std::function<void(bool sessionPresent)> OnConnectUserCallback; typedef std::function<void(bool sessionPresent)> OnConnectUserCallback;
typedef std::function<void(AsyncMqttClientDisconnectReason reason)> OnDisconnectUserCallback; typedef std::function<void(AsyncMqttClientDisconnectReason reason)> OnDisconnectUserCallback;
typedef std::function<void(uint16_t packetId, uint8_t qos)> OnSubscribeUserCallback; typedef std::function<void(uint16_t packetId, uint8_t qos)> OnSubscribeUserCallback;
typedef std::function<void(uint16_t packetId)> OnUnsubscribeUserCallback; typedef std::function<void(uint16_t packetId)> OnUnsubscribeUserCallback;
typedef std::function<void(char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total)> OnMessageUserCallback; typedef std::function<void(char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total)> OnMessageUserCallback;
typedef std::function<void(uint16_t packetId)> OnPublishUserCallback; typedef std::function<void(uint16_t packetId)> OnPublishUserCallback;
}; // namespace AsyncMqttClientInternals }; // namespace AsyncMqttClientInternals
class AsyncMqttClient { class AsyncMqttClient {

View File

@@ -13,120 +13,111 @@
template <class T> template <class T>
class HttpGetEndpoint { class HttpGetEndpoint {
public: public:
HttpGetEndpoint(JsonStateReader<T> stateReader, HttpGetEndpoint(JsonStateReader<T> stateReader,
StatefulService<T>* statefulService, StatefulService<T> * statefulService,
AsyncWebServer* server, AsyncWebServer * server,
const String& servicePath, const String & servicePath,
SecurityManager* securityManager, SecurityManager * securityManager,
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
_stateReader(stateReader), _statefulService(statefulService), _bufferSize(bufferSize) { : _stateReader(stateReader)
} , _statefulService(statefulService)
, _bufferSize(bufferSize) {
}
HttpGetEndpoint(JsonStateReader<T> stateReader, HttpGetEndpoint(JsonStateReader<T> stateReader,
StatefulService<T>* statefulService, StatefulService<T> * statefulService,
AsyncWebServer* server, AsyncWebServer * server,
const String& servicePath, const String & servicePath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
_stateReader(stateReader), _statefulService(statefulService), _bufferSize(bufferSize) { : _stateReader(stateReader)
} , _statefulService(statefulService)
, _bufferSize(bufferSize) {
}
protected: protected:
JsonStateReader<T> _stateReader; JsonStateReader<T> _stateReader;
StatefulService<T>* _statefulService; StatefulService<T> * _statefulService;
size_t _bufferSize; size_t _bufferSize;
void fetchSettings(AsyncWebServerRequest* request) { void fetchSettings(AsyncWebServerRequest * request) {
} }
}; };
template <class T> template <class T>
class HttpPostEndpoint { class HttpPostEndpoint {
public: public:
HttpPostEndpoint(JsonStateReader<T> stateReader, HttpPostEndpoint(JsonStateReader<T> stateReader,
JsonStateUpdater<T> stateUpdater, JsonStateUpdater<T> stateUpdater,
StatefulService<T>* statefulService, StatefulService<T> * statefulService,
AsyncWebServer* server, AsyncWebServer * server,
const String& servicePath, const String & servicePath,
SecurityManager* securityManager, SecurityManager * securityManager,
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
_stateReader(stateReader), : _stateReader(stateReader)
_stateUpdater(stateUpdater), , _stateUpdater(stateUpdater)
_statefulService(statefulService), , _statefulService(statefulService)
_bufferSize(bufferSize) { , _bufferSize(bufferSize) {
}
HttpPostEndpoint(JsonStateReader<T> stateReader,
JsonStateUpdater<T> stateUpdater,
StatefulService<T>* statefulService,
AsyncWebServer* server,
const String& servicePath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) :
_stateReader(stateReader),
_stateUpdater(stateUpdater),
_statefulService(statefulService),
_bufferSize(bufferSize) {
}
protected:
JsonStateReader<T> _stateReader;
JsonStateUpdater<T> _stateUpdater;
StatefulService<T>* _statefulService;
size_t _bufferSize;
void updateSettings(AsyncWebServerRequest* request, JsonVariant& json) {
if (!json.is<JsonObject>()) {
return;
} }
JsonObject jsonObject = json.as<JsonObject>();
StateUpdateResult outcome = _statefulService->updateWithoutPropagation(jsonObject, _stateUpdater); HttpPostEndpoint(JsonStateReader<T> stateReader,
if (outcome == StateUpdateResult::ERROR) { JsonStateUpdater<T> stateUpdater,
return; StatefulService<T> * 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<T> _stateReader;
JsonStateUpdater<T> _stateUpdater;
StatefulService<T> * _statefulService;
size_t _bufferSize;
void updateSettings(AsyncWebServerRequest * request, JsonVariant & json) {
if (!json.is<JsonObject>()) {
return;
}
JsonObject jsonObject = json.as<JsonObject>();
StateUpdateResult outcome = _statefulService->updateWithoutPropagation(jsonObject, _stateUpdater);
if (outcome == StateUpdateResult::ERROR) {
return;
}
if (outcome == StateUpdateResult::CHANGED) {
}
} }
}
}; };
template <class T> template <class T>
class HttpEndpoint : public HttpGetEndpoint<T>, public HttpPostEndpoint<T> { class HttpEndpoint : public HttpGetEndpoint<T>, public HttpPostEndpoint<T> {
public: public:
HttpEndpoint(JsonStateReader<T> stateReader, HttpEndpoint(JsonStateReader<T> stateReader,
JsonStateUpdater<T> stateUpdater, JsonStateUpdater<T> stateUpdater,
StatefulService<T>* statefulService, StatefulService<T> * statefulService,
AsyncWebServer* server, AsyncWebServer * server,
const String& servicePath, const String & servicePath,
SecurityManager* securityManager, SecurityManager * securityManager,
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
HttpGetEndpoint<T>(stateReader, : HttpGetEndpoint<T>(stateReader, statefulService, server, servicePath, securityManager, authenticationPredicate, bufferSize)
statefulService, , HttpPostEndpoint<T>(stateReader, stateUpdater, statefulService, server, servicePath, securityManager, authenticationPredicate, bufferSize) {
server, }
servicePath,
securityManager,
authenticationPredicate,
bufferSize),
HttpPostEndpoint<T>(stateReader,
stateUpdater,
statefulService,
server,
servicePath,
securityManager,
authenticationPredicate,
bufferSize) {
}
HttpEndpoint(JsonStateReader<T> stateReader, HttpEndpoint(JsonStateReader<T> stateReader,
JsonStateUpdater<T> stateUpdater, JsonStateUpdater<T> stateUpdater,
StatefulService<T>* statefulService, StatefulService<T> * statefulService,
AsyncWebServer* server, AsyncWebServer * server,
const String& servicePath, const String & servicePath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
HttpGetEndpoint<T>(stateReader, statefulService, server, servicePath, bufferSize), : HttpGetEndpoint<T>(stateReader, statefulService, server, servicePath, bufferSize)
HttpPostEndpoint<T>(stateReader, stateUpdater, statefulService, server, servicePath, bufferSize) { , HttpPostEndpoint<T>(stateReader, stateUpdater, statefulService, server, servicePath, bufferSize) {
} }
}; };
#endif #endif

View File

@@ -61,51 +61,51 @@ typedef enum {
} wifi_auth_mode_t; } wifi_auth_mode_t;
typedef struct { typedef struct {
uint32_t status; /**< status of scanning APs: 0 — success, 1 - failure */ uint32_t status; /**< status of scanning APs: 0 — success, 1 - failure */
uint8_t number; /**< number of scan results */ uint8_t number; /**< number of scan results */
uint8_t scan_id; /**< scan sequence number, used for block scan */ uint8_t scan_id; /**< scan sequence number, used for block scan */
} wifi_event_sta_scan_done_t; } wifi_event_sta_scan_done_t;
/** Argument structure for WIFI_EVENT_STA_CONNECTED event */ /** Argument structure for WIFI_EVENT_STA_CONNECTED event */
typedef struct { typedef struct {
uint8_t ssid[32]; /**< SSID of connected AP */ uint8_t ssid[32]; /**< SSID of connected AP */
uint8_t ssid_len; /**< SSID length of connected AP */ uint8_t ssid_len; /**< SSID length of connected AP */
uint8_t bssid[6]; /**< BSSID of connected AP*/ uint8_t bssid[6]; /**< BSSID of connected AP*/
uint8_t channel; /**< channel of connected AP*/ uint8_t channel; /**< channel of connected AP*/
wifi_auth_mode_t authmode;/**< authentication mode used by AP*/ wifi_auth_mode_t authmode; /**< authentication mode used by AP*/
} wifi_event_sta_connected_t; } wifi_event_sta_connected_t;
/** Argument structure for WIFI_EVENT_STA_DISCONNECTED event */ /** Argument structure for WIFI_EVENT_STA_DISCONNECTED event */
typedef struct { typedef struct {
uint8_t ssid[32]; /**< SSID of disconnected AP */ uint8_t ssid[32]; /**< SSID of disconnected AP */
uint8_t ssid_len; /**< SSID length of disconnected AP */ uint8_t ssid_len; /**< SSID length of disconnected AP */
uint8_t bssid[6]; /**< BSSID of disconnected AP */ uint8_t bssid[6]; /**< BSSID of disconnected AP */
uint8_t reason; /**< reason of disconnection */ uint8_t reason; /**< reason of disconnection */
} wifi_event_sta_disconnected_t; } wifi_event_sta_disconnected_t;
/** Argument structure for WIFI_EVENT_STA_AUTHMODE_CHANGE event */ /** Argument structure for WIFI_EVENT_STA_AUTHMODE_CHANGE event */
typedef struct { typedef struct {
wifi_auth_mode_t old_mode; /**< the old 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_auth_mode_t new_mode; /**< the new auth mode of AP */
} wifi_event_sta_authmode_change_t; } wifi_event_sta_authmode_change_t;
/** Argument structure for WIFI_EVENT_STA_WPS_ER_PIN event */ /** Argument structure for WIFI_EVENT_STA_WPS_ER_PIN event */
typedef struct { 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; } wifi_event_sta_wps_er_pin_t;
/** Argument structure for WIFI_EVENT_STA_WPS_ER_FAILED event */ /** Argument structure for WIFI_EVENT_STA_WPS_ER_FAILED event */
typedef enum { typedef enum {
WPS_FAIL_REASON_NORMAL = 0, /**< ESP32 WPS normal fail reason */ WPS_FAIL_REASON_NORMAL = 0, /**< ESP32 WPS normal fail reason */
WPS_FAIL_REASON_RECV_M2D, /**< ESP32 WPS receive M2D frame */ WPS_FAIL_REASON_RECV_M2D, /**< ESP32 WPS receive M2D frame */
WPS_FAIL_REASON_MAX WPS_FAIL_REASON_MAX
} wifi_event_sta_wps_fail_reason_t; } wifi_event_sta_wps_fail_reason_t;
typedef union { typedef union {
wifi_event_sta_scan_done_t wifi_scan_done; wifi_event_sta_scan_done_t wifi_scan_done;
wifi_event_sta_authmode_change_t wifi_sta_authmode_change; wifi_event_sta_authmode_change_t wifi_sta_authmode_change;
wifi_event_sta_connected_t wifi_sta_connected; wifi_event_sta_connected_t wifi_sta_connected;
wifi_event_sta_disconnected_t wifi_sta_disconnected; wifi_event_sta_disconnected_t wifi_sta_disconnected;
} arduino_event_info_t; } arduino_event_info_t;
typedef struct { typedef struct {

View File

@@ -4,139 +4,136 @@
#include "../../src/emsesp_stub.h" // proddy added #include "../../src/emsesp_stub.h" // proddy added
SecuritySettingsService::SecuritySettingsService(AsyncWebServer* server, FS* fs) : SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs)
_httpEndpoint(SecuritySettings::read, SecuritySettings::update, this, server, SECURITY_SETTINGS_PATH, this), : _httpEndpoint(SecuritySettings::read, SecuritySettings::update, this, server, SECURITY_SETTINGS_PATH, this)
_fsPersistence(SecuritySettings::read, SecuritySettings::update, this, fs, SECURITY_SETTINGS_FILE), , _fsPersistence(SecuritySettings::read, SecuritySettings::update, this, fs, SECURITY_SETTINGS_FILE)
_jwtHandler(FACTORY_JWT_SECRET) { , _jwtHandler(FACTORY_JWT_SECRET) {
addUpdateHandler([&](const String& originId) { configureJWTHandler(); }, false); addUpdateHandler([&](const String & originId) { configureJWTHandler(); }, false);
} }
void SecuritySettingsService::begin() { void SecuritySettingsService::begin() {
_fsPersistence.readFromFS(); _fsPersistence.readFromFS();
configureJWTHandler(); configureJWTHandler();
} }
Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest* request) { Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest * request) {
AsyncWebHeader* authorizationHeader = request->getHeader(AUTHORIZATION_HEADER); AsyncWebHeader * authorizationHeader = request->getHeader(AUTHORIZATION_HEADER);
if (authorizationHeader) { if (authorizationHeader) {
String value = authorizationHeader->value(); String value = authorizationHeader->value();
if (value.startsWith(AUTHORIZATION_HEADER_PREFIX)) { if (value.startsWith(AUTHORIZATION_HEADER_PREFIX)) {
value = value.substring(AUTHORIZATION_HEADER_PREFIX_LEN); value = value.substring(AUTHORIZATION_HEADER_PREFIX_LEN);
return authenticateJWT(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);
} }
} else if (request->hasParam(ACCESS_TOKEN_PARAMATER)) { return Authentication();
AsyncWebParameter* tokenParamater = request->getParam(ACCESS_TOKEN_PARAMATER);
String value = tokenParamater->value();
return authenticateJWT(value);
}
return Authentication();
} }
void SecuritySettingsService::configureJWTHandler() { void SecuritySettingsService::configureJWTHandler() {
_jwtHandler.setSecret(_state.jwtSecret); _jwtHandler.setSecret(_state.jwtSecret);
} }
Authentication SecuritySettingsService::authenticateJWT(String& jwt) { Authentication SecuritySettingsService::authenticateJWT(String & jwt) {
DynamicJsonDocument payloadDocument(MAX_JWT_SIZE); DynamicJsonDocument payloadDocument(MAX_JWT_SIZE);
_jwtHandler.parseJWT(jwt, payloadDocument); _jwtHandler.parseJWT(jwt, payloadDocument);
if (payloadDocument.is<JsonObject>()) { if (payloadDocument.is<JsonObject>()) {
JsonObject parsedPayload = payloadDocument.as<JsonObject>(); JsonObject parsedPayload = payloadDocument.as<JsonObject>();
String username = parsedPayload["username"]; 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) { for (User _user : _state.users) {
if (_user.username == username && validatePayload(parsedPayload, &_user)) { if (_user.username == username && _user.password == password) {
return Authentication(_user); return Authentication(_user);
} }
} }
} return Authentication();
return Authentication();
} }
Authentication SecuritySettingsService::authenticate(const String& username, const String& password) { inline void populateJWTPayload(JsonObject & payload, User * user) {
for (User _user : _state.users) { payload["username"] = user->username;
if (_user.username == username && _user.password == password) { payload["admin"] = user->admin;
return Authentication(_user);
}
}
return Authentication();
} }
inline void populateJWTPayload(JsonObject& payload, User* user) { boolean SecuritySettingsService::validatePayload(JsonObject & parsedPayload, User * user) {
payload["username"] = user->username; DynamicJsonDocument jsonDocument(MAX_JWT_SIZE);
payload["admin"] = user->admin; JsonObject payload = jsonDocument.to<JsonObject>();
populateJWTPayload(payload, user);
return payload == parsedPayload;
} }
boolean SecuritySettingsService::validatePayload(JsonObject& parsedPayload, User* user) { String SecuritySettingsService::generateJWT(User * user) {
DynamicJsonDocument jsonDocument(MAX_JWT_SIZE); DynamicJsonDocument jsonDocument(MAX_JWT_SIZE);
JsonObject payload = jsonDocument.to<JsonObject>(); JsonObject payload = jsonDocument.to<JsonObject>();
populateJWTPayload(payload, user); populateJWTPayload(payload, user);
return payload == parsedPayload; return _jwtHandler.buildJWT(payload);
}
String SecuritySettingsService::generateJWT(User* user) {
DynamicJsonDocument jsonDocument(MAX_JWT_SIZE);
JsonObject payload = jsonDocument.to<JsonObject>();
populateJWTPayload(payload, user);
return _jwtHandler.buildJWT(payload);
} }
ArRequestFilterFunction SecuritySettingsService::filterRequest(AuthenticationPredicate predicate) { ArRequestFilterFunction SecuritySettingsService::filterRequest(AuthenticationPredicate predicate) {
return [this, predicate](AsyncWebServerRequest* request) { return [this, predicate](AsyncWebServerRequest * request) {
Authentication authentication = authenticateRequest(request); Authentication authentication = authenticateRequest(request);
return predicate(authentication); return predicate(authentication);
}; };
} }
ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
AuthenticationPredicate predicate) { return [this, onRequest, predicate](AsyncWebServerRequest * request) {
return [this, onRequest, predicate](AsyncWebServerRequest* request) { Authentication authentication = authenticateRequest(request);
Authentication authentication = authenticateRequest(request); if (!predicate(authentication)) {
if (!predicate(authentication)) { request->send(401);
request->send(401); return;
return; }
} onRequest(request);
onRequest(request); };
};
} }
ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
AuthenticationPredicate predicate) { return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant & json) {
return [this, onRequest, predicate](AsyncWebServerRequest* request, JsonVariant& json) { Authentication authentication = authenticateRequest(request);
Authentication authentication = authenticateRequest(request); if (!predicate(authentication)) {
if (!predicate(authentication)) { request->send(401);
request->send(401); return;
return; }
} onRequest(request, json);
onRequest(request, json); };
};
} }
#else #else
User ADMIN_USER = User(FACTORY_ADMIN_USERNAME, FACTORY_ADMIN_PASSWORD, true); 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() { SecuritySettingsService::~SecuritySettingsService() {
} }
ArRequestFilterFunction SecuritySettingsService::filterRequest(AuthenticationPredicate predicate) { 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 // Return the admin user on all request - disabling security features
Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest* request) { Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest * request) {
return Authentication(ADMIN_USER); return Authentication(ADMIN_USER);
} }
// Return the function unwrapped // Return the function unwrapped
ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
AuthenticationPredicate predicate) { return onRequest;
return onRequest;
} }
ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
AuthenticationPredicate predicate) { return onRequest;
return onRequest;
} }
#endif #endif

View File

@@ -16,10 +16,10 @@
#endif #endif
enum class StateUpdateResult { 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 CHANGED_RESTART, // The update changed the state and the service should be restarted
UNCHANGED, // The state was unchanged, 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 ERROR // There was a problem updating the state, propagation should not take place
}; };
template <typename T> template <typename T>

View File

@@ -32,7 +32,7 @@ void AnalogSensor::start() {
analogSetAttenuation(ADC_2_5db); // for all channels 1.5V 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 // Add API call for /info
Command::add( Command::add(

View File

@@ -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 // output list of all commands to console for a specific DeviceType
void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbose) { void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbose) {
if (cmdfunctions_.empty()) { if (cmdfunctions_.empty()) {
shell.println(("No commands available")); shell.println("No commands available");
return; return;
} }

View File

@@ -59,12 +59,12 @@ void EMSESPShell::stopped() {
// this is one of the first functions called when the shell is started // this is one of the first functions called when the shell is started
void EMSESPShell::display_banner() { void EMSESPShell::display_banner() {
println(); println();
printfln(("┌──────────────────────────────────────┐")); printfln("┌──────────────────────────────────────┐");
printfln(("│ %sEMS-ESP version %-10s%s │"), COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_BOLD_OFF); 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(("│ %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(("│ type %shelp%s to show available commands │"), COLOR_UNDERLINE, COLOR_RESET);
printfln(("└──────────────────────────────────────┘")); printfln("└──────────────────────────────────────┘");
println(); println();
// set console name // set console name
@@ -151,16 +151,16 @@ void EMSESPShell::add_console_commands() {
}, },
"local"); "local");
} else { } 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<std::string> & arguments __attribute__((unused))) -> const std::vector<std::string> { [](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) -> const std::vector<std::string> {
return std::vector<std::string>{ return std::vector<std::string>{
(("0B")), ("0B"),
(("0D")), ("0D"),
(("0A")), ("0A"),
(("0F")), ("0F"),
(("12")), ("12"),
}; };
}); });
@@ -189,7 +189,7 @@ void EMSESPShell::add_console_commands() {
if (arguments.size() == 0) { if (arguments.size() == 0) {
EMSESP::scan_devices(); EMSESP::scan_devices();
} else { } else {
shell.printfln(("Performing a deep scan...")); shell.printfln("Performing a deep scan...");
EMSESP::clear_all_devices(); EMSESP::clear_all_devices();
std::vector<uint8_t> Device_Ids; std::vector<uint8_t> Device_Ids;
@@ -240,7 +240,7 @@ void EMSESPShell::add_console_commands() {
uint8_t device_id = Helpers::hextoint(arguments.front().c_str()); uint8_t device_id = Helpers::hextoint(arguments.front().c_str());
if (!EMSESP::valid_device(device_id)) { if (!EMSESP::valid_device(device_id)) {
shell.printfln(("Invalid deviceID")); shell.printfln("Invalid deviceID");
return; return;
} }
@@ -305,28 +305,28 @@ void EMSESPShell::add_console_commands() {
EMSESP::watch_id(watch_id); EMSESP::watch_id(watch_id);
} else { } else {
shell.printfln(("Invalid: use watch raw|on|off|unknown|id [id]")); shell.printfln("Invalid: use watch raw|on|off|unknown|id [id]");
return; return;
} }
uint8_t watch = EMSESP::watch(); uint8_t watch = EMSESP::watch();
if (watch == EMSESP::WATCH_OFF) { if (watch == EMSESP::WATCH_OFF) {
shell.printfln(("Watching telegrams is off")); shell.printfln("Watching telegrams is off");
return; return;
} }
// if logging is off, the watch won't show anything, show force it back to NOTICE // if logging is off, the watch won't show anything, show force it back to NOTICE
if (shell.log_level() < Level::NOTICE) { if (shell.log_level() < Level::NOTICE) {
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) { 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) { } 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 { } else {
shell.printfln(("Watching unknown telegrams")); // WATCH_UNKNOWN shell.printfln("Watching unknown telegrams"); // WATCH_UNKNOWN
} }
watch_id = EMSESP::watch_id(); watch_id = EMSESP::watch_id();
@@ -351,7 +351,7 @@ void EMSESPShell::add_console_commands() {
// validate the device_type // validate the device_type
uint8_t device_type = EMSdevice::device_name_2_device_type(arguments[0].c_str()); uint8_t device_type = EMSdevice::device_name_2_device_type(arguments[0].c_str());
if (!Command::device_has_commands(device_type)) { 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); Command::show_devices(shell);
return; return;
} }
@@ -359,7 +359,7 @@ void EMSESPShell::add_console_commands() {
// validate that a command is present // validate that a command is present
if (arguments.size() < 2) { 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 Command::show(shell, device_type, false); // non-verbose mode
return; return;
} }
@@ -399,8 +399,8 @@ void EMSESPShell::add_console_commands() {
} }
if (return_code == CommandRet::NOT_FOUND) { if (return_code == CommandRet::NOT_FOUND) {
shell.println(("Unknown command")); shell.println("Unknown command");
shell.print(("Available commands are: ")); shell.print("Available commands are: ");
Command::show(shell, device_type, false); // non-verbose mode Command::show(shell, device_type, false); // non-verbose mode
} else if (return_code != CommandRet::OK) { } else if (return_code != CommandRet::OK) {
shell.printfln(("Bad syntax (error code %d)"), return_code); shell.printfln(("Bad syntax (error code %d)"), return_code);
@@ -494,7 +494,7 @@ void Console::load_standard_commands(unsigned int context) {
return; return;
} }
} else { } else {
shell.print(("levels: ")); shell.print("levels: ");
std::vector<std::string> v = uuid::log::levels_lowercase(); std::vector<std::string> v = uuid::log::levels_lowercase();
size_t i = v.size(); size_t i = v.size();
while (i--) { while (i--) {
@@ -543,7 +543,7 @@ void Console::load_standard_commands(unsigned int context) {
} else { } else {
shell.delay_until(now + INVALID_PASSWORD_DELAY_MS, [](Shell & shell) { shell.delay_until(now + INVALID_PASSWORD_DELAY_MS, [](Shell & shell) {
shell.logger().log(LogLevel::NOTICE, LogFacility::AUTH, ("Invalid su password on console")); 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())) { if (securitySettings.jwtSecret.equals(password.c_str())) {
EMSESP::system_.format(shell); EMSESP::system_.format(shell);
} else { } else {
shell.println(("incorrect password")); shell.println("incorrect password");
} }
}); });
} }
@@ -602,9 +602,9 @@ void Console::load_system_commands(unsigned int context) {
return StateUpdateResult::CHANGED; return StateUpdateResult::CHANGED;
}, },
"local"); "local");
shell.println(("su password updated")); shell.println("su password updated");
} else { } 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"); shell.println("Use `wifi reconnect` to save and apply the new settings");
} else { } 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::Shell(commands, ShellContext::MAIN, local ? (CommandFlags::USER | CommandFlags::LOCAL) : CommandFlags::USER)
, uuid::console::StreamConsole(stream) , uuid::console::StreamConsole(stream)
, EMSESPShell() , EMSESPShell()
, name_((("Serial"))) , name_(("Serial"))
, pty_(SIZE_MAX) , pty_(SIZE_MAX)
, addr_() , addr_()
, port_(0) { , port_(0) {

View File

@@ -42,7 +42,7 @@ void DallasSensor::start() {
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
bus_.begin(dallas_gpio_); bus_.begin(dallas_gpio_);
LOG_INFO(("Starting Dallas sensor service")); LOG_INFO("Starting Dallas sensor service");
#endif #endif
// Add API calls // Add API calls
@@ -84,7 +84,7 @@ void DallasSensor::loop() {
if (state_ == State::IDLE) { if (state_ == State::IDLE) {
if (time_now - last_activity_ >= READ_INTERVAL_MS) { if (time_now - last_activity_ >= READ_INTERVAL_MS) {
#ifdef EMSESP_DEBUG_SENSOR #ifdef EMSESP_DEBUG_SENSOR
LOG_DEBUG(("[DEBUG] Read sensor temperature")); LOG_DEBUG("[DEBUG] Read sensor temperature");
#endif #endif
if (bus_.reset() || parasite_) { if (bus_.reset() || parasite_) {
YIELD; YIELD;
@@ -99,7 +99,7 @@ void DallasSensor::loop() {
if (++scanretry_ > SCAN_MAX) { // every 30 sec if (++scanretry_ > SCAN_MAX) { // every 30 sec
scanretry_ = 0; scanretry_ = 0;
#ifdef EMSESP_DEBUG_SENSOR #ifdef EMSESP_DEBUG_SENSOR
LOG_ERROR(("Bus reset failed")); LOG_ERROR("Bus reset failed");
#endif #endif
for (auto & sensor : sensors_) { for (auto & sensor : sensors_) {
sensor.temperature_c = EMS_VALUE_SHORT_NOTSET; sensor.temperature_c = EMS_VALUE_SHORT_NOTSET;
@@ -112,13 +112,13 @@ void DallasSensor::loop() {
} else if (state_ == State::READING) { } else if (state_ == State::READING) {
if (temperature_convert_complete() && (time_now - last_activity_ > CONVERSION_MS)) { if (temperature_convert_complete() && (time_now - last_activity_ > CONVERSION_MS)) {
#ifdef EMSESP_DEBUG_SENSOR #ifdef EMSESP_DEBUG_SENSOR
LOG_DEBUG(("Scanning for sensors")); LOG_DEBUG("Scanning for sensors");
#endif #endif
bus_.reset_search(); bus_.reset_search();
state_ = State::SCANNING; state_ = State::SCANNING;
} else if (time_now - last_activity_ > READ_TIMEOUT_MS) { } else if (time_now - last_activity_ > READ_TIMEOUT_MS) {
#ifdef EMSESP_DEBUG_SENSOR #ifdef EMSESP_DEBUG_SENSOR
LOG_WARNING(("Dallas sensor read timeout")); LOG_WARNING("Dallas sensor read timeout");
#endif #endif
state_ = State::IDLE; state_ = State::IDLE;
sensorfails_++; sensorfails_++;
@@ -126,7 +126,7 @@ void DallasSensor::loop() {
} else if (state_ == State::SCANNING) { } else if (state_ == State::SCANNING) {
if (time_now - last_activity_ > SCAN_TIMEOUT_MS) { if (time_now - last_activity_ > SCAN_TIMEOUT_MS) {
#ifdef EMSESP_DEBUG_SENSOR #ifdef EMSESP_DEBUG_SENSOR
LOG_ERROR(("Dallas sensor scan timeout")); LOG_ERROR("Dallas sensor scan timeout");
#endif #endif
state_ = State::IDLE; state_ = State::IDLE;
sensorfails_++; sensorfails_++;

View File

@@ -2083,9 +2083,9 @@ bool Boiler::set_ww_circulation_mode(const char * value, const int8_t id) {
if (v < 7) { if (v < 7) {
// LOG_INFO(("Setting dhw circulation mode %dx3min"), v); // LOG_INFO(("Setting dhw circulation mode %dx3min"), v);
} else if (v == 7) { } else if (v == 7) {
// LOG_INFO(("Setting dhw circulation mode continuous")); // LOG_INFO("Setting dhw circulation mode continuous");
} else { } else {
// LOG_WARNING(("Set dhw circulation mode: Invalid value")); // LOG_WARNING("Set dhw circulation mode: Invalid value");
return false; return false;
} }
@@ -2109,12 +2109,12 @@ bool Boiler::set_reset(const char * value, const int8_t id) {
} }
if (num == 1) { if (num == 1) {
// LOG_INFO(("Reset boiler maintenance message")); // LOG_INFO("Reset boiler maintenance message");
write_command(0x05, 0x08, 0xFF, 0x1C); write_command(0x05, 0x08, 0xFF, 0x1C);
has_update(&reset_); has_update(&reset_);
return true; return true;
} else if (num == 2) { } else if (num == 2) {
// LOG_INFO(("Reset boiler error message")); // LOG_INFO("Reset boiler error message");
write_command(0x05, 0x00, 0x5A); // error reset write_command(0x05, 0x00, 0x5A); // error reset
has_update(&reset_); has_update(&reset_);
return true; return true;
@@ -2131,7 +2131,7 @@ bool Boiler::set_maintenance(const char * value, const int8_t id) {
std::string s; std::string s;
if (Helpers::value2string(value, s)) { if (Helpers::value2string(value, s)) {
if (s == Helpers::translated_word(FL_(reset))) { 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); write_command(0x05, 0x08, 0xFF, 0x1C);
return true; return true;
} }
@@ -2169,7 +2169,7 @@ bool Boiler::set_maintenance(const char * value, const int8_t id) {
return true; return true;
} }
LOG_WARNING(("Setting maintenance: wrong format")); LOG_WARNING("Setting maintenance: wrong format");
return false; return false;
} }
//maintenance //maintenance
@@ -2183,7 +2183,7 @@ bool Boiler::set_maintenancetime(const char * value, const int8_t id) {
return true; return true;
} }
} }
LOG_WARNING(("Setting maintenance: wrong format")); LOG_WARNING("Setting maintenance: wrong format");
return false; return false;
} }
@@ -2204,7 +2204,7 @@ bool Boiler::set_maintenancedate(const char * value, const int8_t id) {
return true; return true;
} }
LOG_WARNING(("Setting maintenance: wrong format")); LOG_WARNING("Setting maintenance: wrong format");
return false; return false;
} }

View File

@@ -1369,7 +1369,7 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
double difference = difftime(now, ttime); double difference = difftime(now, ttime);
if (difference > 15 || difference < -15) { if (difference > 15 || difference < -15) {
set_datetime("ntp", -1); // set from NTP set_datetime("ntp", -1); // set from NTP
LOG_INFO(("thermostat time correction from ntp")); LOG_INFO("thermostat time correction from ntp");
} }
} }
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
@@ -1380,7 +1380,7 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
} }
struct timeval newnow = {.tv_sec = ttime}; struct timeval newnow = {.tv_sec = ttime};
settimeofday(&newnow, nullptr); settimeofday(&newnow, nullptr);
LOG_INFO(("ems-esp time set from thermostat")); LOG_INFO("ems-esp time set from thermostat");
} }
#endif #endif
} }
@@ -2132,7 +2132,7 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) {
return false; return false;
} }
if (!EMSESP::system_.ntp_connected()) { 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 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[6] = (dt[20] - '0'); // day of week, Mo:0
data[7] = (dt[22] - '0') + 2; // DST and flag data[7] = (dt[22] - '0') + 2; // DST and flag
} else { } else {
LOG_WARNING(("Set date: invalid data, wrong length")); LOG_WARNING("Set date: invalid data, wrong length");
return false; 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) { 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) {

View File

@@ -62,19 +62,19 @@ std::string EMSdevice::uom_to_string(uint8_t uom) {
std::string EMSdevice::brand_to_string() const { std::string EMSdevice::brand_to_string() const {
switch (brand_) { switch (brand_) {
case EMSdevice::Brand::BOSCH: case EMSdevice::Brand::BOSCH:
return (("Bosch")); return ("Bosch");
case EMSdevice::Brand::JUNKERS: case EMSdevice::Brand::JUNKERS:
return (("Junkers")); return ("Junkers");
case EMSdevice::Brand::BUDERUS: case EMSdevice::Brand::BUDERUS:
return (("Buderus")); return ("Buderus");
case EMSdevice::Brand::NEFIT: case EMSdevice::Brand::NEFIT:
return (("Nefit")); return ("Nefit");
case EMSdevice::Brand::SIEGER: case EMSdevice::Brand::SIEGER:
return (("Sieger")); return ("Sieger");
case EMSdevice::Brand::WORCESTER: case EMSdevice::Brand::WORCESTER:
return (("Worcester")); return ("Worcester");
case EMSdevice::Brand::IVT: case EMSdevice::Brand::IVT:
return (("IVT")); return ("IVT");
default: default:
return (("")); return ((""));
} }
@@ -302,28 +302,28 @@ void EMSdevice::show_telegram_handlers(uuid::console::Shell & shell) const {
} }
shell.printf(COLOR_RESET); shell.printf(COLOR_RESET);
*/ */
shell.printf((" Received telegram type IDs: ")); shell.printf(" Received telegram type IDs: ");
for (const auto & tf : telegram_functions_) { for (const auto & tf : telegram_functions_) {
if (tf.received_ && !tf.fetch_) { if (tf.received_ && !tf.fetch_) {
shell.printf(("0x%02X "), tf.telegram_type_id_); shell.printf(("0x%02X "), tf.telegram_type_id_);
} }
} }
shell.println(); shell.println();
shell.printf((" Fetched telegram type IDs: ")); shell.printf(" Fetched telegram type IDs: ");
for (const auto & tf : telegram_functions_) { for (const auto & tf : telegram_functions_) {
if (tf.fetch_) { if (tf.fetch_) {
shell.printf(("0x%02X "), tf.telegram_type_id_); shell.printf(("0x%02X "), tf.telegram_type_id_);
} }
} }
shell.println(); shell.println();
shell.printf((" Pending telegram type IDs: ")); shell.printf(" Pending telegram type IDs: ");
for (const auto & tf : telegram_functions_) { for (const auto & tf : telegram_functions_) {
if (!tf.received_ && !tf.fetch_) { if (!tf.received_ && !tf.fetch_) {
shell.printf(("0x%02X "), tf.telegram_type_id_); shell.printf(("0x%02X "), tf.telegram_type_id_);
} }
} }
shell.println(); shell.println();
shell.printf((" Ignored telegram type IDs: ")); shell.printf(" Ignored telegram type IDs: ");
for (auto handlers : handlers_ignored_) { for (auto handlers : handlers_ignored_) {
shell.printf(("0x%02X "), handlers); 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<const Telegram> telegram) const { std::string EMSdevice::telegram_type_name(std::shared_ptr<const Telegram> telegram) const {
// see if it's one of the common ones, like Version // see if it's one of the common ones, like Version
if (telegram->type_id == EMS_TYPE_VERSION) { if (telegram->type_id == EMS_TYPE_VERSION) {
return (("Version")); return ("Version");
} else if (telegram->type_id == EMS_TYPE_UBADevices) { } else if (telegram->type_id == EMS_TYPE_UBADevices) {
return (("UBADevices")); return ("UBADevices");
} }
for (const auto & tf : telegram_functions_) { for (const auto & tf : telegram_functions_) {

View File

@@ -190,7 +190,7 @@ void EMSESP::uart_init() {
if (System::is_valid_gpio(rx_gpio) && System::is_valid_gpio(tx_gpio)) { if (System::is_valid_gpio(rx_gpio) && System::is_valid_gpio(tx_gpio)) {
EMSuart::start(tx_mode, rx_gpio, tx_gpio); // start UART EMSuart::start(tx_mode, rx_gpio, tx_gpio); // start UART
} else { } 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 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 // EMS bus information
switch (bus_status()) { switch (bus_status()) {
case BUS_STATUS_OFFLINE: case BUS_STATUS_OFFLINE:
shell.printfln(("EMS Bus is disconnected.")); shell.printfln("EMS Bus is disconnected.");
break; break;
case BUS_STATUS_TX_ERRORS: 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; break;
default: default:
shell.printfln(("EMS Bus is connected.")); shell.printfln("EMS Bus is connected.");
break; break;
} }
shell.println(); shell.println();
if (bus_status() != BUS_STATUS_OFFLINE) { 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); }); 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((" Bus protocol: %s"), EMSbus::is_ht3() ? ("HT3") : ("Buderus"));
shell.printfln((" #recognized EMS devices: %d"), EMSESP::emsdevices.size()); shell.printfln((" #recognized EMS devices: %d"), EMSESP::emsdevices.size());
@@ -265,7 +265,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) {
// Rx queue // Rx queue
auto rx_telegrams = rxservice_.queue(); auto rx_telegrams = rxservice_.queue();
if (rx_telegrams.empty()) { if (rx_telegrams.empty()) {
shell.printfln(("Rx Queue is empty")); shell.printfln("Rx Queue is empty");
} else { } else {
shell.printfln(("Rx Queue (%ld telegram%s):"), rx_telegrams.size(), rx_telegrams.size() == 1 ? "" : "s"); shell.printfln(("Rx Queue (%ld telegram%s):"), rx_telegrams.size(), rx_telegrams.size() == 1 ? "" : "s");
for (const auto & it : rx_telegrams) { for (const auto & it : rx_telegrams) {
@@ -278,7 +278,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) {
// Tx queue // Tx queue
auto tx_telegrams = txservice_.queue(); auto tx_telegrams = txservice_.queue();
if (tx_telegrams.empty()) { if (tx_telegrams.empty()) {
shell.printfln(("Tx Queue is empty")); shell.printfln("Tx Queue is empty");
} else { } else {
shell.printfln(("Tx Queue (%ld telegram%s):"), tx_telegrams.size(), tx_telegrams.size() == 1 ? "" : "s"); 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 // show EMS device values to the shell console
void EMSESP::show_device_values(uuid::console::Shell & shell) { void EMSESP::show_device_values(uuid::console::Shell & shell) {
if (emsdevices.empty()) { if (emsdevices.empty()) {
shell.printfln(("No EMS devices detected.")); shell.printfln("No EMS devices detected.");
shell.println(); shell.println();
return; return;
} }
@@ -359,7 +359,7 @@ void EMSESP::show_device_values(uuid::console::Shell & shell) {
// show Dallas temperature sensors and Analog sensors // show Dallas temperature sensors and Analog sensors
void EMSESP::show_sensor_values(uuid::console::Shell & shell) { void EMSESP::show_sensor_values(uuid::console::Shell & shell) {
if (dallassensor_.have_sensors()) { if (dallassensor_.have_sensors()) {
shell.printfln(("Temperature sensors:")); shell.printfln("Temperature sensors:");
char s[10]; char s[10];
char s2[10]; char s2[10];
uint8_t fahrenheit = EMSESP::system_.fahrenheit() ? 2 : 0; 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()) { if (analogsensor_.have_sensors()) {
char s[10]; char s[10];
char s2[10]; char s2[10];
shell.printfln(("Analog sensors:")); shell.printfln("Analog sensors:");
for (const auto & sensor : analogsensor_.sensors()) { for (const auto & sensor : analogsensor_.sensors()) {
switch (sensor.type()) { switch (sensor.type()) {
case AnalogSensor::AnalogType::ADC: case AnalogSensor::AnalogType::ADC:
@@ -537,7 +537,7 @@ void EMSESP::publish_device_values(uint8_t device_type) {
} }
if (need_publish) { if (need_publish) {
if (doc.overflowed()) { 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); Mqtt::publish(Mqtt::tag_to_topic(device_type, DeviceValueTAG::TAG_NONE), json);
} }
@@ -808,7 +808,7 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
// only process broadcast telegrams or ones sent to us on request // only process broadcast telegrams or ones sent to us on request
// if ((telegram->dest != 0x00) && (telegram->dest != rxservice_.ems_bus_id())) { // if ((telegram->dest != 0x00) && (telegram->dest != rxservice_.ems_bus_id())) {
if (telegram->operation == Telegram::Operation::RX_READ) { if (telegram->operation == Telegram::Operation::RX_READ) {
// LOG_DEBUG(("read telegram received, not processing")); // LOG_DEBUG("read telegram received, not processing");
return false; 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 // for each associated EMS device go and get its system information
void EMSESP::show_devices(uuid::console::Shell & shell) { void EMSESP::show_devices(uuid::console::Shell & shell) {
if (emsdevices.empty()) { 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(); shell.println();
return; return;
} }
shell.printfln(("These EMS devices are currently active:")); shell.printfln("These EMS devices are currently active:");
shell.println(); shell.println();
// count the number of thermostats // 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"; name = "generic boiler";
device_type = DeviceType::BOILER; device_type = DeviceType::BOILER;
flags = DeviceFlags::EMS_DEVICE_FLAG_HEATPUMP; 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 { } else {
LOG_WARNING(("Unrecognized EMS device (device ID 0x%02X, no product ID). Please report on GitHub."), device_id); LOG_WARNING(("Unrecognized EMS device (device ID 0x%02X, no product ID). Please report on GitHub."), device_id);
return false; 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 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 ((tx_state == Telegram::Operation::TX_WRITE) && (length == 1)) {
if (first_value == TxService::TX_WRITE_SUCCESS) { 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_.increment_telegram_write_count(); // last tx/write was confirmed ok
txservice_.send_poll(); // close the bus txservice_.send_poll(); // close the bus
publish_id_ = txservice_.post_send_query(); // follow up with any post-read if set publish_id_ = txservice_.post_send_query(); // follow up with any post-read if set
txservice_.reset_retry_count(); txservice_.reset_retry_count();
tx_successful = true; tx_successful = true;
} else if (first_value == TxService::TX_WRITE_FAIL) { } 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_.send_poll(); // close the bus
txservice_.reset_retry_count(); 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 src = data[0];
uint8_t dest = data[1]; uint8_t dest = data[1];
if (txservice_.is_last_tx(src, dest)) { 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_.increment_telegram_read_count();
txservice_.send_poll(); // close the bus txservice_.send_poll(); // close the bus
txservice_.reset_retry_count(); 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 webLogService.begin(); // start web log service. now we can start capturing logs to the web log
#ifdef EMSESP_DEBUG #ifdef EMSESP_DEBUG
LOG_NOTICE(("System is running in Debug mode")); LOG_NOTICE("System is running in Debug mode");
#endif #endif
LOG_INFO(("Last system reset reason Core0: %s, Core1: %s"), system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str()); 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 // do any system upgrades
if (system_.check_upgrade()) { 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(); system_.system_restart();
}; };

View File

@@ -192,7 +192,7 @@ void Mqtt::show_mqtt(uuid::console::Shell & shell) {
shell.println(); shell.println();
// show subscriptions // show subscriptions
shell.printfln(("MQTT topic subscriptions:")); shell.printfln("MQTT topic subscriptions:");
for (const auto & mqtt_subfunction : mqtt_subfunctions_) { for (const auto & mqtt_subfunction : mqtt_subfunctions_) {
shell.printfln((" %s/%s"), mqtt_base_.c_str(), mqtt_subfunction.topic_.c_str()); 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 // show queues
if (mqtt_messages_.empty()) { if (mqtt_messages_.empty()) {
shell.printfln(("MQTT queue is empty")); shell.printfln("MQTT queue is empty");
shell.println(); shell.println();
return; return;
} }
@@ -341,7 +341,7 @@ void Mqtt::show_topic_handlers(uuid::console::Shell & shell, const uint8_t devic
return; return;
} }
// shell.print((" Subscribed MQTT topics: ")); // shell.print(" Subscribed MQTT topics: ");
// for (const auto & mqtt_subfunction : mqtt_subfunctions_) { // for (const auto & mqtt_subfunction : mqtt_subfunctions_) {
// if (mqtt_subfunction.device_type_ == device_type) { // if (mqtt_subfunction.device_type_ == device_type) {
// shell.printf(("%s "), mqtt_subfunction.topic_.c_str()); // 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 the last published failed, don't bother checking it. wait for the next retry
if (mqtt_message.packet_id_ == 0) { if (mqtt_message.packet_id_ == 0) {
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
LOG_DEBUG(("[DEBUG] ACK for failed message pid 0")); LOG_DEBUG("[DEBUG] ACK for failed message pid 0");
#endif #endif
return; return;
} }
@@ -450,15 +450,15 @@ void Mqtt::start() {
} }
connecting_ = false; connecting_ = false;
if (reason == AsyncMqttClientDisconnectReason::TCP_DISCONNECTED) { if (reason == AsyncMqttClientDisconnectReason::TCP_DISCONNECTED) {
LOG_WARNING(("MQTT disconnected: TCP")); LOG_WARNING("MQTT disconnected: TCP");
} else if (reason == AsyncMqttClientDisconnectReason::MQTT_IDENTIFIER_REJECTED) { } 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) { } 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) { } 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) { } else if (reason == AsyncMqttClientDisconnectReason::MQTT_NOT_AUTHORIZED) {
LOG_WARNING(("MQTT disconnected: Not authorized")); LOG_WARNING("MQTT disconnected: Not authorized");
} else { } else {
LOG_WARNING(("MQTT disconnected: code %d"), reason); LOG_WARNING(("MQTT disconnected: code %d"), reason);
} }
@@ -535,7 +535,7 @@ void Mqtt::on_connect() {
return; return;
} }
LOG_INFO(("MQTT connected")); LOG_INFO("MQTT connected");
connecting_ = true; connecting_ = true;
connectcount_++; connectcount_++;
@@ -686,7 +686,7 @@ std::shared_ptr<const MqttMessage> Mqtt::queue_message(const uint8_t operation,
// if the queue is full, make room but removing the last one // if the queue is full, make room but removing the last one
if (mqtt_messages_.size() >= MAX_MQTT_MESSAGES) { if (mqtt_messages_.size() >= MAX_MQTT_MESSAGES) {
mqtt_messages_.pop_front(); mqtt_messages_.pop_front();
LOG_WARNING(("Queue overflow, removing one message")); LOG_WARNING("Queue overflow, removing one message");
mqtt_publish_fails_++; mqtt_publish_fails_++;
} }
mqtt_messages_.emplace_back(mqtt_message_id_++, std::move(message)); 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 // it will have a real packet ID
if (mqtt_message.packet_id_ > 0) { if (mqtt_message.packet_id_ > 0) {
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
LOG_DEBUG(("[DEBUG] Waiting for QOS-ACK")); LOG_DEBUG("[DEBUG] Waiting for QOS-ACK");
#endif #endif
// if we don't get the ack within 10 minutes, republish with new packet_id // if we don't get the ack within 10 minutes, republish with new packet_id
if (uuid::get_uptime_sec() - last_publish_queue_ < 600) { if (uuid::get_uptime_sec() - last_publish_queue_ < 600) {

View File

@@ -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 // 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) { if (!shower_state_ && (time_now - timer_start_) > SHOWER_MIN_DURATION) {
set_shower_state(true); 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 // check if the shower has been on too long
else if ((time_now - timer_start_) > shower_alert_trigger_) { 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 // turn back on the hot water for the shower
void Shower::shower_alert_stop() { void Shower::shower_alert_stop() {
if (doing_cold_shot_) { if (doing_cold_shot_) {
LOG_DEBUG(("Shower Alert stopped")); LOG_DEBUG("Shower Alert stopped");
(void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "true"); (void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "true");
doing_cold_shot_ = false; doing_cold_shot_ = false;
} }
@@ -117,7 +117,7 @@ void Shower::shower_alert_stop() {
// turn off hot water to send a shot of cold // turn off hot water to send a shot of cold
void Shower::shower_alert_start() { void Shower::shower_alert_start() {
if (shower_alert_) { if (shower_alert_) {
LOG_DEBUG(("Shower Alert started")); LOG_DEBUG("Shower Alert started");
(void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false"); (void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
doing_cold_shot_ = true; doing_cold_shot_ = true;
alert_timer_start_ = uuid::get_uptime(); // timer starts now alert_timer_start_ = uuid::get_uptime(); // timer starts now

View File

@@ -77,7 +77,7 @@ bool System::command_fetch(const char * value, const int8_t id) {
std::string value_s; std::string value_s;
if (Helpers::value2string(value, value_s)) { if (Helpers::value2string(value, value_s)) {
if (value_s == "all") { if (value_s == "all") {
LOG_INFO(("Requesting data from EMS devices")); LOG_INFO("Requesting data from EMS devices");
EMSESP::fetch_device_values(); EMSESP::fetch_device_values();
return true; return true;
} else if (value_s == (F_(boiler))) { } 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 (Helpers::value2string(value, value_s)) {
if (value_s == "ha") { if (value_s == "ha") {
EMSESP::publish_all(true); // includes 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; return true;
} else if (value_s == (F_(boiler))) { } else if (value_s == (F_(boiler))) {
EMSESP::publish_device_values(EMSdevice::DeviceType::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(); EMSESP::publish_all();
LOG_INFO(("Publishing all data to MQTT")); LOG_INFO("Publishing all data to MQTT");
return true; return true;
} }
@@ -192,7 +192,7 @@ bool System::command_watch(const char * value, const int8_t id) {
// restart EMS-ESP // restart EMS-ESP
void System::system_restart() { void System::system_restart() {
LOG_INFO(("Restarting EMS-ESP...")); LOG_INFO("Restarting EMS-ESP...");
Shell::loop_all(); Shell::loop_all();
delay(1000); // wait a second delay(1000); // wait a second
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
@@ -202,7 +202,7 @@ void System::system_restart() {
// saves all settings // saves all settings
void System::wifi_reconnect() { void System::wifi_reconnect() {
LOG_INFO(("WiFi reconnecting...")); LOG_INFO("WiFi reconnecting...");
Shell::loop_all(); Shell::loop_all();
EMSESP::console_.loop(); EMSESP::console_.loop();
delay(1000); // wait a second delay(1000); // wait a second
@@ -241,7 +241,7 @@ void System::syslog_init() {
// start & configure syslog // start & configure syslog
if (!was_enabled) { if (!was_enabled) {
syslog_.start(); syslog_.start();
EMSESP::logger().info(("Starting Syslog")); EMSESP::logger().info("Starting Syslog");
} }
syslog_.log_level((uuid::log::Level)syslog_level_); syslog_.log_level((uuid::log::Level)syslog_level_);
syslog_.mark_interval(syslog_mark_interval_); syslog_.mark_interval(syslog_mark_interval_);
@@ -255,7 +255,7 @@ void System::syslog_init() {
} else if (was_enabled) { } else if (was_enabled) {
// in case service is still running, this flushes the queue // in case service is still running, this flushes the queue
// https://github.com/emsesp/EMS-ESP/issues/496 // 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_.log_level((uuid::log::Level)-1);
syslog_.mark_interval(0); syslog_.mark_interval(0);
syslog_.destination(""); syslog_.destination("");
@@ -399,7 +399,7 @@ void System::start() {
// button single click // button single click
void System::button_OnClick(PButton & b) { void System::button_OnClick(PButton & b) {
LOG_DEBUG(("Button pressed - single click")); LOG_DEBUG("Button pressed - single click");
#ifdef EMSESP_DEBUG #ifdef EMSESP_DEBUG
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
@@ -410,20 +410,20 @@ void System::button_OnClick(PButton & b) {
// button double click // button double click
void System::button_OnDblClick(PButton & b) { void System::button_OnDblClick(PButton & b) {
LOG_DEBUG(("Button pressed - double click - reconnect")); LOG_DEBUG("Button pressed - double click - reconnect");
EMSESP::system_.wifi_reconnect(); EMSESP::system_.wifi_reconnect();
} }
// button long press // button long press
void System::button_OnLongPress(PButton & b) { void System::button_OnLongPress(PButton & b) {
LOG_DEBUG(("Button pressed - long press")); LOG_DEBUG("Button pressed - long press");
} }
// button indefinite press // button indefinite press
void System::button_OnVLongPress(PButton & b) { void System::button_OnVLongPress(PButton & b) {
LOG_DEBUG(("Button pressed - very long press")); LOG_DEBUG("Button pressed - very long press");
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
LOG_WARNING(("Performing factory reset...")); LOG_WARNING("Performing factory reset...");
EMSESP::console_.loop(); EMSESP::console_.loop();
EMSESP::esp8266React.factoryReset(); EMSESP::esp8266React.factoryReset();
#endif #endif
@@ -437,12 +437,12 @@ void System::button_init(bool refresh) {
if (is_valid_gpio(pbutton_gpio_)) { if (is_valid_gpio(pbutton_gpio_)) {
if (!myPButton_.init(pbutton_gpio_, HIGH)) { if (!myPButton_.init(pbutton_gpio_, HIGH)) {
LOG_DEBUG(("Multi-functional button not detected")); LOG_DEBUG("Multi-functional button not detected");
} else { } else {
LOG_DEBUG(("Multi-functional button enabled")); LOG_DEBUG("Multi-functional button enabled");
} }
} else { } else {
LOG_WARNING(("Invalid button GPIO. Check config.")); LOG_WARNING("Invalid button GPIO. Check config.");
} }
myPButton_.onClick(BUTTON_Debounce, button_OnClick); myPButton_.onClick(BUTTON_Debounce, button_OnClick);
@@ -772,7 +772,7 @@ int8_t System::wifi_quality(int8_t dBm) {
// print users to console // print users to console
void System::show_users(uuid::console::Shell & shell) { void System::show_users(uuid::console::Shell & shell) {
shell.printfln(("Users:")); shell.printfln("Users:");
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
EMSESP::esp8266React.getSecuritySettingsService()->read([&](SecuritySettings & securitySettings) { EMSESP::esp8266React.getSecuritySettingsService()->read([&](SecuritySettings & securitySettings) {
@@ -801,19 +801,19 @@ void System::show_system(uuid::console::Shell & shell) {
shell.println("Network:"); shell.println("Network:");
switch (WiFi.status()) { switch (WiFi.status()) {
case WL_IDLE_STATUS: case WL_IDLE_STATUS:
shell.printfln((" Network: Idle")); shell.printfln(" Network: Idle");
break; break;
case WL_NO_SSID_AVAIL: case WL_NO_SSID_AVAIL:
shell.printfln((" Network: Network not found")); shell.printfln(" Network: Network not found");
break; break;
case WL_SCAN_COMPLETED: case WL_SCAN_COMPLETED:
shell.printfln((" Network: Network scan complete")); shell.printfln(" Network: Network scan complete");
break; break;
case WL_CONNECTED: case WL_CONNECTED:
shell.printfln((" Network: connected")); shell.printfln(" Network: connected");
shell.printfln((" SSID: %s"), WiFi.SSID().c_str()); shell.printfln((" SSID: %s"), WiFi.SSID().c_str());
shell.printfln((" BSSID: %s"), WiFi.BSSIDstr().c_str()); shell.printfln((" BSSID: %s"), WiFi.BSSIDstr().c_str());
shell.printfln((" RSSI: %d dBm (%d %%)"), WiFi.RSSI(), wifi_quality(WiFi.RSSI())); 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; break;
case WL_CONNECT_FAILED: case WL_CONNECT_FAILED:
shell.printfln((" WiFi Network: Connection failed")); shell.printfln(" WiFi Network: Connection failed");
break; break;
case WL_CONNECTION_LOST: case WL_CONNECTION_LOST:
shell.printfln((" WiFi Network: Connection lost")); shell.printfln(" WiFi Network: Connection lost");
break; break;
case WL_DISCONNECTED: case WL_DISCONNECTED:
shell.printfln((" WiFi Network: Disconnected")); shell.printfln(" WiFi Network: Disconnected");
break; break;
case WL_NO_SHIELD: case WL_NO_SHIELD:
default: default:
shell.printfln((" WiFi Network: Unknown")); shell.printfln(" WiFi Network: Unknown");
break; break;
} }
// show Ethernet if connected // show Ethernet if connected
if (ethernet_connected_) { if (ethernet_connected_) {
shell.println(); shell.println();
shell.printfln((" Ethernet Network: connected")); shell.printfln(" Ethernet Network: connected");
shell.printfln((" MAC address: %s"), ETH.macAddress().c_str()); shell.printfln((" MAC address: %s"), ETH.macAddress().c_str());
shell.printfln((" Hostname: %s"), ETH.getHostname()); 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()); 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:"); shell.println("Syslog:");
if (!syslog_enabled_) { if (!syslog_enabled_) {
shell.printfln((" Syslog: disabled")); shell.printfln(" Syslog: disabled");
} else { } else {
shell.printfln((" Syslog: %s"), syslog_.started() ? "started" : "stopped"); 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(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.printfln((" IP: %s"), uuid::printable_to_string(syslog_.ip()).c_str());
shell.print((" ")); shell.print(" ");
shell.printfln(F_(port_fmt), syslog_port_); shell.printfln(F_(port_fmt), syslog_port_);
shell.print((" ")); shell.print(" ");
shell.printfln(F_(log_level_fmt), uuid::log::format_level_lowercase(static_cast<uuid::log::Level>(syslog_level_))); shell.printfln(F_(log_level_fmt), uuid::log::format_level_lowercase(static_cast<uuid::log::Level>(syslog_level_)));
shell.print((" ")); shell.print(" ");
shell.printfln(F_(mark_interval_fmt), syslog_mark_interval_); shell.printfln(F_(mark_interval_fmt), syslog_mark_interval_);
shell.printfln((" Queued: %d"), syslog_.queued()); 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 // it's a customization file, just replace it and there's no need to reboot
saveSettings(EMSESP_CUSTOMIZATION_FILE, "Customizations", input); saveSettings(EMSESP_CUSTOMIZATION_FILE, "Customizations", input);
} else { } else {
LOG_ERROR(("Unrecognized file uploaded")); LOG_ERROR("Unrecognized file uploaded");
} }
} else { } else {
LOG_ERROR(("Unrecognized file uploaded, not json")); LOG_ERROR("Unrecognized file uploaded, not json");
} }
// close (just in case) and remove the temp file // 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"); node = output.createNestedObject("Bus Status");
switch (EMSESP::bus_status()) { switch (EMSESP::bus_status()) {
case EMSESP::BUS_STATUS_OFFLINE: case EMSESP::BUS_STATUS_OFFLINE:
node["bus status"] = (("disconnected")); node["bus status"] = ("disconnected");
break; break;
case EMSESP::BUS_STATUS_TX_ERRORS: 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; break;
case EMSESP::BUS_STATUS_CONNECTED: case EMSESP::BUS_STATUS_CONNECTED:
node["bus status"] = (("connected")); node["bus status"] = ("connected");
break; break;
default: default:
node["bus status"] = (("unknown")); node["bus status"] = ("unknown");
break; break;
} }
if (EMSESP::bus_status() != EMSESP::BUS_STATUS_OFFLINE) { if (EMSESP::bus_status() != EMSESP::BUS_STATUS_OFFLINE) {

View File

@@ -120,7 +120,7 @@ std::string Telegram::to_string() const {
// returns telegram's message body only, in hex // returns telegram's message body only, in hex
std::string Telegram::to_string_message() const { std::string Telegram::to_string_message() const {
if (this->message_length == 0) { if (this->message_length == 0) {
return (("<empty>")); return ("<empty>");
} }
return Helpers::data_to_hex(this->message_data, this->message_length); 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); uint16_t status = EMSuart::transmit(telegram_raw, length);
if (status == EMS_TX_STATUS_ERR) { 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) { if (telegram->operation == Telegram::Operation::TX_READ) {
increment_telegram_read_fail_count(); // another Tx fail increment_telegram_read_fail_count(); // another Tx fail
} else { } 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); uint16_t status = EMSuart::transmit(telegram_raw, length);
if (status == EMS_TX_STATUS_ERR) { 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 increment_telegram_fail_count(); // another Tx fail
} }
} }

View File

@@ -30,7 +30,7 @@ bool Test::run_test(const char * command, int8_t id) {
} }
if (strcmp(command, "general") == 0) { 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(0x08, 123); // Nefit Trendline
add_device(0x18, 157); // Bosch CR100 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) { 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(0x08, 123); // GB072
add_device(0x10, 158); // RC310 add_device(0x10, 158); // RC310
@@ -86,7 +86,7 @@ bool Test::run_test(const char * command, int8_t id) {
} }
if (strcmp(command, "310") == 0) { 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(0x08, 123); // GB072
add_device(0x10, 158); // RC310 add_device(0x10, 158); // RC310
@@ -113,7 +113,7 @@ bool Test::run_test(const char * command, int8_t id) {
} }
if (strcmp(command, "gateway") == 0) { if (strcmp(command, "gateway") == 0) {
EMSESP::logger().info(("Adding a Gateway...")); EMSESP::logger().info("Adding a Gateway...");
// add 0x48 KM200, via a version command // add 0x48 KM200, via a version command
rx_telegram({0x48, 0x0B, 0x02, 0x00, 0xBD, 0x04, 0x06, 00, 00, 00, 00, 00, 00, 00}); 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) { if (strcmp(command, "mixer") == 0) {
EMSESP::logger().info(("Adding a mixer...")); EMSESP::logger().info("Adding a mixer...");
// add controller // add controller
add_device(0x09, 114); add_device(0x09, 114);
@@ -155,7 +155,7 @@ bool Test::run_test(const char * command, int8_t id) {
} }
if (strcmp(command, "boiler") == 0) { if (strcmp(command, "boiler") == 0) {
EMSESP::logger().info(("Adding boiler...")); EMSESP::logger().info("Adding boiler...");
add_device(0x08, 123); // Nefit Trendline add_device(0x08, 123); // Nefit Trendline
// UBAuptime // UBAuptime
@@ -172,7 +172,7 @@ bool Test::run_test(const char * command, int8_t id) {
} }
if (strcmp(command, "thermostat") == 0) { if (strcmp(command, "thermostat") == 0) {
EMSESP::logger().info(("Adding thermostat...")); EMSESP::logger().info("Adding thermostat...");
add_device(0x10, 192); // FW120 add_device(0x10, 192); // FW120
@@ -185,7 +185,7 @@ bool Test::run_test(const char * command, int8_t id) {
} }
if (strcmp(command, "solar") == 0) { if (strcmp(command, "solar") == 0) {
EMSESP::logger().info(("Adding solar...")); EMSESP::logger().info("Adding solar...");
add_device(0x30, 163); // SM100 add_device(0x30, 163); // SM100
@@ -204,7 +204,7 @@ bool Test::run_test(const char * command, int8_t id) {
} }
if (strcmp(command, "heatpump") == 0) { if (strcmp(command, "heatpump") == 0) {
EMSESP::logger().info(("Adding heatpump...")); EMSESP::logger().info("Adding heatpump...");
add_device(0x38, 200); // Enviline module add_device(0x38, 200); // Enviline module
add_device(0x10, 192); // FW120 thermostat 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") { if (command == "general") {
shell.printfln(("Testing adding a general boiler & thermostat...")); shell.printfln("Testing adding a general boiler & thermostat...");
run_test("general"); run_test("general");
shell.invoke_command("show devices"); shell.invoke_command("show devices");
shell.invoke_command("show"); shell.invoke_command("show");
@@ -247,7 +247,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "render") { if (command == "render") {
shell.printfln(("Testing render...")); shell.printfln("Testing render...");
// check read_value to make sure it handles all the data type correctly // 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 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") { if (command == "devices") {
shell.printfln(("Testing devices...")); shell.printfln("Testing devices...");
// A fake response - UBADevices(0x07) // A fake response - UBADevices(0x07)
rx_telegram({0x08, 0x00, 0x07, 0x00, 0x0B, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); 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 // check for boiler and controller on same product_id
if (command == "double") { if (command == "double") {
shell.printfln(("Testing double...")); shell.printfln("Testing double...");
add_device(0x08, 206); // Nefit Excellent HR30 add_device(0x08, 206); // Nefit Excellent HR30
add_device(0x09, 206); // Nefit Excellent HR30 Controller 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") { if (command == "620") {
EMSESP::logger().info(("Testing 620...")); EMSESP::logger().info("Testing 620...");
// Version Controller // Version Controller
uart_telegram({0x09, 0x0B, 0x02, 0x00, 0x5F, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); 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 // unknown device
if (command == "unknown") { if (command == "unknown") {
shell.printfln(("Testing unknown...")); shell.printfln("Testing unknown...");
// add boiler // add boiler
add_device(0x08, 84); add_device(0x08, 84);
@@ -361,19 +361,19 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "unknown2") { if (command == "unknown2") {
shell.printfln(("Testing unknown2...")); shell.printfln("Testing unknown2...");
// simulate getting version information back from an unknown device // 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 rx_telegram({0x09, 0x0B, 0x02, 0x00, 0x5A, 0x01, 0x02}); // productID is 90 which doesn't exist
} }
if (command == "gateway") { if (command == "gateway") {
shell.printfln(("Testing Gateway...")); shell.printfln("Testing Gateway...");
run_test("gateway"); run_test("gateway");
} }
if (command == "310") { if (command == "310") {
shell.printfln(("Testing RC310...")); shell.printfln("Testing RC310...");
run_test("310"); run_test("310");
shell.invoke_command("show devices"); shell.invoke_command("show devices");
shell.invoke_command("show"); shell.invoke_command("show");
@@ -382,14 +382,14 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "2thermostats") { if (command == "2thermostats") {
shell.printfln(("Testing multiple thermostats...")); shell.printfln("Testing multiple thermostats...");
run_test("2thermostats"); run_test("2thermostats");
shell.invoke_command("show"); shell.invoke_command("show");
shell.invoke_command("show devices"); shell.invoke_command("show devices");
} }
if (command == "web") { if (command == "web") {
shell.printfln(("Testing Web...")); shell.printfln("Testing Web...");
Mqtt::enabled(false); // turn off mqtt Mqtt::enabled(false); // turn off mqtt
Mqtt::ha_enabled(false); // turn off ha 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") { if (command == "board_profile") {
shell.printfln(("Testing board profile...")); shell.printfln("Testing board profile...");
shell.invoke_command("system"); shell.invoke_command("system");
shell.invoke_command("set board_profile wemos"); 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") { if (command == "boiler") {
shell.printfln(("Testing boiler...")); shell.printfln("Testing boiler...");
// Mqtt::ha_enabled(false); // Mqtt::ha_enabled(false);
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
Mqtt::nested_format(1); 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") { if (command == "shower_alert") {
shell.printfln(("Testing Shower Alert...")); shell.printfln("Testing Shower Alert...");
run_test("boiler"); run_test("boiler");
@@ -484,7 +484,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "fr120") { if (command == "fr120") {
shell.printfln(("Testing adding a thermostat FR120...")); shell.printfln("Testing adding a thermostat FR120...");
add_device(0x10, 191); // FR120 thermostat 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") { if (command == "ha") {
shell.printfln(("Testing HA mqtt discovery")); shell.printfln("Testing HA mqtt discovery");
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
// Mqtt::ha_enabled(false); // Mqtt::ha_enabled(false);
@@ -518,7 +518,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "lastcode") { if (command == "lastcode") {
shell.printfln(("Testing lastcode")); shell.printfln("Testing lastcode");
Mqtt::ha_enabled(false); Mqtt::ha_enabled(false);
Mqtt::nested_format(1); Mqtt::nested_format(1);
@@ -536,7 +536,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "dv") { if (command == "dv") {
shell.printfln(("Testing device value rendering")); shell.printfln("Testing device value rendering");
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
Mqtt::nested_format(1); Mqtt::nested_format(1);
@@ -550,12 +550,12 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "dallas") { if (command == "dallas") {
shell.printfln(("Testing adding Dallas sensor")); shell.printfln("Testing adding Dallas sensor");
emsesp::EMSESP::dallassensor_.test(); emsesp::EMSESP::dallassensor_.test();
} }
if (command == "dallas_full") { 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::ha_enabled(true);
Mqtt::nested_format(1); Mqtt::nested_format(1);
// Mqtt::nested_format(0); // Mqtt::nested_format(0);
@@ -571,7 +571,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "analog") { if (command == "analog") {
shell.printfln(("Testing adding Analog sensor")); shell.printfln("Testing adding Analog sensor");
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
// Mqtt::ha_enabled(false); // Mqtt::ha_enabled(false);
Mqtt::nested_format(1); Mqtt::nested_format(1);
@@ -602,7 +602,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "masked") { if (command == "masked") {
shell.printfln(("Testing masked entities")); shell.printfln("Testing masked entities");
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
Mqtt::send_response(false); Mqtt::send_response(false);
@@ -626,7 +626,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "dv2") { if (command == "dv2") {
shell.printfln(("Testing device value lost")); shell.printfln("Testing device value lost");
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
Mqtt::send_response(false); 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 (command == "api_values") {
#if defined(EMSESP_STANDALONE) #if defined(EMSESP_STANDALONE)
shell.printfln(("Testing API getting values")); shell.printfln("Testing API getting values");
Mqtt::ha_enabled(false); Mqtt::ha_enabled(false);
Mqtt::nested_format(1); Mqtt::nested_format(1);
Mqtt::send_response(false); 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") { if (command == "mqtt_post") {
shell.printfln(("Testing MQTT incoming changes")); shell.printfln("Testing MQTT incoming changes");
Mqtt::ha_enabled(false); Mqtt::ha_enabled(false);
Mqtt::nested_format(1); Mqtt::nested_format(1);
Mqtt::send_response(false); 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) #if defined(EMSESP_STANDALONE)
// https://github.com/emsesp/EMS-ESP32/issues/541 // https://github.com/emsesp/EMS-ESP32/issues/541
if (command == "api_wwmode") { if (command == "api_wwmode") {
shell.printfln(("Testing API wwmode")); shell.printfln("Testing API wwmode");
Mqtt::ha_enabled(false); Mqtt::ha_enabled(false);
Mqtt::nested_format(1); Mqtt::nested_format(1);
run_test("310"); run_test("310");
@@ -715,7 +715,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
#endif #endif
if (command == "api") { 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(true);
// Mqtt::ha_enabled(false); // 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") { 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 Mqtt::ha_enabled(false); // turn off HA Discovery to stop the chatter
run_test("boiler"); run_test("boiler");
@@ -1010,7 +1010,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "thermostat") { if (command == "thermostat") {
shell.printfln(("Testing adding a thermostat FW120...")); shell.printfln("Testing adding a thermostat FW120...");
run_test("thermostat"); run_test("thermostat");
shell.invoke_command("show"); shell.invoke_command("show");
@@ -1026,7 +1026,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "tc100") { 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 a thermostat
add_device(0x18, 202); // Bosch TC100 - https://github.com/emsesp/EMS-ESP/issues/474 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") { if (command == "solar") {
shell.printfln(("Testing Solar")); shell.printfln("Testing Solar");
run_test("solar"); run_test("solar");
uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on (1)sh 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") { if (command == "heatpump") {
shell.printfln(("Testing Heat Pump")); shell.printfln("Testing Heat Pump");
run_test("heatpump"); run_test("heatpump");
shell.invoke_command("call"); shell.invoke_command("call");
shell.invoke_command("call heatpump info"); shell.invoke_command("call heatpump info");
} }
if (command == "solar200") { if (command == "solar200") {
shell.printfln(("Testing Solar SM200")); shell.printfln("Testing Solar SM200");
add_device(0x30, 164); // 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") { if (command == "km") {
shell.printfln(("Testing KM200 Gateway")); shell.printfln("Testing KM200 Gateway");
add_device(0x10, 158); // RC300 add_device(0x10, 158); // RC300
add_device(0x48, 189); // KM200 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") { 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 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") { if (command == "rx2") {
shell.printfln(("Testing Rx2...")); shell.printfln("Testing Rx2...");
for (uint8_t i = 0; i < 30; i++) { 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}); uart_telegram({0x08, 0x0B, 0x33, 0x00, 0x08, 0xFF, 0x34, 0xFB, 0x00, 0x28, 0x00, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0x00});
} }
} }
if (command == "rx") { if (command == "rx") {
shell.printfln(("Testing Rx...")); shell.printfln("Testing Rx...");
// fake telegrams. length includes CRC // 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) // 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") { 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) // TX queue example - Me -> Thermostat, (0x91), telegram: 0B 17 91 05 44 45 46 47 (#data=4)
uint8_t t11[] = {0x44, 0x45, 0x46, 0x47}; 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") { if (command == "poll") {
shell.printfln(("Testing Poll...")); shell.printfln("Testing Poll...");
// simulate sending a read request // 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) // 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") { if (command == "cmd") {
shell.printfln(("Testing Commands...")); shell.printfln("Testing Commands...");
// add a thermostat with 3 HCs // add a thermostat with 3 HCs
add_device(0x10, 192); // FW120 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") { if (command == "pin") {
shell.printfln(("Testing pin...")); shell.printfln("Testing pin...");
shell.invoke_command("call system pin"); shell.invoke_command("call system pin");
shell.invoke_command("call system pin 1 true"); shell.invoke_command("call system pin 1 true");
} }
if (command == "mqtt2") { if (command == "mqtt2") {
shell.printfln(("Testing MQTT large payloads...")); shell.printfln("Testing MQTT large payloads...");
DynamicJsonDocument doc(EMSESP_JSON_SIZE_XXLARGE_DYN); 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") { if (command == "mqtt") {
shell.printfln(("Testing MQTT...")); shell.printfln("Testing MQTT...");
Mqtt::ha_enabled(false); Mqtt::ha_enabled(false);
Mqtt::enabled(true); Mqtt::enabled(true);
@@ -1422,7 +1422,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "poll2") { 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); EMSESP::show_ems(shell);
@@ -1433,7 +1433,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "rx2") { 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, 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}); 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 // https://github.com/emsesp/EMS-ESP/issues/380#issuecomment-633663007
if (command == "rx3") { if (command == "rx3") {
shell.printfln(("Testing rx3...")); shell.printfln("Testing rx3...");
uart_telegram({0x21, 0x0B, 0xFF, 0x00}); uart_telegram({0x21, 0x0B, 0xFF, 0x00});
} }
// testing the UART tx command, without a queue // testing the UART tx command, without a queue
if (command == "tx2") { if (command == "tx2") {
shell.printfln(("Testing tx2...")); shell.printfln("Testing tx2...");
uint8_t t[] = {0x0B, 0x88, 0x18, 0x00, 0x20, 0xD4}; // including CRC uint8_t t[] = {0x0B, 0x88, 0x18, 0x00, 0x20, 0xD4}; // including CRC
EMSuart::transmit(t, sizeof(t)); 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 // send read request with offset
if (command == "offset") { if (command == "offset") {
shell.printfln(("Testing offset...")); shell.printfln("Testing offset...");
// send_read_request(0x18, 0x08); // send_read_request(0x18, 0x08);
EMSESP::txservice_.read_request(0x18, 0x08, 27); // no offset EMSESP::txservice_.read_request(0x18, 0x08, 27); // no offset
} }
if (command == "mixer") { if (command == "mixer") {
shell.printfln(("Testing Mixer...")); shell.printfln("Testing Mixer...");
run_test("mixer"); run_test("mixer");
@@ -1477,7 +1477,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "crash") { if (command == "crash") {
shell.printfln(("Forcing a crash...")); shell.printfln("Forcing a crash...");
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdiv-by-zero" #pragma GCC diagnostic ignored "-Wdiv-by-zero"

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.5.0b3" #define EMSESP_APP_VERSION "3.5.0b3_o"

View File

@@ -117,7 +117,7 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) {
emsesp::EMSESP::logger().err(error); emsesp::EMSESP::logger().err(error);
api_fails_++; api_fails_++;
} else { } 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 there was no json output from the call, default to the output message 'OK'.
if (!output.size()) { if (!output.size()) {
output["message"] = "OK"; output["message"] = "OK";

View File

@@ -238,7 +238,7 @@ void WebDataService::write_value(AsyncWebServerRequest * request, JsonVariant &
if (return_code != CommandRet::OK) { 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()); EMSESP::logger().err(("Write command failed %s (%s)"), (const char *)output["message"], Command::return_code_string(return_code).c_str());
} else { } else {
EMSESP::logger().debug(("Write command successful")); EMSESP::logger().debug("Write command successful");
} }
response->setCode((return_code == CommandRet::OK) ? 200 : 204); response->setCode((return_code == CommandRet::OK) ? 200 : 204);

View File

@@ -48,7 +48,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
break; break;
case ARDUINO_EVENT_ETH_START: case ARDUINO_EVENT_ETH_START:
// EMSESP::logger().info(("Ethernet initialized")); // EMSESP::logger().info("Ethernet initialized");
ETH.setHostname(EMSESP::system_.hostname().c_str()); ETH.setHostname(EMSESP::system_.hostname().c_str());
// configure for static IP // configure for static IP
@@ -74,12 +74,12 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
break; break;
case ARDUINO_EVENT_ETH_DISCONNECTED: case ARDUINO_EVENT_ETH_DISCONNECTED:
EMSESP::logger().warning(("Ethernet disconnected")); EMSESP::logger().warning("Ethernet disconnected");
EMSESP::system_.ethernet_connected(false); EMSESP::system_.ethernet_connected(false);
break; break;
case ARDUINO_EVENT_ETH_STOP: case ARDUINO_EVENT_ETH_STOP:
EMSESP::logger().info(("Ethernet stopped")); EMSESP::logger().info("Ethernet stopped");
EMSESP::system_.ethernet_connected(false); EMSESP::system_.ethernet_connected(false);
break; break;
@@ -202,7 +202,7 @@ void WebStatusService::mDNS_start() const {
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) { EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
if (networkSettings.enableMDNS) { if (networkSettings.enableMDNS) {
if (!MDNS.begin(EMSESP::system_.hostname().c_str())) { 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; return;
} }
@@ -214,13 +214,13 @@ void WebStatusService::mDNS_start() const {
MDNS.addServiceTxt("http", "tcp", "version", EMSESP_APP_VERSION); MDNS.addServiceTxt("http", "tcp", "version", EMSESP_APP_VERSION);
MDNS.addServiceTxt("http", "tcp", "address", address_s.c_str()); MDNS.addServiceTxt("http", "tcp", "address", address_s.c_str());
EMSESP::logger().info(("mDNS responder service started")); EMSESP::logger().info("mDNS responder service started");
} }
}); });
#else #else
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) { EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
if (networkSettings.enableMDNS) { if (networkSettings.enableMDNS) {
EMSESP::logger().info(("mDNS responder service started")); EMSESP::logger().info("mDNS responder service started");
} }
}); });
#endif #endif