diff --git a/README.md b/README.md index 6ce06bbeb..3f87ea6f0 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,6 @@ EMS-ESP is a project owned and maintained by [proddy](https://github.com/proddy) - [uuid-\*](https://github.com/nomis/mcu-uuid-console) from @nomis. The console, syslog, telnet and logging are based off these open source libraries - [ArduinoJson](https://github.com/bblanchon/ArduinoJson) for all the JSON - [espMqttClient](https://github.com/bertmelis/espMqttClient) for the MQTT client, with custom modifications from @MichaelDvP and @proddy -- ESPAsyncWebServer and AsyncTCP for the Web server and TCP backends, with custom modifications for performance ## **License** diff --git a/interface/package.json b/interface/package.json index a0c3d4113..c9f3a0562 100644 --- a/interface/package.json +++ b/interface/package.json @@ -24,8 +24,8 @@ "@babel/core": "^7.23.6", "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", - "@mui/icons-material": "^5.15.1", - "@mui/material": "^5.15.1", + "@mui/icons-material": "^5.15.2", + "@mui/material": "^5.15.2", "@table-library/react-table-library": "4.1.7", "@types/imagemin": "^8.0.5", "@types/lodash-es": "^4.17.12", @@ -33,7 +33,7 @@ "@types/react": "^18.2.45", "@types/react-dom": "^18.2.18", "@types/react-router-dom": "^5.3.3", - "alova": "^2.16.1", + "alova": "^2.16.2", "async-validator": "^4.2.5", "history": "^5.3.0", "jwt-decode": "^4.0.0", @@ -52,8 +52,8 @@ "devDependencies": { "@preact/compat": "^17.1.2", "@preact/preset-vite": "^2.7.0", - "@typescript-eslint/eslint-plugin": "^6.15.0", - "@typescript-eslint/parser": "^6.15.0", + "@typescript-eslint/eslint-plugin": "^6.16.0", + "@typescript-eslint/parser": "^6.16.0", "concurrently": "^8.2.2", "eslint": "^8.56.0", "eslint-config-airbnb": "^19.0.4", diff --git a/interface/yarn.lock b/interface/yarn.lock index 918635456..4fd6b45a2 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -401,7 +401,7 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.23.5": +"@babel/runtime@npm:^7.23.6": version: 7.23.6 resolution: "@babel/runtime@npm:7.23.6" dependencies: @@ -970,14 +970,14 @@ __metadata: languageName: node linkType: hard -"@mui/base@npm:5.0.0-beta.28": - version: 5.0.0-beta.28 - resolution: "@mui/base@npm:5.0.0-beta.28" +"@mui/base@npm:5.0.0-beta.29": + version: 5.0.0-beta.29 + resolution: "@mui/base@npm:5.0.0-beta.29" dependencies: - "@babel/runtime": "npm:^7.23.5" + "@babel/runtime": "npm:^7.23.6" "@floating-ui/react-dom": "npm:^2.0.4" "@mui/types": "npm:^7.2.11" - "@mui/utils": "npm:^5.15.1" + "@mui/utils": "npm:^5.15.2" "@popperjs/core": "npm:^2.11.8" clsx: "npm:^2.0.0" prop-types: "npm:^15.8.1" @@ -988,22 +988,22 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: fb37f4301035bfcd5b6a7280521e3fcccd46ee34f096318c93516c03f3ed9e0bcb0dfbdeeca7611d0ccc42eadef483b7fd9c253cb3a19bbe86d3575144af84ac + checksum: a651464968af6ebb775c24d2b9badc735b1d595e526ff7f8181186e6eed0735b14af8324db22a8744039ad79ce6dbb7c62920bb92a57959a66cf8e72d68af9aa languageName: node linkType: hard -"@mui/core-downloads-tracker@npm:^5.15.1": - version: 5.15.1 - resolution: "@mui/core-downloads-tracker@npm:5.15.1" - checksum: a2035c49a8a76298fe9acbf4a79cd50eba3fc82e25d5568e11ad7146bac4b4fdebe72a2d63eb33583ca3345fc3e91d805329a6837b924080317246d84684f726 +"@mui/core-downloads-tracker@npm:^5.15.2": + version: 5.15.2 + resolution: "@mui/core-downloads-tracker@npm:5.15.2" + checksum: 8c88ac73a1d87c8ce565f6295dcd084c643580848e8f59159402e9db89975263da06305a0e605d3744479e917c2d297319496534bca9df8338e203162f1e7c33 languageName: node linkType: hard -"@mui/icons-material@npm:^5.15.1": - version: 5.15.1 - resolution: "@mui/icons-material@npm:5.15.1" +"@mui/icons-material@npm:^5.15.2": + version: 5.15.2 + resolution: "@mui/icons-material@npm:5.15.2" dependencies: - "@babel/runtime": "npm:^7.23.5" + "@babel/runtime": "npm:^7.23.6" peerDependencies: "@mui/material": ^5.0.0 "@types/react": ^17.0.0 || ^18.0.0 @@ -1011,20 +1011,20 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: b9d15ec65b6b948dcfc79f6aa19cc21ebde5c424f629378c3c2a37cdd2649404ee539cad43bada0618309bb2e9d9f4d734b5a2742900b6775c36f17cf15dcc5e + checksum: 6dad9fa436889ab89217d428f38b1f7868eb5db0b8aa2b16086f6e81666763767a29db8897e76d078919df7349a149c6e16da1aea1b3ae48ca0b7ee1e0d9d458 languageName: node linkType: hard -"@mui/material@npm:^5.15.1": - version: 5.15.1 - resolution: "@mui/material@npm:5.15.1" +"@mui/material@npm:^5.15.2": + version: 5.15.2 + resolution: "@mui/material@npm:5.15.2" dependencies: - "@babel/runtime": "npm:^7.23.5" - "@mui/base": "npm:5.0.0-beta.28" - "@mui/core-downloads-tracker": "npm:^5.15.1" - "@mui/system": "npm:^5.15.1" + "@babel/runtime": "npm:^7.23.6" + "@mui/base": "npm:5.0.0-beta.29" + "@mui/core-downloads-tracker": "npm:^5.15.2" + "@mui/system": "npm:^5.15.2" "@mui/types": "npm:^7.2.11" - "@mui/utils": "npm:^5.15.1" + "@mui/utils": "npm:^5.15.2" "@types/react-transition-group": "npm:^4.4.10" clsx: "npm:^2.0.0" csstype: "npm:^3.1.2" @@ -1044,16 +1044,16 @@ __metadata: optional: true "@types/react": optional: true - checksum: e40b61e03eb65b8390f88a0f37adcbeebad4d7b6b41e1995334a2946b0fab003818c3b7a1c2f46bed56c3d1fa360fe261d0ec1cab1fcfe322bcb8a26a94929c1 + checksum: 1ce902070022c40009e01208e95d0d61205ffdbcf4fadd16e6337acdfccfb1c66004525ffe277691c7f3fbdfcebb998f1544c054a31164d580cb040e8a7d2d80 languageName: node linkType: hard -"@mui/private-theming@npm:^5.15.1": - version: 5.15.1 - resolution: "@mui/private-theming@npm:5.15.1" +"@mui/private-theming@npm:^5.15.2": + version: 5.15.2 + resolution: "@mui/private-theming@npm:5.15.2" dependencies: - "@babel/runtime": "npm:^7.23.5" - "@mui/utils": "npm:^5.15.1" + "@babel/runtime": "npm:^7.23.6" + "@mui/utils": "npm:^5.15.2" prop-types: "npm:^15.8.1" peerDependencies: "@types/react": ^17.0.0 || ^18.0.0 @@ -1061,15 +1061,15 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 4730b3a62ff5e955896ba731579c571c4948716525c3f6b44eb2590f78b7c016538a50390b473b5c2e648d82ff03c6771cc0bc9ff93edfb8bb311e9751b822e4 + checksum: 2b1665044fd77286068100bd5c67ba3a31320084b442788e1c0224359b6e8e3213505676fa1db451c970b2e432811b12cbcf2f882c9063d37497dbfcfcd8811e languageName: node linkType: hard -"@mui/styled-engine@npm:^5.15.1": - version: 5.15.1 - resolution: "@mui/styled-engine@npm:5.15.1" +"@mui/styled-engine@npm:^5.15.2": + version: 5.15.2 + resolution: "@mui/styled-engine@npm:5.15.2" dependencies: - "@babel/runtime": "npm:^7.23.5" + "@babel/runtime": "npm:^7.23.6" "@emotion/cache": "npm:^11.11.0" csstype: "npm:^3.1.2" prop-types: "npm:^15.8.1" @@ -1082,19 +1082,19 @@ __metadata: optional: true "@emotion/styled": optional: true - checksum: 0e03bb6ccc54587b1fa9cacf68d6d7ac6285f7cd0d6294e2cee9212097e640655894762f0ac9020f69da9cf06f887dbeda8f9a7a217625359a2df82ebf082013 + checksum: c004a37f4343139896059a706e96175a0f8975cc8807bcea96c099a68a94cf24d7869e685b06511389c9a6e4412acac5ef07614659983a7782f203012b78315b languageName: node linkType: hard -"@mui/system@npm:^5.15.1": - version: 5.15.1 - resolution: "@mui/system@npm:5.15.1" +"@mui/system@npm:^5.15.2": + version: 5.15.2 + resolution: "@mui/system@npm:5.15.2" dependencies: - "@babel/runtime": "npm:^7.23.5" - "@mui/private-theming": "npm:^5.15.1" - "@mui/styled-engine": "npm:^5.15.1" + "@babel/runtime": "npm:^7.23.6" + "@mui/private-theming": "npm:^5.15.2" + "@mui/styled-engine": "npm:^5.15.2" "@mui/types": "npm:^7.2.11" - "@mui/utils": "npm:^5.15.1" + "@mui/utils": "npm:^5.15.2" clsx: "npm:^2.0.0" csstype: "npm:^3.1.2" prop-types: "npm:^15.8.1" @@ -1110,7 +1110,7 @@ __metadata: optional: true "@types/react": optional: true - checksum: 8e2e2cff80218ec5ea13ca5ce7d7b81e31f3e2ab3f0c3149230c8b221724a09635b1794ede9b65b3ec825bd062ede0eecbf839a00ba57c9091ce7799dc196129 + checksum: 05335cc7856750a930e5eef4eaf3e935c1d6dd78add48e86d1d976736adea71c5f37f3c329fd0a8f5fd9d11e40775ab5a62192dc056d240cb365416ad4db5568 languageName: node linkType: hard @@ -1126,11 +1126,11 @@ __metadata: languageName: node linkType: hard -"@mui/utils@npm:^5.15.1": - version: 5.15.1 - resolution: "@mui/utils@npm:5.15.1" +"@mui/utils@npm:^5.15.2": + version: 5.15.2 + resolution: "@mui/utils@npm:5.15.2" dependencies: - "@babel/runtime": "npm:^7.23.5" + "@babel/runtime": "npm:^7.23.6" "@types/prop-types": "npm:^15.7.11" prop-types: "npm:^15.8.1" react-is: "npm:^18.2.0" @@ -1140,7 +1140,7 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 3d583ea55402295f9249f2fa1db652bbdca49df5227f731b067e04718d5704774e81b60b741231e49093eda6d4e80ce4fad315006516cb705acc7b0ac68f9d76 + checksum: 9ede26d8e2b456a5ecf088d4e2d6903613be57eae97fcd30a9f31ff2c35a0e4329c728bd20c94c6f3468038935c3101a040c2cfb7dd6ff7a490811af0675d90a languageName: node linkType: hard @@ -1689,15 +1689,15 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^6.15.0": - version: 6.15.0 - resolution: "@typescript-eslint/eslint-plugin@npm:6.15.0" +"@typescript-eslint/eslint-plugin@npm:^6.16.0": + version: 6.16.0 + resolution: "@typescript-eslint/eslint-plugin@npm:6.16.0" dependencies: "@eslint-community/regexpp": "npm:^4.5.1" - "@typescript-eslint/scope-manager": "npm:6.15.0" - "@typescript-eslint/type-utils": "npm:6.15.0" - "@typescript-eslint/utils": "npm:6.15.0" - "@typescript-eslint/visitor-keys": "npm:6.15.0" + "@typescript-eslint/scope-manager": "npm:6.16.0" + "@typescript-eslint/type-utils": "npm:6.16.0" + "@typescript-eslint/utils": "npm:6.16.0" + "@typescript-eslint/visitor-keys": "npm:6.16.0" debug: "npm:^4.3.4" graphemer: "npm:^1.4.0" ignore: "npm:^5.2.4" @@ -1710,44 +1710,44 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 9020370c5e89b52b65ed2373c755d4b70f57ec7ebcf02d3e2f323f31ec81717af110d8e5f903b189b71e0a952f042e0fe2b637e77959c3102907efed4ba55512 + checksum: 4bedce948ac3c20492a59813ee5d4f1f2306310857864dfaac2736f6c38e18785002c36844fd64c9fbdf3059fc390b29412be105fd7a118177f1eeeb1eb533f7 languageName: node linkType: hard -"@typescript-eslint/parser@npm:^6.15.0": - version: 6.15.0 - resolution: "@typescript-eslint/parser@npm:6.15.0" +"@typescript-eslint/parser@npm:^6.16.0": + version: 6.16.0 + resolution: "@typescript-eslint/parser@npm:6.16.0" dependencies: - "@typescript-eslint/scope-manager": "npm:6.15.0" - "@typescript-eslint/types": "npm:6.15.0" - "@typescript-eslint/typescript-estree": "npm:6.15.0" - "@typescript-eslint/visitor-keys": "npm:6.15.0" + "@typescript-eslint/scope-manager": "npm:6.16.0" + "@typescript-eslint/types": "npm:6.16.0" + "@typescript-eslint/typescript-estree": "npm:6.16.0" + "@typescript-eslint/visitor-keys": "npm:6.16.0" debug: "npm:^4.3.4" peerDependencies: eslint: ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: fdd1f584e5068216c36a01e40750950ef309b36a522f6ecde36931690558a319960a702b4b4a806f335fb28ca99f8a07bb206571141550aaab1f6f40066f6605 + checksum: 3d941ce345dc2ce29957e2110957662873d514b094b8939923c3281d858c11cd1f9058db862644afe14f68d087770f39a0a1f9e523a2013ed5d2fdf3421b34d0 languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:6.15.0": - version: 6.15.0 - resolution: "@typescript-eslint/scope-manager@npm:6.15.0" +"@typescript-eslint/scope-manager@npm:6.16.0": + version: 6.16.0 + resolution: "@typescript-eslint/scope-manager@npm:6.16.0" dependencies: - "@typescript-eslint/types": "npm:6.15.0" - "@typescript-eslint/visitor-keys": "npm:6.15.0" - checksum: 168d783c06a99784362e2eaaa56396b31716ee785779707ef984c2abb3e822c56440473efc6580cb8b84b2da508731ad184a00b3618bc7f3f93d8243804f2fcf + "@typescript-eslint/types": "npm:6.16.0" + "@typescript-eslint/visitor-keys": "npm:6.16.0" + checksum: 3360aae4b85f5c31d20ad48d771cc09a6f8f6b1811b00d94f06e55b5a09c610ac75631b1c4edecb3bec682d41351b87e7d14d42bee84aa032064d0e13463035b languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:6.15.0": - version: 6.15.0 - resolution: "@typescript-eslint/type-utils@npm:6.15.0" +"@typescript-eslint/type-utils@npm:6.16.0": + version: 6.16.0 + resolution: "@typescript-eslint/type-utils@npm:6.16.0" dependencies: - "@typescript-eslint/typescript-estree": "npm:6.15.0" - "@typescript-eslint/utils": "npm:6.15.0" + "@typescript-eslint/typescript-estree": "npm:6.16.0" + "@typescript-eslint/utils": "npm:6.16.0" debug: "npm:^4.3.4" ts-api-utils: "npm:^1.0.1" peerDependencies: @@ -1755,59 +1755,60 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 8dabb355f09f57de8b46d726ad95a57593e5b87427dee5182afecb490624424afec02b69a27018b352dcb5f930eb391cb8cdc12cd60a93231d4f04e63e2f2c0b + checksum: 5964b87a87252bed278a248eb568902babd7c34defd3af8c3df371926d96aec716f33f1dc14bde170e93f73ed1b0af6e591e647853d0f33f378e2c7b3b73fc5b languageName: node linkType: hard -"@typescript-eslint/types@npm:6.15.0": - version: 6.15.0 - resolution: "@typescript-eslint/types@npm:6.15.0" - checksum: d55de64d532c9016c922cc36b86ab661d7d64d942057486a0bca7a7db07fade95c3de59bfe364bc76ab538fb979ca2e4e6744c3acf8919a2d61e73cc7f544363 +"@typescript-eslint/types@npm:6.16.0": + version: 6.16.0 + resolution: "@typescript-eslint/types@npm:6.16.0" + checksum: 236ca318c2440c95068e5d4d147e2bfed62447775e18695e21c8ca04a341a74d01c37ed2b417629b7bf2fb91ad4fd5e2a6570215d16fc24dd1507ce6973b4e22 languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:6.15.0": - version: 6.15.0 - resolution: "@typescript-eslint/typescript-estree@npm:6.15.0" +"@typescript-eslint/typescript-estree@npm:6.16.0": + version: 6.16.0 + resolution: "@typescript-eslint/typescript-estree@npm:6.16.0" dependencies: - "@typescript-eslint/types": "npm:6.15.0" - "@typescript-eslint/visitor-keys": "npm:6.15.0" + "@typescript-eslint/types": "npm:6.16.0" + "@typescript-eslint/visitor-keys": "npm:6.16.0" debug: "npm:^4.3.4" globby: "npm:^11.1.0" is-glob: "npm:^4.0.3" + minimatch: "npm:9.0.3" semver: "npm:^7.5.4" ts-api-utils: "npm:^1.0.1" peerDependenciesMeta: typescript: optional: true - checksum: 920f7f3bfe463a9da943e1a686b7f13ac802a5e33be52f39ac711aa53a1e274dbe173b41bba05581c560fabfc3e1fadcfd81ab53a036afe25fb1a76651fcad7a + checksum: 8e1ef03ecabaf3791b11240a51217836dbb74850e458258db77ac5eab5508cd9c63fb671924993d1e7654718c0c857c3550d51ecba0845fe489d143bb858e1b1 languageName: node linkType: hard -"@typescript-eslint/utils@npm:6.15.0": - version: 6.15.0 - resolution: "@typescript-eslint/utils@npm:6.15.0" +"@typescript-eslint/utils@npm:6.16.0": + version: 6.16.0 + resolution: "@typescript-eslint/utils@npm:6.16.0" dependencies: "@eslint-community/eslint-utils": "npm:^4.4.0" "@types/json-schema": "npm:^7.0.12" "@types/semver": "npm:^7.5.0" - "@typescript-eslint/scope-manager": "npm:6.15.0" - "@typescript-eslint/types": "npm:6.15.0" - "@typescript-eslint/typescript-estree": "npm:6.15.0" + "@typescript-eslint/scope-manager": "npm:6.16.0" + "@typescript-eslint/types": "npm:6.16.0" + "@typescript-eslint/typescript-estree": "npm:6.16.0" semver: "npm:^7.5.4" peerDependencies: eslint: ^7.0.0 || ^8.0.0 - checksum: 7895240933ad28295508f8c4286a8b905550a35eda83a11ecf9511e53078e0af07e75a1872f1bc757f165b41fdc84616ea97c1e2e3bf80cff985935f25596228 + checksum: 84dd02f7c8e47fae699cc222da5cbea08b28c6e1cc7827860430bc86c2a17ee3f86e198a4356902b95930f85785aa662266ea9c476f69bf80c6a5f648e55f9f4 languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:6.15.0": - version: 6.15.0 - resolution: "@typescript-eslint/visitor-keys@npm:6.15.0" +"@typescript-eslint/visitor-keys@npm:6.16.0": + version: 6.16.0 + resolution: "@typescript-eslint/visitor-keys@npm:6.16.0" dependencies: - "@typescript-eslint/types": "npm:6.15.0" + "@typescript-eslint/types": "npm:6.16.0" eslint-visitor-keys: "npm:^3.4.1" - checksum: 4641a829485f67a5d9d3558aa0d152e5ab57b468cfd9653168ce9a141e1f051730669a024505183b64f7a7e5d8f62533af4ebd4ad7366b551390461e9c45ec18 + checksum: 19e559f14ea0092585a374b8c5f1aca9b6b271fc23909d9857de9cf71a1e1d3abc0afd237e9c02d7a5fbdfe8e3be7853cf9fedf40a6f16bac3495cb7f4e67982 languageName: node linkType: hard @@ -1826,8 +1827,8 @@ __metadata: "@babel/core": "npm:^7.23.6" "@emotion/react": "npm:^11.11.3" "@emotion/styled": "npm:^11.11.0" - "@mui/icons-material": "npm:^5.15.1" - "@mui/material": "npm:^5.15.1" + "@mui/icons-material": "npm:^5.15.2" + "@mui/material": "npm:^5.15.2" "@preact/compat": "npm:^17.1.2" "@preact/preset-vite": "npm:^2.7.0" "@table-library/react-table-library": "npm:4.1.7" @@ -1837,9 +1838,9 @@ __metadata: "@types/react": "npm:^18.2.45" "@types/react-dom": "npm:^18.2.18" "@types/react-router-dom": "npm:^5.3.3" - "@typescript-eslint/eslint-plugin": "npm:^6.15.0" - "@typescript-eslint/parser": "npm:^6.15.0" - alova: "npm:^2.16.1" + "@typescript-eslint/eslint-plugin": "npm:^6.16.0" + "@typescript-eslint/parser": "npm:^6.16.0" + alova: "npm:^2.16.2" async-validator: "npm:^4.2.5" concurrently: "npm:^8.2.2" eslint: "npm:^8.56.0" @@ -1941,10 +1942,10 @@ __metadata: languageName: node linkType: hard -"alova@npm:^2.16.1": - version: 2.16.1 - resolution: "alova@npm:2.16.1" - checksum: 88f0a175ed433606ff5f564151fc92e2d16e04a04f87362cbe76c1f0c33382e49719ce48f081fe03f707c28b78200c50b933155051d9a82be1d4bfcb73f1d0f9 +"alova@npm:^2.16.2": + version: 2.16.2 + resolution: "alova@npm:2.16.2" + checksum: 06fafddf380d4d8e8e5dd172ebcaa0bc229c76c11b2675cfb2c0ab884a36d4818159267adb14ec7a3cbe681464793085b0386d7741e6a6a732c764b14c8783a8 languageName: node linkType: hard @@ -6177,6 +6178,15 @@ __metadata: languageName: node linkType: hard +"minimatch@npm:9.0.3, minimatch@npm:^9.0.1": + version: 9.0.3 + resolution: "minimatch@npm:9.0.3" + dependencies: + brace-expansion: "npm:^2.0.1" + checksum: c81b47d28153e77521877649f4bab48348d10938df9e8147a58111fe00ef89559a2938de9f6632910c4f7bf7bb5cd81191a546167e58d357f0cfb1e18cecc1c5 + languageName: node + linkType: hard + "minimatch@npm:^3.0.5, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2": version: 3.1.2 resolution: "minimatch@npm:3.1.2" @@ -6186,15 +6196,6 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:^9.0.1": - version: 9.0.3 - resolution: "minimatch@npm:9.0.3" - dependencies: - brace-expansion: "npm:^2.0.1" - checksum: c81b47d28153e77521877649f4bab48348d10938df9e8147a58111fe00ef89559a2938de9f6632910c4f7bf7bb5cd81191a546167e58d357f0cfb1e18cecc1c5 - languageName: node - linkType: hard - "minimist@npm:^1.1.3, minimist@npm:^1.2.0, minimist@npm:^1.2.6": version: 1.2.8 resolution: "minimist@npm:1.2.8" diff --git a/lib/PsychicHttp/src/PsychicHttpServer.cpp b/lib/PsychicHttp/src/PsychicHttpServer.cpp index fbad5ff4f..c7938ad63 100644 --- a/lib/PsychicHttp/src/PsychicHttpServer.cpp +++ b/lib/PsychicHttp/src/PsychicHttpServer.cpp @@ -150,7 +150,7 @@ PsychicEndpoint * PsychicHttpServer::on(const char * uri, http_method method, Ps // Register endpoint with ESP-IDF server esp_err_t ret = httpd_register_uri_handler(this->server, &my_uri); if (ret != ESP_OK) { - ESP_LOGE(PH_TAG, "Add endpoint failed (%s)", esp_err_to_name(ret)); + ESP_LOGE(PH_TAG, "Add endpoint %s failed (%s)", uri, esp_err_to_name(ret)); // modified by proddy } //save it for later diff --git a/lib/framework/HttpEndpoint.h b/lib/framework/HttpEndpoint.h index bfcb81cea..859003689 100644 --- a/lib/framework/HttpEndpoint.h +++ b/lib/framework/HttpEndpoint.h @@ -42,9 +42,6 @@ class HttpGetEndpoint { AuthenticationPredicate _authenticationPredicate; void registerURI() { -#ifdef EMSESP_DEBUG - ESP_LOGE("HttpGetEndpoint", "Addding GET endpoint %s", _servicePath); -#endif _server->on(_servicePath, HTTP_GET, _securityManager->wrapRequest( @@ -91,9 +88,6 @@ class HttpPostEndpoint { const char * _servicePath; void registerURI() { -#ifdef EMSESP_DEBUG - ESP_LOGE("HttpPostEndpoint", "Addding POST endpoint %s", _servicePath); -#endif _server->on(_servicePath, HTTP_POST, _securityManager->wrapCallback( @@ -110,7 +104,7 @@ class HttpPostEndpoint { } else if ((outcome == StateUpdateResult::CHANGED) || (outcome == StateUpdateResult::CHANGED_RESTART)) { // TODO see if this works as intended. Before the stat was updated on an onDisconnect // request->onDisconnect([this]() { _statefulService->callUpdateHandlers(HTTP_ENDPOINT_ORIGIN_ID); }); - // TODO add https + // TODO add support for https _statefulService->callUpdateHandlers(HTTP_ENDPOINT_ORIGIN_ID); // persist the changes to the FS } diff --git a/lib_standalone/AsyncJson.h b/lib_standalone/AsyncJson.h deleted file mode 100644 index 2ec4a6322..000000000 --- a/lib_standalone/AsyncJson.h +++ /dev/null @@ -1,258 +0,0 @@ - -#ifndef ASYNC_JSON_H_ -#define ASYNC_JSON_H_ -#include -#include - -#define DYNAMIC_JSON_DOCUMENT_SIZE 1024 - -constexpr const char * JSON_MIMETYPE = "application/json"; - -class ChunkPrint : public Print { - private: - uint8_t * _destination; - size_t _to_skip; - size_t _to_write; - size_t _pos; - - public: - ChunkPrint(uint8_t * destination, size_t from, size_t len) - : _destination(destination) - , _to_skip(from) - , _to_write(len) - , _pos{0} { - } - virtual ~ChunkPrint() { - } - size_t write(uint8_t c) { - if (_to_skip > 0) { - _to_skip--; - return 1; - } else if (_to_write > 0) { - _to_write--; - _destination[_pos++] = c; - return 1; - } - return 0; - } - size_t write(const uint8_t * buffer, size_t size) { - return this->Print::write(buffer, size); - } -}; - -class PrettyAsyncJsonResponse { - protected: - DynamicJsonDocument _jsonBuffer; - - JsonVariant _root; - bool _isValid; - - public: - PrettyAsyncJsonResponse(bool isArray = false, size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE) - : _jsonBuffer(maxJsonBufferSize) - , _isValid{false} { - if (isArray) - _root = _jsonBuffer.createNestedArray(); - else - _root = _jsonBuffer.createNestedObject(); - } - - ~PrettyAsyncJsonResponse() { - } - - JsonVariant & getRoot() { - return _root; - } - - bool _sourceValid() const { - return _isValid; - } - - size_t setLength() { - return 0; - } - - void setContentType(const char * s) { - } - - size_t getSize() { - return _jsonBuffer.size(); - } - - size_t _fillBuffer(uint8_t * data, size_t len) { - return len; - } - - void setCode(uint16_t) { - } -}; - -class MsgpackAsyncJsonResponse { - protected: - DynamicJsonDocument _jsonBuffer; - JsonVariant _root; - bool _isValid; - - public: - MsgpackAsyncJsonResponse(bool isArray = false, size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE) - : _jsonBuffer(maxJsonBufferSize) - , _isValid{false} { - if (isArray) - _root = _jsonBuffer.createNestedArray(); - else - _root = _jsonBuffer.createNestedObject(); - } - - ~MsgpackAsyncJsonResponse() { - } - - JsonVariant & getRoot() { - return _root; - } - - bool _sourceValid() const { - return _isValid; - } - - size_t setLength() { - return 0; - } - - void setContentType(const char * s) { - } - - size_t getSize() { - return _jsonBuffer.size(); - } - - size_t _fillBuffer(uint8_t * data, size_t len) { - return len; - } - - void setCode(uint16_t) { - } -}; - -class AsyncJsonResponse { - protected: - DynamicJsonDocument _jsonBuffer; - - JsonVariant _root; - bool _isValid; - - public: - AsyncJsonResponse(bool isArray = false, size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE) - : _jsonBuffer(maxJsonBufferSize) - , _isValid{false} { - if (isArray) - _root = _jsonBuffer.createNestedArray(); - else - _root = _jsonBuffer.createNestedObject(); - } - - ~AsyncJsonResponse() { - } - - JsonVariant & getRoot() { - return _root; - } - - bool _sourceValid() const { - return _isValid; - } - - size_t setLength() { - return 0; - } - - size_t getSize() { - return _jsonBuffer.size(); - } - - size_t _fillBuffer(uint8_t * data, size_t len) { - return len; - } - - void setCode(uint16_t) { - } -}; - -typedef std::function ArJsonRequestHandlerFunction; - -class AsyncCallbackJsonWebHandler : public AsyncWebHandler { - private: - protected: - const String _uri; - WebRequestMethodComposite _method; - ArJsonRequestHandlerFunction _onRequest; - size_t _contentLength; - size_t _maxContentLength; - size_t _maxJsonBufferSize; - - public: - AsyncCallbackJsonWebHandler(const String & uri, ArJsonRequestHandlerFunction onRequest, size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE) - : _uri(uri) - , _method(HTTP_POST | HTTP_PUT | HTTP_PATCH) - , _onRequest(onRequest) - , _maxContentLength(16384) { - } - - void setMethod(WebRequestMethodComposite method) { - _method = method; - } - void setMaxContentLength(int maxContentLength) { - _maxContentLength = maxContentLength; - } - void setMaxJsonBufferSize(int maxJsonBufferSize) { - _maxJsonBufferSize = maxJsonBufferSize; - } - void onRequest(ArJsonRequestHandlerFunction fn) { - _onRequest = fn; - } - - virtual bool canHandle(AsyncWebServerRequest * request) override final { - if (!_onRequest) - return false; - - if (!(_method & request->method())) - return false; - - request->addInterestingHeader("ANY"); - return true; - } - - virtual void handleRequest(AsyncWebServerRequest * request) override final { - if (_onRequest) { - if (request->_tempObject != NULL) { - DynamicJsonDocument jsonBuffer(1024); - DeserializationError error = deserializeJson(jsonBuffer, (uint8_t *)(request->_tempObject)); - if (!error) { - JsonVariant json = jsonBuffer.as(); - - _onRequest(request, json); - return; - } - } - request->send(_contentLength > _maxContentLength ? 413 : 400); - } else { - request->send(500); - } - } - virtual void handleUpload(AsyncWebServerRequest * request, const String & filename, size_t index, uint8_t * data, size_t len, bool final) override final { - } - virtual void handleBody(AsyncWebServerRequest * request, uint8_t * data, size_t len, size_t index, size_t total) override final { - if (_onRequest) { - _contentLength = total; - if (total > 0 && request->_tempObject == NULL && total < _maxContentLength) { - request->_tempObject = malloc(total); - } - if (request->_tempObject != NULL) { - memcpy((uint8_t *)(request->_tempObject) + index, data, len); - } - } - } - virtual bool isRequestHandlerTrivial() override final { - return _onRequest ? false : true; - } -}; -#endif diff --git a/lib_standalone/ESP8266React.h b/lib_standalone/ESP8266React.h index b19417273..cb5b4e58e 100644 --- a/lib_standalone/ESP8266React.h +++ b/lib_standalone/ESP8266React.h @@ -1,13 +1,10 @@ #ifndef ESP8266React_h #define ESP8266React_h - #include #include -#include #include -#include #include @@ -146,7 +143,7 @@ class ESP8266React { class EMSESPSettingsService { public: - EMSESPSettingsService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager); + EMSESPSettingsService(PsychicHttpServer * server, FS * fs, SecurityManager * securityManager); void begin(); }; diff --git a/lib_standalone/ESPAsyncWebServer.h b/lib_standalone/ESPAsyncWebServer.h deleted file mode 100644 index 50b341849..000000000 --- a/lib_standalone/ESPAsyncWebServer.h +++ /dev/null @@ -1,251 +0,0 @@ -#ifndef _ESPAsyncWebServer_H_ -#define _ESPAsyncWebServer_H_ - -#include "Arduino.h" - -#include -#include -#include - -class AsyncWebServer; -class AsyncWebServerRequest; -class AsyncWebServerResponse; -class AsyncJsonResponse; -class PrettyAsyncJsonResponse; -class MsgpackAsyncJsonResponse; -class AsyncEventSource; - -class AsyncWebParameter { - private: - String _name; - String _value; - size_t _size; - bool _isForm; - bool _isFile; - - public: - AsyncWebParameter(const String & name, const String & value, bool form = false, bool file = false, size_t size = 0) - : _name(name) - , _value(value) - , _size(size) - , _isForm(form) - , _isFile(file) { - } - const String & name() const { - return _name; - } - const String & value() const { - return _value; - } - size_t size() const { - return _size; - } - bool isPost() const { - return _isForm; - } - bool isFile() const { - return _isFile; - } -}; - -typedef enum { - HTTP_GET = 0b00000001, - HTTP_POST = 0b00000010, - HTTP_DELETE = 0b00000100, - HTTP_PUT = 0b00001000, - HTTP_PATCH = 0b00010000, - HTTP_HEAD = 0b00100000, - HTTP_OPTIONS = 0b01000000, - HTTP_ANY = 0b01111111, -} WebRequestMethod; - -typedef uint8_t WebRequestMethodComposite; -typedef std::function ArDisconnectHandler; - -class AsyncWebServerRequest { - friend class AsyncWebServer; - friend class AsyncCallbackWebHandler; - - private: - AsyncClient * _client; - AsyncWebServer * _server; - WebRequestMethodComposite _method; - - String _url; - - public: - void * _tempObject; - - AsyncWebServerRequest(AsyncWebServer *, AsyncClient *){}; - AsyncWebServerRequest(){}; - ~AsyncWebServerRequest(){}; - - AsyncClient * client() { - return _client; - } - - WebRequestMethodComposite method() const { - return _method; - } - - void method(WebRequestMethodComposite method_s) { - _method = method_s; - } - - void addInterestingHeader(const String & name){}; - - size_t args() const { - return 0; - } - - void send(AsyncWebServerResponse * response){}; - void send(AsyncJsonResponse * response){}; - void send(PrettyAsyncJsonResponse * response){}; - void send(MsgpackAsyncJsonResponse * response){}; - void send(int code, const String & contentType = String(), const String & content = String()){}; - void send(int code, const String & contentType, const __FlashStringHelper *){}; - - const String & url() const { - return _url; - } - - void url(const String & url_s) { - _url = url_s; - } - - bool hasParam(const String & name, bool post, bool file) const { - return false; - } - - bool hasParam(const char * name, bool post, bool file) const { - return false; - } - - bool hasParam(const char * name) const { - return false; - } - - bool hasParam(const __FlashStringHelper * data) const { - return false; - } - - bool hasParam(const __FlashStringHelper * data, bool post, bool file) const { - return false; - } - - AsyncWebParameter * getParam(const String & name, bool post, bool file) const { - return nullptr; - } - - AsyncWebParameter * getParam(const __FlashStringHelper * data, bool post, bool file) const { - return nullptr; - } - - AsyncWebParameter * getParam(const __FlashStringHelper * data) const { - return nullptr; - } - - AsyncWebParameter * getParam(const char * name) const { - return nullptr; - } - - AsyncWebParameter * getParam(size_t num) const { - return nullptr; - } - - AsyncWebServerResponse * beginResponse(int code, const String & contentType = String(), const String & content = String()) { - return nullptr; - } - - size_t headers() const; // get header count - size_t params() const; // get arguments count -}; - -typedef std::function ArRequestFilterFunction; - -class AsyncWebHandler { - protected: - String _username; - String _password; - - public: - AsyncWebHandler() - : _username("") - , _password("") { - } - - virtual ~AsyncWebHandler() { - } - virtual bool canHandle(AsyncWebServerRequest * request __attribute__((unused))) { - return false; - } - virtual void handleRequest(AsyncWebServerRequest * request __attribute__((unused))) { - } - virtual void handleUpload(AsyncWebServerRequest * request __attribute__((unused)), - const String & filename __attribute__((unused)), - size_t index __attribute__((unused)), - uint8_t * data __attribute__((unused)), - size_t len __attribute__((unused)), - bool final __attribute__((unused))) { - } - virtual void handleBody(AsyncWebServerRequest * request __attribute__((unused)), - uint8_t * data __attribute__((unused)), - size_t len __attribute__((unused)), - size_t index __attribute__((unused)), - size_t total __attribute__((unused))) { - } - - virtual bool isRequestHandlerTrivial() { - return true; - } - - AsyncWebHandler & setFilter(ArRequestFilterFunction fn) { - return *this; - } -}; - -class AsyncWebServerResponse { - public: - AsyncWebServerResponse(); - virtual ~AsyncWebServerResponse(); -}; - -typedef std::function ArRequestHandlerFunction; -typedef std::function ArUploadHandlerFunction; -typedef std::function ArBodyHandlerFunction; - -class AsyncWebServer { - protected: - AsyncServer _server; - - public: - AsyncWebServer(uint16_t port) - : _server(port){}; - - ~AsyncWebServer(){}; - - void begin(){}; - void end(); - - AsyncWebHandler & addHandler(AsyncWebHandler * handler) { - return *handler; - } - - void on(const char * uri, WebRequestMethodComposite method, ArRequestHandlerFunction onRequest){}; -}; - - -class AsyncEventSource : public AsyncWebHandler { - public: - AsyncEventSource(const String & url){}; - ~AsyncEventSource(){}; - - size_t count() const { - return 1; - } - - void send(const char * message, const char * event = NULL, uint32_t id = 0, uint32_t reconnect = 0){}; -}; - - -#endif diff --git a/lib_standalone/HttpEndpoint.h b/lib_standalone/HttpEndpoint.h index f06662702..859003689 100644 --- a/lib_standalone/HttpEndpoint.h +++ b/lib_standalone/HttpEndpoint.h @@ -3,45 +3,55 @@ #include -#include -#include +#include #include #include #define HTTP_ENDPOINT_ORIGIN_ID "http" +#define HTTPS_ENDPOINT_ORIGIN_ID "https" + +using namespace std::placeholders; // for `_1` etc template class HttpGetEndpoint { public: HttpGetEndpoint(JsonStateReader stateReader, StatefulService * statefulService, - AsyncWebServer * server, - const String & servicePath, + PsychicHttpServer * server, + const char * servicePath, SecurityManager * securityManager, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, size_t bufferSize = DEFAULT_BUFFER_SIZE) : _stateReader(stateReader) , _statefulService(statefulService) - , _bufferSize(bufferSize) { - } - - HttpGetEndpoint(JsonStateReader stateReader, - StatefulService * statefulService, - AsyncWebServer * server, - const String & servicePath, - size_t bufferSize = DEFAULT_BUFFER_SIZE) - : _stateReader(stateReader) - , _statefulService(statefulService) - , _bufferSize(bufferSize) { + , _bufferSize(bufferSize) + , _server(server) + , _servicePath(servicePath) + , _securityManager(securityManager) + , _authenticationPredicate(authenticationPredicate) { } protected: - JsonStateReader _stateReader; - StatefulService * _statefulService; - size_t _bufferSize; + JsonStateReader _stateReader; + StatefulService * _statefulService; + size_t _bufferSize; + PsychicHttpServer * _server; + const char * _servicePath; + SecurityManager * _securityManager; + AuthenticationPredicate _authenticationPredicate; - void fetchSettings(AsyncWebServerRequest * request) { + void registerURI() { + _server->on(_servicePath, + HTTP_GET, + _securityManager->wrapRequest( + [this](PsychicRequest * request) { + PsychicJsonResponse response = PsychicJsonResponse(request, false, _bufferSize); + JsonObject jsonObject = response.getRoot(); + _statefulService->read(jsonObject, _stateReader); + return response.send(); + }, + _authenticationPredicate)); } }; @@ -51,46 +61,64 @@ class HttpPostEndpoint { HttpPostEndpoint(JsonStateReader stateReader, JsonStateUpdater stateUpdater, StatefulService * statefulService, - AsyncWebServer * server, - const String & servicePath, + PsychicHttpServer * server, + const char * servicePath, SecurityManager * securityManager, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, size_t bufferSize = DEFAULT_BUFFER_SIZE) : _stateReader(stateReader) , _stateUpdater(stateUpdater) , _statefulService(statefulService) + , _server(server) + , _servicePath(servicePath) + , _securityManager(securityManager) + , _authenticationPredicate(authenticationPredicate) , _bufferSize(bufferSize) { } - HttpPostEndpoint(JsonStateReader stateReader, - JsonStateUpdater stateUpdater, - StatefulService * statefulService, - AsyncWebServer * server, - const String & servicePath, - size_t bufferSize = DEFAULT_BUFFER_SIZE) - : _stateReader(stateReader) - , _stateUpdater(stateUpdater) - , _statefulService(statefulService) - , _bufferSize(bufferSize) { - } protected: - JsonStateReader _stateReader; - JsonStateUpdater _stateUpdater; - StatefulService * _statefulService; - size_t _bufferSize; + JsonStateReader _stateReader; + JsonStateUpdater _stateUpdater; + StatefulService * _statefulService; + size_t _bufferSize; + SecurityManager * _securityManager; + AuthenticationPredicate _authenticationPredicate; + PsychicHttpServer * _server; + const char * _servicePath; - void updateSettings(AsyncWebServerRequest * request, JsonVariant & json) { - if (!json.is()) { - return; - } - JsonObject jsonObject = json.as(); - StateUpdateResult outcome = _statefulService->updateWithoutPropagation(jsonObject, _stateUpdater); - if (outcome == StateUpdateResult::ERROR) { - return; - } - if (outcome == StateUpdateResult::CHANGED) { - } + void registerURI() { + _server->on(_servicePath, + HTTP_POST, + _securityManager->wrapCallback( + [this](PsychicRequest * request, JsonVariant & json) { + if (!json.is()) { + return request->reply(400); + } + + JsonObject jsonObject = json.as(); + StateUpdateResult outcome = _statefulService->updateWithoutPropagation(jsonObject, _stateUpdater); + + if (outcome == StateUpdateResult::ERROR) { + return request->reply(400); + } else if ((outcome == StateUpdateResult::CHANGED) || (outcome == StateUpdateResult::CHANGED_RESTART)) { + // TODO see if this works as intended. Before the stat was updated on an onDisconnect + // request->onDisconnect([this]() { _statefulService->callUpdateHandlers(HTTP_ENDPOINT_ORIGIN_ID); }); + // TODO add support for https + _statefulService->callUpdateHandlers(HTTP_ENDPOINT_ORIGIN_ID); // persist the changes to the FS + } + + PsychicJsonResponse response = PsychicJsonResponse(request, false, _bufferSize); + jsonObject = response.getRoot(); + + _statefulService->read(jsonObject, _stateReader); + + if (outcome == StateUpdateResult::CHANGED_RESTART) { + return request->reply(205); // reboot required + } + return response.send(); + }, + _authenticationPredicate)); } }; @@ -100,8 +128,8 @@ class HttpEndpoint : public HttpGetEndpoint, public HttpPostEndpoint { HttpEndpoint(JsonStateReader stateReader, JsonStateUpdater stateUpdater, StatefulService * statefulService, - AsyncWebServer * server, - const String & servicePath, + PsychicHttpServer * server, + const char * servicePath, SecurityManager * securityManager, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, size_t bufferSize = DEFAULT_BUFFER_SIZE) @@ -109,14 +137,10 @@ class HttpEndpoint : public HttpGetEndpoint, public HttpPostEndpoint { , HttpPostEndpoint(stateReader, stateUpdater, statefulService, server, servicePath, securityManager, authenticationPredicate, bufferSize) { } - HttpEndpoint(JsonStateReader stateReader, - JsonStateUpdater stateUpdater, - StatefulService * statefulService, - AsyncWebServer * server, - const String & servicePath, - size_t bufferSize = DEFAULT_BUFFER_SIZE) - : HttpGetEndpoint(stateReader, statefulService, server, servicePath, bufferSize) - , HttpPostEndpoint(stateReader, stateUpdater, statefulService, server, servicePath, bufferSize) { + // register the web server on() endpoints + void registerURI() { + HttpGetEndpoint::registerURI(); + HttpPostEndpoint::registerURI(); } }; diff --git a/lib_standalone/SecurityManager.h b/lib_standalone/SecurityManager.h index c21a3477e..5532a07ba 100644 --- a/lib_standalone/SecurityManager.h +++ b/lib_standalone/SecurityManager.h @@ -3,7 +3,6 @@ #include #include -#include #include #ifndef FACTORY_JWT_SECRET @@ -72,11 +71,6 @@ class SecurityManager { virtual Authentication authenticate(const String & username, const String & password) = 0; virtual String generateJWT(User * user) = 0; #endif - - virtual Authentication authenticateRequest(AsyncWebServerRequest * request) = 0; - virtual ArRequestFilterFunction filterRequest(AuthenticationPredicate predicate) = 0; - virtual ArRequestHandlerFunction wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) = 0; - virtual ArJsonRequestHandlerFunction wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) = 0; }; #endif diff --git a/platformio.ini b/platformio.ini index 29f9c5637..d603668c1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -183,8 +183,6 @@ build_flags = ; latest arduino 3.0/IDF 5.1.(alpha 3): ; platform = https://github.com/platformio/platform-espressif32.git ; platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5 -; -; platform = https://github.com/platformio/platform-espressif32.git ; platform_packages = https://github.com/espressif/arduino-esp32.git#3.0.0-alpha2 platform = espressif32 @@ -203,7 +201,7 @@ extra_scripts = build_unflags = ${common.unbuild_flags} build_flags = ${common.build_flags} - -D ARDUINOTRACE_ENABLE=0 + ; -D ARDUINOTRACE_ENABLE=1 -D TASMOTA_SDK -D EMSESP_TEST -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_WARN @@ -232,6 +230,7 @@ build_src_flags = -I./lib/PButton -I./lib/espMqttClient/src -I./lib/espMqttClient/src/Transport + -I./lib/PsychicHttp build_src_filter = +<*> -<.git/> @@ -243,5 +242,6 @@ build_src_filter = +<../lib/PButton> +<../lib/espMqttClient/src> +<../lib/espMqttClient/src/Transport> + +<../lib/PsychicHttp> lib_compat_mode = off lib_ldf_mode = off \ No newline at end of file diff --git a/src/emsesp.cpp b/src/emsesp.cpp index d37559e95..e0dce39db 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -1404,11 +1404,7 @@ EMSESP::EMSESP() // add web server endpoint void EMSESP::handler(const char * uri, const char * contentType, const uint8_t * content, size_t len) { - // remap to root - if (strcmp(uri, "/index.html") == 0) { - uri = "/"; - } - webServer.on(uri, HTTP_GET, [contentType, content, len](PsychicRequest * request) { + PsychicHttpRequestCallback fn = [contentType, content, len](PsychicRequest * request) { PsychicResponse response(request); response.setCode(200); response.setContentType(contentType); @@ -1416,7 +1412,17 @@ void EMSESP::handler(const char * uri, const char * contentType, const uint8_t * // response.addHeader("Content-Encoding", "br"); // Brotli - only works over HTTPS response.setContent(content, len); return response.send(); - }); + }; + + PsychicWebHandler * handler = new PsychicWebHandler(); + handler->onRequest(fn); + webServer.on(uri, HTTP_GET, handler); + + // Set default end-point for all non matching requests + // this is easier than using webServer.onNotFound() + if (strcmp(uri, "/index.html") == 0) { + webServer.defaultEndpoint->setHandler(handler); + } }; // configure web server @@ -1426,9 +1432,9 @@ void EMSESP::setupWeb() { // WWWData has 19 (in registerRoutes(handler) // esp8266React services has 13 // custom projects has around 23 - webServer.config.max_uri_handlers = 70; + webServer.config.max_uri_handlers = 80; - // TODO add support for HTTPS + // TODO add support for https webServer.listen(80); // start the web server DefaultHeaders::Instance().addHeader("Server", "EMS-ESP"); @@ -1447,18 +1453,6 @@ void EMSESP::setupWeb() { webSchedulerService.registerURI(); // /rest/schedule webCustomEntityService.registerURI(); // /rest/customentities - webServer.onNotFound([](PsychicRequest * request) { - if (request->method() == HTTP_GET) { - Serial.printf("redirecting not found %s\n", request->uri().c_str()); // TODO remove debug - String url = "http://" + request->host(); // TODO add support for https - return request->redirect(url.c_str()); - } else if (request->method() == HTTP_OPTIONS) { - return request->reply(200); - } else { - return request->reply(404); - } - }); - // Add CORS if specified in the network settings esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) { if (networkSettings.enableCORS) { @@ -1498,7 +1492,7 @@ void EMSESP::start() { // do a quick scan of the filesystem to see if we have a /config folder // so we know if this is a new install or not #ifndef EMSESP_STANDALONE - File root = LittleFS.open("/config"); + File root = LittleFS.open("/config"); // FS_CONFIG_DIRECTORY bool factory_settings = !root; if (!root) { #if defined(EMSESP_DEBUG) diff --git a/src/emsesp.h b/src/emsesp.h index 18b4a4cf7..755a34d86 100644 --- a/src/emsesp.h +++ b/src/emsesp.h @@ -69,7 +69,7 @@ // uses StaticJsonDocument #define EMSESP_JSON_SIZE_SMALL 256 #define EMSESP_JSON_SIZE_MEDIUM 768 -#define EMSESP_JSON_SIZE_LARGE 1024 // used in forming HA config payloads, also in *AsyncJsonResponse +#define EMSESP_JSON_SIZE_LARGE 1024 // used in forming HA config payloads // used in larger buffers like DynamicJsonDocument #define EMSESP_JSON_SIZE_XLARGE 2048 diff --git a/src/helpers.cpp b/src/helpers.cpp index c9c5eb9b5..8158c2f7b 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -683,7 +683,6 @@ std::string Helpers::toUpper(std::string const & s) { // capitalizes one UTF-8 character in char array // works with Latin1 (1 byte), Polish amd some other (2 bytes) characters -// TODO add special characters that occur in other supported languages #if defined(EMSESP_STANDALONE) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wtype-limits" diff --git a/src/web/WebCustomizationService.cpp b/src/web/WebCustomizationService.cpp index 1486cea83..2998e937c 100644 --- a/src/web/WebCustomizationService.cpp +++ b/src/web/WebCustomizationService.cpp @@ -208,15 +208,13 @@ esp_err_t WebCustomizationService::device_entities(PsychicRequest * request) { PsychicJsonResponse response = PsychicJsonResponse(request, true, EMSESP_JSON_SIZE_XXXXLARGE, true); // is array and also msgpack JsonArray output = response.getRoot(); - // TODO add back memory management + // TODO add back memory managegement. Be careful we do need to free()/delete() any object we extend with new() // while (!response) { // delete response; // buffer -= 1024; // // response = new MsgpackAsyncJsonResponse(true, buffer); // } - // TODO add msgpack - for (const auto & emsdevice : EMSESP::emsdevices) { if (emsdevice->unique_id() == id) { #ifndef EMSESP_STANDALONE diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index 419c5d196..e7393a0cb 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -178,7 +178,7 @@ esp_err_t WebDataService::device_data(PsychicRequest * request) { PsychicJsonResponse response = PsychicJsonResponse(request, false, EMSESP_JSON_SIZE_XXXXLARGE, true); // is jsonobject and also msgpack JsonObject output = response.getRoot(); - // TODO add back memory management? + // TODO add back memory managegement. Be careful we do need to free()/delete() any object we extend with new() // check size // while (!response) { // delete response; diff --git a/src/web/WebLogService.cpp b/src/web/WebLogService.cpp index 3197ccee5..291eefa40 100644 --- a/src/web/WebLogService.cpp +++ b/src/web/WebLogService.cpp @@ -80,7 +80,7 @@ void WebLogService::registerURI() { return request->reply(200); }); - // TODO remove? + // TODO this can be removed when ported over // server->addHandler(&events_); } diff --git a/src/web/WebLogService.h b/src/web/WebLogService.h index 22a8e7ff9..66913425e 100644 --- a/src/web/WebLogService.h +++ b/src/web/WebLogService.h @@ -48,10 +48,11 @@ class WebLogService : public uuid::log::Handler { virtual void operator<<(std::shared_ptr message); private: - PsychicEventSource _events; SecurityManager * _securityManager; PsychicHttpServer * _server; + PsychicEventSource _events; + class QueuedLogMessage { public: QueuedLogMessage(unsigned long id, std::shared_ptr && content); @@ -65,9 +66,6 @@ class WebLogService : public uuid::log::Handler { void transmit(const QueuedLogMessage & message); char * messagetime(char * out, const uint64_t t, const size_t bufsize); - // TODO remove this? - // PsychicJsonHandler setValues_; // for POSTs - esp_err_t fetchLog(PsychicRequest * request); esp_err_t getValues(PsychicRequest * request); esp_err_t setValues(PsychicRequest * request, JsonVariant & json);