diff --git a/interface/package.json b/interface/package.json index 6e2bd9301..14b862a2a 100644 --- a/interface/package.json +++ b/interface/package.json @@ -72,7 +72,7 @@ "prettier": "^3.2.5", "rollup-plugin-visualizer": "^5.12.0", "terser": "^5.27.0", - "vite": "^5.1.0", + "vite": "^5.1.1", "vite-plugin-imagemin": "^0.6.1", "vite-tsconfig-paths": "^4.3.1" }, diff --git a/interface/src/App.tsx b/interface/src/App.tsx index f69032319..77f79e41d 100644 --- a/interface/src/App.tsx +++ b/interface/src/App.tsx @@ -4,7 +4,6 @@ import { ToastContainer, Slide } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.min.css'; import { localStorageDetector } from 'typesafe-i18n/detectors'; -import { FeaturesLoader } from './contexts/features'; import type { FC } from 'react'; import AppRouting from 'AppRouting'; import CustomTheme from 'CustomTheme'; @@ -27,9 +26,7 @@ const App: FC = () => { return ( - - - + { const { LL, setLocale, locale } = useContext(I18nContext); - const { features } = useContext(FeaturesContext); - const [signInRequest, setSignInRequest] = useState({ username: '', password: '' @@ -112,7 +109,6 @@ const SignIn: FC = () => { })} > {PROJECT_NAME} - {features.version} diff --git a/interface/src/api/features.ts b/interface/src/api/features.ts deleted file mode 100644 index c0dd66e4f..000000000 --- a/interface/src/api/features.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { alovaInstance } from './endpoints'; - -import type { Features } from 'types'; - -export const readFeatures = () => alovaInstance.Get('/rest/features'); diff --git a/interface/src/contexts/features/FeaturesLoader.tsx b/interface/src/contexts/features/FeaturesLoader.tsx deleted file mode 100644 index 38e5e0196..000000000 --- a/interface/src/contexts/features/FeaturesLoader.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { useRequest } from 'alova'; - -import { FeaturesContext } from '.'; -import type { FC } from 'react'; - -import type { RequiredChildrenProps } from 'utils'; -import * as FeaturesApi from 'api/features'; - -const FeaturesLoader: FC = (props) => { - const { data: features } = useRequest(FeaturesApi.readFeatures); - - if (features) { - return ( - - {props.children} - - ); - } -}; - -export default FeaturesLoader; diff --git a/interface/src/contexts/features/context.ts b/interface/src/contexts/features/context.ts deleted file mode 100644 index 78a8f1ec2..000000000 --- a/interface/src/contexts/features/context.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { createContext } from 'react'; - -import type { Features } from 'types'; - -export interface FeaturesContextValue { - features: Features; -} - -const FeaturesContextDefaultValue = {} as FeaturesContextValue; -export const FeaturesContext = createContext(FeaturesContextDefaultValue); diff --git a/interface/src/contexts/features/index.ts b/interface/src/contexts/features/index.ts deleted file mode 100644 index f8df83c02..000000000 --- a/interface/src/contexts/features/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './context'; -export { default as FeaturesLoader } from './FeaturesLoader'; diff --git a/interface/src/framework/system/SystemStatusForm.tsx b/interface/src/framework/system/SystemStatusForm.tsx index 940b4339d..ba710e36e 100644 --- a/interface/src/framework/system/SystemStatusForm.tsx +++ b/interface/src/framework/system/SystemStatusForm.tsx @@ -29,7 +29,6 @@ import { import { useRequest } from 'alova'; import { useContext, useState } from 'react'; import { toast } from 'react-toastify'; -import { FeaturesContext } from '../../contexts/features'; import RestartMonitor from './RestartMonitor'; import SystemStatusVersionDialog from './SystemStatusVersionDialog'; import type { FC } from 'react'; @@ -54,8 +53,6 @@ const SystemStatusForm: FC = () => { const [restarting, setRestarting] = useState(); const [versionDialogOpen, setVersionDialogOpen] = useState(false); - const { features } = useContext(FeaturesContext); - const { send: restartCommand } = useRequest(SystemApi.restart(), { immediate: false }); @@ -215,7 +212,7 @@ const SystemStatusForm: FC = () => { - + @@ -355,7 +352,7 @@ const SystemStatusForm: FC = () => { open={versionDialogOpen} onClose={() => setVersionDialogOpen(false)} version={data.emsesp_version} - platform={features.platform} + platform={data.esp_platform} /> )} diff --git a/interface/src/project/DashboardDevices.tsx b/interface/src/project/DashboardDevices.tsx index f59047e3f..d95bc9f3a 100644 --- a/interface/src/project/DashboardDevices.tsx +++ b/interface/src/project/DashboardDevices.tsx @@ -94,8 +94,14 @@ const DashboardDevices: FC = () => { }, []); const leftOffset = () => { - const left = document.getElementById('devices-window')?.getBoundingClientRect().left; - const right = document.getElementById('devices-window')?.getBoundingClientRect().right; + const devicesWindow = document.getElementById('devices-window'); + if (!devicesWindow) { + return 0; + } + + const clientRect = devicesWindow.getBoundingClientRect(); + const left = clientRect.left; + const right = clientRect.right; if (!left || !right) { return 0; @@ -416,11 +422,11 @@ const DashboardDevices: FC = () => { const renderCoreData = () => ( {!coreData.connected && } - {coreData.connected && coreData.devices.length === 0 && ( + {/* {coreData.connected && coreData.devices.length === 0 && ( - )} + )} */} - {coreData.devices.length !== 0 && ( + {coreData.connected && ( {(tableList: any) => ( <> diff --git a/interface/src/types/index.ts b/interface/src/types/index.ts index 632d8907b..420f7e2bf 100644 --- a/interface/src/types/index.ts +++ b/interface/src/types/index.ts @@ -1,5 +1,4 @@ export * from './ap'; -export * from './features'; export * from './me'; export * from './mqtt'; export * from './ntp'; diff --git a/interface/yarn.lock b/interface/yarn.lock index 8ec0fc147..10b067180 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -1895,7 +1895,7 @@ __metadata: terser: "npm:^5.27.0" typesafe-i18n: "npm:^5.26.2" typescript: "npm:^5.3.3" - vite: "npm:^5.1.0" + vite: "npm:^5.1.1" vite-plugin-imagemin: "npm:^0.6.1" vite-tsconfig-paths: "npm:^4.3.1" languageName: unknown @@ -8793,9 +8793,9 @@ __metadata: languageName: node linkType: hard -"vite@npm:^5.1.0": - version: 5.1.0 - resolution: "vite@npm:5.1.0" +"vite@npm:^5.1.1": + version: 5.1.1 + resolution: "vite@npm:5.1.1" dependencies: esbuild: "npm:^0.19.3" fsevents: "npm:~2.3.3" @@ -8829,7 +8829,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: 10/14d136f2e71d657cb55bec2a9330951e27e572ed79c4e79e3edc24decfa87f95664b8206614bfcf6a61db933667e554a8eed389291ad8af49de0784548a83a4c + checksum: 10/bdb8e683caddaa0a9adcbf40144ca8ea3660836b208862b07d43787ea867845919af16e58745365bd13ed3b7f66bbf9788a6869ee22cfaacac01645b59729c34 languageName: node linkType: hard diff --git a/lib/ArduinoJson/ArduinoJson.h b/lib/ArduinoJson/ArduinoJson.h old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/CHANGELOG.md b/lib/ArduinoJson/CHANGELOG.md old mode 100644 new mode 100755 index e82281e20..fa4cfe6f0 --- a/lib/ArduinoJson/CHANGELOG.md +++ b/lib/ArduinoJson/CHANGELOG.md @@ -1,6 +1,13 @@ ArduinoJson: change log ======================= +v7.0.3 (2024-02-05) +------ + +* Improve error messages when using `char` or `char*` (issue #2043) +* Reduce stack consumption (issue #2046) +* Fix compatibility with GCC 4.8 (issue #2045) + v7.0.2 (2024-01-19) ------ diff --git a/lib/ArduinoJson/CMakeLists.txt b/lib/ArduinoJson/CMakeLists.txt deleted file mode 100644 index 6efa04b3b..000000000 --- a/lib/ArduinoJson/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# ArduinoJson - https://arduinojson.org -# Copyright © 2014-2024, Benoit BLANCHON -# MIT License - -cmake_minimum_required(VERSION 3.15) - -if(ESP_PLATFORM) - # Build ArduinoJson as an ESP-IDF component - idf_component_register(INCLUDE_DIRS src) - return() -endif() - -project(ArduinoJson VERSION 7.0.2) - -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - include(CTest) -endif() - -add_subdirectory(src) - -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - include(extras/CompileOptions.cmake) - add_subdirectory(extras/tests) - add_subdirectory(extras/fuzzing) -endif() diff --git a/lib/ArduinoJson/LICENSE.txt b/lib/ArduinoJson/LICENSE.txt old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/README.md b/lib/ArduinoJson/README.md new file mode 100755 index 000000000..2900240e5 --- /dev/null +++ b/lib/ArduinoJson/README.md @@ -0,0 +1,155 @@ +

+ ArduinoJson +

+ +--- + +[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bblanchon/ArduinoJson/ci.yml?branch=7.x&logo=github)](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A7.x) +[![Continuous Integration](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/7.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/7.x) +[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) +[![Coveralls branch](https://img.shields.io/coveralls/github/bblanchon/ArduinoJson/7.x?logo=coveralls)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=7.x) +[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github&color=orange)](https://github.com/bblanchon/ArduinoJson/stargazers) +[![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github&color=orange)](https://github.com/sponsors/bblanchon) + +ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). + +## Features + +* [JSON deserialization](https://arduinojson.org/v7/api/json/deserializejson/) + * [Optionally decodes UTF-16 escape sequences to UTF-8](https://arduinojson.org/v7/api/config/decode_unicode/) + * [Optionally supports comments in the input](https://arduinojson.org/v7/api/config/enable_comments/) + * [Optionally filters the input to keep only desired values](https://arduinojson.org/v7/api/json/deserializejson/#filtering) + * Supports single quotes as a string delimiter + * Compatible with [NDJSON](http://ndjson.org/) and [JSON Lines](https://jsonlines.org/) +* [JSON serialization](https://arduinojson.org/v7/api/json/serializejson/) + * [Can write to a buffer or a stream](https://arduinojson.org/v7/api/json/serializejson/) + * [Optionally indents the document (prettified JSON)](https://arduinojson.org/v7/api/json/serializejsonpretty/) +* [MessagePack serialization](https://arduinojson.org/v7/api/msgpack/serializemsgpack/) +* [MessagePack deserialization](https://arduinojson.org/v7/api/msgpack/deserializemsgpack/) +* Efficient + * [Twice smaller than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/) + * [Almost 10% faster than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/) + * [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/) + * [Deduplicates strings](https://arduinojson.org/news/2020/08/01/version-6-16-0/) +* Versatile + * Supports [custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v7/how-to/use-external-ram-on-esp32/) + * Supports [`String`](https://arduinojson.org/v7/api/config/enable_arduino_string/), [`std::string`](https://arduinojson.org/v7/api/config/enable_std_string/), and [`std::string_view`](https://arduinojson.org/v7/api/config/enable_string_view/) + * Supports [`Stream`](https://arduinojson.org/v7/api/config/enable_arduino_stream/) and [`std::istream`/`std::ostream`](https://arduinojson.org/v7/api/config/enable_std_stream/) + * Supports [Flash strings](https://arduinojson.org/v7/api/config/enable_progmem/) + * Supports [custom readers](https://arduinojson.org/v7/api/json/deserializejson/#custom-reader) and [custom writers](https://arduinojson.org/v7/api/json/serializejson/#custom-writer) + * Supports [custom converters](https://arduinojson.org/news/2021/05/04/version-6-18-0/) +* Portable + * Usable on any C++ project (not limited to Arduino) + * Compatible with C++11, C++14 and C++17 + * Support for C++98/C++03 available on [ArduinoJson 6.20.x](https://github.com/bblanchon/ArduinoJson/tree/6.20.x) + * Zero warnings with `-Wall -Wextra -pedantic` and `/W4` + * [Header-only library](https://en.wikipedia.org/wiki/Header-only) + * Works with virtually any board + * Arduino boards: [Uno](https://amzn.to/38aL2ik), [Due](https://amzn.to/36YkWi2), [Micro](https://amzn.to/35WkdwG), [Nano](https://amzn.to/2QTvwRX), [Mega](https://amzn.to/36XWhuf), [Yun](https://amzn.to/30odURc), [Leonardo](https://amzn.to/36XWjlR)... + * Espressif chips: [ESP8266](https://amzn.to/36YluV8), [ESP32](https://amzn.to/2G4pRCB) + * Lolin (WeMos) boards: [D1 mini](https://amzn.to/2QUpz7q), [D1 Mini Pro](https://amzn.to/36UsGSs)... + * Teensy boards: [4.0](https://amzn.to/30ljXGq), [3.2](https://amzn.to/2FT0EuC), [2.0](https://amzn.to/2QXUMXj) + * Particle boards: [Argon](https://amzn.to/2FQHa9X), [Boron](https://amzn.to/36WgLUd), [Electron](https://amzn.to/30vEc4k), [Photon](https://amzn.to/387F9Cd)... + * Texas Instruments boards: [MSP430](https://amzn.to/30nJWgg)... + * Soft cores: [Nios II](https://en.wikipedia.org/wiki/Nios_II)... + * Tested on all major development environments + * [Arduino IDE](https://www.arduino.cc/en/Main/Software) + * [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/) + * [Atollic TrueSTUDIO](https://atollic.com/truestudio/) + * [Energia](http://energia.nu/) + * [IAR Embedded Workbench](https://www.iar.com/iar-embedded-workbench/) + * [Keil uVision](http://www.keil.com/) + * [MPLAB X IDE](http://www.microchip.com/mplab/mplab-x-ide) + * [Particle](https://www.particle.io/) + * [PlatformIO](http://platformio.org/) + * [Sloeber plugin for Eclipse](https://eclipse.baeyens.it/) + * [Visual Micro](http://www.visualmicro.com/) + * [Visual Studio](https://www.visualstudio.com/) + * [Even works with online compilers like wandbox.org](https://wandbox.org/permlink/RlZSKy17DjJ6HcdN) + * [CMake friendly](https://arduinojson.org/v7/how-to/use-arduinojson-with-cmake/) +* Well designed + * [Elegant API](http://arduinojson.org/v7/example/) + * [Thread-safe](https://en.wikipedia.org/wiki/Thread_safety) + * Self-contained (no external dependency) + * `const` friendly + * [`for` friendly](https://arduinojson.org/v7/api/jsonobject/begin_end/) + * [TMP friendly](https://en.wikipedia.org/wiki/Template_metaprogramming) + * Handles [integer overflows](https://arduinojson.org/v7/api/jsonvariant/as/#integer-overflows) +* Well tested + * [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=7.x) + * Continuously tested on + * [Visual Studio 2017, 2019, 2022](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/7.x) + * [GCC 4.8, 5, 6, 7, 8, 9, 10, 11, 12](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) + * [Clang 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10, 11, 12, 13, 14, 15](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) + * [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) + * Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/) +* Well documented + * [Tutorials](https://arduinojson.org/v7/doc/deserialization/) + * [Examples](https://arduinojson.org/v7/example/) + * [How-tos](https://arduinojson.org/v7/example/) + * [FAQ](https://arduinojson.org/v7/faq/) + * [Troubleshooter](https://arduinojson.org/v7/troubleshooter/) + * [Book](https://arduinojson.org/book/) + * [Changelog](CHANGELOG.md) +* Vibrant user community + * Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories) + * [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson) + * [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed) + +## Quickstart + +### Deserialization + +Here is a program that parses a JSON document with ArduinoJson. + +```c++ +const char* json = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; + +JsonDocument doc; +deserializeJson(doc, json); + +const char* sensor = doc["sensor"]; +long time = doc["time"]; +double latitude = doc["data"][0]; +double longitude = doc["data"][1]; +``` + +See the [tutorial on arduinojson.org](https://arduinojson.org/v7/doc/deserialization/) + +### Serialization + +Here is a program that generates a JSON document with ArduinoJson: + +```c++ +JsonDocument doc; + +doc["sensor"] = "gps"; +doc["time"] = 1351824120; +doc["data"][0] = 48.756080; +doc["data"][1] = 2.302038; + +serializeJson(doc, Serial); +// This prints: +// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]} +``` + +See the [tutorial on arduinojson.org](https://arduinojson.org/v7/doc/serialization/) + +## Sponsors + +ArduinoJson is thankful to its sponsors. Please give them a visit; they deserve it! + +

+ + Programming Electronics Academy + +

+

+ + 1technophile + +

+ +If you run a commercial project that embeds ArduinoJson, think about [sponsoring the library's development](https://github.com/sponsors/bblanchon): it ensures the code that your products rely on stays actively maintained. It can also give your project some exposure to the makers' community. + +If you are an individual user and want to support the development (or give a sign of appreciation), consider purchasing the book [Mastering ArduinoJson](https://arduinojson.org/book/) ❤, or simply [cast a star](https://github.com/bblanchon/ArduinoJson/stargazers) ⭐. diff --git a/lib/ArduinoJson/SUPPORT.md b/lib/ArduinoJson/SUPPORT.md new file mode 100755 index 000000000..c47e1b1ba --- /dev/null +++ b/lib/ArduinoJson/SUPPORT.md @@ -0,0 +1,27 @@ +# ArduinoJson Support + +First off, thank you very much for using ArduinoJson. + +We'll be very happy to help you, but first please read the following. + +## Before asking for help + +1. Read the [FAQ](https://arduinojson.org/faq/?utm_source=github&utm_medium=support) +2. Search in the [API Reference](https://arduinojson.org/api/?utm_source=github&utm_medium=support) + +If you did not find the answer, please create a [new issue on GitHub](https://github.com/bblanchon/ArduinoJson/issues/new). + +It is OK to add a comment to a currently opened issue, but please avoid adding comments to a closed issue. + +## Before hitting the Submit button + +Please provide all the relevant information: + +* Good title +* Short description of the problem +* Target platform +* Compiler model and version +* [MVCE](https://stackoverflow.com/help/mcve) +* Compiler output + +Good questions get fast answers! diff --git a/lib/ArduinoJson/idf_component.yml b/lib/ArduinoJson/idf_component.yml deleted file mode 100644 index 429d37339..000000000 --- a/lib/ArduinoJson/idf_component.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: "7.0.2" -description: >- - A simple and efficient JSON library for embedded C++. - ⭐ 6444 stars on GitHub! - Supports serialization, deserialization, MessagePack, streams, filtering, and more. - Fully tested and documented. -url: https://arduinojson.org/ -files: - exclude: - - "**/.vs/**/*" - - ".devcontainer/**/*" - - "examples/**/*" - - "extras/**/*" diff --git a/lib/ArduinoJson/library.json b/lib/ArduinoJson/library.json deleted file mode 100644 index 46f156ac4..000000000 --- a/lib/ArduinoJson/library.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "ArduinoJson", - "keywords": "json, rest, http, web", - "description": "A simple and efficient JSON library for embedded C++. ⭐ 6444 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented.", - "homepage": "https://arduinojson.org/?utm_source=meta&utm_medium=library.json", - "repository": { - "type": "git", - "url": "https://github.com/bblanchon/ArduinoJson.git" - }, - "version": "7.0.2", - "authors": { - "name": "Benoit Blanchon", - "url": "https://blog.benoitblanchon.fr" - }, - "export": { - "include": ["src", "examples", "LICENSE.txt", "ArduinoJson.h"] - }, - "frameworks": "*", - "platforms": "*", - "build": { - "libArchive": false - } -} diff --git a/lib/ArduinoJson/library.properties b/lib/ArduinoJson/library.properties deleted file mode 100644 index e9d9c2c7d..000000000 --- a/lib/ArduinoJson/library.properties +++ /dev/null @@ -1,11 +0,0 @@ -name=ArduinoJson -version=7.0.2 -author=Benoit Blanchon -maintainer=Benoit Blanchon -sentence=A simple and efficient JSON library for embedded C++. -paragraph=⭐ 6444 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented. -category=Data Processing -url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties -architectures=* -repository=https://github.com/bblanchon/ArduinoJson.git -license=MIT diff --git a/lib/ArduinoJson/src/ArduinoJson.h b/lib/ArduinoJson/src/ArduinoJson.h old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson.hpp b/lib/ArduinoJson/src/ArduinoJson.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayData.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayData.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayImpl.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayImpl.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp old mode 100644 new mode 100755 index 2ae26624a..f36b68ea3 --- a/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp @@ -22,25 +22,25 @@ class ElementProxy : public VariantRefBase>, ElementProxy(const ElementProxy& src) : upstream_(src.upstream_), index_(src.index_) {} - FORCE_INLINE ElementProxy& operator=(const ElementProxy& src) { + ElementProxy& operator=(const ElementProxy& src) { this->set(src); return *this; } template - FORCE_INLINE ElementProxy& operator=(const T& src) { + ElementProxy& operator=(const T& src) { this->set(src); return *this; } template - FORCE_INLINE ElementProxy& operator=(T* src) { + ElementProxy& operator=(T* src) { this->set(src); return *this; } private: - FORCE_INLINE ResourceManager* getResourceManager() const { + ResourceManager* getResourceManager() const { return VariantAttorney::getResourceManager(upstream_); } @@ -50,7 +50,7 @@ class ElementProxy : public VariantRefBase>, VariantAttorney::getResourceManager(upstream_)); } - FORCE_INLINE VariantData* getOrCreateData() const { + VariantData* getOrCreateData() const { auto data = VariantAttorney::getOrCreateData(upstream_); if (!data) return nullptr; diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp old mode 100644 new mode 100755 index 069c353de..292336308 --- a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp @@ -20,11 +20,10 @@ class JsonArray : public detail::VariantOperators { typedef JsonArrayIterator iterator; // Constructs an unbound reference. - FORCE_INLINE JsonArray() : data_(0), resources_(0) {} + JsonArray() : data_(0), resources_(0) {} // INTERNAL USE ONLY - FORCE_INLINE JsonArray(detail::ArrayData* data, - detail::ResourceManager* resources) + JsonArray(detail::ArrayData* data, detail::ResourceManager* resources) : data_(data), resources_(resources) {} // Returns a JsonVariant pointing to the array. @@ -63,20 +62,20 @@ class JsonArray : public detail::VariantOperators { // Appends a value to the array. // https://arduinojson.org/v7/api/jsonarray/add/ template - FORCE_INLINE bool add(const T& value) const { + bool add(const T& value) const { return add().set(value); } // Appends a value to the array. // https://arduinojson.org/v7/api/jsonarray/add/ template - FORCE_INLINE bool add(T* value) const { + bool add(T* value) const { return add().set(value); } // Returns an iterator to the first element of the array. // https://arduinojson.org/v7/api/jsonarray/begin/ - FORCE_INLINE iterator begin() const { + iterator begin() const { if (!data_) return iterator(); return iterator(data_->createIterator(resources_), resources_); @@ -84,13 +83,13 @@ class JsonArray : public detail::VariantOperators { // Returns an iterator following the last element of the array. // https://arduinojson.org/v7/api/jsonarray/end/ - FORCE_INLINE iterator end() const { + iterator end() const { return iterator(); } // Copies an array. // https://arduinojson.org/v7/api/jsonarray/set/ - FORCE_INLINE bool set(JsonArrayConst src) const { + bool set(JsonArrayConst src) const { if (!data_) return false; @@ -105,13 +104,13 @@ class JsonArray : public detail::VariantOperators { // Removes the element at the specified iterator. // https://arduinojson.org/v7/api/jsonarray/remove/ - FORCE_INLINE void remove(iterator it) const { + void remove(iterator it) const { detail::ArrayData::remove(data_, it.iterator_, resources_); } // Removes the element at the specified index. // https://arduinojson.org/v7/api/jsonarray/remove/ - FORCE_INLINE void remove(size_t index) const { + void remove(size_t index) const { detail::ArrayData::removeElement(data_, index, resources_); } @@ -123,7 +122,7 @@ class JsonArray : public detail::VariantOperators { // Gets or sets the element at the specified index. // https://arduinojson.org/v7/api/jsonarray/subscript/ - FORCE_INLINE detail::ElementProxy operator[](size_t index) const { + detail::ElementProxy operator[](size_t index) const { return {*this, index}; } @@ -133,25 +132,25 @@ class JsonArray : public detail::VariantOperators { // Returns true if the reference is unbound. // https://arduinojson.org/v7/api/jsonarray/isnull/ - FORCE_INLINE bool isNull() const { + bool isNull() const { return data_ == 0; } // Returns true if the reference is bound. // https://arduinojson.org/v7/api/jsonarray/isnull/ - FORCE_INLINE operator bool() const { + operator bool() const { return data_ != 0; } // Returns the depth (nesting level) of the array. // https://arduinojson.org/v7/api/jsonarray/nesting/ - FORCE_INLINE size_t nesting() const { + size_t nesting() const { return detail::VariantData::nesting(collectionToVariant(data_), resources_); } // Returns the number of elements in the array. // https://arduinojson.org/v7/api/jsonarray/size/ - FORCE_INLINE size_t size() const { + size_t size() const { return data_ ? data_->size(resources_) : 0; } diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp old mode 100644 new mode 100755 index 526975a24..6c0d7db2f --- a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp @@ -23,7 +23,7 @@ class JsonArrayConst : public detail::VariantOperators { // Returns an iterator to the first element of the array. // https://arduinojson.org/v7/api/jsonarrayconst/begin/ - FORCE_INLINE iterator begin() const { + iterator begin() const { if (!data_) return iterator(); return iterator(data_->createIterator(resources_), resources_); @@ -31,21 +31,21 @@ class JsonArrayConst : public detail::VariantOperators { // Returns an iterator to the element following the last element of the array. // https://arduinojson.org/v7/api/jsonarrayconst/end/ - FORCE_INLINE iterator end() const { + iterator end() const { return iterator(); } // Creates an unbound reference. - FORCE_INLINE JsonArrayConst() : data_(0) {} + JsonArrayConst() : data_(0) {} // INTERNAL USE ONLY - FORCE_INLINE JsonArrayConst(const detail::ArrayData* data, - const detail::ResourceManager* resources) + JsonArrayConst(const detail::ArrayData* data, + const detail::ResourceManager* resources) : data_(data), resources_(resources) {} // Returns the element at the specified index. // https://arduinojson.org/v7/api/jsonarrayconst/subscript/ - FORCE_INLINE JsonVariantConst operator[](size_t index) const { + JsonVariantConst operator[](size_t index) const { return JsonVariantConst( detail::ArrayData::getElement(data_, index, resources_), resources_); } @@ -56,25 +56,25 @@ class JsonArrayConst : public detail::VariantOperators { // Returns true if the reference is unbound. // https://arduinojson.org/v7/api/jsonarrayconst/isnull/ - FORCE_INLINE bool isNull() const { + bool isNull() const { return data_ == 0; } // Returns true if the reference is bound. // https://arduinojson.org/v7/api/jsonarrayconst/isnull/ - FORCE_INLINE operator bool() const { + operator bool() const { return data_ != 0; } // Returns the depth (nesting level) of the array. // https://arduinojson.org/v7/api/jsonarrayconst/nesting/ - FORCE_INLINE size_t nesting() const { + size_t nesting() const { return detail::VariantData::nesting(getData(), resources_); } // Returns the number of elements in the array. // https://arduinojson.org/v7/api/jsonarrayconst/size/ - FORCE_INLINE size_t size() const { + size_t size() const { return data_ ? data_->size(resources_) : 0; } diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayIterator.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayIterator.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/Utilities.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/Utilities.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp old mode 100644 new mode 100755 index 1010795ce..07fe7e043 --- a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp @@ -107,6 +107,10 @@ class CollectionData { return collection->remove(it, resources); } + SlotId head() const { + return head_; + } + protected: iterator addSlot(ResourceManager*); diff --git a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp b/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationOptions.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationOptions.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/VariantReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/VariantReader.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp b/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp old mode 100644 new mode 100755 index d2daf97ad..0f336f1a2 --- a/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp @@ -30,7 +30,8 @@ class JsonDocument : public detail::VariantOperators { } // Move-constructor - JsonDocument(JsonDocument&& src) : JsonDocument() { + JsonDocument(JsonDocument&& src) + : JsonDocument(detail::DefaultAllocator::instance()) { swap(*this, src); } @@ -169,9 +170,8 @@ class JsonDocument : public detail::VariantOperators { // Gets or sets a root object's member. // https://arduinojson.org/v7/api/jsondocument/subscript/ template - FORCE_INLINE typename detail::enable_if< - detail::IsString::value, - detail::MemberProxy>::type + typename detail::enable_if::value, + detail::MemberProxy>::type operator[](const TString& key) { return {*this, key}; } @@ -179,9 +179,8 @@ class JsonDocument : public detail::VariantOperators { // Gets or sets a root object's member. // https://arduinojson.org/v7/api/jsondocument/subscript/ template - FORCE_INLINE typename detail::enable_if< - detail::IsString::value, - detail::MemberProxy>::type + typename detail::enable_if::value, + detail::MemberProxy>::type operator[](TChar* key) { return {*this, key}; } @@ -189,8 +188,8 @@ class JsonDocument : public detail::VariantOperators { // Gets a root object's member. // https://arduinojson.org/v7/api/jsondocument/subscript/ template - FORCE_INLINE typename detail::enable_if::value, - JsonVariantConst>::type + typename detail::enable_if::value, + JsonVariantConst>::type operator[](const TString& key) const { return JsonVariantConst( data_.getMember(detail::adaptString(key), &resources_), &resources_); @@ -199,8 +198,8 @@ class JsonDocument : public detail::VariantOperators { // Gets a root object's member. // https://arduinojson.org/v7/api/jsondocument/subscript/ template - FORCE_INLINE typename detail::enable_if::value, - JsonVariantConst>::type + typename detail::enable_if::value, + JsonVariantConst>::type operator[](TChar* key) const { return JsonVariantConst( data_.getMember(detail::adaptString(key), &resources_), &resources_); @@ -208,13 +207,13 @@ class JsonDocument : public detail::VariantOperators { // Gets or sets a root array's element. // https://arduinojson.org/v7/api/jsondocument/subscript/ - FORCE_INLINE detail::ElementProxy operator[](size_t index) { + detail::ElementProxy operator[](size_t index) { return {*this, index}; } // Gets a root array's member. // https://arduinojson.org/v7/api/jsondocument/subscript/ - FORCE_INLINE JsonVariantConst operator[](size_t index) const { + JsonVariantConst operator[](size_t index) const { return JsonVariantConst(data_.getElement(index, &resources_), &resources_); } @@ -239,28 +238,28 @@ class JsonDocument : public detail::VariantOperators { // Appends a value to the root array. // https://arduinojson.org/v7/api/jsondocument/add/ template - FORCE_INLINE bool add(const TValue& value) { + bool add(const TValue& value) { return add().set(value); } // Appends a value to the root array. // https://arduinojson.org/v7/api/jsondocument/add/ template - FORCE_INLINE bool add(TChar* value) { + bool add(TChar* value) { return add().set(value); } // Removes an element of the root array. // https://arduinojson.org/v7/api/jsondocument/remove/ - FORCE_INLINE void remove(size_t index) { + void remove(size_t index) { detail::VariantData::removeElement(getData(), index, getResourceManager()); } // Removes a member of the root object. // https://arduinojson.org/v7/api/jsondocument/remove/ template - FORCE_INLINE typename detail::enable_if::value>::type - remove(TChar* key) { + typename detail::enable_if::value>::type remove( + TChar* key) { detail::VariantData::removeMember(getData(), detail::adaptString(key), getResourceManager()); } @@ -268,18 +267,18 @@ class JsonDocument : public detail::VariantOperators { // Removes a member of the root object. // https://arduinojson.org/v7/api/jsondocument/remove/ template - FORCE_INLINE - typename detail::enable_if::value>::type - remove(const TString& key) { + + typename detail::enable_if::value>::type remove( + const TString& key) { detail::VariantData::removeMember(getData(), detail::adaptString(key), getResourceManager()); } - FORCE_INLINE operator JsonVariant() { + operator JsonVariant() { return getVariant(); } - FORCE_INLINE operator JsonVariantConst() const { + operator JsonVariantConst() const { return getVariant(); } diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/EscapeSequence.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/EscapeSequence.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/JsonDeserializer.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/JsonDeserializer.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp old mode 100644 new mode 100755 index f4751f0c2..6b02cc593 --- a/lib/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp @@ -19,19 +19,20 @@ class JsonSerializer : public VariantDataVisitor { JsonSerializer(TWriter writer, const ResourceManager* resources) : formatter_(writer), resources_(resources) {} - FORCE_INLINE size_t visit(const ArrayData& array) { + size_t visit(const ArrayData& array) { write('['); - auto it = array.createIterator(resources_); + auto slotId = array.head(); - while (!it.done()) { - it->accept(*this); + while (slotId != NULL_SLOT) { + auto slot = resources_->getSlot(slotId); - it.next(resources_); - if (it.done()) - break; + slot->data()->accept(*this); - write(','); + slotId = slot->next(); + + if (slotId != NULL_SLOT) + write(','); } write(']'); @@ -41,18 +42,19 @@ class JsonSerializer : public VariantDataVisitor { size_t visit(const ObjectData& object) { write('{'); - auto it = object.createIterator(resources_); + auto slotId = object.head(); - while (!it.done()) { - formatter_.writeString(it.key()); + while (slotId != NULL_SLOT) { + auto slot = resources_->getSlot(slotId); + + formatter_.writeString(slot->key()); write(':'); - it->accept(*this); + slot->data()->accept(*this); - it.next(resources_); - if (it.done()) - break; + slotId = slot->next(); - write(','); + if (slotId != NULL_SLOT) + write(','); } write('}'); diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/Latch.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/Latch.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/Utf16.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/Utf16.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Memory/Alignment.hpp b/lib/ArduinoJson/src/ArduinoJson/Memory/Alignment.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Memory/Allocator.hpp b/lib/ArduinoJson/src/ArduinoJson/Memory/Allocator.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Memory/ResourceManager.hpp b/lib/ArduinoJson/src/ArduinoJson/Memory/ResourceManager.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Memory/StringBuilder.hpp b/lib/ArduinoJson/src/ArduinoJson/Memory/StringBuilder.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Memory/StringNode.hpp b/lib/ArduinoJson/src/ArduinoJson/Memory/StringNode.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Memory/StringPool.hpp b/lib/ArduinoJson/src/ArduinoJson/Memory/StringPool.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Memory/VariantPool.hpp b/lib/ArduinoJson/src/ArduinoJson/Memory/VariantPool.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Memory/VariantPoolImpl.hpp b/lib/ArduinoJson/src/ArduinoJson/Memory/VariantPoolImpl.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Memory/VariantPoolList.hpp b/lib/ArduinoJson/src/ArduinoJson/Memory/VariantPoolList.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Misc/SerializedValue.hpp b/lib/ArduinoJson/src/ArduinoJson/Misc/SerializedValue.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp old mode 100644 new mode 100755 index 5c3fc24ea..15c5a0e32 --- a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp @@ -59,10 +59,14 @@ class MsgPackSerializer : public VariantDataVisitor { writeByte(0xDD); writeInteger(uint32_t(n)); } - for (auto it = array.createIterator(resources_); !it.done(); - it.next(resources_)) { - it->accept(*this); + + auto slotId = array.head(); + while (slotId != NULL_SLOT) { + auto slot = resources_->getSlot(slotId); + slot->data()->accept(*this); + slotId = slot->next(); } + return bytesWritten(); } @@ -77,11 +81,15 @@ class MsgPackSerializer : public VariantDataVisitor { writeByte(0xDF); writeInteger(uint32_t(n)); } - for (auto it = object.createIterator(resources_); !it.done(); - it.next(resources_)) { - visit(it.key()); - it->accept(*this); + + auto slotId = object.head(); + while (slotId != NULL_SLOT) { + auto slot = resources_->getSlot(slotId); + visit(slot->key()); + slot->data()->accept(*this); + slotId = slot->next(); } + return bytesWritten(); } diff --git a/lib/ArduinoJson/src/ArduinoJson/MsgPack/endianess.hpp b/lib/ArduinoJson/src/ArduinoJson/MsgPack/endianess.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/MsgPack/ieee754.hpp b/lib/ArduinoJson/src/ArduinoJson/MsgPack/ieee754.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Namespace.hpp b/lib/ArduinoJson/src/ArduinoJson/Namespace.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatParts.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatParts.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonFloat.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonFloat.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonInteger.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonInteger.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/arithmeticCompare.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/arithmeticCompare.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/convertNumber.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/convertNumber.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Object/JsonObject.hpp b/lib/ArduinoJson/src/ArduinoJson/Object/JsonObject.hpp old mode 100644 new mode 100755 index 096afa87b..e4e7dee4a --- a/lib/ArduinoJson/src/ArduinoJson/Object/JsonObject.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Object/JsonObject.hpp @@ -20,11 +20,10 @@ class JsonObject : public detail::VariantOperators { typedef JsonObjectIterator iterator; // Creates an unbound reference. - FORCE_INLINE JsonObject() : data_(0), resources_(0) {} + JsonObject() : data_(0), resources_(0) {} // INTERNAL USE ONLY - FORCE_INLINE JsonObject(detail::ObjectData* data, - detail::ResourceManager* resource) + JsonObject(detail::ObjectData* data, detail::ResourceManager* resource) : data_(data), resources_(resource) {} operator JsonVariant() const { @@ -43,31 +42,31 @@ class JsonObject : public detail::VariantOperators { // Returns true if the reference is unbound. // https://arduinojson.org/v7/api/jsonobject/isnull/ - FORCE_INLINE bool isNull() const { + bool isNull() const { return data_ == 0; } // Returns true if the reference is bound. // https://arduinojson.org/v7/api/jsonobject/isnull/ - FORCE_INLINE operator bool() const { + operator bool() const { return data_ != 0; } // Returns the depth (nesting level) of the object. // https://arduinojson.org/v7/api/jsonobject/nesting/ - FORCE_INLINE size_t nesting() const { + size_t nesting() const { return detail::VariantData::nesting(collectionToVariant(data_), resources_); } // Returns the number of members in the object. // https://arduinojson.org/v7/api/jsonobject/size/ - FORCE_INLINE size_t size() const { + size_t size() const { return data_ ? data_->size(resources_) : 0; } // Returns an iterator to the first key-value pair of the object. // https://arduinojson.org/v7/api/jsonobject/begin/ - FORCE_INLINE iterator begin() const { + iterator begin() const { if (!data_) return iterator(); return iterator(data_->createIterator(resources_), resources_); @@ -75,7 +74,7 @@ class JsonObject : public detail::VariantOperators { // Returns an iterator following the last key-value pair of the object. // https://arduinojson.org/v7/api/jsonobject/end/ - FORCE_INLINE iterator end() const { + iterator end() const { return iterator(); } @@ -87,7 +86,7 @@ class JsonObject : public detail::VariantOperators { // Copies an object. // https://arduinojson.org/v7/api/jsonobject/set/ - FORCE_INLINE bool set(JsonObjectConst src) { + bool set(JsonObjectConst src) { if (!data_ || !src.data_) return false; @@ -103,20 +102,20 @@ class JsonObject : public detail::VariantOperators { // Gets or sets the member with specified key. // https://arduinojson.org/v7/api/jsonobject/subscript/ template - FORCE_INLINE - typename detail::enable_if::value, - detail::MemberProxy>::type - operator[](const TString& key) const { + + typename detail::enable_if::value, + detail::MemberProxy>::type + operator[](const TString& key) const { return {*this, key}; } // Gets or sets the member with specified key. // https://arduinojson.org/v7/api/jsonobject/subscript/ template - FORCE_INLINE - typename detail::enable_if::value, - detail::MemberProxy>::type - operator[](TChar* key) const { + + typename detail::enable_if::value, + detail::MemberProxy>::type + operator[](TChar* key) const { return {*this, key}; } @@ -145,9 +144,9 @@ class JsonObject : public detail::VariantOperators { // Returns true if the object contains the specified key. // https://arduinojson.org/v7/api/jsonobject/containskey/ template - FORCE_INLINE - typename detail::enable_if::value, bool>::type - containsKey(const TString& key) const { + + typename detail::enable_if::value, bool>::type + containsKey(const TString& key) const { return detail::ObjectData::getMember(data_, detail::adaptString(key), resources_) != 0; } @@ -155,9 +154,9 @@ class JsonObject : public detail::VariantOperators { // Returns true if the object contains the specified key. // https://arduinojson.org/v7/api/jsonobject/containskey/ template - FORCE_INLINE - typename detail::enable_if::value, bool>::type - containsKey(TChar* key) const { + + typename detail::enable_if::value, bool>::type + containsKey(TChar* key) const { return detail::ObjectData::getMember(data_, detail::adaptString(key), resources_) != 0; } diff --git a/lib/ArduinoJson/src/ArduinoJson/Object/JsonObjectConst.hpp b/lib/ArduinoJson/src/ArduinoJson/Object/JsonObjectConst.hpp old mode 100644 new mode 100755 index 8f2c8bb10..908fa275d --- a/lib/ArduinoJson/src/ArduinoJson/Object/JsonObjectConst.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Object/JsonObjectConst.hpp @@ -32,31 +32,31 @@ class JsonObjectConst : public detail::VariantOperators { // Returns true if the reference is unbound. // https://arduinojson.org/v7/api/jsonobjectconst/isnull/ - FORCE_INLINE bool isNull() const { + bool isNull() const { return data_ == 0; } // Returns true if the reference is bound. // https://arduinojson.org/v7/api/jsonobjectconst/isnull/ - FORCE_INLINE operator bool() const { + operator bool() const { return data_ != 0; } // Returns the depth (nesting level) of the object. // https://arduinojson.org/v7/api/jsonobjectconst/nesting/ - FORCE_INLINE size_t nesting() const { + size_t nesting() const { return detail::VariantData::nesting(getData(), resources_); } // Returns the number of members in the object. // https://arduinojson.org/v7/api/jsonobjectconst/size/ - FORCE_INLINE size_t size() const { + size_t size() const { return data_ ? data_->size(resources_) : 0; } // Returns an iterator to the first key-value pair of the object. // https://arduinojson.org/v7/api/jsonobjectconst/begin/ - FORCE_INLINE iterator begin() const { + iterator begin() const { if (!data_) return iterator(); return iterator(data_->createIterator(resources_), resources_); @@ -64,14 +64,14 @@ class JsonObjectConst : public detail::VariantOperators { // Returns an iterator following the last key-value pair of the object. // https://arduinojson.org/v7/api/jsonobjectconst/end/ - FORCE_INLINE iterator end() const { + iterator end() const { return iterator(); } // Returns true if the object contains the specified key. // https://arduinojson.org/v7/api/jsonobjectconst/containskey/ template - FORCE_INLINE bool containsKey(const TString& key) const { + bool containsKey(const TString& key) const { return detail::ObjectData::getMember(data_, detail::adaptString(key), resources_) != 0; } @@ -79,7 +79,7 @@ class JsonObjectConst : public detail::VariantOperators { // Returns true if the object contains the specified key. // https://arduinojson.org/v7/api/jsonobjectconst/containskey/ template - FORCE_INLINE bool containsKey(TChar* key) const { + bool containsKey(TChar* key) const { return detail::ObjectData::getMember(data_, detail::adaptString(key), resources_) != 0; } @@ -87,8 +87,8 @@ class JsonObjectConst : public detail::VariantOperators { // Gets the member with specified key. // https://arduinojson.org/v7/api/jsonobjectconst/subscript/ template - FORCE_INLINE typename detail::enable_if::value, - JsonVariantConst>::type + typename detail::enable_if::value, + JsonVariantConst>::type operator[](const TString& key) const { return JsonVariantConst(detail::ObjectData::getMember( data_, detail::adaptString(key), resources_), @@ -98,8 +98,8 @@ class JsonObjectConst : public detail::VariantOperators { // Gets the member with specified key. // https://arduinojson.org/v7/api/jsonobjectconst/subscript/ template - FORCE_INLINE typename detail::enable_if::value, - JsonVariantConst>::type + typename detail::enable_if::value, + JsonVariantConst>::type operator[](TChar* key) const { return JsonVariantConst(detail::ObjectData::getMember( data_, detail::adaptString(key), resources_), diff --git a/lib/ArduinoJson/src/ArduinoJson/Object/JsonObjectIterator.hpp b/lib/ArduinoJson/src/ArduinoJson/Object/JsonObjectIterator.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Object/JsonPair.hpp b/lib/ArduinoJson/src/ArduinoJson/Object/JsonPair.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp b/lib/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp old mode 100644 new mode 100755 index 2a56f6dae..eb9feedeb --- a/lib/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp @@ -17,41 +17,41 @@ class MemberProxy friend class VariantAttorney; public: - FORCE_INLINE MemberProxy(TUpstream upstream, TStringRef key) + MemberProxy(TUpstream upstream, TStringRef key) : upstream_(upstream), key_(key) {} MemberProxy(const MemberProxy& src) : upstream_(src.upstream_), key_(src.key_) {} - FORCE_INLINE MemberProxy& operator=(const MemberProxy& src) { + MemberProxy& operator=(const MemberProxy& src) { this->set(src); return *this; } template - FORCE_INLINE MemberProxy& operator=(const T& src) { + MemberProxy& operator=(const T& src) { this->set(src); return *this; } template - FORCE_INLINE MemberProxy& operator=(T* src) { + MemberProxy& operator=(T* src) { this->set(src); return *this; } private: - FORCE_INLINE ResourceManager* getResourceManager() const { + ResourceManager* getResourceManager() const { return VariantAttorney::getResourceManager(upstream_); } - FORCE_INLINE VariantData* getData() const { + VariantData* getData() const { return VariantData::getMember( VariantAttorney::getData(upstream_), adaptString(key_), VariantAttorney::getResourceManager(upstream_)); } - FORCE_INLINE VariantData* getOrCreateData() const { + VariantData* getOrCreateData() const { auto data = VariantAttorney::getOrCreateData(upstream_); if (!data) return nullptr; diff --git a/lib/ArduinoJson/src/ArduinoJson/Object/ObjectData.hpp b/lib/ArduinoJson/src/ArduinoJson/Object/ObjectData.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Object/ObjectImpl.hpp b/lib/ArduinoJson/src/ArduinoJson/Object/ObjectImpl.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/alias_cast.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/alias_cast.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/assert.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/assert.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/attributes.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/attributes.hpp old mode 100644 new mode 100755 index 2eaaa57cf..268026f21 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/attributes.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/attributes.hpp @@ -7,7 +7,6 @@ #ifdef _MSC_VER // Visual Studio # define FORCE_INLINE // __forceinline causes C4714 when returning std::string -# define NO_INLINE __declspec(noinline) # ifndef ARDUINOJSON_DEPRECATED # define ARDUINOJSON_DEPRECATED(msg) __declspec(deprecated(msg)) @@ -16,7 +15,6 @@ #elif defined(__GNUC__) // GCC or Clang # define FORCE_INLINE __attribute__((always_inline)) -# define NO_INLINE __attribute__((noinline)) # ifndef ARDUINOJSON_DEPRECATED # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) @@ -29,7 +27,6 @@ #else // Other compilers # define FORCE_INLINE -# define NO_INLINE # ifndef ARDUINOJSON_DEPRECATED # define ARDUINOJSON_DEPRECATED(msg) diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/ctype.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/ctype.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/limits.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/limits.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/math.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/math.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/mpl/max.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/mpl/max.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/preprocessor.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/preprocessor.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/conditional.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/conditional.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/declval.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/declval.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/enable_if.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/enable_if.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_array.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_array.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_class.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_class.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_const.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_const.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_enum.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_enum.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_integral.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_integral.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_pointer.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_pointer.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_same.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_same.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_signed.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_signed.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_unsigned.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_unsigned.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_unsigned.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_unsigned.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_void.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_void.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_const.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_const.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/type_identity.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/type_identity.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/utility.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/utility.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Serialization/CountingDecorator.hpp b/lib/ArduinoJson/src/ArduinoJson/Serialization/CountingDecorator.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Serialization/Writer.hpp b/lib/ArduinoJson/src/ArduinoJson/Serialization/Writer.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/ArduinoStringWriter.hpp b/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/ArduinoStringWriter.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/DummyWriter.hpp b/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/DummyWriter.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/PrintWriter.hpp b/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/PrintWriter.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/StaticStringWriter.hpp b/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/StaticStringWriter.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStreamWriter.hpp b/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStreamWriter.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStringWriter.hpp b/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStringWriter.hpp old mode 100644 new mode 100755 index 46dc8ba55..6ac4d9738 --- a/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStringWriter.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStringWriter.hpp @@ -9,15 +9,13 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE -template -using void_t = void; - template struct is_std_string : false_type {}; template struct is_std_string< - T, void_t> + T, typename enable_if::value && + is_same::value>::type> : true_type {}; template diff --git a/lib/ArduinoJson/src/ArduinoJson/Serialization/measure.hpp b/lib/ArduinoJson/src/ArduinoJson/Serialization/measure.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp b/lib/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashString.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashString.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonString.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonString.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamString.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamString.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringObject.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringObject.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/IsString.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/IsString.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/JsonString.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/JsonString.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/StringAdapter.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/StringAdapter.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/StringAdapters.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/StringAdapters.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/StringTraits.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/StringTraits.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/Converter.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/Converter.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp old mode 100644 new mode 100755 index cc89687ee..8e35f72b5 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp @@ -21,6 +21,10 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE template struct Converter { + static_assert(!detail::is_same::value, + "type 'char' is not supported, use 'signed char', 'unsigned " + "char' or another integer type instead"); + static void toJson(const T& src, JsonVariant dst) { // clang-format off convertToJson(src, dst); // Error here? See https://arduinojson.org/v7/unsupported-set/ @@ -28,6 +32,9 @@ struct Converter { } static T fromJson(JsonVariantConst src) { + static_assert(!detail::is_same::value, + "type 'char*' is not supported, use 'const char*' instead"); + // clang-format off T result; // Error here? See https://arduinojson.org/v7/non-default-constructible/ convertFromJson(src, result); // Error here? See https://arduinojson.org/v7/unsupported-as/ @@ -36,6 +43,9 @@ struct Converter { } static bool checkJson(JsonVariantConst src) { + static_assert(!detail::is_same::value, + "type 'char*' is not supported, use 'const char*' instead"); + T dummy = T(); // clang-format off return canConvertFromJson(src, dummy); // Error here? See https://arduinojson.org/v7/unsupported-is/ diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariant.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariant.hpp old mode 100644 new mode 100755 index f38963c1b..5039c38ae --- a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariant.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariant.hpp @@ -23,15 +23,15 @@ class JsonVariant : public detail::VariantRefBase, : data_(data), resources_(resources) {} private: - FORCE_INLINE detail::ResourceManager* getResourceManager() const { + detail::ResourceManager* getResourceManager() const { return resources_; } - FORCE_INLINE detail::VariantData* getData() const { + detail::VariantData* getData() const { return data_; } - FORCE_INLINE detail::VariantData* getOrCreateData() const { + detail::VariantData* getOrCreateData() const { return data_; } diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantConst.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantConst.hpp old mode 100644 new mode 100755 index 8ff741110..7e7b8c0d8 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantConst.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantConst.hpp @@ -38,18 +38,18 @@ class JsonVariantConst : public detail::VariantTag, // Returns true if the value is null or the reference is unbound. // https://arduinojson.org/v7/api/jsonvariantconst/isnull/ - FORCE_INLINE bool isNull() const { + bool isNull() const { return detail::VariantData::isNull(data_); } // Returns true if the reference is unbound. - FORCE_INLINE bool isUnbound() const { + bool isUnbound() const { return !data_; } // Returns the depth (nesting level) of the value. // https://arduinojson.org/v7/api/jsonvariantconst/nesting/ - FORCE_INLINE size_t nesting() const { + size_t nesting() const { return detail::VariantData::nesting(data_, resources_); } @@ -62,9 +62,9 @@ class JsonVariantConst : public detail::VariantTag, // Casts the value to the specified type. // https://arduinojson.org/v7/api/jsonvariantconst/as/ template - FORCE_INLINE typename detail::enable_if::value && - !detail::is_same::value, - T>::type + typename detail::enable_if::value && + !detail::is_same::value, + T>::type as() const { return Converter::fromJson(*this); } @@ -72,21 +72,21 @@ class JsonVariantConst : public detail::VariantTag, // Returns true if the value is of the specified type. // https://arduinojson.org/v7/api/jsonvariantconst/is/ template - FORCE_INLINE typename detail::enable_if::value && - !detail::is_same::value, - bool>::type + typename detail::enable_if::value && + !detail::is_same::value, + bool>::type is() const { return Converter::checkJson(*this); } template - FORCE_INLINE operator T() const { + operator T() const { return as(); } // Gets array's element at specified index. // https://arduinojson.org/v7/api/jsonvariantconst/subscript/ - FORCE_INLINE JsonVariantConst operator[](size_t index) const { + JsonVariantConst operator[](size_t index) const { return JsonVariantConst( detail::VariantData::getElement(data_, index, resources_), resources_); } @@ -94,8 +94,8 @@ class JsonVariantConst : public detail::VariantTag, // Gets object's member with specified key. // https://arduinojson.org/v7/api/jsonvariantconst/subscript/ template - FORCE_INLINE typename detail::enable_if::value, - JsonVariantConst>::type + typename detail::enable_if::value, + JsonVariantConst>::type operator[](const TString& key) const { return JsonVariantConst(detail::VariantData::getMember( data_, detail::adaptString(key), resources_), @@ -105,8 +105,8 @@ class JsonVariantConst : public detail::VariantTag, // Gets object's member with specified key. // https://arduinojson.org/v7/api/jsonvariantconst/subscript/ template - FORCE_INLINE typename detail::enable_if::value, - JsonVariantConst>::type + typename detail::enable_if::value, + JsonVariantConst>::type operator[](TChar* key) const { return JsonVariantConst(detail::VariantData::getMember( data_, detail::adaptString(key), resources_), @@ -116,9 +116,9 @@ class JsonVariantConst : public detail::VariantTag, // Returns true if tge object contains the specified key. // https://arduinojson.org/v7/api/jsonvariantconst/containskey/ template - FORCE_INLINE - typename detail::enable_if::value, bool>::type - containsKey(const TString& key) const { + + typename detail::enable_if::value, bool>::type + containsKey(const TString& key) const { return detail::VariantData::getMember(getData(), detail::adaptString(key), resources_) != 0; } @@ -126,9 +126,9 @@ class JsonVariantConst : public detail::VariantTag, // Returns true if tge object contains the specified key. // https://arduinojson.org/v7/api/jsonvariantconst/containskey/ template - FORCE_INLINE - typename detail::enable_if::value, bool>::type - containsKey(TChar* key) const { + + typename detail::enable_if::value, bool>::type + containsKey(TChar* key) const { return detail::VariantData::getMember(getData(), detail::adaptString(key), resources_) != 0; } diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantCopier.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantCopier.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantVisitor.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantVisitor.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantAttorney.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantAttorney.hpp old mode 100644 new mode 100755 index 24f22dda5..b75eb3806 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantAttorney.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantAttorney.hpp @@ -16,19 +16,18 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE class VariantAttorney { public: template - FORCE_INLINE static auto getResourceManager(TClient& client) + static auto getResourceManager(TClient& client) -> decltype(client.getResourceManager()) { return client.getResourceManager(); } template - FORCE_INLINE static auto getData(TClient& client) - -> decltype(client.getData()) { + static auto getData(TClient& client) -> decltype(client.getData()) { return client.getData(); } template - FORCE_INLINE static VariantData* getOrCreateData(TClient& client) { + static VariantData* getOrCreateData(TClient& client) { return client.getOrCreateData(); } }; diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantContent.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantContent.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantDataVisitor.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantDataVisitor.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantOperators.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantOperators.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp old mode 100644 new mode 100755 index c81334af2..318915e8d --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp @@ -28,39 +28,38 @@ class VariantRefBase : public VariantTag { public: // Sets the value to null. // https://arduinojson.org/v7/api/jsonvariant/clear/ - FORCE_INLINE void clear() const { + void clear() const { VariantData::setNull(getOrCreateData(), getResourceManager()); } // Returns true if the value is null or the reference is unbound. // https://arduinojson.org/v7/api/jsonvariant/isnull/ - FORCE_INLINE bool isNull() const { + bool isNull() const { return VariantData::isNull(getData()); } // Returns true if the reference is unbound. - FORCE_INLINE bool isUnbound() const { + bool isUnbound() const { return !getData(); } // Casts the value to the specified type. // https://arduinojson.org/v7/api/jsonvariant/as/ template - FORCE_INLINE - typename enable_if::value, T>::type - as() const { + + typename enable_if::value, T>::type as() + const { return Converter::fromJson(getVariantConst()); } // Casts the value to the specified type. // https://arduinojson.org/v7/api/jsonvariant/as/ template - FORCE_INLINE typename enable_if::value, T>::type - as() const; + typename enable_if::value, T>::type as() const; template ::value>::type> - FORCE_INLINE operator T() const { + operator T() const { return as(); } @@ -91,33 +90,31 @@ class VariantRefBase : public VariantTag { // Returns true if the value is of the specified type. // https://arduinojson.org/v7/api/jsonvariant/is/ template - FORCE_INLINE typename enable_if::value && - !is_same::value && - !is_same::value, - bool>::type - is() const { + FORCE_INLINE + typename enable_if::value, bool>::type + is() const { return Converter::checkJson(getVariantConst()); } // Copies the specified value. // https://arduinojson.org/v7/api/jsonvariant/set/ template - FORCE_INLINE bool set(const T& value) const; + bool set(const T& value) const; // Copies the specified value. // https://arduinojson.org/v7/api/jsonvariant/set/ template - FORCE_INLINE bool set(T* value) const; + bool set(T* value) const; // Returns the size of the array or object. // https://arduinojson.org/v7/api/jsonvariant/size/ - FORCE_INLINE size_t size() const { + size_t size() const { return VariantData::size(getData(), getResourceManager()); } // Returns the depth (nesting level) of the value. // https://arduinojson.org/v7/api/jsonvariant/nesting/ - FORCE_INLINE size_t nesting() const { + size_t nesting() const { return VariantData::nesting(getData(), getResourceManager()); } @@ -138,28 +135,27 @@ class VariantRefBase : public VariantTag { // Appends a value to the array. // https://arduinojson.org/v7/api/jsonvariant/add/ template - FORCE_INLINE bool add(const T& value) const { + bool add(const T& value) const { return add().set(value); } // Appends a value to the array. // https://arduinojson.org/v7/api/jsonvariant/add/ template - FORCE_INLINE bool add(T* value) const { + bool add(T* value) const { return add().set(value); } // Removes an element of the array. // https://arduinojson.org/v7/api/jsonvariant/remove/ - FORCE_INLINE void remove(size_t index) const { + void remove(size_t index) const { VariantData::removeElement(getData(), index, getResourceManager()); } // Removes a member of the object. // https://arduinojson.org/v7/api/jsonvariant/remove/ template - FORCE_INLINE typename enable_if::value>::type remove( - TChar* key) const { + typename enable_if::value>::type remove(TChar* key) const { VariantData::removeMember(getData(), adaptString(key), getResourceManager()); } @@ -167,7 +163,7 @@ class VariantRefBase : public VariantTag { // Removes a member of the object. // https://arduinojson.org/v7/api/jsonvariant/remove/ template - FORCE_INLINE typename enable_if::value>::type remove( + typename enable_if::value>::type remove( const TString& key) const { VariantData::removeMember(getData(), adaptString(key), getResourceManager()); @@ -175,19 +171,19 @@ class VariantRefBase : public VariantTag { // Gets or sets an array element. // https://arduinojson.org/v7/api/jsonvariant/subscript/ - FORCE_INLINE ElementProxy operator[](size_t index) const; + ElementProxy operator[](size_t index) const; // Returns true if the object contains the specified key. // https://arduinojson.org/v7/api/jsonvariant/containskey/ template - FORCE_INLINE typename enable_if::value, bool>::type - containsKey(const TString& key) const; + typename enable_if::value, bool>::type containsKey( + const TString& key) const; // Returns true if the object contains the specified key. // https://arduinojson.org/v7/api/jsonvariant/containskey/ template - FORCE_INLINE typename enable_if::value, bool>::type - containsKey(TChar* key) const; + typename enable_if::value, bool>::type containsKey( + TChar* key) const; // Gets or sets an object member. // https://arduinojson.org/v7/api/jsonvariant/subscript/ @@ -256,15 +252,15 @@ class VariantRefBase : public VariantTag { return static_cast(*this); } - FORCE_INLINE ResourceManager* getResourceManager() const { + ResourceManager* getResourceManager() const { return VariantAttorney::getResourceManager(derived()); } - FORCE_INLINE VariantData* getData() const { + VariantData* getData() const { return VariantAttorney::getData(derived()); } - FORCE_INLINE VariantData* getOrCreateData() const { + VariantData* getOrCreateData() const { return VariantAttorney::getOrCreateData(derived()); } @@ -274,7 +270,7 @@ class VariantRefBase : public VariantTag { return ArduinoJson::JsonVariantConst(getData(), getResourceManager()); } - FORCE_INLINE ArduinoJson::JsonVariant getOrCreateVariant() const; + ArduinoJson::JsonVariant getOrCreateVariant() const; }; ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBaseImpl.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBaseImpl.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantSlot.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantSlot.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTag.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTag.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTo.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTo.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/compatibility.hpp b/lib/ArduinoJson/src/ArduinoJson/compatibility.hpp old mode 100644 new mode 100755 diff --git a/lib/ArduinoJson/src/ArduinoJson/version.hpp b/lib/ArduinoJson/src/ArduinoJson/version.hpp old mode 100644 new mode 100755 index e41890e9f..dc1215a6d --- a/lib/ArduinoJson/src/ArduinoJson/version.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/version.hpp @@ -4,8 +4,8 @@ #pragma once -#define ARDUINOJSON_VERSION "7.0.2" +#define ARDUINOJSON_VERSION "7.0.3" #define ARDUINOJSON_VERSION_MAJOR 7 #define ARDUINOJSON_VERSION_MINOR 0 -#define ARDUINOJSON_VERSION_REVISION 2 -#define ARDUINOJSON_VERSION_MACRO V702 +#define ARDUINOJSON_VERSION_REVISION 3 +#define ARDUINOJSON_VERSION_MACRO V703 diff --git a/lib/ArduinoJson/src/CMakeLists.txt b/lib/ArduinoJson/src/CMakeLists.txt deleted file mode 100644 index cc782e702..000000000 --- a/lib/ArduinoJson/src/CMakeLists.txt +++ /dev/null @@ -1,91 +0,0 @@ -# ArduinoJson - https://arduinojson.org -# Copyright © 2014-2024, Benoit BLANCHON -# MIT License - -# I have no idea what this is about, I simply followed the instructions from: -# https://dominikberner.ch/cmake-interface-lib/ - -add_library(ArduinoJson INTERFACE) - -include(GNUInstallDirs) - -# Adding the install interface generator expression makes sure that the include -# files are installed to the proper location (provided by GNUInstallDirs) -target_include_directories(ArduinoJson - INTERFACE - $ - $ -) - -target_compile_definitions(ArduinoJson - INTERFACE - ARDUINOJSON_DEBUG=$ -) - -# locations are provided by GNUInstallDirs -install( - TARGETS - ArduinoJson - EXPORT - ArduinoJson_Targets - ARCHIVE DESTINATION - ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION - ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION - ${CMAKE_INSTALL_BINDIR} -) - -include(CMakePackageConfigHelpers) - -if(${CMAKE_VERSION} VERSION_GREATER "3.14.0") - set(ARCH_INDEPENDENT "ARCH_INDEPENDENT") -endif() - -write_basic_package_version_file( - "${PROJECT_BINARY_DIR}/ArduinoJsonConfigVersion.cmake" - VERSION - ${PROJECT_VERSION} - COMPATIBILITY - SameMajorVersion - ${ARCH_INDEPENDENT} -) - -configure_package_config_file( - "${PROJECT_SOURCE_DIR}/extras/ArduinoJsonConfig.cmake.in" - "${PROJECT_BINARY_DIR}/ArduinoJsonConfig.cmake" - INSTALL_DESTINATION - ${CMAKE_INSTALL_DATAROOTDIR}/ArduinoJson/cmake -) - -install( - EXPORT - ArduinoJson_Targets - FILE - ArduinoJsonTargets.cmake - DESTINATION - ${CMAKE_INSTALL_DATAROOTDIR}/ArduinoJson/cmake -) - -install( - FILES - "${PROJECT_BINARY_DIR}/ArduinoJsonConfig.cmake" - "${PROJECT_BINARY_DIR}/ArduinoJsonConfigVersion.cmake" - DESTINATION - "${CMAKE_INSTALL_DATAROOTDIR}/ArduinoJson/cmake" -) - -install( - FILES - ArduinoJson.h - ArduinoJson.hpp - DESTINATION - include -) - -install( - DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}/ArduinoJson" - DESTINATION - include -) diff --git a/lib/AsyncTCP/library.json b/lib/AsyncTCP/library.json deleted file mode 100644 index e6befd42b..000000000 --- a/lib/AsyncTCP/library.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "AsyncTCP-esphome", - "description": "Asynchronous TCP Library for ESP32", - "keywords": "async,tcp", - "authors": { - "name": "Hristo Gochkov", - "maintainer": true - }, - "repository": { - "type": "git", - "url": "https://github.com/esphome/AsyncTCP.git" - }, - "version": "2.1.1", - "license": "LGPL-3.0", - "frameworks": "arduino", - "platforms": [ - "espressif32", - "libretiny" - ], - "build": { - "libCompatMode": 2 - } -} diff --git a/lib/ESPAsyncWebServer/library.json b/lib/ESPAsyncWebServer/library.json deleted file mode 100644 index 94271bdd4..000000000 --- a/lib/ESPAsyncWebServer/library.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "ESP Async WebServer", - "version": "2.6.1", - "description": "Asynchronous HTTP and WebSocket Server Library for ESP32. Supports: WebSocket, SSE, Authentication, Arduino Json 7, File Upload, Static File serving, URL Rewrite, URL Redirect, etc.", - "keywords": "http,async,websocket,webserver", - "homepage": "https://github.com/mathieucarbou/ESPAsyncWebServer", - "repository": { - "type": "git", - "url": "https://github.com/mathieucarbou/ESPAsyncWebServer.git" - }, - "authors": [ - { - "name": "Hristo Gochkov" - }, - { - "name": "Mathieu Carbou", - "maintainer": true - } - ], - "license": "LGPL-3.0", - "frameworks": "arduino", - "platforms": [ - "espressif32" - ], - "dependencies": [ - { - "owner": "esphome", - "name": "AsyncTCP-esphome", - "version": "^2.1.1", - "platforms": "espressif32" - } - ], - "export": { - "include": [ - "examples", - "src", - "library.json", - "library.properties", - "LICENSE", - "README.md" - ] - } -} \ No newline at end of file diff --git a/lib/ESPAsyncWebServer/src/AsyncJson.h b/lib/ESPAsyncWebServer/src/AsyncJson.h index 7c8e278e4..207200519 100644 --- a/lib/ESPAsyncWebServer/src/AsyncJson.h +++ b/lib/ESPAsyncWebServer/src/AsyncJson.h @@ -1,55 +1,14 @@ // AsyncJson.h -/* - Async Response to use with ArduinoJson and AsyncWebServer - Written by Andrew Melvin (SticilFace) with help from me-no-dev and BBlanchon. - Example of callback in use - - server.on("/json", HTTP_ANY, [](AsyncWebServerRequest * request) { - - AsyncJsonResponse * response = new AsyncJsonResponse(); - JsonObject& root = response->getRoot(); - root["key1"] = "key number one"; - JsonObject& nested = root.createNestedObject("nested"); - nested["key1"] = "key number one"; - - response->setLength(); - request->send(response); - }); - - -------------------- - - Async Request to use with ArduinoJson and AsyncWebServer - Written by Arsène von Wyss (avonwyss) - - Example - - AsyncCallbackJsonWebHandler* handler = new AsyncCallbackJsonWebHandler("/rest/endpoint"); - handler->onRequest([](AsyncWebServerRequest *request, JsonVariant &json) { - JsonObject& jsonObj = json.as(); - // ... - }); - server.addHandler(handler); - -*/ #ifndef ASYNC_JSON_H_ #define ASYNC_JSON_H_ + #include #include #include -#if ARDUINOJSON_VERSION_MAJOR == 6 -#ifndef DYNAMIC_JSON_DOCUMENT_SIZE -#define DYNAMIC_JSON_DOCUMENT_SIZE 1024 -#endif -#endif - constexpr const char * JSON_MIMETYPE = "application/json"; -/* - * Json Response - * */ - class ChunkPrint : public Print { private: uint8_t * _destination; @@ -82,89 +41,18 @@ class ChunkPrint : public Print { } }; -// added by Proddy -class MsgpackAsyncJsonResponse : public AsyncAbstractResponse { +// added msgPack by Proddy +class AsyncJsonResponse : public AsyncAbstractResponse { protected: JsonDocument _jsonBuffer; JsonVariant _root; bool _isValid; + bool _isMsgPack; public: - MsgpackAsyncJsonResponse(bool isArray = false) - : _isValid{false} { - _code = 200; - _contentType = JSON_MIMETYPE; - if (isArray) - _root = _jsonBuffer.to(); - else - _root = _jsonBuffer.add(); - } - - ~MsgpackAsyncJsonResponse() { - } - JsonVariant getRoot() { - return _root; - } - bool _sourceValid() const { - return _isValid; - } - size_t setLength() { - _contentLength = measureMsgPack(_root); - if (_contentLength) { - _isValid = true; - } - return _contentLength; - } - - size_t getSize() { - return _jsonBuffer.size(); - } - - size_t _fillBuffer(uint8_t * data, size_t len) { - ChunkPrint dest(data, _sentLength, len); - serializeMsgPack(_root, dest); - return len; - } -}; - -class AsyncJsonResponse : public AsyncAbstractResponse { - protected: -#if ARDUINOJSON_VERSION_MAJOR == 5 - DynamicJsonBuffer _jsonBuffer; -#elif ARDUINOJSON_VERSION_MAJOR == 6 - DynamicJsonDocument _jsonBuffer; -#else - JsonDocument _jsonBuffer; -#endif - - JsonVariant _root; - bool _isValid; - - public: -#if ARDUINOJSON_VERSION_MAJOR == 5 - AsyncJsonResponse(bool isArray = false) - : _isValid{false} { - _code = 200; - _contentType = JSON_MIMETYPE; - if (isArray) - _root = _jsonBuffer.createArray(); - else - _root = _jsonBuffer.createObject(); - } -#elif ARDUINOJSON_VERSION_MAJOR == 6 - AsyncJsonResponse(bool isArray = false, size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE) - : _jsonBuffer(maxJsonBufferSize) - , _isValid{false} { - _code = 200; - _contentType = JSON_MIMETYPE; - if (isArray) - _root = _jsonBuffer.createNestedArray(); - else - _root = _jsonBuffer.createNestedObject(); - } -#else - AsyncJsonResponse(bool isArray = false) - : _isValid{false} { + AsyncJsonResponse(bool isArray = false, bool isMsgPack = false) + : _isValid{false} + , _isMsgPack{isMsgPack} { _code = 200; _contentType = JSON_MIMETYPE; if (isArray) @@ -172,7 +60,6 @@ class AsyncJsonResponse : public AsyncAbstractResponse { else _root = _jsonBuffer.add(); } -#endif ~AsyncJsonResponse() { } @@ -183,11 +70,7 @@ class AsyncJsonResponse : public AsyncAbstractResponse { return _isValid; } size_t setLength() { -#if ARDUINOJSON_VERSION_MAJOR == 5 - _contentLength = _root.measureLength(); -#else - _contentLength = measureJson(_root); -#endif + _contentLength = _isMsgPack ? measureMsgPack(_root) : measureJson(_root); if (_contentLength) { _isValid = true; @@ -201,33 +84,18 @@ class AsyncJsonResponse : public AsyncAbstractResponse { size_t _fillBuffer(uint8_t * data, size_t len) { ChunkPrint dest(data, _sentLength, len); - -#if ARDUINOJSON_VERSION_MAJOR == 5 - _root.printTo(dest); -#else - serializeJson(_root, dest); -#endif + _isMsgPack ? serializeMsgPack(_root, dest) : serializeJson(_root, dest); return len; } }; class PrettyAsyncJsonResponse : public AsyncJsonResponse { public: -#if ARDUINOJSON_VERSION_MAJOR == 6 - PrettyAsyncJsonResponse(bool isArray = false, size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE) - : AsyncJsonResponse{isArray, maxJsonBufferSize} { - } -#else PrettyAsyncJsonResponse(bool isArray = false) : AsyncJsonResponse{isArray} { } -#endif size_t setLength() { -#if ARDUINOJSON_VERSION_MAJOR == 5 - _contentLength = _root.measurePrettyLength(); -#else _contentLength = measureJsonPretty(_root); -#endif if (_contentLength) { _isValid = true; } @@ -235,11 +103,7 @@ class PrettyAsyncJsonResponse : public AsyncJsonResponse { } size_t _fillBuffer(uint8_t * data, size_t len) { ChunkPrint dest(data, _sentLength, len); -#if ARDUINOJSON_VERSION_MAJOR == 5 - _root.prettyPrintTo(dest); -#else serializeJsonPretty(_root, dest); -#endif return len; } }; @@ -253,28 +117,15 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler { WebRequestMethodComposite _method; ArJsonRequestHandlerFunction _onRequest; size_t _contentLength; -#if ARDUINOJSON_VERSION_MAJOR == 6 - const size_t maxJsonBufferSize; -#endif - size_t _maxContentLength; + size_t _maxContentLength; public: -#if ARDUINOJSON_VERSION_MAJOR == 6 - AsyncCallbackJsonWebHandler(const String & uri, ArJsonRequestHandlerFunction onRequest, size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE) - : _uri(uri) - , _method(HTTP_POST | HTTP_PUT | HTTP_PATCH) - , _onRequest(onRequest) - , maxJsonBufferSize(maxJsonBufferSize) - , _maxContentLength(16384) { - } -#else AsyncCallbackJsonWebHandler(const String & uri, ArJsonRequestHandlerFunction onRequest) : _uri(uri) - , _method(HTTP_POST | HTTP_PUT | HTTP_PATCH) + , _method(HTTP_GET | HTTP_POST | HTTP_PUT | HTTP_PATCH) , _onRequest(onRequest) , _maxContentLength(16384) { } -#endif void setMethod(WebRequestMethodComposite method) { _method = method; @@ -286,6 +137,7 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler { _onRequest = fn; } + virtual bool canHandle(AsyncWebServerRequest * request) override final { if (!_onRequest) return false; @@ -305,28 +157,17 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler { virtual void handleRequest(AsyncWebServerRequest * request) override final { if (_onRequest) { + JsonVariant json; // empty variant if (request->_tempObject != NULL) { -#if ARDUINOJSON_VERSION_MAJOR == 5 - DynamicJsonBuffer jsonBuffer; - JsonVariant json = jsonBuffer.parse((uint8_t *)(request->_tempObject)); - if (json.success()) { -#elif ARDUINOJSON_VERSION_MAJOR == 6 - DynamicJsonDocument jsonBuffer(this->maxJsonBufferSize); - DeserializationError error = deserializeJson(jsonBuffer, (uint8_t *)(request->_tempObject)); - if (!error) { - JsonVariant json = jsonBuffer.as(); -#else JsonDocument jsonBuffer; DeserializationError error = deserializeJson(jsonBuffer, (uint8_t *)(request->_tempObject)); if (!error) { - JsonVariant json = jsonBuffer.as(); -#endif - + json = jsonBuffer.as(); _onRequest(request, json); return; } } - request->send(_contentLength > _maxContentLength ? 413 : 400); + _onRequest(request, json); } else { request->send(500); } diff --git a/lib/framework/APStatus.h b/lib/framework/APStatus.h index 2b7d35a04..addda2a25 100644 --- a/lib/framework/APStatus.h +++ b/lib/framework/APStatus.h @@ -10,7 +10,6 @@ #include #include -// #define MAX_AP_STATUS_SIZE 1024 #define AP_STATUS_SERVICE_PATH "/rest/apStatus" class APStatus { diff --git a/lib/framework/AuthenticationService.cpp b/lib/framework/AuthenticationService.cpp index fd316a87c..f0fc92dbb 100644 --- a/lib/framework/AuthenticationService.cpp +++ b/lib/framework/AuthenticationService.cpp @@ -2,8 +2,6 @@ using namespace std::placeholders; // for `_1` etc -#if FT_ENABLED(FT_SECURITY) - AuthenticationService::AuthenticationService(AsyncWebServer * server, SecurityManager * securityManager) : _securityManager(securityManager) , _signInHandler(SIGN_IN_PATH, std::bind(&AuthenticationService::signIn, this, _1, _2)) { @@ -43,5 +41,3 @@ void AuthenticationService::signIn(AsyncWebServerRequest * request, JsonVariant AsyncWebServerResponse * response = request->beginResponse(401); request->send(response); } - -#endif diff --git a/lib/framework/AuthenticationService.h b/lib/framework/AuthenticationService.h index d8a823485..c7ca70646 100644 --- a/lib/framework/AuthenticationService.h +++ b/lib/framework/AuthenticationService.h @@ -10,8 +10,6 @@ #define MAX_AUTHENTICATION_SIZE 256 -#if FT_ENABLED(FT_SECURITY) - class AuthenticationService { public: AuthenticationService(AsyncWebServer * server, SecurityManager * securityManager); @@ -26,5 +24,3 @@ class AuthenticationService { }; #endif - -#endif diff --git a/lib/framework/ESP8266React.cpp b/lib/framework/ESP8266React.cpp index 8fd7719da..94a3b78fd 100644 --- a/lib/framework/ESP8266React.cpp +++ b/lib/framework/ESP8266React.cpp @@ -3,8 +3,7 @@ #include ESP8266React::ESP8266React(AsyncWebServer * server, FS * fs) - : _featureService(server) - , _securitySettingsService(server, fs) + : _securitySettingsService(server, fs) , _networkSettingsService(server, fs, &_securitySettingsService) , _wifiScanner(server, &_securitySettingsService) , _networkStatus(server, &_securitySettingsService) @@ -20,12 +19,12 @@ ESP8266React::ESP8266React(AsyncWebServer * server, FS * fs) , _restartService(server, &_securitySettingsService) , _factoryResetService(server, fs, &_securitySettingsService) , _systemStatus(server, &_securitySettingsService) { - // Serve static resources from PROGMEM + // Serve static resources WWWData::registerRoutes([server, this](const String & uri, const String & contentType, const uint8_t * content, size_t len) { ArRequestHandlerFunction requestHandler = [contentType, content, len](AsyncWebServerRequest * request) { AsyncWebServerResponse * response = request->beginResponse_P(200, contentType, content, len); response->addHeader("Content-Encoding", "gzip"); - // response->addHeader("Cache-Control", "public, immutable, max-age=31536000"); + response->addHeader("Cache-Control", "public, immutable, max-age=31536000"); // response->addHeader("Content-Encoding", "br"); // only works over HTTPS request->send(response); }; diff --git a/lib/framework/ESP8266React.h b/lib/framework/ESP8266React.h index 2bab9e190..2a86019e1 100644 --- a/lib/framework/ESP8266React.h +++ b/lib/framework/ESP8266React.h @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -72,7 +71,6 @@ class ESP8266React { } private: - FeaturesService _featureService; SecuritySettingsService _securitySettingsService; NetworkSettingsService _networkSettingsService; WiFiScanner _wifiScanner; diff --git a/lib/framework/Features.h b/lib/framework/Features.h index 204caaa18..1629b39ef 100644 --- a/lib/framework/Features.h +++ b/lib/framework/Features.h @@ -1,10 +1,6 @@ #ifndef Features_h #define Features_h -// modified by Proddy - -#define FT_ENABLED(feature) feature - // project feature on by default #ifndef FT_PROJECT #define FT_PROJECT 1 diff --git a/lib/framework/FeaturesService.cpp b/lib/framework/FeaturesService.cpp deleted file mode 100644 index cddb85586..000000000 --- a/lib/framework/FeaturesService.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include "../../src/emsesp_stub.hpp" - -using namespace std::placeholders; // for `_1` etc - -FeaturesService::FeaturesService(AsyncWebServer * server) { - server->on(FEATURES_SERVICE_PATH, HTTP_GET, std::bind(&FeaturesService::features, this, _1)); -} - -void FeaturesService::features(AsyncWebServerRequest * request) { - AsyncJsonResponse * response = new AsyncJsonResponse(false); - JsonObject root = response->getRoot(); - - root["version"] = EMSESP_APP_VERSION; - root["platform"] = EMSESP_PLATFORM; - - response->setLength(); - request->send(response); -} diff --git a/lib/framework/FeaturesService.h b/lib/framework/FeaturesService.h deleted file mode 100644 index dc64a8b3d..000000000 --- a/lib/framework/FeaturesService.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef FeaturesService_h -#define FeaturesService_h - -#include - -#include -#include -#include -#include - -// #define MAX_FEATURES_SIZE 256 -#define FEATURES_SERVICE_PATH "/rest/features" - -class FeaturesService { - public: - FeaturesService(AsyncWebServer * server); - - private: - void features(AsyncWebServerRequest * request); -}; - -#endif diff --git a/lib/framework/HttpEndpoint.h b/lib/framework/HttpEndpoint.h index 3c1902583..ba57c7caf 100644 --- a/lib/framework/HttpEndpoint.h +++ b/lib/framework/HttpEndpoint.h @@ -34,55 +34,39 @@ class HttpEndpoint { , _stateUpdater(stateUpdater) , _statefulService(statefulService) { // Create the GET and POST endpoints - // We can't use HTTP_ANY and process one a single endpoint due to the way the ESPAsyncWebServer library works - // Could also use server->on() but this is more efficient - - // create the GET - GEThandler = new AsyncCallbackWebHandler(); - GEThandler->setUri(servicePath); - GEThandler->setMethod(HTTP_GET); - GEThandler->onRequest(securityManager->wrapRequest(std::bind(&HttpEndpoint::fetchSettings, this, _1), authenticationPredicate)); - server->addHandler(GEThandler); - - // create the POST - POSThandler = - new AsyncCallbackJsonWebHandler(servicePath, - securityManager->wrapCallback(std::bind(&HttpEndpoint::updateSettings, this, _1, _2), authenticationPredicate)); - POSThandler->setMethod(HTTP_POST); + POSThandler = new AsyncCallbackJsonWebHandler(servicePath, + securityManager->wrapCallback([this](AsyncWebServerRequest * request, + JsonVariant json) { handleRequest(request, json); }, + authenticationPredicate)); server->addHandler(POSThandler); } protected: // for POST - void updateSettings(AsyncWebServerRequest * request, JsonVariant json) { - if (!json.is()) { - request->send(400); - return; - } - JsonObject jsonObject = json.as(); - StateUpdateResult outcome = _statefulService->updateWithoutPropagation(jsonObject, _stateUpdater); - if (outcome == StateUpdateResult::ERROR) { - request->send(400); - return; - } else if ((outcome == StateUpdateResult::CHANGED) || (outcome == StateUpdateResult::CHANGED_RESTART)) { - request->onDisconnect([this]() { _statefulService->callUpdateHandlers(HTTP_ENDPOINT_ORIGIN_ID); }); - } - AsyncJsonResponse * response = new AsyncJsonResponse(false); - jsonObject = response->getRoot().to(); - _statefulService->read(jsonObject, _stateReader); - if (outcome == StateUpdateResult::CHANGED_RESTART) { - response->setCode(205); // reboot required - } - response->setLength(); - request->send(response); - } + void handleRequest(AsyncWebServerRequest * request, JsonVariant json) { + if (request->method() == HTTP_POST) { + // Handle POST + if (!json.is()) { + request->send(400); + return; + } + + StateUpdateResult outcome = _statefulService->updateWithoutPropagation(json.as(), _stateUpdater); + + if (outcome == StateUpdateResult::ERROR) { + request->send(400); // error + return; + } else if (outcome == StateUpdateResult::CHANGED_RESTART) { + request->send(205); // reboot required + return; + } else if (outcome == StateUpdateResult::CHANGED) { + request->onDisconnect([this]() { _statefulService->callUpdateHandlers(HTTP_ENDPOINT_ORIGIN_ID); }); + } + } - // for GET - void fetchSettings(AsyncWebServerRequest * request) { AsyncJsonResponse * response = new AsyncJsonResponse(false); JsonObject jsonObject = response->getRoot().to(); _statefulService->read(jsonObject, _stateReader); - response->setLength(); request->send(response); } diff --git a/lib/framework/MqttStatus.h b/lib/framework/MqttStatus.h index f8260bd54..eb7ba980b 100644 --- a/lib/framework/MqttStatus.h +++ b/lib/framework/MqttStatus.h @@ -7,7 +7,6 @@ #include #include -// #define MAX_MQTT_STATUS_SIZE 1024 #define MQTT_STATUS_SERVICE_PATH "/rest/mqttStatus" class MqttStatus { diff --git a/lib/framework/NTPStatus.h b/lib/framework/NTPStatus.h index 152933fe3..2dec0a9f4 100644 --- a/lib/framework/NTPStatus.h +++ b/lib/framework/NTPStatus.h @@ -11,7 +11,6 @@ #include #include -// #define MAX_NTP_STATUS_SIZE 1024 #define NTP_STATUS_SERVICE_PATH "/rest/ntpStatus" class NTPStatus { diff --git a/lib/framework/NetworkSettingsService.cpp b/lib/framework/NetworkSettingsService.cpp index ad2cf0e9c..09369efb4 100644 --- a/lib/framework/NetworkSettingsService.cpp +++ b/lib/framework/NetworkSettingsService.cpp @@ -26,7 +26,6 @@ void NetworkSettingsService::begin() { // WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN); // default is FAST_SCAN, connect issues in 2.0.14 // WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL); // is default, no need to set - _fsPersistence.readFromFS(); // reconfigureWiFiConnection(); } @@ -36,6 +35,7 @@ void NetworkSettingsService::reconfigureWiFiConnection() { if (WiFi.isConnected() && _state.ssid.length() == 0) { return; } + // disconnect and de-configure wifi if (WiFi.disconnect(true)) { _stopping = true; @@ -84,15 +84,16 @@ void NetworkSettingsService::manageSTA() { WiFi.begin(_state.ssid.c_str(), _state.password.c_str()); } // set power after wifi is startet, fixed value for C3_V1 - if (WiFi.isConnected()) { + // if (WiFi.isConnected()) { #ifdef BOARD_C3_MINI_V1 - // v1 needs this value, see https://github.com/emsesp/EMS-ESP32/pull/620#discussion_r993173979 - WiFi.setTxPower(WIFI_POWER_8_5dBm); // https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi + // v1 needs this value, see https://github.com/emsesp/EMS-ESP32/pull/620#discussion_r993173979 + WiFi.setTxPower(WIFI_POWER_8_5dBm); // https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi #else - // esp_wifi_set_max_tx_power(_state.tx_power * 4); - WiFi.setTxPower((wifi_power_t)(_state.tx_power * 4)); + // esp_wifi_set_max_tx_power(_state.tx_power * 4); + // TODO make it dynamic + WiFi.setTxPower((wifi_power_t)(_state.tx_power * 4)); #endif - } + // } } else { // not connected but STA-mode active => disconnect reconfigureWiFiConnection(); } diff --git a/lib/framework/SecurityManager.h b/lib/framework/SecurityManager.h index 6bc1257ac..2f1610588 100644 --- a/lib/framework/SecurityManager.h +++ b/lib/framework/SecurityManager.h @@ -18,8 +18,6 @@ #define AUTHORIZATION_HEADER_PREFIX "Bearer " #define AUTHORIZATION_HEADER_PREFIX_LEN 7 -// #define MAX_JWT_SIZE 128 - class User { public: String username; @@ -70,7 +68,6 @@ class AuthenticationPredicates { class SecurityManager { public: -#if FT_ENABLED(FT_SECURITY) /* * Authenticate, returning the user if found */ @@ -81,8 +78,6 @@ class SecurityManager { */ virtual String generateJWT(User * user) = 0; -#endif - /* * Check the request header for the Authorization token */ diff --git a/lib/framework/SecuritySettingsService.cpp b/lib/framework/SecuritySettingsService.cpp index 9b5ab85c6..2a83e34b6 100644 --- a/lib/framework/SecuritySettingsService.cpp +++ b/lib/framework/SecuritySettingsService.cpp @@ -1,7 +1,5 @@ #include -#if FT_ENABLED(FT_SECURITY) - #include "../../src/emsesp_stub.hpp" SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs) @@ -125,33 +123,3 @@ void SecuritySettingsService::generateToken(AsyncWebServerRequest * request) { } request->send(401); } - -#else - -User ADMIN_USER = User(FACTORY_ADMIN_USERNAME, FACTORY_ADMIN_PASSWORD, true); - -SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs) - : SecurityManager() { -} -SecuritySettingsService::~SecuritySettingsService() { -} - -ArRequestFilterFunction SecuritySettingsService::filterRequest(AuthenticationPredicate predicate) { - return [this, predicate](AsyncWebServerRequest * request) { return true; }; -} - -// Return the admin user on all request - disabling security features -Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest * request) { - return Authentication(ADMIN_USER); -} - -// Return the function unwrapped -ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { - return onRequest; -} - -ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { - return onRequest; -} - -#endif diff --git a/lib/framework/SecuritySettingsService.h b/lib/framework/SecuritySettingsService.h index f122d0ba2..3ec8dd755 100644 --- a/lib/framework/SecuritySettingsService.h +++ b/lib/framework/SecuritySettingsService.h @@ -28,11 +28,9 @@ #define GENERATE_TOKEN_SIZE 512 #define GENERATE_TOKEN_PATH "/rest/generateToken" -#if FT_ENABLED(FT_SECURITY) - class SecuritySettings { public: - String jwtSecret; + String jwtSecret; std::vector users; // std::list users; @@ -102,19 +100,4 @@ class SecuritySettingsService : public StatefulService, public boolean validatePayload(JsonObject parsedPayload, User * user); }; -#else - -class SecuritySettingsService : public SecurityManager { - public: - SecuritySettingsService(AsyncWebServer * server, FS * fs); - ~SecuritySettingsService(); - - // minimal set of functions to support framework with security settings disabled - Authentication authenticateRequest(AsyncWebServerRequest * request); - ArRequestFilterFunction filterRequest(AuthenticationPredicate predicate); - ArRequestHandlerFunction wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate); - ArJsonRequestHandlerFunction wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate); -}; - -#endif -#endif +#endif \ No newline at end of file diff --git a/lib/framework/SystemStatus.h b/lib/framework/SystemStatus.h index 3f5c456be..4970e81b9 100644 --- a/lib/framework/SystemStatus.h +++ b/lib/framework/SystemStatus.h @@ -10,7 +10,6 @@ #include #include -// #define MAX_ESP_STATUS_SIZE 1024 #define SYSTEM_STATUS_SERVICE_PATH "/rest/systemStatus" class SystemStatus { diff --git a/lib/framework/WiFiScanner.h b/lib/framework/WiFiScanner.h index f73097477..e73a2e669 100644 --- a/lib/framework/WiFiScanner.h +++ b/lib/framework/WiFiScanner.h @@ -11,8 +11,6 @@ #define SCAN_NETWORKS_SERVICE_PATH "/rest/scanNetworks" #define LIST_NETWORKS_SERVICE_PATH "/rest/listNetworks" -// #define MAX_WIFI_SCANNER_SIZE 1024 - class WiFiScanner { public: WiFiScanner(AsyncWebServer * server, SecurityManager * securityManager); diff --git a/lib_standalone/AsyncJson.h b/lib_standalone/AsyncJson.h index 6ab5a5c35..676062f34 100644 --- a/lib_standalone/AsyncJson.h +++ b/lib_standalone/AsyncJson.h @@ -86,61 +86,18 @@ class PrettyAsyncJsonResponse { } }; -class MsgpackAsyncJsonResponse { - protected: - JsonDocument _jsonBuffer; - JsonVariant _root; - bool _isValid; - - public: - MsgpackAsyncJsonResponse(bool isArray = false) - : _isValid{false} { - if (isArray) - _root = _jsonBuffer.to(); - else - _root = _jsonBuffer.add(); - } - - ~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: JsonDocument _jsonBuffer; JsonVariant _root; bool _isValid; + bool _isMsgPack; public: - AsyncJsonResponse(bool isArray = false) - : _isValid{false} { + AsyncJsonResponse(bool isArray = false, bool isMsgPack = false) + : _isValid{false} + , _isMsgPack{isMsgPack} { if (isArray) _root = _jsonBuffer.to(); else diff --git a/lib_standalone/Features.h b/lib_standalone/Features.h index 28cd6d551..526806569 100644 --- a/lib_standalone/Features.h +++ b/lib_standalone/Features.h @@ -1,8 +1,6 @@ #ifndef Features_h #define Features_h -#define FT_ENABLED(feature) feature - // project feature off by default #ifndef FT_PROJECT #define FT_PROJECT 0 diff --git a/lib_standalone/SecurityManager.h b/lib_standalone/SecurityManager.h index cebff2229..80f83d049 100644 --- a/lib_standalone/SecurityManager.h +++ b/lib_standalone/SecurityManager.h @@ -69,11 +69,6 @@ class AuthenticationPredicates { class SecurityManager { public: -#if FT_ENABLED(FT_SECURITY) - 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; diff --git a/lib_standalone/SecuritySettingsService.cpp b/lib_standalone/SecuritySettingsService.cpp index 7cc393418..58b894995 100644 --- a/lib_standalone/SecuritySettingsService.cpp +++ b/lib_standalone/SecuritySettingsService.cpp @@ -2,116 +2,6 @@ #include -#if FT_ENABLED(FT_SECURITY) - -#include "../../src/emsesp_stub.h" // proddy added - -SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs) - : _httpEndpoint(SecuritySettings::read, SecuritySettings::update, this, server, SECURITY_SETTINGS_PATH, this) - , _fsPersistence(SecuritySettings::read, SecuritySettings::update, this, fs, SECURITY_SETTINGS_FILE) - , _jwtHandler(FACTORY_JWT_SECRET) { - addUpdateHandler([&](const String & originId) { configureJWTHandler(); }, false); -} - -void SecuritySettingsService::begin() { - _fsPersistence.readFromFS(); - configureJWTHandler(); -} - -Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest * request) { - AsyncWebHeader * authorizationHeader = request->getHeader(AUTHORIZATION_HEADER); - if (authorizationHeader) { - String value = authorizationHeader->value(); - if (value.startsWith(AUTHORIZATION_HEADER_PREFIX)) { - value = value.substring(AUTHORIZATION_HEADER_PREFIX_LEN); - return authenticateJWT(value); - } - } else if (request->hasParam(ACCESS_TOKEN_PARAMATER)) { - AsyncWebParameter * tokenParamater = request->getParam(ACCESS_TOKEN_PARAMATER); - String value = tokenParamater->value(); - return authenticateJWT(value); - } - return Authentication(); -} - -void SecuritySettingsService::configureJWTHandler() { - _jwtHandler.setSecret(_state.jwtSecret); -} - -Authentication SecuritySettingsService::authenticateJWT(String & jwt) { - JsonDocument payloadDocument; - _jwtHandler.parseJWT(jwt, payloadDocument); - if (payloadDocument.is()) { - JsonObject parsedPayload = payloadDocument.as(); - String username = parsedPayload["username"]; - for (User _user : _state.users) { - if (_user.username == username && validatePayload(parsedPayload, &_user)) { - return Authentication(_user); - } - } - } - return Authentication(); -} - -Authentication SecuritySettingsService::authenticate(const String & username, const String & password) { - for (User _user : _state.users) { - if (_user.username == username && _user.password == password) { - return Authentication(_user); - } - } - return Authentication(); -} - -inline void populateJWTPayload(JsonObject payload, User * user) { - payload["username"] = user->username; - payload["admin"] = user->admin; -} - -boolean SecuritySettingsService::validatePayload(JsonObject parsedPayload, User * user) { - JsonDocument jsonDocument; - JsonObject payload = jsonDocument.to(); - populateJWTPayload(payload, user); - return payload == parsedPayload; -} - -String SecuritySettingsService::generateJWT(User * user) { - JsonDocument jsonDocument; - JsonObject payload = jsonDocument.to(); - populateJWTPayload(payload, user); - return _jwtHandler.buildJWT(payload); -} - -ArRequestFilterFunction SecuritySettingsService::filterRequest(AuthenticationPredicate predicate) { - return [this, predicate](AsyncWebServerRequest * request) { - Authentication authentication = authenticateRequest(request); - return predicate(authentication); - }; -} - -ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { - return [this, onRequest, predicate](AsyncWebServerRequest * request) { - Authentication authentication = authenticateRequest(request); - if (!predicate(authentication)) { - request->send(401); - return; - } - onRequest(request); - }; -} - -ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { - return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant json) { - Authentication authentication = authenticateRequest(request); - if (!predicate(authentication)) { - request->send(401); - return; - } - onRequest(request, json); - }; -} - -#else - User ADMIN_USER = User(FACTORY_ADMIN_USERNAME, FACTORY_ADMIN_PASSWORD, true); SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs) @@ -138,6 +28,4 @@ ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequest return onRequest; } -#endif - #endif \ No newline at end of file diff --git a/lib_standalone/SecuritySettingsService.h b/lib_standalone/SecuritySettingsService.h index a283854e0..cf8dca1d9 100644 --- a/lib_standalone/SecuritySettingsService.h +++ b/lib_standalone/SecuritySettingsService.h @@ -25,71 +25,6 @@ #define SECURITY_SETTINGS_FILE "/config/securitySettings.json" #define SECURITY_SETTINGS_PATH "/rest/securitySettings" -#if FT_ENABLED(FT_SECURITY) - -class SecuritySettings { - public: - String jwtSecret; - std::list users; - - static void read(SecuritySettings & settings, JsonObject root) { - // secret - root["jwt_secret"] = settings.jwtSecret; - - // users - JsonArray users = root["users"].to(); - for (User user : settings.users) { - JsonObject userRoot = users.add(); - userRoot["username"] = user.username; - userRoot["password"] = user.password; - userRoot["admin"] = user.admin; - } - } - - static StateUpdateResult update(JsonObject root, SecuritySettings & settings) { - // secret - settings.jwtSecret = root["jwt_secret"] | FACTORY_JWT_SECRET; - - // users - settings.users.clear(); - if (root["users"].is()) { - for (JsonVariant user : root["users"].as()) { - settings.users.push_back(User(user["username"], user["password"], user["admin"])); - } - } else { - settings.users.push_back(User(FACTORY_ADMIN_USERNAME, FACTORY_ADMIN_PASSWORD, true)); - settings.users.push_back(User(FACTORY_GUEST_USERNAME, FACTORY_GUEST_PASSWORD, false)); - } - return StateUpdateResult::CHANGED; - } -}; - -class SecuritySettingsService : public StatefulService, public SecurityManager { - public: - SecuritySettingsService(AsyncWebServer * server, FS * fs); - - void begin(); - - // Functions to implement SecurityManager - Authentication authenticate(const String & username, const String & password); - Authentication authenticateRequest(AsyncWebServerRequest * request); - String generateJWT(User * user); - ArRequestFilterFunction filterRequest(AuthenticationPredicate predicate); - ArRequestHandlerFunction wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate); - ArJsonRequestHandlerFunction wrapCallback(ArJsonRequestHandlerFunction callback, AuthenticationPredicate predicate); - - private: - HttpEndpoint _httpEndpoint; - FSPersistence _fsPersistence; - ArduinoJsonJWT _jwtHandler; - - void configureJWTHandler(); - Authentication authenticateJWT(String & jwt); - boolean validatePayload(JsonObject parsedPayload, User * user); -}; - -#else - class SecuritySettingsService : public SecurityManager { public: SecuritySettingsService(AsyncWebServer * server, FS * fs); @@ -103,4 +38,3 @@ class SecuritySettingsService : public SecurityManager { }; #endif -#endif diff --git a/mock-api/handler.ts b/mock-api/handler.ts index 87e02c773..692c55b5c 100644 --- a/mock-api/handler.ts +++ b/mock-api/handler.ts @@ -363,7 +363,6 @@ const mqtt_status = { }; // SYSTEM -const FEATURES_ENDPOINT = REST_ENDPOINT_ROOT + 'features'; const VERIFY_AUTHORIZATION_ENDPOINT = REST_ENDPOINT_ROOT + 'verifyAuthorization'; const SYSTEM_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'systemStatus'; const SECURITY_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'securitySettings'; @@ -375,6 +374,9 @@ const GENERATE_TOKEN_ENDPOINT = REST_ENDPOINT_ROOT + 'generateToken'; const system_status = { emsesp_version: '3.6-demo', esp_platform: 'ESP32', + cpu_type: 'ESP32-S3', + cpu_rev: '0', + cpu_cores: 2, max_alloc_heap: 89, psram_size: 0, free_psram: 0, @@ -385,9 +387,11 @@ const system_status = { flash_chip_speed: 40000000, fs_used: 40, fs_free: 24, + partition: 'app0', app_used: 1863, app_free: 121, - uptime: '000+00:15:42.707' + uptime: '000+00:15:42.707', + arduino_version: 'ESP32 Arduino v2.0.14' }; let security_settings = { jwt_secret: 'naughty!', @@ -396,17 +400,7 @@ let security_settings = { { username: 'guest', password: 'guest', admin: false } ] }; -const features = { - project: true, - security: true, - mqtt: true, - ntp: true, - ota: true, - upload_firmware: true, - version: 'v3.6-demo', - // platform: 'ESP32' - platform: 'ESP32-S3' -}; + const verify_authentication = { access_token: '1234' }; const signin = { access_token: @@ -2377,7 +2371,6 @@ router security_settings = await request.json(); return new Response('OK', { status: 200 }); }) - .get(FEATURES_ENDPOINT, () => new Response(JSON.stringify(features), { headers })) .get(VERIFY_AUTHORIZATION_ENDPOINT, () => new Response(JSON.stringify(verify_authentication), { headers })) .post(RESTART_ENDPOINT, () => new Response('OK', { status: 200 })) .post(FACTORY_RESET_ENDPOINT, () => new Response('OK', { status: 200 })) diff --git a/pio_local.ini_example b/pio_local.ini_example index 77c68f171..9e25f8543 100644 --- a/pio_local.ini_example +++ b/pio_local.ini_example @@ -71,7 +71,7 @@ build_flags = -D EMSESP_TEST -D EMSESP_DEBUG -D CONFIG_ETH_ENABLED - -D TASMOTA_SDK + -D CONFIG_ASYNC_TCP_STACK_SIZE=8192 '-DEMSESP_DEFAULT_BOARD_PROFILE="Test"' [env:lolin_s3] diff --git a/platformio.ini b/platformio.ini index 0244b16d5..6fc6f2e13 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,6 +15,7 @@ extra_configs = core_build_flags = -D ARDUINO_ARCH_ESP32=1 -D ESP32=1 + -O2 -std=gnu++17 core_unbuild_flags = -std=gnu++11 @@ -98,7 +99,6 @@ board_build.partitions = esp32_partition_16M.csv build_unflags = ${common.unbuild_flags} build_flags = ${espressi32_base.build_flags} - -O2 '-DEMSESP_DEFAULT_BOARD_PROFILE="S32S3"' [env:esp32_4M] @@ -108,7 +108,6 @@ board_upload.flash_size = 4MB board_build.partitions = esp32_partition_4M.csv build_flags = ${espressi32_base_tasmota.build_flags} - -Os [env:esp32_4Mplus] extends = espressi32_base_tasmota @@ -163,7 +162,6 @@ board_upload.use_1200bps_touch = false board_upload.wait_for_upload_port = false build_flags = ${espressi32_base.build_flags} - -O2 '-DEMSESP_DEFAULT_BOARD_PROFILE="S32S3"' ; to build and run: pio run -e standalone -t exec @@ -176,8 +174,9 @@ build_flags = -lpthread -std=gnu++11 -Og -ggdb build_src_flags = - -Wall -Wextra -Werror -Wswitch-enum -Wno-unused-parameter -Wno-inconsistent-missing-override -Wno-unused-lambda-capture -Wno-sign-compare - -Wno-missing-braces + -Wall -Wextra -Werror + -Wno-unused-parameter -Wno-sign-compare + ; -Wswitch-enum -Wno-unused-parameter -Wno-inconsistent-missing-override -Wno-unused-lambda-capture -Wno-missing-braces -I./lib_standalone -I./lib/ArduinoJson/src -I./lib/uuid-common/src diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 337b0979d..5e09dd21f 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -924,9 +924,6 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev doc["uniq_id"] = uniq_id; doc["obj_id"] = uniq_id; // same as unique_id - const char * ic_ha = "ic"; // icon - only set this if there is no device class - const char * uom_ha = "unit_of_meas"; // unit of measure - char sample_val[30] = "0"; // sample, correct(!) entity value, used only to prevent warning/error in HA if real value is not published yet // we add the command topic parameter for commands @@ -985,10 +982,10 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev case DeviceValueUOM::DEGREES: case DeviceValueUOM::DEGREES_R: case DeviceValueUOM::K: - doc[ic_ha] = F_(icondegrees); + doc["ic"] = F_(icondegrees); break; case DeviceValueUOM::PERCENT: - doc[ic_ha] = F_(iconpercent); + doc["ic"] = F_(iconpercent); break; default: break; @@ -1042,9 +1039,35 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev doc["pl_off"] = Helpers::render_boolean(result, false); snprintf(sample_val, sizeof(sample_val), "'%s'", Helpers::render_boolean(result, false)); } - } else { - // always set the uom, using the standards except for hours/minutes/seconds - // using HA specific codes from https://github.com/home-assistant/core/blob/dev/homeassistant/const.py + } + + doc["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + " else " + sample_val + "}}"; + + // Add the state class, device class and sometimes the icon. Used only for read-only sensors like Sensor and Binary Sensor + if (readonly_sensors) { + // first set the catagory for System entities + // https://github.com/emsesp/EMS-ESP32/discussions/1459#discussioncomment-7694873 + if (device_type == EMSdevice::DeviceType::SYSTEM) { + doc["ent_cat"] = "diagnostic"; + } + + add_ha_uom(doc.as(), type, uom, entity); // add the UoM, device and state class + } + + doc["dev"] = dev_json; // add the dev json object to the end + add_ha_sections_to_doc(nullptr, stat_t, doc, false, val_cond); // no name, since the "dev" has already been added + + return queue_ha(topic, doc.as()); +} + +void Mqtt::add_ha_uom(JsonObject doc, const uint8_t type, const uint8_t uom, const char * entity) { + const char * dc_ha = "dev_cla"; // device class + const char * sc_ha = "stat_cla"; // state class + + // set icon, except for booleans + // using HA specific codes from https://github.com/home-assistant/core/blob/dev/homeassistant/const.py + if (type != DeviceValueType::BOOL) { + const char * uom_ha = "unit_of_meas"; // unit of measure if (uom == DeviceValueUOM::HOURS) { doc[uom_ha] = "h"; } else if (uom == DeviceValueUOM::MINUTES) { @@ -1056,105 +1079,87 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev } } - doc["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + " else " + sample_val + "}}"; - - // Add the state class, device class and sometimes the icon. Used only for read-only sensors Sensor and Binary Sensor - if (readonly_sensors) { - // first set the catagory for System entities - // https://github.com/emsesp/EMS-ESP32/discussions/1459#discussioncomment-7694873 - if (device_type == EMSdevice::DeviceType::SYSTEM) { - doc["ent_cat"] = "diagnostic"; - } - - const char * dc_ha = "dev_cla"; // device class - const char * sc_ha = "stat_cla"; // state class - - switch (uom) { - case DeviceValueUOM::DEGREES: - case DeviceValueUOM::DEGREES_R: - case DeviceValueUOM::K: - doc[sc_ha] = F_(measurement); - doc[dc_ha] = "temperature"; // no icon needed - break; - case DeviceValueUOM::PERCENT: - doc[sc_ha] = F_(measurement); - doc[dc_ha] = "power_factor"; // no icon needed - break; - case DeviceValueUOM::SECONDS: - case DeviceValueUOM::MINUTES: - case DeviceValueUOM::HOURS: - if (type == DeviceValueType::TIME) { - doc[sc_ha] = F_(total_increasing); - } else { - doc[sc_ha] = F_(measurement); - } - doc[dc_ha] = "duration"; // https://github.com/emsesp/EMS-ESP32/issues/822 - break; - case DeviceValueUOM::KB: - doc[ic_ha] = F_(iconkb); - break; - case DeviceValueUOM::LMIN: - doc[ic_ha] = F_(iconlmin); - doc[sc_ha] = F_(measurement); - break; - case DeviceValueUOM::WH: - if (entity == FL_(energyToday)[0]) { - doc[sc_ha] = F_(total_increasing); - } else { - doc[sc_ha] = F_(measurement); - } - doc[dc_ha] = "energy"; - break; - case DeviceValueUOM::KWH: + // set state and device class + switch (uom) { + case DeviceValueUOM::DEGREES: + case DeviceValueUOM::DEGREES_R: + case DeviceValueUOM::K: + doc[sc_ha] = F_(measurement); + doc[dc_ha] = "temperature"; + break; + case DeviceValueUOM::PERCENT: + doc[sc_ha] = F_(measurement); + doc[dc_ha] = "power_factor"; + break; + case DeviceValueUOM::SECONDS: + case DeviceValueUOM::MINUTES: + case DeviceValueUOM::HOURS: + if (type == DeviceValueType::TIME) { doc[sc_ha] = F_(total_increasing); - doc[dc_ha] = "energy"; - break; - case DeviceValueUOM::UA: - doc[ic_ha] = F_(iconua); + } else { doc[sc_ha] = F_(measurement); - break; - case DeviceValueUOM::BAR: - doc[sc_ha] = F_(measurement); - doc[dc_ha] = "pressure"; - break; - case DeviceValueUOM::W: - case DeviceValueUOM::KW: - doc[sc_ha] = F_(measurement); - doc[dc_ha] = "power"; - break; - case DeviceValueUOM::DBM: - doc[sc_ha] = F_(measurement); - doc[dc_ha] = "signal_strength"; - break; - case DeviceValueUOM::CONNECTIVITY: - doc[sc_ha] = F_(measurement); - doc[dc_ha] = "connectivity"; - break; - case DeviceValueUOM::NONE: - // for device entities which have numerical values, with no UOM - if ((type != DeviceValueType::STRING) - && (type == DeviceValueType::INT || type == DeviceValueType::UINT || type == DeviceValueType::SHORT || type == DeviceValueType::USHORT - || type == DeviceValueType::ULONG)) { - doc[ic_ha] = F_(iconnum); // set icon - // determine if its a measurement or total increasing - // most of the values are measurement. for example Tx Reads will increment but can be reset to 0 after a restart - // all the starts are increasing, and they are ULONGs - if (type == DeviceValueType::ULONG) { - doc[sc_ha] = F_(total_increasing); - } else { - doc[sc_ha] = F_(measurement); // default to measurement - } - } - break; - default: - break; } + doc[dc_ha] = "duration"; // https://github.com/emsesp/EMS-ESP32/issues/822 + break; + case DeviceValueUOM::KB: + doc["ic"] = F_(iconkb); + break; + case DeviceValueUOM::LMIN: + doc["ic"] = F_(iconlmin); + doc[sc_ha] = F_(measurement); + break; + case DeviceValueUOM::WH: + if (entity == FL_(energyToday)[0]) { + doc[sc_ha] = F_(total_increasing); + } else { + doc[sc_ha] = F_(measurement); + } + doc[dc_ha] = "energy"; + break; + case DeviceValueUOM::KWH: + doc[sc_ha] = F_(total_increasing); + doc[dc_ha] = "energy"; + break; + case DeviceValueUOM::UA: + doc["ic"] = F_(iconua); + doc[sc_ha] = F_(measurement); + break; + case DeviceValueUOM::BAR: + doc[sc_ha] = F_(measurement); + doc[dc_ha] = "pressure"; + break; + case DeviceValueUOM::W: + case DeviceValueUOM::KW: + doc[sc_ha] = F_(measurement); + doc[dc_ha] = "power"; + break; + case DeviceValueUOM::DBM: + doc[sc_ha] = F_(measurement); + doc[dc_ha] = "signal_strength"; + break; + case DeviceValueUOM::CONNECTIVITY: + doc[sc_ha] = F_(measurement); + doc[dc_ha] = "connectivity"; + break; + case DeviceValueUOM::NONE: + // for device entities which have numerical values, with no UOM + if ((type != DeviceValueType::STRING) + && (type == DeviceValueType::INT || type == DeviceValueType::UINT || type == DeviceValueType::SHORT || type == DeviceValueType::USHORT + || type == DeviceValueType::ULONG)) { + doc["ic"] = F_(iconnum); // set icon + // determine if its a measurement or total increasing + // most of the values are measurement. for example Tx Reads will increment but can be reset to 0 after a restart + // all the starts are increasing, and they are ULONGs + if (type == DeviceValueType::ULONG) { + doc[sc_ha] = F_(total_increasing); + } else { + doc[sc_ha] = F_(measurement); // default to measurement + } + } + break; + default: + break; } - - doc["dev"] = dev_json; // add the dev json object to the end - add_ha_sections_to_doc(nullptr, stat_t, doc, false, val_cond); // no name, since the "dev" has already been added - - return queue_ha(topic, doc.as()); } bool Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp, const bool remove, const int16_t min, const uint32_t max) { diff --git a/src/mqtt.h b/src/mqtt.h index ec4ea2d9d..a50b23ff9 100644 --- a/src/mqtt.h +++ b/src/mqtt.h @@ -222,6 +222,8 @@ class Mqtt { static std::string tag_to_topic(uint8_t device_type, uint8_t tag); + static void add_ha_uom(JsonObject doc, const uint8_t type, const uint8_t uom, const char * entity = nullptr); + static void add_ha_sections_to_doc(const char * name, const char * state_t, JsonDocument & config, diff --git a/src/version.h b/src/version.h index 494ba5d68..64902b839 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.6.5-test.12b" +#define EMSESP_APP_VERSION "3.6.5-test.13" diff --git a/src/web/WebCustomEntityService.cpp b/src/web/WebCustomEntityService.cpp index 94d6241d1..0a3019f7c 100644 --- a/src/web/WebCustomEntityService.cpp +++ b/src/web/WebCustomEntityService.cpp @@ -441,6 +441,8 @@ void WebCustomEntityService::publish(const bool force) { } } + Mqtt::add_ha_uom(config.as(), entityItem.value_type, entityItem.uom); // add uom + Mqtt::add_ha_sections_to_doc("custom", stat_t, config, !ha_created, val_cond); ha_created |= Mqtt::queue_ha(topic, config.as()); diff --git a/src/web/WebCustomEntityService.h b/src/web/WebCustomEntityService.h index 7b81c3c31..f044dcb03 100644 --- a/src/web/WebCustomEntityService.h +++ b/src/web/WebCustomEntityService.h @@ -32,7 +32,7 @@ class CustomEntityItem { uint16_t type_id; uint8_t offset; int8_t value_type; - uint8_t uom; + uint8_t uom; // DeviceValueUOM std::string name; double factor; bool writeable; diff --git a/src/web/WebCustomizationService.cpp b/src/web/WebCustomizationService.cpp index 04b6c1b61..5e96f1ba2 100644 --- a/src/web/WebCustomizationService.cpp +++ b/src/web/WebCustomizationService.cpp @@ -186,7 +186,7 @@ void WebCustomizationService::device_entities(AsyncWebServerRequest * request) { if (request->hasParam(F_(id))) { id = Helpers::atoint(request->getParam(F_(id))->value().c_str()); // get id from url - auto * response = new MsgpackAsyncJsonResponse(true); + auto * response = new AsyncJsonResponse(true, true); // array and msgpack // while (!response) { // delete response; diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index 4d8454450..f1a9bd240 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -179,7 +179,7 @@ void WebDataService::device_data(AsyncWebServerRequest * request) { if (request->hasParam(F_(id))) { id = Helpers::atoint(request->getParam(F_(id))->value().c_str()); // get id from url - auto * response = new MsgpackAsyncJsonResponse(false); + auto * response = new AsyncJsonResponse(false, true); // use msgPack // check size // while (!response) {