From 87d1dee06087c8fac451ed2a4e86871afad2a2eb Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 4 Jan 2024 17:57:31 +0100 Subject: [PATCH 01/24] Improve StringView constexpr and compare operators --- include/StringView.h | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/include/StringView.h b/include/StringView.h index 048af223..02848f2d 100644 --- a/include/StringView.h +++ b/include/StringView.h @@ -20,6 +20,7 @@ namespace OpenShock { static constexpr StringView Null() { return StringView(nullptr); } static constexpr StringView Empty() { return StringView(""); } + constexpr StringView() : _ptrBeg(nullptr), _ptrEnd(nullptr) { } constexpr StringView(const char* const ptr) : _ptrBeg(ptr), _ptrEnd(_getStringEnd(ptr)) { } constexpr StringView(const char* const ptr, std::size_t len) : _ptrBeg(ptr), _ptrEnd(ptr + len) { } constexpr StringView(const char* const ptrBeg, const char* const ptrEnd) : _ptrBeg(ptrBeg), _ptrEnd(ptrEnd) { } @@ -37,6 +38,9 @@ namespace OpenShock { constexpr const_iterator end() const { return _ptrEnd; } const_reverse_iterator rend() const { return std::make_reverse_iterator(begin()); } + constexpr char front() const { return *_ptrBeg; } + constexpr char back() const { return *(_ptrEnd - 1); } + constexpr std::size_t size() const { if (isNull()) return 0; @@ -46,7 +50,7 @@ namespace OpenShock { constexpr bool isNullOrEmpty() const { return size() == 0; } - StringView substr(std::size_t pos, std::size_t count = StringView::npos) const { + constexpr StringView substr(std::size_t pos, std::size_t count = StringView::npos) const { if (isNullOrEmpty()) { return *this; } @@ -64,7 +68,7 @@ namespace OpenShock { return StringView(_ptrBeg + pos, _ptrBeg + pos + count); } - std::size_t find(char needle, std::size_t pos = 0) const { + constexpr std::size_t find(char needle, std::size_t pos = 0) const { std::size_t _size = this->size(); for (std::size_t i = pos; i < _size; ++i) { @@ -305,10 +309,6 @@ namespace OpenShock { explicit operator std::string() const { return toString(); } constexpr char operator[](std::size_t index) const { - if (isNull()) { - return '\0'; - } - return _ptrBeg[index]; } @@ -321,6 +321,15 @@ namespace OpenShock { constexpr bool operator==(const char* const other) { return *this == StringView(other); } constexpr bool operator!=(const char* const other) { return !(*this == other); } + constexpr bool operator<(const StringView& other) const { + if (this == &other) return false; + + return std::lexicographical_compare(_ptrBeg, _ptrEnd, other._ptrBeg, other._ptrEnd); + } + constexpr bool operator<=(const StringView& other) const { return *this < other || *this == other; } + constexpr bool operator>(const StringView& other) const { return !(*this <= other); } + constexpr bool operator>=(const StringView& other) const { return !(*this < other); } + constexpr StringView& operator=(const char* const ptr) { _ptrBeg = ptr; _ptrEnd = _getStringEnd(ptr); From 3190844cd988b0ce8bfb9cbfad15c9b4d6c98ea7 Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 4 Jan 2024 18:15:47 +0100 Subject: [PATCH 02/24] Fix bug --- include/StringView.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/StringView.h b/include/StringView.h index 02848f2d..05b17b23 100644 --- a/include/StringView.h +++ b/include/StringView.h @@ -321,14 +321,14 @@ namespace OpenShock { constexpr bool operator==(const char* const other) { return *this == StringView(other); } constexpr bool operator!=(const char* const other) { return !(*this == other); } - constexpr bool operator<(const StringView& other) const { + bool operator<(const StringView& other) const { if (this == &other) return false; return std::lexicographical_compare(_ptrBeg, _ptrEnd, other._ptrBeg, other._ptrEnd); } - constexpr bool operator<=(const StringView& other) const { return *this < other || *this == other; } - constexpr bool operator>(const StringView& other) const { return !(*this <= other); } - constexpr bool operator>=(const StringView& other) const { return !(*this < other); } + bool operator<=(const StringView& other) const { return *this < other || *this == other; } + bool operator>(const StringView& other) const { return !(*this <= other); } + bool operator>=(const StringView& other) const { return !(*this < other); } constexpr StringView& operator=(const char* const ptr) { _ptrBeg = ptr; From add8c3a785578d867adb1bf70372e7e965647f7f Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 4 Jan 2024 18:35:17 +0100 Subject: [PATCH 03/24] Fix index operator integer type --- include/StringView.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/StringView.h b/include/StringView.h index 05b17b23..a0be9732 100644 --- a/include/StringView.h +++ b/include/StringView.h @@ -308,7 +308,12 @@ namespace OpenShock { explicit operator std::string() const { return toString(); } - constexpr char operator[](std::size_t index) const { + /// Returns a reference to the character at the specified index, Going out of bounds is undefined behavior + constexpr char const& operator[](int index) const { + return _ptrBeg[index]; + } + /// Returns a const reference to the character at the specified index, Going out of bounds is undefined behavior + constexpr char const& operator[](std::size_t index) const { return _ptrBeg[index]; } From b65beacdb8f873c72eb5302a97251674f18a1c78 Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 4 Jan 2024 18:35:36 +0100 Subject: [PATCH 04/24] Add SemVer type --- include/SemVer.h | 76 ++++++++++++ src/SemVer.cpp | 300 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 376 insertions(+) create mode 100644 include/SemVer.h create mode 100644 src/SemVer.cpp diff --git a/include/SemVer.h b/include/SemVer.h new file mode 100644 index 00000000..12632e83 --- /dev/null +++ b/include/SemVer.h @@ -0,0 +1,76 @@ +#pragma once + +#include "StringView.h" + +#include + +namespace OpenShock { + struct SemVer { + std::uint16_t major; + std::uint16_t minor; + std::uint16_t patch; + std::string prerelease; + std::string build; + + SemVer() : major(0), minor(0), patch(0), prerelease(), build() {} + SemVer(std::uint16_t major, std::uint16_t minor, std::uint16_t patch) + : major(major), minor(minor), patch(patch), prerelease(), build() + {} + SemVer(std::uint16_t major, std::uint16_t minor, std::uint16_t patch, StringView prerelease, StringView build) + : major(major), minor(minor), patch(patch), prerelease(prerelease.data(), prerelease.length()), build(build.data(), build.length()) + {} + + bool operator==(const SemVer& other) const { + return major == other.major && minor == other.minor && patch == other.patch && prerelease == other.prerelease && build == other.build; + } + bool operator!=(const SemVer& other) const { + return !(*this == other); + } + bool operator<(const SemVer& other) const { + if (major < other.major) { + return true; + } + if (major > other.major) { + return false; + } + + if (minor < other.minor) { + return true; + } + if (minor > other.minor) { + return false; + } + + if (patch < other.patch) { + return true; + } + if (patch > other.patch) { + return false; + } + + if (prerelease < other.prerelease) { + return true; + } + if (prerelease > other.prerelease) { + return false; + } + + return build < other.build; + } + bool operator<=(const SemVer& other) const { + return *this < other || *this == other; + } + bool operator>(const SemVer& other) const { + return !(*this <= other); + } + bool operator>=(const SemVer& other) const { + return !(*this < other); + } + + bool isValid() const; + + std::string toString() const; + }; + + static bool TryParseSemVer(StringView str, SemVer& out); +} // namespace OpenShock diff --git a/src/SemVer.cpp b/src/SemVer.cpp new file mode 100644 index 00000000..4bffcd95 --- /dev/null +++ b/src/SemVer.cpp @@ -0,0 +1,300 @@ +#include "SemVer.h" + +const char* const TAG = "SemVer"; + +using namespace OpenShock; + +constexpr bool _semverIsLetter(char c) { + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); +} +constexpr bool _semverIsPositiveDigit(char c) { + return c >= '1' && c <= '9'; +} +constexpr bool _semverIsDigit(char c) { + return c == '0' || _semverIsPositiveDigit(c); +} +constexpr bool _semverIsDigits(StringView str) { + if (str.isNullOrEmpty()) { + return false; + } + + for (auto c : str) { + if (!_semverIsDigit(c)) { + return false; + } + } + + return true; +} +constexpr bool _semverIsNonDigit(char c) { + return _semverIsLetter(c) || c == '-'; +} +constexpr bool _semverIsIdentifierChararacter(char c) { + return _semverIsDigit(c) || _semverIsNonDigit(c); +} +constexpr bool _semverIsIdentifierChararacters(StringView str) { + if (str.isNullOrEmpty()) { + return false; + } + + for (auto c : str) { + if (!_semverIsIdentifierChararacter(c)) { + return false; + } + } + + return true; +} +constexpr bool _semverIsNumericIdentifier(StringView str) { + if (str.isNullOrEmpty()) { + return false; + } + + if (str.length() == 1) { + return _semverIsDigit(str[0]); + } + + return _semverIsPositiveDigit(str[0]) && _semverIsDigits(str.substr(1)); +} +constexpr bool _semverIsAlphanumericIdentifier(StringView str) { + if (str.isNullOrEmpty()) { + return false; + } + + if (str.length() == 1) { + return _semverIsNonDigit(str[0]); + } + + std::size_t nonDigitPos = StringView::npos; + for (std::size_t i = 0; i < str.length(); ++i) { + if (_semverIsNonDigit(str[i])) { + nonDigitPos = i; + break; + } + } + + if (nonDigitPos == StringView::npos) { + return false; + } + + auto after = str.substr(nonDigitPos + 1); + + if (nonDigitPos == 0) { + return _semverIsIdentifierChararacters(after); + } + + auto before = str.substr(0, nonDigitPos); + + if (nonDigitPos == str.length() - 1) { + return _semverIsIdentifierChararacters(before); + } + + return _semverIsIdentifierChararacters(before) && _semverIsIdentifierChararacters(after); +} +constexpr bool _semverIsBuildIdentifier(StringView str) { + return _semverIsAlphanumericIdentifier(str) || _semverIsDigits(str); +} +constexpr bool _semverIsPrereleaseIdentifier(StringView str) { + return _semverIsAlphanumericIdentifier(str) || _semverIsNumericIdentifier(str); +} +constexpr bool _semverIsDotSeperatedBuildIdentifiers(StringView str) { + if (str.isNullOrEmpty()) { + return false; + } + + auto dotIdx = str.find('.'); + while (dotIdx != StringView::npos) { + auto part = str.substr(0, dotIdx); + if (!_semverIsBuildIdentifier(part)) { + return false; + } + + str = str.substr(dotIdx + 1); + dotIdx = str.find('.'); + } + + return _semverIsBuildIdentifier(str); +} +constexpr bool _semverIsDotSeperatedPreleaseIdentifiers(StringView str) { + if (str.isNullOrEmpty()) { + return false; + } + + auto dotIdx = str.find('.'); + while (dotIdx != StringView::npos) { + auto part = str.substr(0, dotIdx); + if (!_semverIsPrereleaseIdentifier(part)) { + return false; + } + + str = str.substr(dotIdx + 1); + dotIdx = str.find('.'); + } + + return _semverIsPrereleaseIdentifier(str); +} +const auto _semverIsPatch = _semverIsNumericIdentifier; +const auto _semverIsMinor = _semverIsNumericIdentifier; +const auto _semverIsMajor = _semverIsNumericIdentifier; +const auto _semverIsPrerelease = _semverIsDotSeperatedPreleaseIdentifiers; +const auto _semverIsBuild = _semverIsDotSeperatedBuildIdentifiers; +bool _semverIsVersionCore(StringView str) { + if (str.isNullOrEmpty()) { + return false; + } + + auto parts = str.split('.'); + if (parts.size() != 3) { + return false; + } + + return _semverIsMajor(parts[0]) && _semverIsMinor(parts[1]) && _semverIsPatch(parts[2]); +} +bool _semverIsSemver(StringView str) { + if (str.isNullOrEmpty()) { + return false; + } + + auto dashPos = str.find('-'); + auto plusPos = str.find('+'); + + if (dashPos == StringView::npos && plusPos == StringView::npos) { + return _semverIsVersionCore(str); + } + + if (dashPos != StringView::npos && plusPos != StringView::npos) { + if (dashPos > plusPos) { + return false; + } + + auto core = str.substr(0, dashPos); + auto prerelease = str.substr(dashPos + 1, plusPos - dashPos - 1); + auto build = str.substr(plusPos + 1); + + return _semverIsVersionCore(core) && _semverIsPrerelease(prerelease) && _semverIsBuild(build); + } + + if (dashPos != StringView::npos) { + auto core = str.substr(0, dashPos); + auto prerelease = str.substr(dashPos + 1); + + return _semverIsVersionCore(core) && _semverIsPrerelease(prerelease); + } + + if (plusPos != StringView::npos) { + auto core = str.substr(0, plusPos); + auto build = str.substr(plusPos + 1); + + return _semverIsVersionCore(core) && _semverIsBuild(build); + } + + return false; +} + +bool _tryParseU16(OpenShock::StringView str, std::uint16_t& out) { + if (str.isNullOrEmpty()) { + return false; + } + + std::uint32_t u32 = 0; + for (auto c : str) { + if (c < '0' || c > '9') { + return false; + } + + u32 *= 10; + u32 += c - '0'; + + if (u32 > std::numeric_limits::max()) { + return false; + } + } + + out = static_cast(u32); + + return true; +} + +bool SemVer::isValid() const { + if (!this->prerelease.empty() && !_semverIsPrereleaseIdentifier(this->prerelease)) { + return false; + } + + if (!this->build.empty() && !_semverIsBuildIdentifier(this->build)) { + return false; + } + + return true; +} + +std::string SemVer::toString() const { + std::string str; + str.reserve(32); + + str += std::to_string(major); + str += '.'; + str += std::to_string(minor); + str += '.'; + str += std::to_string(patch); + + if (!prerelease.empty()) { + str += '-'; + str.append(prerelease.data(), prerelease.length()); + } + + if (!build.empty()) { + str += '+'; + str.append(build.data(), build.length()); + } + + return str; +} + +bool OpenShock::TryParseSemVer(StringView semverStr, SemVer& semver) { + auto parts = semverStr.split('.'); + if (parts.size() != 3) { + ESP_LOGE(TAG, "Must have 3 dot-separated parts: %s", semverStr.data()); + return false; + } + + StringView majorStr = parts[0], minorStr = parts[1], patchStr = parts[2]; + + auto dashIdx = patchStr.find('-'); + if (dashIdx != StringView::npos) { + semver.prerelease = patchStr.substr(dashIdx + 1); + patchStr = patchStr.substr(0, dashIdx); + } + + auto plusIdx = semver.prerelease.find('+'); + if (plusIdx != StringView::npos) { + semver.build = semver.prerelease.substr(plusIdx + 1); + semver.prerelease = semver.prerelease.substr(0, plusIdx); + } + + if (!_tryParseU16(majorStr, semver.major)) { + ESP_LOGE(TAG, "Invalid major version: %s", majorStr.data()); + return false; + } + + if (!_tryParseU16(minorStr, semver.minor)) { + ESP_LOGE(TAG, "Invalid minor version: %s", minorStr.data()); + return false; + } + + if (!_tryParseU16(patchStr, semver.patch)) { + ESP_LOGE(TAG, "Invalid patch version: %s", patchStr.data()); + return false; + } + + if (!_semverIsPrerelease(semver.prerelease)) { + ESP_LOGE(TAG, "Invalid prerelease: %s", semver.prerelease.data()); + return false; + } + + if (!_semverIsBuild(semver.build)) { + ESP_LOGE(TAG, "Invalid build: %s", semver.build.data()); + return false; + } + + return true; +} From 46435b9c95222cfa3b47777d52ff67f4867af203 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 06:55:45 +0000 Subject: [PATCH 05/24] build(deps): Bump the npm-dependencies group in /frontend with 8 updates Bumps the npm-dependencies group in /frontend with 8 updates: | Package | From | To | | --- | --- | --- | | [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) | `1.5.3` | `1.5.4` | | [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `20.10.6` | `20.10.7` | | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) | `6.17.0` | `6.18.0` | | [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) | `6.17.0` | `6.18.0` | | [postcss](https://github.com/postcss/postcss) | `8.4.32` | `8.4.33` | | [tailwindcss](https://github.com/tailwindlabs/tailwindcss) | `3.4.0` | `3.4.1` | | [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) | `5.0.10` | `5.0.11` | | [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) | `1.1.1` | `1.1.3` | Updates `@floating-ui/dom` from 1.5.3 to 1.5.4 - [Release notes](https://github.com/floating-ui/floating-ui/releases) - [Changelog](https://github.com/floating-ui/floating-ui/blob/master/packages/dom/CHANGELOG.md) - [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.5.4/packages/dom) Updates `@types/node` from 20.10.6 to 20.10.7 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Updates `@typescript-eslint/eslint-plugin` from 6.17.0 to 6.18.0 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.18.0/packages/eslint-plugin) Updates `@typescript-eslint/parser` from 6.17.0 to 6.18.0 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.18.0/packages/parser) Updates `postcss` from 8.4.32 to 8.4.33 - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](https://github.com/postcss/postcss/compare/8.4.32...8.4.33) Updates `tailwindcss` from 3.4.0 to 3.4.1 - [Release notes](https://github.com/tailwindlabs/tailwindcss/releases) - [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/v3.4.1/CHANGELOG.md) - [Commits](https://github.com/tailwindlabs/tailwindcss/compare/v3.4.0...v3.4.1) Updates `vite` from 5.0.10 to 5.0.11 - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v5.0.11/packages/vite) Updates `vitest` from 1.1.1 to 1.1.3 - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v1.1.3/packages/vitest) --- updated-dependencies: - dependency-name: "@floating-ui/dom" dependency-type: direct:production update-type: version-update:semver-patch dependency-group: npm-dependencies - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm-dependencies - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm-dependencies - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm-dependencies - dependency-name: postcss dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm-dependencies - dependency-name: tailwindcss dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm-dependencies - dependency-name: vite dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm-dependencies - dependency-name: vitest dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm-dependencies ... Signed-off-by: dependabot[bot] --- frontend/package-lock.json | 217 +++++++++++++++++++------------------ frontend/package.json | 16 +-- 2 files changed, 117 insertions(+), 116 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index dcb95af1..4b8724ba 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -8,7 +8,7 @@ "name": "frontend", "version": "0.0.1", "dependencies": { - "@floating-ui/dom": "1.5.3" + "@floating-ui/dom": "1.5.4" }, "devDependencies": { "@playwright/test": "1.40.1", @@ -19,25 +19,25 @@ "@sveltejs/vite-plugin-svelte": "^3.0.1", "@tailwindcss/forms": "0.5.7", "@tailwindcss/typography": "0.5.10", - "@types/node": "20.10.6", - "@typescript-eslint/eslint-plugin": "6.17.0", - "@typescript-eslint/parser": "6.17.0", + "@types/node": "20.10.7", + "@typescript-eslint/eslint-plugin": "6.18.0", + "@typescript-eslint/parser": "6.18.0", "autoprefixer": "10.4.16", "eslint": "8.56.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-svelte": "2.35.1", "flatbuffers": "23.5.26", - "postcss": "8.4.32", + "postcss": "8.4.33", "prettier": "3.1.1", "prettier-plugin-svelte": "3.1.2", "svelte": "4.2.8", "svelte-check": "3.6.2", - "tailwindcss": "3.4.0", + "tailwindcss": "3.4.1", "tslib": "2.6.2", "typescript": "5.3.3", - "vite": "^5.0.10", + "vite": "^5.0.11", "vite-plugin-tailwind-purgecss": "^0.2.0", - "vitest": "1.1.1" + "vitest": "1.1.3" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -483,26 +483,26 @@ } }, "node_modules/@floating-ui/core": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.5.2.tgz", - "integrity": "sha512-Ii3MrfY/GAIN3OhXNzpCKaLxHQfJF9qvwq/kEJYdqDxeIHa01K8sldugal6TmeeXl+WMvhv9cnVzUTaFFJF09A==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.5.3.tgz", + "integrity": "sha512-O0WKDOo0yhJuugCx6trZQj5jVJ9yR0ystG2JaNAemYUWce+pmM6WUEFIibnWyEJKdrDxhm75NoSRME35FNaM/Q==", "dependencies": { - "@floating-ui/utils": "^0.1.3" + "@floating-ui/utils": "^0.2.0" } }, "node_modules/@floating-ui/dom": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.5.3.tgz", - "integrity": "sha512-ClAbQnEqJAKCJOEbbLo5IUlZHkNszqhuxS4fHAVxRPXPya6Ysf2G8KypnYcOTpx6I8xcgF9bbHb6g/2KpbV8qA==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.5.4.tgz", + "integrity": "sha512-jByEsHIY+eEdCjnTVu+E3ephzTOzkQ8hgUfGwos+bg7NlH33Zc5uO+QHz1mrQUOgIKKDD1RtS201P9NvAfq3XQ==", "dependencies": { - "@floating-ui/core": "^1.4.2", - "@floating-ui/utils": "^0.1.3" + "@floating-ui/core": "^1.5.3", + "@floating-ui/utils": "^0.2.0" } }, "node_modules/@floating-ui/utils": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.1.6.tgz", - "integrity": "sha512-OfX7E2oUDYxtBvsuS4e/jSn4Q9Qb6DzgeYtsAdkPZ47znpoNsMgZw0+tVijiv3uGNR6dgNlty6r9rzIzHjtd/A==" + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.1.tgz", + "integrity": "sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q==" }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.13", @@ -974,9 +974,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.10.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz", - "integrity": "sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==", + "version": "20.10.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.7.tgz", + "integrity": "sha512-fRbIKb8C/Y2lXxB5eVMj4IU7xpdox0Lh8bUPEdtLysaylsml1hOOx1+STloRs/B9nf7C6kPRmmg/V7aQW7usNg==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -995,16 +995,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.17.0.tgz", - "integrity": "sha512-Vih/4xLXmY7V490dGwBQJTpIZxH4ZFH6eCVmQ4RFkB+wmaCTDAx4dtgoWwMNGKLkqRY1L6rPqzEbjorRnDo4rQ==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.0.tgz", + "integrity": "sha512-3lqEvQUdCozi6d1mddWqd+kf8KxmGq2Plzx36BlkjuQe3rSTm/O98cLf0A4uDO+a5N1KD2SeEEl6fW97YHY+6w==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.17.0", - "@typescript-eslint/type-utils": "6.17.0", - "@typescript-eslint/utils": "6.17.0", - "@typescript-eslint/visitor-keys": "6.17.0", + "@typescript-eslint/scope-manager": "6.18.0", + "@typescript-eslint/type-utils": "6.18.0", + "@typescript-eslint/utils": "6.18.0", + "@typescript-eslint/visitor-keys": "6.18.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -1030,15 +1030,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.17.0.tgz", - "integrity": "sha512-C4bBaX2orvhK+LlwrY8oWGmSl4WolCfYm513gEccdWZj0CwGadbIADb0FtVEcI+WzUyjyoBj2JRP8g25E6IB8A==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.18.0.tgz", + "integrity": "sha512-v6uR68SFvqhNQT41frCMCQpsP+5vySy6IdgjlzUWoo7ALCnpaWYcz/Ij2k4L8cEsL0wkvOviCMpjmtRtHNOKzA==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.17.0", - "@typescript-eslint/types": "6.17.0", - "@typescript-eslint/typescript-estree": "6.17.0", - "@typescript-eslint/visitor-keys": "6.17.0", + "@typescript-eslint/scope-manager": "6.18.0", + "@typescript-eslint/types": "6.18.0", + "@typescript-eslint/typescript-estree": "6.18.0", + "@typescript-eslint/visitor-keys": "6.18.0", "debug": "^4.3.4" }, "engines": { @@ -1058,13 +1058,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.17.0.tgz", - "integrity": "sha512-RX7a8lwgOi7am0k17NUO0+ZmMOX4PpjLtLRgLmT1d3lBYdWH4ssBUbwdmc5pdRX8rXon8v9x8vaoOSpkHfcXGA==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.0.tgz", + "integrity": "sha512-o/UoDT2NgOJ2VfHpfr+KBY2ErWvCySNUIX/X7O9g8Zzt/tXdpfEU43qbNk8LVuWUT2E0ptzTWXh79i74PP0twA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.17.0", - "@typescript-eslint/visitor-keys": "6.17.0" + "@typescript-eslint/types": "6.18.0", + "@typescript-eslint/visitor-keys": "6.18.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1075,13 +1075,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.17.0.tgz", - "integrity": "sha512-hDXcWmnbtn4P2B37ka3nil3yi3VCQO2QEB9gBiHJmQp5wmyQWqnjA85+ZcE8c4FqnaB6lBwMrPkgd4aBYz3iNg==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.0.tgz", + "integrity": "sha512-ZeMtrXnGmTcHciJN1+u2CigWEEXgy1ufoxtWcHORt5kGvpjjIlK9MUhzHm4RM8iVy6dqSaZA/6PVkX6+r+ChjQ==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.17.0", - "@typescript-eslint/utils": "6.17.0", + "@typescript-eslint/typescript-estree": "6.18.0", + "@typescript-eslint/utils": "6.18.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -1102,9 +1102,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.17.0.tgz", - "integrity": "sha512-qRKs9tvc3a4RBcL/9PXtKSehI/q8wuU9xYJxe97WFxnzH8NWWtcW3ffNS+EWg8uPvIerhjsEZ+rHtDqOCiH57A==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.0.tgz", + "integrity": "sha512-/RFVIccwkwSdW/1zeMx3hADShWbgBxBnV/qSrex6607isYjj05t36P6LyONgqdUrNLl5TYU8NIKdHUYpFvExkA==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1115,13 +1115,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.17.0.tgz", - "integrity": "sha512-gVQe+SLdNPfjlJn5VNGhlOhrXz4cajwFd5kAgWtZ9dCZf4XJf8xmgCTLIqec7aha3JwgLI2CK6GY1043FRxZwg==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.0.tgz", + "integrity": "sha512-klNvl+Ql4NsBNGB4W9TZ2Od03lm7aGvTbs0wYaFYsplVPhr+oeXjlPZCDI4U9jgJIDK38W1FKhacCFzCC+nbIg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.17.0", - "@typescript-eslint/visitor-keys": "6.17.0", + "@typescript-eslint/types": "6.18.0", + "@typescript-eslint/visitor-keys": "6.18.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1167,17 +1167,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.17.0.tgz", - "integrity": "sha512-LofsSPjN/ITNkzV47hxas2JCsNCEnGhVvocfyOcLzT9c/tSZE7SfhS/iWtzP1lKNOEfLhRTZz6xqI8N2RzweSQ==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.0.tgz", + "integrity": "sha512-wiKKCbUeDPGaYEYQh1S580dGxJ/V9HI7K5sbGAVklyf+o5g3O+adnS4UNJajplF4e7z2q0uVBaTdT/yLb4XAVA==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.17.0", - "@typescript-eslint/types": "6.17.0", - "@typescript-eslint/typescript-estree": "6.17.0", + "@typescript-eslint/scope-manager": "6.18.0", + "@typescript-eslint/types": "6.18.0", + "@typescript-eslint/typescript-estree": "6.18.0", "semver": "^7.5.4" }, "engines": { @@ -1192,12 +1192,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.17.0.tgz", - "integrity": "sha512-H6VwB/k3IuIeQOyYczyyKN8wH6ed8EwliaYHLxOIhyF0dYEIsN8+Bk3GE19qafeMKyZJJHP8+O1HiFhFLUNKSg==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.0.tgz", + "integrity": "sha512-1wetAlSZpewRDb2h9p/Q8kRjdGuqdTAQbkJIOUMLug2LBLG+QOjiWoSj6/3B/hA9/tVTFFdtiKvAYoYnSRW/RA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.17.0", + "@typescript-eslint/types": "6.18.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -1215,13 +1215,13 @@ "dev": true }, "node_modules/@vitest/expect": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-1.1.1.tgz", - "integrity": "sha512-Qpw01C2Hyb3085jBkOJLQ7HRX0Ncnh2qV4p+xWmmhcIUlMykUF69zsnZ1vPmAjZpomw9+5tWEGOQ0GTfR8U+kA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-1.1.3.tgz", + "integrity": "sha512-MnJqsKc1Ko04lksF9XoRJza0bGGwTtqfbyrsYv5on4rcEkdo+QgUdITenBQBUltKzdxW7K3rWh+nXRULwsdaVg==", "dev": true, "dependencies": { - "@vitest/spy": "1.1.1", - "@vitest/utils": "1.1.1", + "@vitest/spy": "1.1.3", + "@vitest/utils": "1.1.3", "chai": "^4.3.10" }, "funding": { @@ -1229,12 +1229,12 @@ } }, "node_modules/@vitest/runner": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-1.1.1.tgz", - "integrity": "sha512-8HokyJo1SnSi3uPFKfWm/Oq1qDwLC4QDcVsqpXIXwsRPAg3gIDh8EbZ1ri8cmQkBxdOu62aOF9B4xcqJhvt4xQ==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-1.1.3.tgz", + "integrity": "sha512-Va2XbWMnhSdDEh/OFxyUltgQuuDRxnarK1hW5QNN4URpQrqq6jtt8cfww/pQQ4i0LjoYxh/3bYWvDFlR9tU73g==", "dev": true, "dependencies": { - "@vitest/utils": "1.1.1", + "@vitest/utils": "1.1.3", "p-limit": "^5.0.0", "pathe": "^1.1.1" }, @@ -1270,9 +1270,9 @@ } }, "node_modules/@vitest/snapshot": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-1.1.1.tgz", - "integrity": "sha512-WnMHjv4VdHLbFGgCdVVvyRkRPnOKN75JJg+LLTdr6ah7YnL75W+7CTIMdzPEPzaDxA8r5yvSVlc1d8lH3yE28w==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-1.1.3.tgz", + "integrity": "sha512-U0r8pRXsLAdxSVAyGNcqOU2H3Z4Y2dAAGGelL50O0QRMdi1WWeYHdrH/QWpN1e8juWfVKsb8B+pyJwTC+4Gy9w==", "dev": true, "dependencies": { "magic-string": "^0.30.5", @@ -1284,9 +1284,9 @@ } }, "node_modules/@vitest/spy": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-1.1.1.tgz", - "integrity": "sha512-hDU2KkOTfFp4WFFPWwHFauddwcKuGQ7gF6Un/ZZkCogoAiTMN7/7YKvUDbywPZZ754iCQGjdUmXN3t4k0jm1IQ==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-1.1.3.tgz", + "integrity": "sha512-Ec0qWyGS5LhATFQtldvChPTAHv08yHIOZfiNcjwRQbFPHpkih0md9KAbs7TfeIfL7OFKoe7B/6ukBTqByubXkQ==", "dev": true, "dependencies": { "tinyspy": "^2.2.0" @@ -1296,12 +1296,13 @@ } }, "node_modules/@vitest/utils": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-1.1.1.tgz", - "integrity": "sha512-E9LedH093vST/JuBSyHLFMpxJKW3dLhe/flUSPFedoyj4wKiFX7Jm8gYLtOIiin59dgrssfmFv0BJ1u8P/LC/A==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-1.1.3.tgz", + "integrity": "sha512-Dyt3UMcdElTll2H75vhxfpZu03uFpXRCHxWnzcrFjZxT1kTbq8ALUYIeBgGolo1gldVdI0YSlQRacsqxTwNqwg==", "dev": true, "dependencies": { "diff-sequences": "^29.6.3", + "estree-walker": "^3.0.3", "loupe": "^2.3.7", "pretty-format": "^29.7.0" }, @@ -1609,9 +1610,9 @@ ] }, "node_modules/chai": { - "version": "4.3.10", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", - "integrity": "sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.0.tgz", + "integrity": "sha512-x9cHNq1uvkCdU+5xTkNh5WtgD4e4yDFCsp9jVc7N7qVeKeftv3gO/ZrviX5d+3ZfxdYnZXZYujjRInu1RogU6A==", "dev": true, "dependencies": { "assertion-error": "^1.1.0", @@ -3318,9 +3319,9 @@ } }, "node_modules/postcss": { - "version": "8.4.32", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.32.tgz", - "integrity": "sha512-D/kj5JNu6oo2EIy+XL/26JEDTlIbB8hw85G8StOE6L74RQAVVP5rej6wxCNqyMbR4RkPfqvezVbPw81Ngd6Kcw==", + "version": "8.4.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", + "integrity": "sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==", "dev": true, "funding": [ { @@ -4227,9 +4228,9 @@ } }, "node_modules/tailwindcss": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.0.tgz", - "integrity": "sha512-VigzymniH77knD1dryXbyxR+ePHihHociZbXnLZHUyzf2MMs2ZVqlUrZ3FvpXP8pno9JzmILt1sZPD19M3IxtA==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.1.tgz", + "integrity": "sha512-qAYmXRfk3ENzuPBakNK0SRrUDipP8NQnEY6772uDhflcQz5EhRdD7JNZxyrFHVQNCwULPBn6FNPp9brpO7ctcA==", "dev": true, "dependencies": { "@alloc/quick-lru": "^5.2.0", @@ -4539,9 +4540,9 @@ "dev": true }, "node_modules/vite": { - "version": "5.0.10", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.10.tgz", - "integrity": "sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==", + "version": "5.0.11", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.11.tgz", + "integrity": "sha512-XBMnDjZcNAw/G1gEiskiM1v6yzM4GE5aMGvhWTlHAYYhxb7S3/V1s3m2LDHa8Vh6yIWYYB0iJwsEaS523c4oYA==", "dev": true, "dependencies": { "esbuild": "^0.19.3", @@ -4594,9 +4595,9 @@ } }, "node_modules/vite-node": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-1.1.1.tgz", - "integrity": "sha512-2bGE5w4jvym5v8llF6Gu1oBrmImoNSs4WmRVcavnG2me6+8UQntTqLiAMFyiAobp+ZXhj5ZFhI7SmLiFr/jrow==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-1.1.3.tgz", + "integrity": "sha512-BLSO72YAkIUuNrOx+8uznYICJfTEbvBAmWClY3hpath5+h1mbPS5OMn42lrTxXuyCazVyZoDkSRnju78GiVCqA==", "dev": true, "dependencies": { "cac": "^6.7.14", @@ -4657,17 +4658,17 @@ } }, "node_modules/vitest": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-1.1.1.tgz", - "integrity": "sha512-Ry2qs4UOu/KjpXVfOCfQkTnwSXYGrqTbBZxw6reIYEFjSy1QUARRg5pxiI5BEXy+kBVntxUYNMlq4Co+2vD3fQ==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-1.1.3.tgz", + "integrity": "sha512-2l8om1NOkiA90/Y207PsEvJLYygddsOyr81wLQ20Ra8IlLKbyQncWsGZjnbkyG2KwwuTXLQjEPOJuxGMG8qJBQ==", "dev": true, "dependencies": { - "@vitest/expect": "1.1.1", - "@vitest/runner": "1.1.1", - "@vitest/snapshot": "1.1.1", - "@vitest/spy": "1.1.1", - "@vitest/utils": "1.1.1", - "acorn-walk": "^8.3.0", + "@vitest/expect": "1.1.3", + "@vitest/runner": "1.1.3", + "@vitest/snapshot": "1.1.3", + "@vitest/spy": "1.1.3", + "@vitest/utils": "1.1.3", + "acorn-walk": "^8.3.1", "cac": "^6.7.14", "chai": "^4.3.10", "debug": "^4.3.4", @@ -4681,7 +4682,7 @@ "tinybench": "^2.5.1", "tinypool": "^0.8.1", "vite": "^5.0.0", - "vite-node": "1.1.1", + "vite-node": "1.1.3", "why-is-node-running": "^2.2.2" }, "bin": { diff --git a/frontend/package.json b/frontend/package.json index c3fca349..2b072949 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -23,28 +23,28 @@ "@sveltejs/vite-plugin-svelte": "^3.0.1", "@tailwindcss/forms": "0.5.7", "@tailwindcss/typography": "0.5.10", - "@types/node": "20.10.6", - "@typescript-eslint/eslint-plugin": "6.17.0", - "@typescript-eslint/parser": "6.17.0", + "@types/node": "20.10.7", + "@typescript-eslint/eslint-plugin": "6.18.0", + "@typescript-eslint/parser": "6.18.0", "autoprefixer": "10.4.16", "eslint": "8.56.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-svelte": "2.35.1", "flatbuffers": "23.5.26", - "postcss": "8.4.32", + "postcss": "8.4.33", "prettier": "3.1.1", "prettier-plugin-svelte": "3.1.2", "svelte": "4.2.8", "svelte-check": "3.6.2", - "tailwindcss": "3.4.0", + "tailwindcss": "3.4.1", "tslib": "2.6.2", "typescript": "5.3.3", - "vite": "^5.0.10", + "vite": "^5.0.11", "vite-plugin-tailwind-purgecss": "^0.2.0", - "vitest": "1.1.1" + "vitest": "1.1.3" }, "type": "module", "dependencies": { - "@floating-ui/dom": "1.5.3" + "@floating-ui/dom": "1.5.4" } } From 983dc642abb4f8319835cbb8a251925992a7755c Mon Sep 17 00:00:00 2001 From: hhvrc Date: Tue, 9 Jan 2024 04:53:32 +0100 Subject: [PATCH 06/24] SHAKE THE TREE --- frontend/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 2b072949..f6f23dc3 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -19,13 +19,13 @@ "@skeletonlabs/skeleton": "2.7.0", "@skeletonlabs/tw-plugin": "0.3.1", "@sveltejs/adapter-static": "^3.0.1", - "@sveltejs/kit": "2.0.6", + "@sveltejs/kit": "2.1.0", "@sveltejs/vite-plugin-svelte": "^3.0.1", "@tailwindcss/forms": "0.5.7", "@tailwindcss/typography": "0.5.10", "@types/node": "20.10.7", - "@typescript-eslint/eslint-plugin": "6.18.0", - "@typescript-eslint/parser": "6.18.0", + "@typescript-eslint/eslint-plugin": "6.18.1", + "@typescript-eslint/parser": "6.18.1", "autoprefixer": "10.4.16", "eslint": "8.56.0", "eslint-config-prettier": "9.1.0", From d1095c6f9cc111359224371736257b0f3c92d1be Mon Sep 17 00:00:00 2001 From: hhvrc Date: Tue, 9 Jan 2024 04:57:56 +0100 Subject: [PATCH 07/24] Update package-lock.json --- frontend/package-lock.json | 107 ++++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 48 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 4b8724ba..c14331fa 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -15,13 +15,13 @@ "@skeletonlabs/skeleton": "2.7.0", "@skeletonlabs/tw-plugin": "0.3.1", "@sveltejs/adapter-static": "^3.0.1", - "@sveltejs/kit": "2.0.6", + "@sveltejs/kit": "2.1.0", "@sveltejs/vite-plugin-svelte": "^3.0.1", "@tailwindcss/forms": "0.5.7", "@tailwindcss/typography": "0.5.10", "@types/node": "20.10.7", - "@typescript-eslint/eslint-plugin": "6.18.0", - "@typescript-eslint/parser": "6.18.0", + "@typescript-eslint/eslint-plugin": "6.18.1", + "@typescript-eslint/parser": "6.18.1", "autoprefixer": "10.4.16", "eslint": "8.56.0", "eslint-config-prettier": "9.1.0", @@ -859,9 +859,9 @@ } }, "node_modules/@sveltejs/kit": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.0.6.tgz", - "integrity": "sha512-dnHtyjBLGXx+hrZQ9GuqLlSfTBixewJaByUVWai7LmB4dgV3FwkK155OltEgONDQW6KW64hLNS/uojdx3uC2/g==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.1.0.tgz", + "integrity": "sha512-XSIjk9uY705VRpLapfScvOI3bKTfPXntLCdWVsQHhLvkTD7TPNHWh45/6nTT1vQ8rJwWzzA5sLide2YLT4FMsg==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -869,6 +869,7 @@ "cookie": "^0.6.0", "devalue": "^4.3.2", "esm-env": "^1.0.0", + "import-meta-resolve": "^4.0.0", "kleur": "^4.1.5", "magic-string": "^0.30.5", "mrmime": "^2.0.0", @@ -995,16 +996,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.0.tgz", - "integrity": "sha512-3lqEvQUdCozi6d1mddWqd+kf8KxmGq2Plzx36BlkjuQe3rSTm/O98cLf0A4uDO+a5N1KD2SeEEl6fW97YHY+6w==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.1.tgz", + "integrity": "sha512-nISDRYnnIpk7VCFrGcu1rnZfM1Dh9LRHnfgdkjcbi/l7g16VYRri3TjXi9Ir4lOZSw5N/gnV/3H7jIPQ8Q4daA==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.18.0", - "@typescript-eslint/type-utils": "6.18.0", - "@typescript-eslint/utils": "6.18.0", - "@typescript-eslint/visitor-keys": "6.18.0", + "@typescript-eslint/scope-manager": "6.18.1", + "@typescript-eslint/type-utils": "6.18.1", + "@typescript-eslint/utils": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -1030,15 +1031,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.18.0.tgz", - "integrity": "sha512-v6uR68SFvqhNQT41frCMCQpsP+5vySy6IdgjlzUWoo7ALCnpaWYcz/Ij2k4L8cEsL0wkvOviCMpjmtRtHNOKzA==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.18.1.tgz", + "integrity": "sha512-zct/MdJnVaRRNy9e84XnVtRv9Vf91/qqe+hZJtKanjojud4wAVy/7lXxJmMyX6X6J+xc6c//YEWvpeif8cAhWA==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.18.0", - "@typescript-eslint/types": "6.18.0", - "@typescript-eslint/typescript-estree": "6.18.0", - "@typescript-eslint/visitor-keys": "6.18.0", + "@typescript-eslint/scope-manager": "6.18.1", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/typescript-estree": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4" }, "engines": { @@ -1058,13 +1059,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.0.tgz", - "integrity": "sha512-o/UoDT2NgOJ2VfHpfr+KBY2ErWvCySNUIX/X7O9g8Zzt/tXdpfEU43qbNk8LVuWUT2E0ptzTWXh79i74PP0twA==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.1.tgz", + "integrity": "sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.18.0", - "@typescript-eslint/visitor-keys": "6.18.0" + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1075,13 +1076,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.0.tgz", - "integrity": "sha512-ZeMtrXnGmTcHciJN1+u2CigWEEXgy1ufoxtWcHORt5kGvpjjIlK9MUhzHm4RM8iVy6dqSaZA/6PVkX6+r+ChjQ==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.1.tgz", + "integrity": "sha512-wyOSKhuzHeU/5pcRDP2G2Ndci+4g653V43gXTpt4nbyoIOAASkGDA9JIAgbQCdCkcr1MvpSYWzxTz0olCn8+/Q==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.18.0", - "@typescript-eslint/utils": "6.18.0", + "@typescript-eslint/typescript-estree": "6.18.1", + "@typescript-eslint/utils": "6.18.1", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -1102,9 +1103,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.0.tgz", - "integrity": "sha512-/RFVIccwkwSdW/1zeMx3hADShWbgBxBnV/qSrex6607isYjj05t36P6LyONgqdUrNLl5TYU8NIKdHUYpFvExkA==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz", + "integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1115,13 +1116,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.0.tgz", - "integrity": "sha512-klNvl+Ql4NsBNGB4W9TZ2Od03lm7aGvTbs0wYaFYsplVPhr+oeXjlPZCDI4U9jgJIDK38W1FKhacCFzCC+nbIg==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.1.tgz", + "integrity": "sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.18.0", - "@typescript-eslint/visitor-keys": "6.18.0", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1167,17 +1168,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.0.tgz", - "integrity": "sha512-wiKKCbUeDPGaYEYQh1S580dGxJ/V9HI7K5sbGAVklyf+o5g3O+adnS4UNJajplF4e7z2q0uVBaTdT/yLb4XAVA==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.1.tgz", + "integrity": "sha512-zZmTuVZvD1wpoceHvoQpOiewmWu3uP9FuTWo8vqpy2ffsmfCE8mklRPi+vmnIYAIk9t/4kOThri2QCDgor+OpQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.18.0", - "@typescript-eslint/types": "6.18.0", - "@typescript-eslint/typescript-estree": "6.18.0", + "@typescript-eslint/scope-manager": "6.18.1", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/typescript-estree": "6.18.1", "semver": "^7.5.4" }, "engines": { @@ -1192,12 +1193,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.0.tgz", - "integrity": "sha512-1wetAlSZpewRDb2h9p/Q8kRjdGuqdTAQbkJIOUMLug2LBLG+QOjiWoSj6/3B/hA9/tVTFFdtiKvAYoYnSRW/RA==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz", + "integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.18.0", + "@typescript-eslint/types": "6.18.1", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -2553,6 +2554,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/import-meta-resolve": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.0.0.tgz", + "integrity": "sha512-okYUR7ZQPH+efeuMJGlq4f8ubUgO50kByRPyt/Cy1Io4PSRsPjxME+YlVaCOx+NIToW7hCsZNFJyTPFFKepRSA==", + "dev": true, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", From a549796c293520da4b1305f326a1e047c25c3c42 Mon Sep 17 00:00:00 2001 From: Red Mushie <82113471+redmushie@users.noreply.github.com> Date: Tue, 9 Jan 2024 07:00:25 +0100 Subject: [PATCH 08/24] Support OTA updating (#92) * build: Optimize 4MiB partition tables for OTA updating * ci: Add cdn init action * ci: Fix accidental break of ci * ci: stuff * ci: Fix rclone config * ci: yes * ci: Add CDN upload * ci: Fix dependency chain * build: Fix per board image merge scripts still expecting old fs image name * ci: Add separate version bump step * ci: Fix cdn-bump-version * ci: Fix typo: cnd => cdn * ci: Fix rclone copy command * ci: Fix stable/beta inversion * ci: Add develop OTA push channel * feature: Add OTA flatbuffer messages * Set the world on fire * yeet * i forgor * cpp compiler error messages are mid * Pushing local changes -- no quality guarantees * Add missing fbs generated file * Fix compilation issues * Better startup sequence * More main behavior cleanup * Redo config and other stuff * Fix build * Fix CI build error * Remove JsonRoot helper * Misc cleanup * Fix compilation errors * Regenerate flatbuffers * Start restructure for OTA implementation * Squashed commit of the following: commit a830784bfe1c1aa92365bb106046df2322092ab4 Author: HentaiHeavenVR Date: Thu Dec 14 19:40:14 2023 +0100 Fix release artifiacts upload commit fa111e439b2da451b06edd4a6272687bd6f67200 Author: HentaiHeavenVR Date: Thu Dec 14 19:27:00 2023 +0100 Fix merge script for ESP32-S3 commit a57ed7d0b22ae16b4250d474da0a61fa5bd361e0 Author: HentaiHeavenVR Date: Thu Dec 14 19:22:26 2023 +0100 fix merged name commit 5a15fe731ba3e8426769dbcaf8de48fce073e52c Author: HentaiHeavenVR Date: Thu Dec 14 19:13:13 2023 +0100 Push testing changes * Make Wemos-D1-Mini-ESP32 default intellisense board * Firmware Board definition should always remain fixed * Shorten CDN url * Add OTA stuff to flatbuffers * Add missing comments * Add OtaUpdateConfig to C++ config * Temp fix stuff * initialization and event handling * Implement metadata fetching * Update and minimize config * Update flatc.exe * Update ConfigMapper.ts * Fix generate_schemas.py * Implement http streaming * Fix chunked http streaming * Fix appending to http buffer * Parse additional chunks in same read * Clean up logging, and uint32 for timeout arg * Implement string view and get more ota stuff done * Implement OTA and new hashes index files * fix typo * Fix hash checks * Simplify, merge and abstract logic * Shut down captive when doing filesystem update * Add version checking, more options, and more * Dont rename to staticfs on build * logging rework * yes * change otainstallfailed message * Uncomment dns server code * formatting n stuff * Update generated code * Implement ota command handling and more ota logic * Fix compilation issues * Check for empty semver parts eh? * Relocate check * Things and stuff * Change schema names and namespaces * Status reporting * Switch to enum for task tracking * Add Firmware boot type detection and reporting * Send BootStatus on Gateway connect * Only send bootstatus once * Implement boot type marking * Remove spammy logs * Move methods into isolated source files * Add missing include * Add updateId stuffz --------- Co-authored-by: hhvrc --- .env | 3 +- chips/ESP32-S2/4MB/merge-image.py | 2 +- frontend/src/lib/MessageHandlers/index.ts | 6 +- .../src/lib/_fbs/open-shock/serialization.ts | 10 - .../open-shock/serialization/configuration.ts | 24 +- .../configuration/backend-config.ts | 136 ++-- .../configuration/captive-portal-config.ts | 104 +-- .../serialization/configuration/config.ts | 215 +++--- .../configuration/ota-update-channel.ts | 9 + .../configuration/ota-update-config.ts | 174 +++++ .../serialization/configuration/rfconfig.ts | 128 ++-- .../configuration/serial-input-config.ts | 102 +-- .../configuration/wi-fi-config.ts | 202 +++--- .../configuration/wi-fi-credentials.ts | 162 ++--- .../device-to-server-message-payload.ts | 34 - .../serialization/device-to-server-message.ts | 69 -- .../_fbs/open-shock/serialization/gateway.ts | 10 + .../serialization/gateway/boot-status.ts | 65 ++ .../{ => gateway}/captive-portal-config.ts | 60 +- .../device-to-gateway-message-payload.ts | 50 ++ .../gateway/device-to-gateway-message.ts | 69 ++ .../gateway-to-device-message-payload.ts | 42 ++ .../gateway/gateway-to-device-message.ts | 69 ++ .../serialization/{ => gateway}/keep-alive.ts | 60 +- .../gateway/ota-install-failed.ts | 70 ++ .../gateway/ota-install-progress-task.ts | 13 + .../gateway/ota-install-progress.ts | 71 ++ .../gateway/ota-install-started.ts | 55 ++ .../serialization/gateway/ota-install.ts | 51 ++ .../{ => gateway}/shocker-command-list.ts | 122 ++-- .../{ => gateway}/shocker-command.ts | 110 +-- .../_fbs/open-shock/serialization/local.ts | 37 +- .../local/account-link-command-result.ts | 66 +- .../local/account-link-command.ts | 100 +-- .../local/account-link-result-code.ts | 24 +- .../local/account-unlink-command.ts | 60 +- .../local/device-to-local-message-payload.ts | 124 ++-- .../local/device-to-local-message.ts | 138 ++-- .../serialization/local/error-message.ts | 100 +-- .../local/local-to-device-message-payload.ts | 160 +++-- .../local/local-to-device-message.ts | 138 ++-- .../ota-update-check-for-updates-command.ts | 50 ++ ...ta-update-handle-update-request-command.ts | 30 + ...te-set-allow-backend-management-command.ts | 30 + .../ota-update-set-check-interval-command.ts | 30 + .../local/ota-update-set-domain-command.ts | 50 ++ .../ota-update-set-is-enabled-command.ts | 30 + ...ate-set-require-manual-approval-command.ts | 30 + .../ota-update-set-update-channel-command.ts | 50 ++ .../local/ota-update-start-update-command.ts | 62 ++ .../serialization/local/ready-message.ts | 148 ++-- .../local/set-rf-pin-result-code.ts | 18 +- .../local/set-rf-tx-pin-command-result.ts | 76 +- .../local/set-rf-tx-pin-command.ts | 60 +- .../serialization/local/wifi-got-ip-event.ts | 100 +-- .../serialization/local/wifi-lost-ip-event.ts | 100 +-- .../local/wifi-network-connect-command.ts | 100 +-- .../local/wifi-network-disconnect-command.ts | 60 +- .../serialization/local/wifi-network-event.ts | 112 +-- .../local/wifi-network-forget-command.ts | 100 +-- .../local/wifi-network-save-command.ts | 144 ++-- .../serialization/local/wifi-scan-command.ts | 60 +- .../local/wifi-scan-status-message.ts | 66 +- .../server-to-device-message-payload.ts | 38 - .../serialization/server-to-device-message.ts | 69 -- .../_fbs/open-shock/serialization/types.ts | 10 +- .../serialization/types/firmware-boot-type.ts | 9 + .../open-shock/serialization/types/sem-ver.ts | 92 +++ .../types/shocker-command-type.ts | 20 +- .../serialization/types/shocker-model-type.ts | 16 +- .../serialization/types/wifi-auth-mode.ts | 32 +- .../types/wifi-network-event-type.ts | 26 +- .../serialization/types/wifi-network.ts | 210 +++--- .../serialization/types/wifi-scan-status.ts | 24 +- frontend/src/lib/mappers/ConfigMapper.ts | 180 +++++ frontend/src/lib/stores/DeviceStateStore.ts | 8 +- frontend/src/lib/types/DeviceState.ts | 3 +- frontend/src/routes/+page.svelte | 4 +- include/CaptivePortal.h | 4 + include/CaptivePortalInstance.h | 2 + include/Constants.h | 8 + include/FirmwareBootType.h | 29 + include/GatewayClient.h | 8 +- include/GatewayConnectionManager.h | 4 + include/Hashing.h | 40 ++ include/Logging.h | 24 +- include/OtaUpdateChannel.h | 29 + include/OtaUpdateManager.h | 31 + include/SemVer.h | 2 +- include/config/Config.h | 7 + include/config/OtaUpdateConfig.h | 44 ++ include/config/RootConfig.h | 2 + include/config/internal/utils.h | 1 + include/event_handlers/impl/WSGateway.h | 5 +- include/serialization/WSGateway.h | 13 +- .../serialization/_fbs/ConfigFile_generated.h | 232 ++++++- .../_fbs/DeviceToGatewayMessage_generated.h | 636 +++++++++++++++++ .../_fbs/DeviceToServerMessage_generated.h | 216 ------ .../_fbs/FirmwareBootType_generated.h | 57 ++ .../_fbs/GatewayToDeviceMessage_generated.h | 432 ++++++++++++ .../_fbs/LocalToDeviceMessage_generated.h | 568 ++++++++++++++- include/serialization/_fbs/SemVer_generated.h | 137 ++++ .../_fbs/ServerToDeviceMessage_generated.h | 357 ---------- include/util/HexUtils.h | 38 +- include/util/PartitionUtils.h | 13 + include/util/StringUtils.h | 8 + schemas/ConfigFile.fbs | 44 ++ schemas/DeviceToGatewayMessage.fbs | 57 ++ schemas/DeviceToServerMessage.fbs | 17 - ...Message.fbs => GatewayToDeviceMessage.fbs} | 19 +- schemas/LocalToDeviceMessage.fbs | 40 ++ schemas/Types/FirmwareBootType.fbs | 7 + schemas/Types/SemVer.fbs | 9 + src/CaptivePortal.cpp | 25 +- src/CaptivePortalInstance.cpp | 67 +- src/GatewayClient.cpp | 53 +- src/GatewayConnectionManager.cpp | 16 + src/OtaUpdateManager.cpp | 655 ++++++++++++++++++ src/config/Config.cpp | 62 ++ src/config/OtaUpdateConfig.cpp | 115 +++ src/config/RootConfig.cpp | 14 +- src/config/internal/utils.cpp | 4 + src/event_handlers/websocket/Gateway.cpp | 9 +- .../websocket/gateway/CaptivePortalConfig.cpp | 2 +- .../websocket/gateway/OtaInstall.cpp | 42 ++ .../websocket/gateway/ShockerCommandList.cpp | 2 +- .../websocket/gateway/_InvalidMessage.cpp | 2 +- src/main.cpp | 83 ++- src/serialization/WSGateway.cpp | 91 +++ src/util/ParitionUtils.cpp | 110 +++ src/util/StringUtils.cpp | 59 ++ 131 files changed, 7228 insertions(+), 2814 deletions(-) delete mode 100644 frontend/src/lib/_fbs/open-shock/serialization.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/configuration/ota-update-channel.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/configuration/ota-update-config.ts delete mode 100644 frontend/src/lib/_fbs/open-shock/serialization/device-to-server-message-payload.ts delete mode 100644 frontend/src/lib/_fbs/open-shock/serialization/device-to-server-message.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway/boot-status.ts rename frontend/src/lib/_fbs/open-shock/serialization/{ => gateway}/captive-portal-config.ts (96%) create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway/device-to-gateway-message-payload.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway/device-to-gateway-message.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway/gateway-to-device-message-payload.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway/gateway-to-device-message.ts rename frontend/src/lib/_fbs/open-shock/serialization/{ => gateway}/keep-alive.ts (96%) create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-failed.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-progress-task.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-progress.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-started.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install.ts rename frontend/src/lib/_fbs/open-shock/serialization/{ => gateway}/shocker-command-list.ts (93%) rename frontend/src/lib/_fbs/open-shock/serialization/{ => gateway}/shocker-command.ts (83%) create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-check-for-updates-command.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-handle-update-request-command.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-allow-backend-management-command.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-check-interval-command.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-domain-command.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-is-enabled-command.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-require-manual-approval-command.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-update-channel-command.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-start-update-command.ts delete mode 100644 frontend/src/lib/_fbs/open-shock/serialization/server-to-device-message-payload.ts delete mode 100644 frontend/src/lib/_fbs/open-shock/serialization/server-to-device-message.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/types/firmware-boot-type.ts create mode 100644 frontend/src/lib/_fbs/open-shock/serialization/types/sem-ver.ts create mode 100644 frontend/src/lib/mappers/ConfigMapper.ts create mode 100644 include/FirmwareBootType.h create mode 100644 include/Hashing.h create mode 100644 include/OtaUpdateChannel.h create mode 100644 include/OtaUpdateManager.h create mode 100644 include/config/OtaUpdateConfig.h create mode 100644 include/serialization/_fbs/DeviceToGatewayMessage_generated.h delete mode 100644 include/serialization/_fbs/DeviceToServerMessage_generated.h create mode 100644 include/serialization/_fbs/FirmwareBootType_generated.h create mode 100644 include/serialization/_fbs/GatewayToDeviceMessage_generated.h create mode 100644 include/serialization/_fbs/SemVer_generated.h delete mode 100644 include/serialization/_fbs/ServerToDeviceMessage_generated.h create mode 100644 include/util/PartitionUtils.h create mode 100644 include/util/StringUtils.h create mode 100644 schemas/DeviceToGatewayMessage.fbs delete mode 100644 schemas/DeviceToServerMessage.fbs rename schemas/{ServerToDeviceMessage.fbs => GatewayToDeviceMessage.fbs} (53%) create mode 100644 schemas/Types/FirmwareBootType.fbs create mode 100644 schemas/Types/SemVer.fbs create mode 100644 src/OtaUpdateManager.cpp create mode 100644 src/config/OtaUpdateConfig.cpp create mode 100644 src/event_handlers/websocket/gateway/OtaInstall.cpp create mode 100644 src/util/ParitionUtils.cpp create mode 100644 src/util/StringUtils.cpp diff --git a/.env b/.env index 1d789eee..3afb5f60 100644 --- a/.env +++ b/.env @@ -1,4 +1,5 @@ OPENSHOCK_API_DOMAIN=api.shocklink.net +OPENSHOCK_FW_CDN_DOMAIN=firmware.openshock.org OPENSHOCK_FW_VERSION=0.0.0-unknown OPENSHOCK_FW_HOSTNAME=OpenShock -OPENSHOCK_FW_AP_PREFIX=OpenShock- \ No newline at end of file +OPENSHOCK_FW_AP_PREFIX=OpenShock- diff --git a/chips/ESP32-S2/4MB/merge-image.py b/chips/ESP32-S2/4MB/merge-image.py index 5b7a8680..bfe06d40 100644 --- a/chips/ESP32-S2/4MB/merge-image.py +++ b/chips/ESP32-S2/4MB/merge-image.py @@ -4,7 +4,7 @@ # fmt: off esptool.main([ - '--chip', 'esp32s2', + '--chip', 'esp32', 'merge_bin', '-o', 'merged.bin', '--flash_size', '4MB', '0x1000', './bootloader.bin', diff --git a/frontend/src/lib/MessageHandlers/index.ts b/frontend/src/lib/MessageHandlers/index.ts index 6e2ea389..b848153a 100644 --- a/frontend/src/lib/MessageHandlers/index.ts +++ b/frontend/src/lib/MessageHandlers/index.ts @@ -13,6 +13,7 @@ import { AccountLinkCommandResult } from '$lib/_fbs/open-shock/serialization/loc import { AccountLinkResultCode } from '$lib/_fbs/open-shock/serialization/local/account-link-result-code'; import { ErrorMessage } from '$lib/_fbs/open-shock/serialization/local/error-message'; import { WifiNetworkEventHandler } from './WifiNetworkEventHandler'; +import { mapConfig } from '$lib/mappers/ConfigMapper'; export type MessageHandler = (wsClient: WebSocketClient, message: DeviceToLocalMessage) => void; @@ -32,7 +33,10 @@ PayloadHandlers[DeviceToLocalMessagePayload.ReadyMessage] = (cli, msg) => { DeviceStateStore.update((store) => { store.wifiConnectedBSSID = payload.connectedWifi()?.bssid() || null; store.accountLinked = payload.accountLinked(); - store.rfTxPin = payload.config()?.rf()?.txPin() ?? 255; // 255 = invalid + store.config = mapConfig(payload.config()); + + console.log('[WS] Updated device state store: ', store); + return store; }); diff --git a/frontend/src/lib/_fbs/open-shock/serialization.ts b/frontend/src/lib/_fbs/open-shock/serialization.ts deleted file mode 100644 index 234e4cb3..00000000 --- a/frontend/src/lib/_fbs/open-shock/serialization.ts +++ /dev/null @@ -1,10 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export { CaptivePortalConfig } from './serialization/captive-portal-config'; -export { ServerToDeviceMessage } from './serialization/server-to-device-message'; -export { ServerToDeviceMessagePayload } from './serialization/server-to-device-message-payload'; -export { ShockerCommand } from './serialization/shocker-command'; -export { ShockerCommandList } from './serialization/shocker-command-list'; -export * as Types from './open-shock/serialization/types'; diff --git a/frontend/src/lib/_fbs/open-shock/serialization/configuration.ts b/frontend/src/lib/_fbs/open-shock/serialization/configuration.ts index 79b60504..b1e1a096 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/configuration.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/configuration.ts @@ -1,11 +1,13 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export { BackendConfig } from './configuration/backend-config'; -export { CaptivePortalConfig } from './configuration/captive-portal-config'; -export { Config } from './configuration/config'; -export { RFConfig } from './configuration/rfconfig'; -export { SerialInputConfig } from './configuration/serial-input-config'; -export { WiFiConfig } from './configuration/wi-fi-config'; -export { WiFiCredentials } from './configuration/wi-fi-credentials'; +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export { BackendConfig } from './configuration/backend-config'; +export { CaptivePortalConfig } from './configuration/captive-portal-config'; +export { Config } from './configuration/config'; +export { OtaUpdateChannel } from './configuration/ota-update-channel'; +export { OtaUpdateConfig } from './configuration/ota-update-config'; +export { RFConfig } from './configuration/rfconfig'; +export { SerialInputConfig } from './configuration/serial-input-config'; +export { WiFiConfig } from './configuration/wi-fi-config'; +export { WiFiCredentials } from './configuration/wi-fi-credentials'; diff --git a/frontend/src/lib/_fbs/open-shock/serialization/configuration/backend-config.ts b/frontend/src/lib/_fbs/open-shock/serialization/configuration/backend-config.ts index e905ae8b..54d691c1 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/configuration/backend-config.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/configuration/backend-config.ts @@ -1,68 +1,68 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class BackendConfig { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):BackendConfig { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsBackendConfig(bb:flatbuffers.ByteBuffer, obj?:BackendConfig):BackendConfig { - return (obj || new BackendConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsBackendConfig(bb:flatbuffers.ByteBuffer, obj?:BackendConfig):BackendConfig { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new BackendConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -/** - * Domain name of the backend server, e.g. "api.shocklink.net" - */ -domain():string|null -domain(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -domain(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -/** - * Authentication token for the backend server - */ -authToken():string|null -authToken(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -authToken(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startBackendConfig(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addDomain(builder:flatbuffers.Builder, domainOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, domainOffset, 0); -} - -static addAuthToken(builder:flatbuffers.Builder, authTokenOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, authTokenOffset, 0); -} - -static endBackendConfig(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createBackendConfig(builder:flatbuffers.Builder, domainOffset:flatbuffers.Offset, authTokenOffset:flatbuffers.Offset):flatbuffers.Offset { - BackendConfig.startBackendConfig(builder); - BackendConfig.addDomain(builder, domainOffset); - BackendConfig.addAuthToken(builder, authTokenOffset); - return BackendConfig.endBackendConfig(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class BackendConfig { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):BackendConfig { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsBackendConfig(bb:flatbuffers.ByteBuffer, obj?:BackendConfig):BackendConfig { + return (obj || new BackendConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsBackendConfig(bb:flatbuffers.ByteBuffer, obj?:BackendConfig):BackendConfig { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new BackendConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Domain name of the backend server, e.g. "api.shocklink.net" + */ +domain():string|null +domain(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +domain(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * Authentication token for the backend server + */ +authToken():string|null +authToken(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +authToken(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startBackendConfig(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addDomain(builder:flatbuffers.Builder, domainOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, domainOffset, 0); +} + +static addAuthToken(builder:flatbuffers.Builder, authTokenOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, authTokenOffset, 0); +} + +static endBackendConfig(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createBackendConfig(builder:flatbuffers.Builder, domainOffset:flatbuffers.Offset, authTokenOffset:flatbuffers.Offset):flatbuffers.Offset { + BackendConfig.startBackendConfig(builder); + BackendConfig.addDomain(builder, domainOffset); + BackendConfig.addAuthToken(builder, authTokenOffset); + return BackendConfig.endBackendConfig(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/configuration/captive-portal-config.ts b/frontend/src/lib/_fbs/open-shock/serialization/configuration/captive-portal-config.ts index 179cefe0..52f1c8eb 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/configuration/captive-portal-config.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/configuration/captive-portal-config.ts @@ -1,52 +1,52 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class CaptivePortalConfig { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):CaptivePortalConfig { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsCaptivePortalConfig(bb:flatbuffers.ByteBuffer, obj?:CaptivePortalConfig):CaptivePortalConfig { - return (obj || new CaptivePortalConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsCaptivePortalConfig(bb:flatbuffers.ByteBuffer, obj?:CaptivePortalConfig):CaptivePortalConfig { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new CaptivePortalConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -/** - * Whether the captive portal is forced to be enabled - * The captive portal will otherwise shut down when a gateway connection is established - */ -alwaysEnabled():boolean { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -} - -static startCaptivePortalConfig(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addAlwaysEnabled(builder:flatbuffers.Builder, alwaysEnabled:boolean) { - builder.addFieldInt8(0, +alwaysEnabled, +false); -} - -static endCaptivePortalConfig(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createCaptivePortalConfig(builder:flatbuffers.Builder, alwaysEnabled:boolean):flatbuffers.Offset { - CaptivePortalConfig.startCaptivePortalConfig(builder); - CaptivePortalConfig.addAlwaysEnabled(builder, alwaysEnabled); - return CaptivePortalConfig.endCaptivePortalConfig(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class CaptivePortalConfig { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):CaptivePortalConfig { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsCaptivePortalConfig(bb:flatbuffers.ByteBuffer, obj?:CaptivePortalConfig):CaptivePortalConfig { + return (obj || new CaptivePortalConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsCaptivePortalConfig(bb:flatbuffers.ByteBuffer, obj?:CaptivePortalConfig):CaptivePortalConfig { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new CaptivePortalConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Whether the captive portal is forced to be enabled + * The captive portal will otherwise shut down when a gateway connection is established + */ +alwaysEnabled():boolean { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +static startCaptivePortalConfig(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addAlwaysEnabled(builder:flatbuffers.Builder, alwaysEnabled:boolean) { + builder.addFieldInt8(0, +alwaysEnabled, +false); +} + +static endCaptivePortalConfig(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createCaptivePortalConfig(builder:flatbuffers.Builder, alwaysEnabled:boolean):flatbuffers.Offset { + CaptivePortalConfig.startCaptivePortalConfig(builder); + CaptivePortalConfig.addAlwaysEnabled(builder, alwaysEnabled); + return CaptivePortalConfig.endCaptivePortalConfig(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/configuration/config.ts b/frontend/src/lib/_fbs/open-shock/serialization/configuration/config.ts index 71af96bb..452f7dfa 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/configuration/config.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/configuration/config.ts @@ -1,101 +1,114 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { BackendConfig } from '../../../open-shock/serialization/configuration/backend-config'; -import { CaptivePortalConfig } from '../../../open-shock/serialization/configuration/captive-portal-config'; -import { RFConfig } from '../../../open-shock/serialization/configuration/rfconfig'; -import { SerialInputConfig } from '../../../open-shock/serialization/configuration/serial-input-config'; -import { WiFiConfig } from '../../../open-shock/serialization/configuration/wi-fi-config'; - - -export class Config { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):Config { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsConfig(bb:flatbuffers.ByteBuffer, obj?:Config):Config { - return (obj || new Config()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsConfig(bb:flatbuffers.ByteBuffer, obj?:Config):Config { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Config()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -/** - * RF Transmitter configuration - */ -rf(obj?:RFConfig):RFConfig|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new RFConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -/** - * WiFi configuration - */ -wifi(obj?:WiFiConfig):WiFiConfig|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? (obj || new WiFiConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -/** - * Captive portal configuration - */ -captivePortal(obj?:CaptivePortalConfig):CaptivePortalConfig|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? (obj || new CaptivePortalConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -/** - * Backend configuration - */ -backend(obj?:BackendConfig):BackendConfig|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? (obj || new BackendConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -/** - * Serial input configuration - */ -serialInput(obj?:SerialInputConfig):SerialInputConfig|null { - const offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? (obj || new SerialInputConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -static startConfig(builder:flatbuffers.Builder) { - builder.startObject(5); -} - -static addRf(builder:flatbuffers.Builder, rfOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, rfOffset, 0); -} - -static addWifi(builder:flatbuffers.Builder, wifiOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, wifiOffset, 0); -} - -static addCaptivePortal(builder:flatbuffers.Builder, captivePortalOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, captivePortalOffset, 0); -} - -static addBackend(builder:flatbuffers.Builder, backendOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, backendOffset, 0); -} - -static addSerialInput(builder:flatbuffers.Builder, serialInputOffset:flatbuffers.Offset) { - builder.addFieldOffset(4, serialInputOffset, 0); -} - -static endConfig(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { BackendConfig } from '../../../open-shock/serialization/configuration/backend-config'; +import { CaptivePortalConfig } from '../../../open-shock/serialization/configuration/captive-portal-config'; +import { OtaUpdateConfig } from '../../../open-shock/serialization/configuration/ota-update-config'; +import { RFConfig } from '../../../open-shock/serialization/configuration/rfconfig'; +import { SerialInputConfig } from '../../../open-shock/serialization/configuration/serial-input-config'; +import { WiFiConfig } from '../../../open-shock/serialization/configuration/wi-fi-config'; + + +export class Config { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Config { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsConfig(bb:flatbuffers.ByteBuffer, obj?:Config):Config { + return (obj || new Config()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsConfig(bb:flatbuffers.ByteBuffer, obj?:Config):Config { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Config()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * RF Transmitter configuration + */ +rf(obj?:RFConfig):RFConfig|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new RFConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +/** + * WiFi configuration + */ +wifi(obj?:WiFiConfig):WiFiConfig|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new WiFiConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +/** + * Captive portal configuration + */ +captivePortal(obj?:CaptivePortalConfig):CaptivePortalConfig|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? (obj || new CaptivePortalConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +/** + * Backend configuration + */ +backend(obj?:BackendConfig):BackendConfig|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? (obj || new BackendConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +/** + * Serial input configuration + */ +serialInput(obj?:SerialInputConfig):SerialInputConfig|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? (obj || new SerialInputConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +/** + * OTA update configuration + */ +otaUpdate(obj?:OtaUpdateConfig):OtaUpdateConfig|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? (obj || new OtaUpdateConfig()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static startConfig(builder:flatbuffers.Builder) { + builder.startObject(6); +} + +static addRf(builder:flatbuffers.Builder, rfOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, rfOffset, 0); +} + +static addWifi(builder:flatbuffers.Builder, wifiOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, wifiOffset, 0); +} + +static addCaptivePortal(builder:flatbuffers.Builder, captivePortalOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, captivePortalOffset, 0); +} + +static addBackend(builder:flatbuffers.Builder, backendOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, backendOffset, 0); +} + +static addSerialInput(builder:flatbuffers.Builder, serialInputOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, serialInputOffset, 0); +} + +static addOtaUpdate(builder:flatbuffers.Builder, otaUpdateOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, otaUpdateOffset, 0); +} + +static endConfig(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/configuration/ota-update-channel.ts b/frontend/src/lib/_fbs/open-shock/serialization/configuration/ota-update-channel.ts new file mode 100644 index 00000000..535cfb3b --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/configuration/ota-update-channel.ts @@ -0,0 +1,9 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum OtaUpdateChannel { + Stable = 0, + Beta = 1, + Develop = 2 +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/configuration/ota-update-config.ts b/frontend/src/lib/_fbs/open-shock/serialization/configuration/ota-update-config.ts new file mode 100644 index 00000000..998eb924 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/configuration/ota-update-config.ts @@ -0,0 +1,174 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { OtaUpdateChannel } from '../../../open-shock/serialization/configuration/ota-update-channel'; +import { FirmwareBootType } from '../../../open-shock/serialization/types/firmware-boot-type'; + + +export class OtaUpdateConfig { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaUpdateConfig { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsOtaUpdateConfig(bb:flatbuffers.ByteBuffer, obj?:OtaUpdateConfig):OtaUpdateConfig { + return (obj || new OtaUpdateConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsOtaUpdateConfig(bb:flatbuffers.ByteBuffer, obj?:OtaUpdateConfig):OtaUpdateConfig { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new OtaUpdateConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Indicates whether OTA updates are enabled. + */ +isEnabled():boolean { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +/** + * The domain name of the OTA Content Delivery Network (CDN). + */ +cdnDomain():string|null +cdnDomain(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +cdnDomain(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * The update channel to use. + */ +updateChannel():OtaUpdateChannel { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : OtaUpdateChannel.Stable; +} + +/** + * Indicates whether to check for updates on startup. + */ +checkOnStartup():boolean { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +/** + * Indicates whether to check for updates periodically. + */ +checkPeriodically():boolean { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +/** + * The interval in minutes between periodic update checks. + */ +checkInterval():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +/** + * Indicates if the backend is authorized to manage the device's update version on behalf of the user. + */ +allowBackendManagement():boolean { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +/** + * Indicates if manual approval via serial input or captive portal is required before installing updates. + */ +requireManualApproval():boolean { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +/** + * Update process ID, used to track the update process server-side across reboots. + */ +updateId():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +/** + * Indicates what kind of firmware boot is happening (normal boot, booting into new firmware, rolling back to old firmware, etc.) + */ +bootType():FirmwareBootType { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : FirmwareBootType.Normal; +} + +static startOtaUpdateConfig(builder:flatbuffers.Builder) { + builder.startObject(10); +} + +static addIsEnabled(builder:flatbuffers.Builder, isEnabled:boolean) { + builder.addFieldInt8(0, +isEnabled, +false); +} + +static addCdnDomain(builder:flatbuffers.Builder, cdnDomainOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, cdnDomainOffset, 0); +} + +static addUpdateChannel(builder:flatbuffers.Builder, updateChannel:OtaUpdateChannel) { + builder.addFieldInt8(2, updateChannel, OtaUpdateChannel.Stable); +} + +static addCheckOnStartup(builder:flatbuffers.Builder, checkOnStartup:boolean) { + builder.addFieldInt8(3, +checkOnStartup, +false); +} + +static addCheckPeriodically(builder:flatbuffers.Builder, checkPeriodically:boolean) { + builder.addFieldInt8(4, +checkPeriodically, +false); +} + +static addCheckInterval(builder:flatbuffers.Builder, checkInterval:number) { + builder.addFieldInt16(5, checkInterval, 0); +} + +static addAllowBackendManagement(builder:flatbuffers.Builder, allowBackendManagement:boolean) { + builder.addFieldInt8(6, +allowBackendManagement, +false); +} + +static addRequireManualApproval(builder:flatbuffers.Builder, requireManualApproval:boolean) { + builder.addFieldInt8(7, +requireManualApproval, +false); +} + +static addUpdateId(builder:flatbuffers.Builder, updateId:number) { + builder.addFieldInt32(8, updateId, 0); +} + +static addBootType(builder:flatbuffers.Builder, bootType:FirmwareBootType) { + builder.addFieldInt8(9, bootType, FirmwareBootType.Normal); +} + +static endOtaUpdateConfig(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createOtaUpdateConfig(builder:flatbuffers.Builder, isEnabled:boolean, cdnDomainOffset:flatbuffers.Offset, updateChannel:OtaUpdateChannel, checkOnStartup:boolean, checkPeriodically:boolean, checkInterval:number, allowBackendManagement:boolean, requireManualApproval:boolean, updateId:number, bootType:FirmwareBootType):flatbuffers.Offset { + OtaUpdateConfig.startOtaUpdateConfig(builder); + OtaUpdateConfig.addIsEnabled(builder, isEnabled); + OtaUpdateConfig.addCdnDomain(builder, cdnDomainOffset); + OtaUpdateConfig.addUpdateChannel(builder, updateChannel); + OtaUpdateConfig.addCheckOnStartup(builder, checkOnStartup); + OtaUpdateConfig.addCheckPeriodically(builder, checkPeriodically); + OtaUpdateConfig.addCheckInterval(builder, checkInterval); + OtaUpdateConfig.addAllowBackendManagement(builder, allowBackendManagement); + OtaUpdateConfig.addRequireManualApproval(builder, requireManualApproval); + OtaUpdateConfig.addUpdateId(builder, updateId); + OtaUpdateConfig.addBootType(builder, bootType); + return OtaUpdateConfig.endOtaUpdateConfig(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/configuration/rfconfig.ts b/frontend/src/lib/_fbs/open-shock/serialization/configuration/rfconfig.ts index 703b927c..b34fb2a4 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/configuration/rfconfig.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/configuration/rfconfig.ts @@ -1,64 +1,64 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class RFConfig { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):RFConfig { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsRFConfig(bb:flatbuffers.ByteBuffer, obj?:RFConfig):RFConfig { - return (obj || new RFConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsRFConfig(bb:flatbuffers.ByteBuffer, obj?:RFConfig):RFConfig { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new RFConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -/** - * The GPIO pin connected to the RF modulator's data pin for transmitting (TX) - */ -txPin():number { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; -} - -/** - * Whether to transmit keepalive messages to keep the devices from entering sleep mode - */ -keepaliveEnabled():boolean { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -} - -static startRFConfig(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addTxPin(builder:flatbuffers.Builder, txPin:number) { - builder.addFieldInt8(0, txPin, 0); -} - -static addKeepaliveEnabled(builder:flatbuffers.Builder, keepaliveEnabled:boolean) { - builder.addFieldInt8(1, +keepaliveEnabled, +false); -} - -static endRFConfig(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createRFConfig(builder:flatbuffers.Builder, txPin:number, keepaliveEnabled:boolean):flatbuffers.Offset { - RFConfig.startRFConfig(builder); - RFConfig.addTxPin(builder, txPin); - RFConfig.addKeepaliveEnabled(builder, keepaliveEnabled); - return RFConfig.endRFConfig(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class RFConfig { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):RFConfig { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsRFConfig(bb:flatbuffers.ByteBuffer, obj?:RFConfig):RFConfig { + return (obj || new RFConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsRFConfig(bb:flatbuffers.ByteBuffer, obj?:RFConfig):RFConfig { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new RFConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * The GPIO pin connected to the RF modulator's data pin for transmitting (TX) + */ +txPin():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +/** + * Whether to transmit keepalive messages to keep the devices from entering sleep mode + */ +keepaliveEnabled():boolean { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +static startRFConfig(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addTxPin(builder:flatbuffers.Builder, txPin:number) { + builder.addFieldInt8(0, txPin, 0); +} + +static addKeepaliveEnabled(builder:flatbuffers.Builder, keepaliveEnabled:boolean) { + builder.addFieldInt8(1, +keepaliveEnabled, +false); +} + +static endRFConfig(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createRFConfig(builder:flatbuffers.Builder, txPin:number, keepaliveEnabled:boolean):flatbuffers.Offset { + RFConfig.startRFConfig(builder); + RFConfig.addTxPin(builder, txPin); + RFConfig.addKeepaliveEnabled(builder, keepaliveEnabled); + return RFConfig.endRFConfig(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/configuration/serial-input-config.ts b/frontend/src/lib/_fbs/open-shock/serialization/configuration/serial-input-config.ts index c7534fd3..28d823e7 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/configuration/serial-input-config.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/configuration/serial-input-config.ts @@ -1,51 +1,51 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class SerialInputConfig { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):SerialInputConfig { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsSerialInputConfig(bb:flatbuffers.ByteBuffer, obj?:SerialInputConfig):SerialInputConfig { - return (obj || new SerialInputConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsSerialInputConfig(bb:flatbuffers.ByteBuffer, obj?:SerialInputConfig):SerialInputConfig { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new SerialInputConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -/** - * Whether to echo typed characters back to the serial console - */ -echoEnabled():boolean { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : true; -} - -static startSerialInputConfig(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addEchoEnabled(builder:flatbuffers.Builder, echoEnabled:boolean) { - builder.addFieldInt8(0, +echoEnabled, +true); -} - -static endSerialInputConfig(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createSerialInputConfig(builder:flatbuffers.Builder, echoEnabled:boolean):flatbuffers.Offset { - SerialInputConfig.startSerialInputConfig(builder); - SerialInputConfig.addEchoEnabled(builder, echoEnabled); - return SerialInputConfig.endSerialInputConfig(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class SerialInputConfig { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):SerialInputConfig { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsSerialInputConfig(bb:flatbuffers.ByteBuffer, obj?:SerialInputConfig):SerialInputConfig { + return (obj || new SerialInputConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsSerialInputConfig(bb:flatbuffers.ByteBuffer, obj?:SerialInputConfig):SerialInputConfig { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new SerialInputConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Whether to echo typed characters back to the serial console + */ +echoEnabled():boolean { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : true; +} + +static startSerialInputConfig(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addEchoEnabled(builder:flatbuffers.Builder, echoEnabled:boolean) { + builder.addFieldInt8(0, +echoEnabled, +true); +} + +static endSerialInputConfig(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createSerialInputConfig(builder:flatbuffers.Builder, echoEnabled:boolean):flatbuffers.Offset { + SerialInputConfig.startSerialInputConfig(builder); + SerialInputConfig.addEchoEnabled(builder, echoEnabled); + return SerialInputConfig.endSerialInputConfig(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/configuration/wi-fi-config.ts b/frontend/src/lib/_fbs/open-shock/serialization/configuration/wi-fi-config.ts index 24bef3f3..126b275f 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/configuration/wi-fi-config.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/configuration/wi-fi-config.ts @@ -1,101 +1,101 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { WiFiCredentials } from '../../../open-shock/serialization/configuration/wi-fi-credentials'; - - -export class WiFiConfig { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WiFiConfig { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsWiFiConfig(bb:flatbuffers.ByteBuffer, obj?:WiFiConfig):WiFiConfig { - return (obj || new WiFiConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsWiFiConfig(bb:flatbuffers.ByteBuffer, obj?:WiFiConfig):WiFiConfig { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new WiFiConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -/** - * Access point SSID - */ -apSsid():string|null -apSsid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -apSsid(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -/** - * Device hostname - */ -hostname():string|null -hostname(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -hostname(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -/** - * WiFi network credentials - */ -credentials(index: number, obj?:WiFiCredentials):WiFiCredentials|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? (obj || new WiFiCredentials()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -} - -credentialsLength():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -static startWiFiConfig(builder:flatbuffers.Builder) { - builder.startObject(3); -} - -static addApSsid(builder:flatbuffers.Builder, apSsidOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, apSsidOffset, 0); -} - -static addHostname(builder:flatbuffers.Builder, hostnameOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, hostnameOffset, 0); -} - -static addCredentials(builder:flatbuffers.Builder, credentialsOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, credentialsOffset, 0); -} - -static createCredentialsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startCredentialsVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static endWiFiConfig(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createWiFiConfig(builder:flatbuffers.Builder, apSsidOffset:flatbuffers.Offset, hostnameOffset:flatbuffers.Offset, credentialsOffset:flatbuffers.Offset):flatbuffers.Offset { - WiFiConfig.startWiFiConfig(builder); - WiFiConfig.addApSsid(builder, apSsidOffset); - WiFiConfig.addHostname(builder, hostnameOffset); - WiFiConfig.addCredentials(builder, credentialsOffset); - return WiFiConfig.endWiFiConfig(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { WiFiCredentials } from '../../../open-shock/serialization/configuration/wi-fi-credentials'; + + +export class WiFiConfig { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WiFiConfig { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsWiFiConfig(bb:flatbuffers.ByteBuffer, obj?:WiFiConfig):WiFiConfig { + return (obj || new WiFiConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsWiFiConfig(bb:flatbuffers.ByteBuffer, obj?:WiFiConfig):WiFiConfig { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new WiFiConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Access point SSID + */ +apSsid():string|null +apSsid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +apSsid(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * Device hostname + */ +hostname():string|null +hostname(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +hostname(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * WiFi network credentials + */ +credentials(index: number, obj?:WiFiCredentials):WiFiCredentials|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? (obj || new WiFiCredentials()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +credentialsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static startWiFiConfig(builder:flatbuffers.Builder) { + builder.startObject(3); +} + +static addApSsid(builder:flatbuffers.Builder, apSsidOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, apSsidOffset, 0); +} + +static addHostname(builder:flatbuffers.Builder, hostnameOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, hostnameOffset, 0); +} + +static addCredentials(builder:flatbuffers.Builder, credentialsOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, credentialsOffset, 0); +} + +static createCredentialsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startCredentialsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endWiFiConfig(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createWiFiConfig(builder:flatbuffers.Builder, apSsidOffset:flatbuffers.Offset, hostnameOffset:flatbuffers.Offset, credentialsOffset:flatbuffers.Offset):flatbuffers.Offset { + WiFiConfig.startWiFiConfig(builder); + WiFiConfig.addApSsid(builder, apSsidOffset); + WiFiConfig.addHostname(builder, hostnameOffset); + WiFiConfig.addCredentials(builder, credentialsOffset); + return WiFiConfig.endWiFiConfig(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/configuration/wi-fi-credentials.ts b/frontend/src/lib/_fbs/open-shock/serialization/configuration/wi-fi-credentials.ts index ba580616..5c894bbc 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/configuration/wi-fi-credentials.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/configuration/wi-fi-credentials.ts @@ -1,81 +1,81 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class WiFiCredentials { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WiFiCredentials { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsWiFiCredentials(bb:flatbuffers.ByteBuffer, obj?:WiFiCredentials):WiFiCredentials { - return (obj || new WiFiCredentials()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsWiFiCredentials(bb:flatbuffers.ByteBuffer, obj?:WiFiCredentials):WiFiCredentials { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new WiFiCredentials()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -/** - * ID of the WiFi network credentials, used for referencing the credentials with a low memory footprint - */ -id():number { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; -} - -/** - * SSID of the WiFi network - */ -ssid():string|null -ssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -ssid(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -/** - * Password of the WiFi network - */ -password():string|null -password(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -password(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startWiFiCredentials(builder:flatbuffers.Builder) { - builder.startObject(3); -} - -static addId(builder:flatbuffers.Builder, id:number) { - builder.addFieldInt8(0, id, 0); -} - -static addSsid(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, ssidOffset, 0); -} - -static addPassword(builder:flatbuffers.Builder, passwordOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, passwordOffset, 0); -} - -static endWiFiCredentials(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createWiFiCredentials(builder:flatbuffers.Builder, id:number, ssidOffset:flatbuffers.Offset, passwordOffset:flatbuffers.Offset):flatbuffers.Offset { - WiFiCredentials.startWiFiCredentials(builder); - WiFiCredentials.addId(builder, id); - WiFiCredentials.addSsid(builder, ssidOffset); - WiFiCredentials.addPassword(builder, passwordOffset); - return WiFiCredentials.endWiFiCredentials(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class WiFiCredentials { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WiFiCredentials { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsWiFiCredentials(bb:flatbuffers.ByteBuffer, obj?:WiFiCredentials):WiFiCredentials { + return (obj || new WiFiCredentials()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsWiFiCredentials(bb:flatbuffers.ByteBuffer, obj?:WiFiCredentials):WiFiCredentials { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new WiFiCredentials()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * ID of the WiFi network credentials, used for referencing the credentials with a low memory footprint + */ +id():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +/** + * SSID of the WiFi network + */ +ssid():string|null +ssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +ssid(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * Password of the WiFi network + */ +password():string|null +password(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +password(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startWiFiCredentials(builder:flatbuffers.Builder) { + builder.startObject(3); +} + +static addId(builder:flatbuffers.Builder, id:number) { + builder.addFieldInt8(0, id, 0); +} + +static addSsid(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, ssidOffset, 0); +} + +static addPassword(builder:flatbuffers.Builder, passwordOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, passwordOffset, 0); +} + +static endWiFiCredentials(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createWiFiCredentials(builder:flatbuffers.Builder, id:number, ssidOffset:flatbuffers.Offset, passwordOffset:flatbuffers.Offset):flatbuffers.Offset { + WiFiCredentials.startWiFiCredentials(builder); + WiFiCredentials.addId(builder, id); + WiFiCredentials.addSsid(builder, ssidOffset); + WiFiCredentials.addPassword(builder, passwordOffset); + return WiFiCredentials.endWiFiCredentials(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/device-to-server-message-payload.ts b/frontend/src/lib/_fbs/open-shock/serialization/device-to-server-message-payload.ts deleted file mode 100644 index 46b1c0b9..00000000 --- a/frontend/src/lib/_fbs/open-shock/serialization/device-to-server-message-payload.ts +++ /dev/null @@ -1,34 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import { KeepAlive } from '../../open-shock/serialization/keep-alive'; - - -export enum DeviceToServerMessagePayload { - NONE = 0, - KeepAlive = 1 -} - -export function unionToDeviceToServerMessagePayload( - type: DeviceToServerMessagePayload, - accessor: (obj:KeepAlive) => KeepAlive|null -): KeepAlive|null { - switch(DeviceToServerMessagePayload[type]) { - case 'NONE': return null; - case 'KeepAlive': return accessor(new KeepAlive())! as KeepAlive; - default: return null; - } -} - -export function unionListToDeviceToServerMessagePayload( - type: DeviceToServerMessagePayload, - accessor: (index: number, obj:KeepAlive) => KeepAlive|null, - index: number -): KeepAlive|null { - switch(DeviceToServerMessagePayload[type]) { - case 'NONE': return null; - case 'KeepAlive': return accessor(index, new KeepAlive())! as KeepAlive; - default: return null; - } -} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/device-to-server-message.ts b/frontend/src/lib/_fbs/open-shock/serialization/device-to-server-message.ts deleted file mode 100644 index 5a3d23b6..00000000 --- a/frontend/src/lib/_fbs/open-shock/serialization/device-to-server-message.ts +++ /dev/null @@ -1,69 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { DeviceToServerMessagePayload, unionToDeviceToServerMessagePayload, unionListToDeviceToServerMessagePayload } from '../../open-shock/serialization/device-to-server-message-payload'; - - -export class DeviceToServerMessage { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):DeviceToServerMessage { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsDeviceToServerMessage(bb:flatbuffers.ByteBuffer, obj?:DeviceToServerMessage):DeviceToServerMessage { - return (obj || new DeviceToServerMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsDeviceToServerMessage(bb:flatbuffers.ByteBuffer, obj?:DeviceToServerMessage):DeviceToServerMessage { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new DeviceToServerMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -payloadType():DeviceToServerMessagePayload { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : DeviceToServerMessagePayload.NONE; -} - -payload(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -static startDeviceToServerMessage(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addPayloadType(builder:flatbuffers.Builder, payloadType:DeviceToServerMessagePayload) { - builder.addFieldInt8(0, payloadType, DeviceToServerMessagePayload.NONE); -} - -static addPayload(builder:flatbuffers.Builder, payloadOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, payloadOffset, 0); -} - -static endDeviceToServerMessage(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static finishDeviceToServerMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset); -} - -static finishSizePrefixedDeviceToServerMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, undefined, true); -} - -static createDeviceToServerMessage(builder:flatbuffers.Builder, payloadType:DeviceToServerMessagePayload, payloadOffset:flatbuffers.Offset):flatbuffers.Offset { - DeviceToServerMessage.startDeviceToServerMessage(builder); - DeviceToServerMessage.addPayloadType(builder, payloadType); - DeviceToServerMessage.addPayload(builder, payloadOffset); - return DeviceToServerMessage.endDeviceToServerMessage(builder); -} -} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway.ts new file mode 100644 index 00000000..655b96d7 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway.ts @@ -0,0 +1,10 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export { CaptivePortalConfig } from './gateway/captive-portal-config'; +export { GatewayToDeviceMessage } from './gateway/gateway-to-device-message'; +export { GatewayToDeviceMessagePayload } from './gateway/gateway-to-device-message-payload'; +export { OtaInstall } from './gateway/ota-install'; +export { ShockerCommand } from './gateway/shocker-command'; +export { ShockerCommandList } from './gateway/shocker-command-list'; diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway/boot-status.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/boot-status.ts new file mode 100644 index 00000000..f9fe5e9f --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/boot-status.ts @@ -0,0 +1,65 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { FirmwareBootType } from '../../../open-shock/serialization/types/firmware-boot-type'; +import { SemVer } from '../../../open-shock/serialization/types/sem-ver'; + + +export class BootStatus { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):BootStatus { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsBootStatus(bb:flatbuffers.ByteBuffer, obj?:BootStatus):BootStatus { + return (obj || new BootStatus()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsBootStatus(bb:flatbuffers.ByteBuffer, obj?:BootStatus):BootStatus { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new BootStatus()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +bootType():FirmwareBootType { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : FirmwareBootType.Normal; +} + +firmwareVersion(obj?:SemVer):SemVer|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new SemVer()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +otaUpdateId():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +static startBootStatus(builder:flatbuffers.Builder) { + builder.startObject(3); +} + +static addBootType(builder:flatbuffers.Builder, bootType:FirmwareBootType) { + builder.addFieldInt8(0, bootType, FirmwareBootType.Normal); +} + +static addFirmwareVersion(builder:flatbuffers.Builder, firmwareVersionOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, firmwareVersionOffset, 0); +} + +static addOtaUpdateId(builder:flatbuffers.Builder, otaUpdateId:number) { + builder.addFieldInt32(2, otaUpdateId, 0); +} + +static endBootStatus(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/captive-portal-config.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/captive-portal-config.ts similarity index 96% rename from frontend/src/lib/_fbs/open-shock/serialization/captive-portal-config.ts rename to frontend/src/lib/_fbs/open-shock/serialization/gateway/captive-portal-config.ts index 29e06422..14d15463 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/captive-portal-config.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/captive-portal-config.ts @@ -1,30 +1,30 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class CaptivePortalConfig { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):CaptivePortalConfig { - this.bb_pos = i; - this.bb = bb; - return this; -} - -enabled():boolean { - return !!this.bb!.readInt8(this.bb_pos); -} - -static sizeOf():number { - return 1; -} - -static createCaptivePortalConfig(builder:flatbuffers.Builder, enabled: boolean):flatbuffers.Offset { - builder.prep(1, 1); - builder.writeInt8(Number(Boolean(enabled))); - return builder.offset(); -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class CaptivePortalConfig { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):CaptivePortalConfig { + this.bb_pos = i; + this.bb = bb; + return this; +} + +enabled():boolean { + return !!this.bb!.readInt8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createCaptivePortalConfig(builder:flatbuffers.Builder, enabled: boolean):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(Number(Boolean(enabled))); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway/device-to-gateway-message-payload.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/device-to-gateway-message-payload.ts new file mode 100644 index 00000000..2da46cc9 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/device-to-gateway-message-payload.ts @@ -0,0 +1,50 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import { BootStatus } from '../../../open-shock/serialization/gateway/boot-status'; +import { KeepAlive } from '../../../open-shock/serialization/gateway/keep-alive'; +import { OtaInstallFailed } from '../../../open-shock/serialization/gateway/ota-install-failed'; +import { OtaInstallProgress } from '../../../open-shock/serialization/gateway/ota-install-progress'; +import { OtaInstallStarted } from '../../../open-shock/serialization/gateway/ota-install-started'; + + +export enum DeviceToGatewayMessagePayload { + NONE = 0, + KeepAlive = 1, + BootStatus = 2, + OtaInstallStarted = 3, + OtaInstallProgress = 4, + OtaInstallFailed = 5 +} + +export function unionToDeviceToGatewayMessagePayload( + type: DeviceToGatewayMessagePayload, + accessor: (obj:BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted) => BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted|null +): BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted|null { + switch(DeviceToGatewayMessagePayload[type]) { + case 'NONE': return null; + case 'KeepAlive': return accessor(new KeepAlive())! as KeepAlive; + case 'BootStatus': return accessor(new BootStatus())! as BootStatus; + case 'OtaInstallStarted': return accessor(new OtaInstallStarted())! as OtaInstallStarted; + case 'OtaInstallProgress': return accessor(new OtaInstallProgress())! as OtaInstallProgress; + case 'OtaInstallFailed': return accessor(new OtaInstallFailed())! as OtaInstallFailed; + default: return null; + } +} + +export function unionListToDeviceToGatewayMessagePayload( + type: DeviceToGatewayMessagePayload, + accessor: (index: number, obj:BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted) => BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted|null, + index: number +): BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted|null { + switch(DeviceToGatewayMessagePayload[type]) { + case 'NONE': return null; + case 'KeepAlive': return accessor(index, new KeepAlive())! as KeepAlive; + case 'BootStatus': return accessor(index, new BootStatus())! as BootStatus; + case 'OtaInstallStarted': return accessor(index, new OtaInstallStarted())! as OtaInstallStarted; + case 'OtaInstallProgress': return accessor(index, new OtaInstallProgress())! as OtaInstallProgress; + case 'OtaInstallFailed': return accessor(index, new OtaInstallFailed())! as OtaInstallFailed; + default: return null; + } +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway/device-to-gateway-message.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/device-to-gateway-message.ts new file mode 100644 index 00000000..1f0048d6 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/device-to-gateway-message.ts @@ -0,0 +1,69 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { DeviceToGatewayMessagePayload, unionToDeviceToGatewayMessagePayload, unionListToDeviceToGatewayMessagePayload } from '../../../open-shock/serialization/gateway/device-to-gateway-message-payload'; + + +export class DeviceToGatewayMessage { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):DeviceToGatewayMessage { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsDeviceToGatewayMessage(bb:flatbuffers.ByteBuffer, obj?:DeviceToGatewayMessage):DeviceToGatewayMessage { + return (obj || new DeviceToGatewayMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsDeviceToGatewayMessage(bb:flatbuffers.ByteBuffer, obj?:DeviceToGatewayMessage):DeviceToGatewayMessage { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new DeviceToGatewayMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +payloadType():DeviceToGatewayMessagePayload { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : DeviceToGatewayMessagePayload.NONE; +} + +payload(obj:any):any|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; +} + +static startDeviceToGatewayMessage(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addPayloadType(builder:flatbuffers.Builder, payloadType:DeviceToGatewayMessagePayload) { + builder.addFieldInt8(0, payloadType, DeviceToGatewayMessagePayload.NONE); +} + +static addPayload(builder:flatbuffers.Builder, payloadOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, payloadOffset, 0); +} + +static endDeviceToGatewayMessage(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishDeviceToGatewayMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedDeviceToGatewayMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createDeviceToGatewayMessage(builder:flatbuffers.Builder, payloadType:DeviceToGatewayMessagePayload, payloadOffset:flatbuffers.Offset):flatbuffers.Offset { + DeviceToGatewayMessage.startDeviceToGatewayMessage(builder); + DeviceToGatewayMessage.addPayloadType(builder, payloadType); + DeviceToGatewayMessage.addPayload(builder, payloadOffset); + return DeviceToGatewayMessage.endDeviceToGatewayMessage(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway/gateway-to-device-message-payload.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/gateway-to-device-message-payload.ts new file mode 100644 index 00000000..0b12d57b --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/gateway-to-device-message-payload.ts @@ -0,0 +1,42 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import { CaptivePortalConfig } from '../../../open-shock/serialization/gateway/captive-portal-config'; +import { OtaInstall } from '../../../open-shock/serialization/gateway/ota-install'; +import { ShockerCommandList } from '../../../open-shock/serialization/gateway/shocker-command-list'; + + +export enum GatewayToDeviceMessagePayload { + NONE = 0, + ShockerCommandList = 1, + CaptivePortalConfig = 2, + OtaInstall = 3 +} + +export function unionToGatewayToDeviceMessagePayload( + type: GatewayToDeviceMessagePayload, + accessor: (obj:CaptivePortalConfig|OtaInstall|ShockerCommandList) => CaptivePortalConfig|OtaInstall|ShockerCommandList|null +): CaptivePortalConfig|OtaInstall|ShockerCommandList|null { + switch(GatewayToDeviceMessagePayload[type]) { + case 'NONE': return null; + case 'ShockerCommandList': return accessor(new ShockerCommandList())! as ShockerCommandList; + case 'CaptivePortalConfig': return accessor(new CaptivePortalConfig())! as CaptivePortalConfig; + case 'OtaInstall': return accessor(new OtaInstall())! as OtaInstall; + default: return null; + } +} + +export function unionListToGatewayToDeviceMessagePayload( + type: GatewayToDeviceMessagePayload, + accessor: (index: number, obj:CaptivePortalConfig|OtaInstall|ShockerCommandList) => CaptivePortalConfig|OtaInstall|ShockerCommandList|null, + index: number +): CaptivePortalConfig|OtaInstall|ShockerCommandList|null { + switch(GatewayToDeviceMessagePayload[type]) { + case 'NONE': return null; + case 'ShockerCommandList': return accessor(index, new ShockerCommandList())! as ShockerCommandList; + case 'CaptivePortalConfig': return accessor(index, new CaptivePortalConfig())! as CaptivePortalConfig; + case 'OtaInstall': return accessor(index, new OtaInstall())! as OtaInstall; + default: return null; + } +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway/gateway-to-device-message.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/gateway-to-device-message.ts new file mode 100644 index 00000000..85a7ecc1 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/gateway-to-device-message.ts @@ -0,0 +1,69 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { GatewayToDeviceMessagePayload, unionToGatewayToDeviceMessagePayload, unionListToGatewayToDeviceMessagePayload } from '../../../open-shock/serialization/gateway/gateway-to-device-message-payload'; + + +export class GatewayToDeviceMessage { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):GatewayToDeviceMessage { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsGatewayToDeviceMessage(bb:flatbuffers.ByteBuffer, obj?:GatewayToDeviceMessage):GatewayToDeviceMessage { + return (obj || new GatewayToDeviceMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsGatewayToDeviceMessage(bb:flatbuffers.ByteBuffer, obj?:GatewayToDeviceMessage):GatewayToDeviceMessage { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new GatewayToDeviceMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +payloadType():GatewayToDeviceMessagePayload { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : GatewayToDeviceMessagePayload.NONE; +} + +payload(obj:any):any|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; +} + +static startGatewayToDeviceMessage(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addPayloadType(builder:flatbuffers.Builder, payloadType:GatewayToDeviceMessagePayload) { + builder.addFieldInt8(0, payloadType, GatewayToDeviceMessagePayload.NONE); +} + +static addPayload(builder:flatbuffers.Builder, payloadOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, payloadOffset, 0); +} + +static endGatewayToDeviceMessage(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishGatewayToDeviceMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedGatewayToDeviceMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createGatewayToDeviceMessage(builder:flatbuffers.Builder, payloadType:GatewayToDeviceMessagePayload, payloadOffset:flatbuffers.Offset):flatbuffers.Offset { + GatewayToDeviceMessage.startGatewayToDeviceMessage(builder); + GatewayToDeviceMessage.addPayloadType(builder, payloadType); + GatewayToDeviceMessage.addPayload(builder, payloadOffset); + return GatewayToDeviceMessage.endGatewayToDeviceMessage(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/keep-alive.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/keep-alive.ts similarity index 96% rename from frontend/src/lib/_fbs/open-shock/serialization/keep-alive.ts rename to frontend/src/lib/_fbs/open-shock/serialization/gateway/keep-alive.ts index db6e0855..3a19cbe7 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/keep-alive.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/keep-alive.ts @@ -1,30 +1,30 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class KeepAlive { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):KeepAlive { - this.bb_pos = i; - this.bb = bb; - return this; -} - -uptime():bigint { - return this.bb!.readUint64(this.bb_pos); -} - -static sizeOf():number { - return 8; -} - -static createKeepAlive(builder:flatbuffers.Builder, uptime: bigint):flatbuffers.Offset { - builder.prep(8, 8); - builder.writeInt64(BigInt(uptime ?? 0)); - return builder.offset(); -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class KeepAlive { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):KeepAlive { + this.bb_pos = i; + this.bb = bb; + return this; +} + +uptime():bigint { + return this.bb!.readUint64(this.bb_pos); +} + +static sizeOf():number { + return 8; +} + +static createKeepAlive(builder:flatbuffers.Builder, uptime: bigint):flatbuffers.Offset { + builder.prep(8, 8); + builder.writeInt64(BigInt(uptime ?? 0)); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-failed.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-failed.ts new file mode 100644 index 00000000..81571d1d --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-failed.ts @@ -0,0 +1,70 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class OtaInstallFailed { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaInstallFailed { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsOtaInstallFailed(bb:flatbuffers.ByteBuffer, obj?:OtaInstallFailed):OtaInstallFailed { + return (obj || new OtaInstallFailed()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsOtaInstallFailed(bb:flatbuffers.ByteBuffer, obj?:OtaInstallFailed):OtaInstallFailed { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new OtaInstallFailed()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +updateId():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +message():string|null +message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +message(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +fatal():boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +static startOtaInstallFailed(builder:flatbuffers.Builder) { + builder.startObject(3); +} + +static addUpdateId(builder:flatbuffers.Builder, updateId:number) { + builder.addFieldInt32(0, updateId, 0); +} + +static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, messageOffset, 0); +} + +static addFatal(builder:flatbuffers.Builder, fatal:boolean) { + builder.addFieldInt8(2, +fatal, +false); +} + +static endOtaInstallFailed(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createOtaInstallFailed(builder:flatbuffers.Builder, updateId:number, messageOffset:flatbuffers.Offset, fatal:boolean):flatbuffers.Offset { + OtaInstallFailed.startOtaInstallFailed(builder); + OtaInstallFailed.addUpdateId(builder, updateId); + OtaInstallFailed.addMessage(builder, messageOffset); + OtaInstallFailed.addFatal(builder, fatal); + return OtaInstallFailed.endOtaInstallFailed(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-progress-task.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-progress-task.ts new file mode 100644 index 00000000..e9a25149 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-progress-task.ts @@ -0,0 +1,13 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum OtaInstallProgressTask { + FetchingMetadata = 0, + PreparingForInstall = 1, + FlashingFilesystem = 2, + VerifyingFilesystem = 3, + FlashingApplication = 4, + MarkingApplicationBootable = 5, + Rebooting = 6 +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-progress.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-progress.ts new file mode 100644 index 00000000..70f756a0 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-progress.ts @@ -0,0 +1,71 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { OtaInstallProgressTask } from '../../../open-shock/serialization/gateway/ota-install-progress-task'; + + +export class OtaInstallProgress { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaInstallProgress { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsOtaInstallProgress(bb:flatbuffers.ByteBuffer, obj?:OtaInstallProgress):OtaInstallProgress { + return (obj || new OtaInstallProgress()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsOtaInstallProgress(bb:flatbuffers.ByteBuffer, obj?:OtaInstallProgress):OtaInstallProgress { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new OtaInstallProgress()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +updateId():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +task():OtaInstallProgressTask { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : OtaInstallProgressTask.FetchingMetadata; +} + +progress():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0; +} + +static startOtaInstallProgress(builder:flatbuffers.Builder) { + builder.startObject(3); +} + +static addUpdateId(builder:flatbuffers.Builder, updateId:number) { + builder.addFieldInt32(0, updateId, 0); +} + +static addTask(builder:flatbuffers.Builder, task:OtaInstallProgressTask) { + builder.addFieldInt8(1, task, OtaInstallProgressTask.FetchingMetadata); +} + +static addProgress(builder:flatbuffers.Builder, progress:number) { + builder.addFieldFloat32(2, progress, 0.0); +} + +static endOtaInstallProgress(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createOtaInstallProgress(builder:flatbuffers.Builder, updateId:number, task:OtaInstallProgressTask, progress:number):flatbuffers.Offset { + OtaInstallProgress.startOtaInstallProgress(builder); + OtaInstallProgress.addUpdateId(builder, updateId); + OtaInstallProgress.addTask(builder, task); + OtaInstallProgress.addProgress(builder, progress); + return OtaInstallProgress.endOtaInstallProgress(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-started.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-started.ts new file mode 100644 index 00000000..bd82a2bd --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install-started.ts @@ -0,0 +1,55 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { SemVer } from '../../../open-shock/serialization/types/sem-ver'; + + +export class OtaInstallStarted { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaInstallStarted { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsOtaInstallStarted(bb:flatbuffers.ByteBuffer, obj?:OtaInstallStarted):OtaInstallStarted { + return (obj || new OtaInstallStarted()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsOtaInstallStarted(bb:flatbuffers.ByteBuffer, obj?:OtaInstallStarted):OtaInstallStarted { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new OtaInstallStarted()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +updateId():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +version(obj?:SemVer):SemVer|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new SemVer()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static startOtaInstallStarted(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addUpdateId(builder:flatbuffers.Builder, updateId:number) { + builder.addFieldInt32(0, updateId, 0); +} + +static addVersion(builder:flatbuffers.Builder, versionOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, versionOffset, 0); +} + +static endOtaInstallStarted(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install.ts new file mode 100644 index 00000000..d3d17fc5 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/ota-install.ts @@ -0,0 +1,51 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { SemVer } from '../../../open-shock/serialization/types/sem-ver'; + + +export class OtaInstall { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaInstall { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsOtaInstall(bb:flatbuffers.ByteBuffer, obj?:OtaInstall):OtaInstall { + return (obj || new OtaInstall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsOtaInstall(bb:flatbuffers.ByteBuffer, obj?:OtaInstall):OtaInstall { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new OtaInstall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +version(obj?:SemVer):SemVer|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new SemVer()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static startOtaInstall(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addVersion(builder:flatbuffers.Builder, versionOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, versionOffset, 0); +} + +static endOtaInstall(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createOtaInstall(builder:flatbuffers.Builder, versionOffset:flatbuffers.Offset):flatbuffers.Offset { + OtaInstall.startOtaInstall(builder); + OtaInstall.addVersion(builder, versionOffset); + return OtaInstall.endOtaInstall(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/shocker-command-list.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/shocker-command-list.ts similarity index 93% rename from frontend/src/lib/_fbs/open-shock/serialization/shocker-command-list.ts rename to frontend/src/lib/_fbs/open-shock/serialization/gateway/shocker-command-list.ts index 238021a4..efdbdc61 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/shocker-command-list.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/shocker-command-list.ts @@ -1,61 +1,61 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { ShockerCommand } from '../../open-shock/serialization/shocker-command'; - - -export class ShockerCommandList { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):ShockerCommandList { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsShockerCommandList(bb:flatbuffers.ByteBuffer, obj?:ShockerCommandList):ShockerCommandList { - return (obj || new ShockerCommandList()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsShockerCommandList(bb:flatbuffers.ByteBuffer, obj?:ShockerCommandList):ShockerCommandList { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new ShockerCommandList()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -commands(index: number, obj?:ShockerCommand):ShockerCommand|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new ShockerCommand()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 8, this.bb!) : null; -} - -commandsLength():number { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -static startShockerCommandList(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addCommands(builder:flatbuffers.Builder, commandsOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, commandsOffset, 0); -} - -static startCommandsVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(8, numElems, 2); -} - -static endShockerCommandList(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // commands - return offset; -} - -static createShockerCommandList(builder:flatbuffers.Builder, commandsOffset:flatbuffers.Offset):flatbuffers.Offset { - ShockerCommandList.startShockerCommandList(builder); - ShockerCommandList.addCommands(builder, commandsOffset); - return ShockerCommandList.endShockerCommandList(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { ShockerCommand } from '../../../open-shock/serialization/gateway/shocker-command'; + + +export class ShockerCommandList { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):ShockerCommandList { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsShockerCommandList(bb:flatbuffers.ByteBuffer, obj?:ShockerCommandList):ShockerCommandList { + return (obj || new ShockerCommandList()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsShockerCommandList(bb:flatbuffers.ByteBuffer, obj?:ShockerCommandList):ShockerCommandList { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new ShockerCommandList()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +commands(index: number, obj?:ShockerCommand):ShockerCommand|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new ShockerCommand()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 8, this.bb!) : null; +} + +commandsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static startShockerCommandList(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addCommands(builder:flatbuffers.Builder, commandsOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, commandsOffset, 0); +} + +static startCommandsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(8, numElems, 2); +} + +static endShockerCommandList(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // commands + return offset; +} + +static createShockerCommandList(builder:flatbuffers.Builder, commandsOffset:flatbuffers.Offset):flatbuffers.Offset { + ShockerCommandList.startShockerCommandList(builder); + ShockerCommandList.addCommands(builder, commandsOffset); + return ShockerCommandList.endShockerCommandList(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/shocker-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/gateway/shocker-command.ts similarity index 83% rename from frontend/src/lib/_fbs/open-shock/serialization/shocker-command.ts rename to frontend/src/lib/_fbs/open-shock/serialization/gateway/shocker-command.ts index fdb23ac7..abf14f61 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/shocker-command.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/gateway/shocker-command.ts @@ -1,55 +1,55 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { ShockerCommandType } from '../../open-shock/serialization/types/shocker-command-type'; -import { ShockerModelType } from '../../open-shock/serialization/types/shocker-model-type'; - - -export class ShockerCommand { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):ShockerCommand { - this.bb_pos = i; - this.bb = bb; - return this; -} - -model():ShockerModelType { - return this.bb!.readUint8(this.bb_pos); -} - -id():number { - return this.bb!.readUint16(this.bb_pos + 2); -} - -type():ShockerCommandType { - return this.bb!.readUint8(this.bb_pos + 4); -} - -intensity():number { - return this.bb!.readUint8(this.bb_pos + 5); -} - -duration():number { - return this.bb!.readUint16(this.bb_pos + 6); -} - -static sizeOf():number { - return 8; -} - -static createShockerCommand(builder:flatbuffers.Builder, model: ShockerModelType, id: number, type: ShockerCommandType, intensity: number, duration: number):flatbuffers.Offset { - builder.prep(2, 8); - builder.writeInt16(duration); - builder.writeInt8(intensity); - builder.writeInt8(type); - builder.writeInt16(id); - builder.pad(1); - builder.writeInt8(model); - return builder.offset(); -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { ShockerCommandType } from '../../../open-shock/serialization/types/shocker-command-type'; +import { ShockerModelType } from '../../../open-shock/serialization/types/shocker-model-type'; + + +export class ShockerCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):ShockerCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +model():ShockerModelType { + return this.bb!.readUint8(this.bb_pos); +} + +id():number { + return this.bb!.readUint16(this.bb_pos + 2); +} + +type():ShockerCommandType { + return this.bb!.readUint8(this.bb_pos + 4); +} + +intensity():number { + return this.bb!.readUint8(this.bb_pos + 5); +} + +duration():number { + return this.bb!.readUint16(this.bb_pos + 6); +} + +static sizeOf():number { + return 8; +} + +static createShockerCommand(builder:flatbuffers.Builder, model: ShockerModelType, id: number, type: ShockerCommandType, intensity: number, duration: number):flatbuffers.Offset { + builder.prep(2, 8); + builder.writeInt16(duration); + builder.writeInt8(intensity); + builder.writeInt8(type); + builder.writeInt16(id); + builder.pad(1); + builder.writeInt8(model); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local.ts b/frontend/src/lib/_fbs/open-shock/serialization/local.ts index ce06d3d2..f7b55800 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local.ts @@ -1,14 +1,23 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export { AccountLinkCommand } from './local/account-link-command'; -export { AccountUnlinkCommand } from './local/account-unlink-command'; -export { LocalToDeviceMessage } from './local/local-to-device-message'; -export { LocalToDeviceMessagePayload } from './local/local-to-device-message-payload'; -export { SetRfTxPinCommand } from './local/set-rf-tx-pin-command'; -export { WifiNetworkConnectCommand } from './local/wifi-network-connect-command'; -export { WifiNetworkDisconnectCommand } from './local/wifi-network-disconnect-command'; -export { WifiNetworkForgetCommand } from './local/wifi-network-forget-command'; -export { WifiNetworkSaveCommand } from './local/wifi-network-save-command'; -export { WifiScanCommand } from './local/wifi-scan-command'; +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export { AccountLinkCommand } from './local/account-link-command'; +export { AccountUnlinkCommand } from './local/account-unlink-command'; +export { LocalToDeviceMessage } from './local/local-to-device-message'; +export { LocalToDeviceMessagePayload } from './local/local-to-device-message-payload'; +export { OtaUpdateCheckForUpdatesCommand } from './local/ota-update-check-for-updates-command'; +export { OtaUpdateHandleUpdateRequestCommand } from './local/ota-update-handle-update-request-command'; +export { OtaUpdateSetAllowBackendManagementCommand } from './local/ota-update-set-allow-backend-management-command'; +export { OtaUpdateSetCheckIntervalCommand } from './local/ota-update-set-check-interval-command'; +export { OtaUpdateSetDomainCommand } from './local/ota-update-set-domain-command'; +export { OtaUpdateSetIsEnabledCommand } from './local/ota-update-set-is-enabled-command'; +export { OtaUpdateSetRequireManualApprovalCommand } from './local/ota-update-set-require-manual-approval-command'; +export { OtaUpdateSetUpdateChannelCommand } from './local/ota-update-set-update-channel-command'; +export { OtaUpdateStartUpdateCommand } from './local/ota-update-start-update-command'; +export { SetRfTxPinCommand } from './local/set-rf-tx-pin-command'; +export { WifiNetworkConnectCommand } from './local/wifi-network-connect-command'; +export { WifiNetworkDisconnectCommand } from './local/wifi-network-disconnect-command'; +export { WifiNetworkForgetCommand } from './local/wifi-network-forget-command'; +export { WifiNetworkSaveCommand } from './local/wifi-network-save-command'; +export { WifiScanCommand } from './local/wifi-scan-command'; diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-command-result.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-command-result.ts index fac7e08c..491d0809 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-command-result.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-command-result.ts @@ -1,33 +1,33 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { AccountLinkResultCode } from '../../../open-shock/serialization/local/account-link-result-code'; - - -export class AccountLinkCommandResult { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):AccountLinkCommandResult { - this.bb_pos = i; - this.bb = bb; - return this; -} - -result():AccountLinkResultCode { - return this.bb!.readUint8(this.bb_pos); -} - -static sizeOf():number { - return 1; -} - -static createAccountLinkCommandResult(builder:flatbuffers.Builder, result: AccountLinkResultCode):flatbuffers.Offset { - builder.prep(1, 1); - builder.writeInt8(result); - return builder.offset(); -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { AccountLinkResultCode } from '../../../open-shock/serialization/local/account-link-result-code'; + + +export class AccountLinkCommandResult { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):AccountLinkCommandResult { + this.bb_pos = i; + this.bb = bb; + return this; +} + +result():AccountLinkResultCode { + return this.bb!.readUint8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createAccountLinkCommandResult(builder:flatbuffers.Builder, result: AccountLinkResultCode):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(result); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-command.ts index 8ffc0f37..1c0188d3 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-command.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-command.ts @@ -1,50 +1,50 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class AccountLinkCommand { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):AccountLinkCommand { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsAccountLinkCommand(bb:flatbuffers.ByteBuffer, obj?:AccountLinkCommand):AccountLinkCommand { - return (obj || new AccountLinkCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsAccountLinkCommand(bb:flatbuffers.ByteBuffer, obj?:AccountLinkCommand):AccountLinkCommand { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new AccountLinkCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -code():string|null -code(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -code(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startAccountLinkCommand(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addCode(builder:flatbuffers.Builder, codeOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, codeOffset, 0); -} - -static endAccountLinkCommand(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createAccountLinkCommand(builder:flatbuffers.Builder, codeOffset:flatbuffers.Offset):flatbuffers.Offset { - AccountLinkCommand.startAccountLinkCommand(builder); - AccountLinkCommand.addCode(builder, codeOffset); - return AccountLinkCommand.endAccountLinkCommand(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class AccountLinkCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):AccountLinkCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsAccountLinkCommand(bb:flatbuffers.ByteBuffer, obj?:AccountLinkCommand):AccountLinkCommand { + return (obj || new AccountLinkCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsAccountLinkCommand(bb:flatbuffers.ByteBuffer, obj?:AccountLinkCommand):AccountLinkCommand { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new AccountLinkCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +code():string|null +code(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +code(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startAccountLinkCommand(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addCode(builder:flatbuffers.Builder, codeOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, codeOffset, 0); +} + +static endAccountLinkCommand(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createAccountLinkCommand(builder:flatbuffers.Builder, codeOffset:flatbuffers.Offset):flatbuffers.Offset { + AccountLinkCommand.startAccountLinkCommand(builder); + AccountLinkCommand.addCode(builder, codeOffset); + return AccountLinkCommand.endAccountLinkCommand(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-result-code.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-result-code.ts index 0e7a7a13..48872d5b 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-result-code.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/account-link-result-code.ts @@ -1,12 +1,12 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export enum AccountLinkResultCode { - Success = 0, - CodeRequired = 1, - InvalidCodeLength = 2, - NoInternetConnection = 3, - InvalidCode = 4, - InternalError = 5 -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum AccountLinkResultCode { + Success = 0, + CodeRequired = 1, + InvalidCodeLength = 2, + NoInternetConnection = 3, + InvalidCode = 4, + InternalError = 5 +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/account-unlink-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/account-unlink-command.ts index 5256be63..936e2ecf 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/account-unlink-command.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/account-unlink-command.ts @@ -1,30 +1,30 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class AccountUnlinkCommand { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):AccountUnlinkCommand { - this.bb_pos = i; - this.bb = bb; - return this; -} - -placeholder():boolean { - return !!this.bb!.readInt8(this.bb_pos); -} - -static sizeOf():number { - return 1; -} - -static createAccountUnlinkCommand(builder:flatbuffers.Builder, placeholder: boolean):flatbuffers.Offset { - builder.prep(1, 1); - builder.writeInt8(Number(Boolean(placeholder))); - return builder.offset(); -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class AccountUnlinkCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):AccountUnlinkCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +placeholder():boolean { + return !!this.bb!.readInt8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createAccountUnlinkCommand(builder:flatbuffers.Builder, placeholder: boolean):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(Number(Boolean(placeholder))); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/device-to-local-message-payload.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/device-to-local-message-payload.ts index 6af05098..5e5dd9e0 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/device-to-local-message-payload.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/device-to-local-message-payload.ts @@ -1,62 +1,62 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import { AccountLinkCommandResult } from '../../../open-shock/serialization/local/account-link-command-result'; -import { ErrorMessage } from '../../../open-shock/serialization/local/error-message'; -import { ReadyMessage } from '../../../open-shock/serialization/local/ready-message'; -import { SetRfTxPinCommandResult } from '../../../open-shock/serialization/local/set-rf-tx-pin-command-result'; -import { WifiGotIpEvent } from '../../../open-shock/serialization/local/wifi-got-ip-event'; -import { WifiLostIpEvent } from '../../../open-shock/serialization/local/wifi-lost-ip-event'; -import { WifiNetworkEvent } from '../../../open-shock/serialization/local/wifi-network-event'; -import { WifiScanStatusMessage } from '../../../open-shock/serialization/local/wifi-scan-status-message'; - - -export enum DeviceToLocalMessagePayload { - NONE = 0, - ReadyMessage = 1, - ErrorMessage = 2, - WifiScanStatusMessage = 3, - WifiNetworkEvent = 4, - WifiGotIpEvent = 5, - WifiLostIpEvent = 6, - AccountLinkCommandResult = 7, - SetRfTxPinCommandResult = 8 -} - -export function unionToDeviceToLocalMessagePayload( - type: DeviceToLocalMessagePayload, - accessor: (obj:AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage) => AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage|null -): AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage|null { - switch(DeviceToLocalMessagePayload[type]) { - case 'NONE': return null; - case 'ReadyMessage': return accessor(new ReadyMessage())! as ReadyMessage; - case 'ErrorMessage': return accessor(new ErrorMessage())! as ErrorMessage; - case 'WifiScanStatusMessage': return accessor(new WifiScanStatusMessage())! as WifiScanStatusMessage; - case 'WifiNetworkEvent': return accessor(new WifiNetworkEvent())! as WifiNetworkEvent; - case 'WifiGotIpEvent': return accessor(new WifiGotIpEvent())! as WifiGotIpEvent; - case 'WifiLostIpEvent': return accessor(new WifiLostIpEvent())! as WifiLostIpEvent; - case 'AccountLinkCommandResult': return accessor(new AccountLinkCommandResult())! as AccountLinkCommandResult; - case 'SetRfTxPinCommandResult': return accessor(new SetRfTxPinCommandResult())! as SetRfTxPinCommandResult; - default: return null; - } -} - -export function unionListToDeviceToLocalMessagePayload( - type: DeviceToLocalMessagePayload, - accessor: (index: number, obj:AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage) => AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage|null, - index: number -): AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage|null { - switch(DeviceToLocalMessagePayload[type]) { - case 'NONE': return null; - case 'ReadyMessage': return accessor(index, new ReadyMessage())! as ReadyMessage; - case 'ErrorMessage': return accessor(index, new ErrorMessage())! as ErrorMessage; - case 'WifiScanStatusMessage': return accessor(index, new WifiScanStatusMessage())! as WifiScanStatusMessage; - case 'WifiNetworkEvent': return accessor(index, new WifiNetworkEvent())! as WifiNetworkEvent; - case 'WifiGotIpEvent': return accessor(index, new WifiGotIpEvent())! as WifiGotIpEvent; - case 'WifiLostIpEvent': return accessor(index, new WifiLostIpEvent())! as WifiLostIpEvent; - case 'AccountLinkCommandResult': return accessor(index, new AccountLinkCommandResult())! as AccountLinkCommandResult; - case 'SetRfTxPinCommandResult': return accessor(index, new SetRfTxPinCommandResult())! as SetRfTxPinCommandResult; - default: return null; - } -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import { AccountLinkCommandResult } from '../../../open-shock/serialization/local/account-link-command-result'; +import { ErrorMessage } from '../../../open-shock/serialization/local/error-message'; +import { ReadyMessage } from '../../../open-shock/serialization/local/ready-message'; +import { SetRfTxPinCommandResult } from '../../../open-shock/serialization/local/set-rf-tx-pin-command-result'; +import { WifiGotIpEvent } from '../../../open-shock/serialization/local/wifi-got-ip-event'; +import { WifiLostIpEvent } from '../../../open-shock/serialization/local/wifi-lost-ip-event'; +import { WifiNetworkEvent } from '../../../open-shock/serialization/local/wifi-network-event'; +import { WifiScanStatusMessage } from '../../../open-shock/serialization/local/wifi-scan-status-message'; + + +export enum DeviceToLocalMessagePayload { + NONE = 0, + ReadyMessage = 1, + ErrorMessage = 2, + WifiScanStatusMessage = 3, + WifiNetworkEvent = 4, + WifiGotIpEvent = 5, + WifiLostIpEvent = 6, + AccountLinkCommandResult = 7, + SetRfTxPinCommandResult = 8 +} + +export function unionToDeviceToLocalMessagePayload( + type: DeviceToLocalMessagePayload, + accessor: (obj:AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage) => AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage|null +): AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage|null { + switch(DeviceToLocalMessagePayload[type]) { + case 'NONE': return null; + case 'ReadyMessage': return accessor(new ReadyMessage())! as ReadyMessage; + case 'ErrorMessage': return accessor(new ErrorMessage())! as ErrorMessage; + case 'WifiScanStatusMessage': return accessor(new WifiScanStatusMessage())! as WifiScanStatusMessage; + case 'WifiNetworkEvent': return accessor(new WifiNetworkEvent())! as WifiNetworkEvent; + case 'WifiGotIpEvent': return accessor(new WifiGotIpEvent())! as WifiGotIpEvent; + case 'WifiLostIpEvent': return accessor(new WifiLostIpEvent())! as WifiLostIpEvent; + case 'AccountLinkCommandResult': return accessor(new AccountLinkCommandResult())! as AccountLinkCommandResult; + case 'SetRfTxPinCommandResult': return accessor(new SetRfTxPinCommandResult())! as SetRfTxPinCommandResult; + default: return null; + } +} + +export function unionListToDeviceToLocalMessagePayload( + type: DeviceToLocalMessagePayload, + accessor: (index: number, obj:AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage) => AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage|null, + index: number +): AccountLinkCommandResult|ErrorMessage|ReadyMessage|SetRfTxPinCommandResult|WifiGotIpEvent|WifiLostIpEvent|WifiNetworkEvent|WifiScanStatusMessage|null { + switch(DeviceToLocalMessagePayload[type]) { + case 'NONE': return null; + case 'ReadyMessage': return accessor(index, new ReadyMessage())! as ReadyMessage; + case 'ErrorMessage': return accessor(index, new ErrorMessage())! as ErrorMessage; + case 'WifiScanStatusMessage': return accessor(index, new WifiScanStatusMessage())! as WifiScanStatusMessage; + case 'WifiNetworkEvent': return accessor(index, new WifiNetworkEvent())! as WifiNetworkEvent; + case 'WifiGotIpEvent': return accessor(index, new WifiGotIpEvent())! as WifiGotIpEvent; + case 'WifiLostIpEvent': return accessor(index, new WifiLostIpEvent())! as WifiLostIpEvent; + case 'AccountLinkCommandResult': return accessor(index, new AccountLinkCommandResult())! as AccountLinkCommandResult; + case 'SetRfTxPinCommandResult': return accessor(index, new SetRfTxPinCommandResult())! as SetRfTxPinCommandResult; + default: return null; + } +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/device-to-local-message.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/device-to-local-message.ts index b989d6fd..953e2207 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/device-to-local-message.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/device-to-local-message.ts @@ -1,69 +1,69 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { DeviceToLocalMessagePayload, unionToDeviceToLocalMessagePayload, unionListToDeviceToLocalMessagePayload } from '../../../open-shock/serialization/local/device-to-local-message-payload'; - - -export class DeviceToLocalMessage { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):DeviceToLocalMessage { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsDeviceToLocalMessage(bb:flatbuffers.ByteBuffer, obj?:DeviceToLocalMessage):DeviceToLocalMessage { - return (obj || new DeviceToLocalMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsDeviceToLocalMessage(bb:flatbuffers.ByteBuffer, obj?:DeviceToLocalMessage):DeviceToLocalMessage { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new DeviceToLocalMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -payloadType():DeviceToLocalMessagePayload { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : DeviceToLocalMessagePayload.NONE; -} - -payload(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -static startDeviceToLocalMessage(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addPayloadType(builder:flatbuffers.Builder, payloadType:DeviceToLocalMessagePayload) { - builder.addFieldInt8(0, payloadType, DeviceToLocalMessagePayload.NONE); -} - -static addPayload(builder:flatbuffers.Builder, payloadOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, payloadOffset, 0); -} - -static endDeviceToLocalMessage(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static finishDeviceToLocalMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset); -} - -static finishSizePrefixedDeviceToLocalMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, undefined, true); -} - -static createDeviceToLocalMessage(builder:flatbuffers.Builder, payloadType:DeviceToLocalMessagePayload, payloadOffset:flatbuffers.Offset):flatbuffers.Offset { - DeviceToLocalMessage.startDeviceToLocalMessage(builder); - DeviceToLocalMessage.addPayloadType(builder, payloadType); - DeviceToLocalMessage.addPayload(builder, payloadOffset); - return DeviceToLocalMessage.endDeviceToLocalMessage(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { DeviceToLocalMessagePayload, unionToDeviceToLocalMessagePayload, unionListToDeviceToLocalMessagePayload } from '../../../open-shock/serialization/local/device-to-local-message-payload'; + + +export class DeviceToLocalMessage { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):DeviceToLocalMessage { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsDeviceToLocalMessage(bb:flatbuffers.ByteBuffer, obj?:DeviceToLocalMessage):DeviceToLocalMessage { + return (obj || new DeviceToLocalMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsDeviceToLocalMessage(bb:flatbuffers.ByteBuffer, obj?:DeviceToLocalMessage):DeviceToLocalMessage { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new DeviceToLocalMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +payloadType():DeviceToLocalMessagePayload { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : DeviceToLocalMessagePayload.NONE; +} + +payload(obj:any):any|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; +} + +static startDeviceToLocalMessage(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addPayloadType(builder:flatbuffers.Builder, payloadType:DeviceToLocalMessagePayload) { + builder.addFieldInt8(0, payloadType, DeviceToLocalMessagePayload.NONE); +} + +static addPayload(builder:flatbuffers.Builder, payloadOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, payloadOffset, 0); +} + +static endDeviceToLocalMessage(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishDeviceToLocalMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedDeviceToLocalMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createDeviceToLocalMessage(builder:flatbuffers.Builder, payloadType:DeviceToLocalMessagePayload, payloadOffset:flatbuffers.Offset):flatbuffers.Offset { + DeviceToLocalMessage.startDeviceToLocalMessage(builder); + DeviceToLocalMessage.addPayloadType(builder, payloadType); + DeviceToLocalMessage.addPayload(builder, payloadOffset); + return DeviceToLocalMessage.endDeviceToLocalMessage(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/error-message.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/error-message.ts index ea45598b..9b62f56a 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/error-message.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/error-message.ts @@ -1,50 +1,50 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class ErrorMessage { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):ErrorMessage { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsErrorMessage(bb:flatbuffers.ByteBuffer, obj?:ErrorMessage):ErrorMessage { - return (obj || new ErrorMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsErrorMessage(bb:flatbuffers.ByteBuffer, obj?:ErrorMessage):ErrorMessage { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new ErrorMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -message():string|null -message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -message(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startErrorMessage(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, messageOffset, 0); -} - -static endErrorMessage(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createErrorMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset):flatbuffers.Offset { - ErrorMessage.startErrorMessage(builder); - ErrorMessage.addMessage(builder, messageOffset); - return ErrorMessage.endErrorMessage(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class ErrorMessage { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):ErrorMessage { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsErrorMessage(bb:flatbuffers.ByteBuffer, obj?:ErrorMessage):ErrorMessage { + return (obj || new ErrorMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsErrorMessage(bb:flatbuffers.ByteBuffer, obj?:ErrorMessage):ErrorMessage { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new ErrorMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +message():string|null +message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +message(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startErrorMessage(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, messageOffset, 0); +} + +static endErrorMessage(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createErrorMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset):flatbuffers.Offset { + ErrorMessage.startErrorMessage(builder); + ErrorMessage.addMessage(builder, messageOffset); + return ErrorMessage.endErrorMessage(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/local-to-device-message-payload.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/local-to-device-message-payload.ts index d07ca177..fc1999fb 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/local-to-device-message-payload.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/local-to-device-message-payload.ts @@ -1,62 +1,98 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import { AccountLinkCommand } from '../../../open-shock/serialization/local/account-link-command'; -import { AccountUnlinkCommand } from '../../../open-shock/serialization/local/account-unlink-command'; -import { SetRfTxPinCommand } from '../../../open-shock/serialization/local/set-rf-tx-pin-command'; -import { WifiNetworkConnectCommand } from '../../../open-shock/serialization/local/wifi-network-connect-command'; -import { WifiNetworkDisconnectCommand } from '../../../open-shock/serialization/local/wifi-network-disconnect-command'; -import { WifiNetworkForgetCommand } from '../../../open-shock/serialization/local/wifi-network-forget-command'; -import { WifiNetworkSaveCommand } from '../../../open-shock/serialization/local/wifi-network-save-command'; -import { WifiScanCommand } from '../../../open-shock/serialization/local/wifi-scan-command'; - - -export enum LocalToDeviceMessagePayload { - NONE = 0, - WifiScanCommand = 1, - WifiNetworkSaveCommand = 2, - WifiNetworkForgetCommand = 3, - WifiNetworkConnectCommand = 4, - WifiNetworkDisconnectCommand = 5, - AccountLinkCommand = 6, - AccountUnlinkCommand = 7, - SetRfTxPinCommand = 8 -} - -export function unionToLocalToDeviceMessagePayload( - type: LocalToDeviceMessagePayload, - accessor: (obj:AccountLinkCommand|AccountUnlinkCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand) => AccountLinkCommand|AccountUnlinkCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand|null -): AccountLinkCommand|AccountUnlinkCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand|null { - switch(LocalToDeviceMessagePayload[type]) { - case 'NONE': return null; - case 'WifiScanCommand': return accessor(new WifiScanCommand())! as WifiScanCommand; - case 'WifiNetworkSaveCommand': return accessor(new WifiNetworkSaveCommand())! as WifiNetworkSaveCommand; - case 'WifiNetworkForgetCommand': return accessor(new WifiNetworkForgetCommand())! as WifiNetworkForgetCommand; - case 'WifiNetworkConnectCommand': return accessor(new WifiNetworkConnectCommand())! as WifiNetworkConnectCommand; - case 'WifiNetworkDisconnectCommand': return accessor(new WifiNetworkDisconnectCommand())! as WifiNetworkDisconnectCommand; - case 'AccountLinkCommand': return accessor(new AccountLinkCommand())! as AccountLinkCommand; - case 'AccountUnlinkCommand': return accessor(new AccountUnlinkCommand())! as AccountUnlinkCommand; - case 'SetRfTxPinCommand': return accessor(new SetRfTxPinCommand())! as SetRfTxPinCommand; - default: return null; - } -} - -export function unionListToLocalToDeviceMessagePayload( - type: LocalToDeviceMessagePayload, - accessor: (index: number, obj:AccountLinkCommand|AccountUnlinkCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand) => AccountLinkCommand|AccountUnlinkCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand|null, - index: number -): AccountLinkCommand|AccountUnlinkCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand|null { - switch(LocalToDeviceMessagePayload[type]) { - case 'NONE': return null; - case 'WifiScanCommand': return accessor(index, new WifiScanCommand())! as WifiScanCommand; - case 'WifiNetworkSaveCommand': return accessor(index, new WifiNetworkSaveCommand())! as WifiNetworkSaveCommand; - case 'WifiNetworkForgetCommand': return accessor(index, new WifiNetworkForgetCommand())! as WifiNetworkForgetCommand; - case 'WifiNetworkConnectCommand': return accessor(index, new WifiNetworkConnectCommand())! as WifiNetworkConnectCommand; - case 'WifiNetworkDisconnectCommand': return accessor(index, new WifiNetworkDisconnectCommand())! as WifiNetworkDisconnectCommand; - case 'AccountLinkCommand': return accessor(index, new AccountLinkCommand())! as AccountLinkCommand; - case 'AccountUnlinkCommand': return accessor(index, new AccountUnlinkCommand())! as AccountUnlinkCommand; - case 'SetRfTxPinCommand': return accessor(index, new SetRfTxPinCommand())! as SetRfTxPinCommand; - default: return null; - } -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import { AccountLinkCommand } from '../../../open-shock/serialization/local/account-link-command'; +import { AccountUnlinkCommand } from '../../../open-shock/serialization/local/account-unlink-command'; +import { OtaUpdateCheckForUpdatesCommand } from '../../../open-shock/serialization/local/ota-update-check-for-updates-command'; +import { OtaUpdateHandleUpdateRequestCommand } from '../../../open-shock/serialization/local/ota-update-handle-update-request-command'; +import { OtaUpdateSetAllowBackendManagementCommand } from '../../../open-shock/serialization/local/ota-update-set-allow-backend-management-command'; +import { OtaUpdateSetCheckIntervalCommand } from '../../../open-shock/serialization/local/ota-update-set-check-interval-command'; +import { OtaUpdateSetDomainCommand } from '../../../open-shock/serialization/local/ota-update-set-domain-command'; +import { OtaUpdateSetIsEnabledCommand } from '../../../open-shock/serialization/local/ota-update-set-is-enabled-command'; +import { OtaUpdateSetRequireManualApprovalCommand } from '../../../open-shock/serialization/local/ota-update-set-require-manual-approval-command'; +import { OtaUpdateSetUpdateChannelCommand } from '../../../open-shock/serialization/local/ota-update-set-update-channel-command'; +import { OtaUpdateStartUpdateCommand } from '../../../open-shock/serialization/local/ota-update-start-update-command'; +import { SetRfTxPinCommand } from '../../../open-shock/serialization/local/set-rf-tx-pin-command'; +import { WifiNetworkConnectCommand } from '../../../open-shock/serialization/local/wifi-network-connect-command'; +import { WifiNetworkDisconnectCommand } from '../../../open-shock/serialization/local/wifi-network-disconnect-command'; +import { WifiNetworkForgetCommand } from '../../../open-shock/serialization/local/wifi-network-forget-command'; +import { WifiNetworkSaveCommand } from '../../../open-shock/serialization/local/wifi-network-save-command'; +import { WifiScanCommand } from '../../../open-shock/serialization/local/wifi-scan-command'; + + +export enum LocalToDeviceMessagePayload { + NONE = 0, + WifiScanCommand = 1, + WifiNetworkSaveCommand = 2, + WifiNetworkForgetCommand = 3, + WifiNetworkConnectCommand = 4, + WifiNetworkDisconnectCommand = 5, + OtaUpdateSetIsEnabledCommand = 6, + OtaUpdateSetDomainCommand = 7, + OtaUpdateSetUpdateChannelCommand = 8, + OtaUpdateSetCheckIntervalCommand = 9, + OtaUpdateSetAllowBackendManagementCommand = 10, + OtaUpdateSetRequireManualApprovalCommand = 11, + OtaUpdateHandleUpdateRequestCommand = 12, + OtaUpdateCheckForUpdatesCommand = 13, + OtaUpdateStartUpdateCommand = 14, + AccountLinkCommand = 15, + AccountUnlinkCommand = 16, + SetRfTxPinCommand = 17 +} + +export function unionToLocalToDeviceMessagePayload( + type: LocalToDeviceMessagePayload, + accessor: (obj:AccountLinkCommand|AccountUnlinkCommand|OtaUpdateCheckForUpdatesCommand|OtaUpdateHandleUpdateRequestCommand|OtaUpdateSetAllowBackendManagementCommand|OtaUpdateSetCheckIntervalCommand|OtaUpdateSetDomainCommand|OtaUpdateSetIsEnabledCommand|OtaUpdateSetRequireManualApprovalCommand|OtaUpdateSetUpdateChannelCommand|OtaUpdateStartUpdateCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand) => AccountLinkCommand|AccountUnlinkCommand|OtaUpdateCheckForUpdatesCommand|OtaUpdateHandleUpdateRequestCommand|OtaUpdateSetAllowBackendManagementCommand|OtaUpdateSetCheckIntervalCommand|OtaUpdateSetDomainCommand|OtaUpdateSetIsEnabledCommand|OtaUpdateSetRequireManualApprovalCommand|OtaUpdateSetUpdateChannelCommand|OtaUpdateStartUpdateCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand|null +): AccountLinkCommand|AccountUnlinkCommand|OtaUpdateCheckForUpdatesCommand|OtaUpdateHandleUpdateRequestCommand|OtaUpdateSetAllowBackendManagementCommand|OtaUpdateSetCheckIntervalCommand|OtaUpdateSetDomainCommand|OtaUpdateSetIsEnabledCommand|OtaUpdateSetRequireManualApprovalCommand|OtaUpdateSetUpdateChannelCommand|OtaUpdateStartUpdateCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand|null { + switch(LocalToDeviceMessagePayload[type]) { + case 'NONE': return null; + case 'WifiScanCommand': return accessor(new WifiScanCommand())! as WifiScanCommand; + case 'WifiNetworkSaveCommand': return accessor(new WifiNetworkSaveCommand())! as WifiNetworkSaveCommand; + case 'WifiNetworkForgetCommand': return accessor(new WifiNetworkForgetCommand())! as WifiNetworkForgetCommand; + case 'WifiNetworkConnectCommand': return accessor(new WifiNetworkConnectCommand())! as WifiNetworkConnectCommand; + case 'WifiNetworkDisconnectCommand': return accessor(new WifiNetworkDisconnectCommand())! as WifiNetworkDisconnectCommand; + case 'OtaUpdateSetIsEnabledCommand': return accessor(new OtaUpdateSetIsEnabledCommand())! as OtaUpdateSetIsEnabledCommand; + case 'OtaUpdateSetDomainCommand': return accessor(new OtaUpdateSetDomainCommand())! as OtaUpdateSetDomainCommand; + case 'OtaUpdateSetUpdateChannelCommand': return accessor(new OtaUpdateSetUpdateChannelCommand())! as OtaUpdateSetUpdateChannelCommand; + case 'OtaUpdateSetCheckIntervalCommand': return accessor(new OtaUpdateSetCheckIntervalCommand())! as OtaUpdateSetCheckIntervalCommand; + case 'OtaUpdateSetAllowBackendManagementCommand': return accessor(new OtaUpdateSetAllowBackendManagementCommand())! as OtaUpdateSetAllowBackendManagementCommand; + case 'OtaUpdateSetRequireManualApprovalCommand': return accessor(new OtaUpdateSetRequireManualApprovalCommand())! as OtaUpdateSetRequireManualApprovalCommand; + case 'OtaUpdateHandleUpdateRequestCommand': return accessor(new OtaUpdateHandleUpdateRequestCommand())! as OtaUpdateHandleUpdateRequestCommand; + case 'OtaUpdateCheckForUpdatesCommand': return accessor(new OtaUpdateCheckForUpdatesCommand())! as OtaUpdateCheckForUpdatesCommand; + case 'OtaUpdateStartUpdateCommand': return accessor(new OtaUpdateStartUpdateCommand())! as OtaUpdateStartUpdateCommand; + case 'AccountLinkCommand': return accessor(new AccountLinkCommand())! as AccountLinkCommand; + case 'AccountUnlinkCommand': return accessor(new AccountUnlinkCommand())! as AccountUnlinkCommand; + case 'SetRfTxPinCommand': return accessor(new SetRfTxPinCommand())! as SetRfTxPinCommand; + default: return null; + } +} + +export function unionListToLocalToDeviceMessagePayload( + type: LocalToDeviceMessagePayload, + accessor: (index: number, obj:AccountLinkCommand|AccountUnlinkCommand|OtaUpdateCheckForUpdatesCommand|OtaUpdateHandleUpdateRequestCommand|OtaUpdateSetAllowBackendManagementCommand|OtaUpdateSetCheckIntervalCommand|OtaUpdateSetDomainCommand|OtaUpdateSetIsEnabledCommand|OtaUpdateSetRequireManualApprovalCommand|OtaUpdateSetUpdateChannelCommand|OtaUpdateStartUpdateCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand) => AccountLinkCommand|AccountUnlinkCommand|OtaUpdateCheckForUpdatesCommand|OtaUpdateHandleUpdateRequestCommand|OtaUpdateSetAllowBackendManagementCommand|OtaUpdateSetCheckIntervalCommand|OtaUpdateSetDomainCommand|OtaUpdateSetIsEnabledCommand|OtaUpdateSetRequireManualApprovalCommand|OtaUpdateSetUpdateChannelCommand|OtaUpdateStartUpdateCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand|null, + index: number +): AccountLinkCommand|AccountUnlinkCommand|OtaUpdateCheckForUpdatesCommand|OtaUpdateHandleUpdateRequestCommand|OtaUpdateSetAllowBackendManagementCommand|OtaUpdateSetCheckIntervalCommand|OtaUpdateSetDomainCommand|OtaUpdateSetIsEnabledCommand|OtaUpdateSetRequireManualApprovalCommand|OtaUpdateSetUpdateChannelCommand|OtaUpdateStartUpdateCommand|SetRfTxPinCommand|WifiNetworkConnectCommand|WifiNetworkDisconnectCommand|WifiNetworkForgetCommand|WifiNetworkSaveCommand|WifiScanCommand|null { + switch(LocalToDeviceMessagePayload[type]) { + case 'NONE': return null; + case 'WifiScanCommand': return accessor(index, new WifiScanCommand())! as WifiScanCommand; + case 'WifiNetworkSaveCommand': return accessor(index, new WifiNetworkSaveCommand())! as WifiNetworkSaveCommand; + case 'WifiNetworkForgetCommand': return accessor(index, new WifiNetworkForgetCommand())! as WifiNetworkForgetCommand; + case 'WifiNetworkConnectCommand': return accessor(index, new WifiNetworkConnectCommand())! as WifiNetworkConnectCommand; + case 'WifiNetworkDisconnectCommand': return accessor(index, new WifiNetworkDisconnectCommand())! as WifiNetworkDisconnectCommand; + case 'OtaUpdateSetIsEnabledCommand': return accessor(index, new OtaUpdateSetIsEnabledCommand())! as OtaUpdateSetIsEnabledCommand; + case 'OtaUpdateSetDomainCommand': return accessor(index, new OtaUpdateSetDomainCommand())! as OtaUpdateSetDomainCommand; + case 'OtaUpdateSetUpdateChannelCommand': return accessor(index, new OtaUpdateSetUpdateChannelCommand())! as OtaUpdateSetUpdateChannelCommand; + case 'OtaUpdateSetCheckIntervalCommand': return accessor(index, new OtaUpdateSetCheckIntervalCommand())! as OtaUpdateSetCheckIntervalCommand; + case 'OtaUpdateSetAllowBackendManagementCommand': return accessor(index, new OtaUpdateSetAllowBackendManagementCommand())! as OtaUpdateSetAllowBackendManagementCommand; + case 'OtaUpdateSetRequireManualApprovalCommand': return accessor(index, new OtaUpdateSetRequireManualApprovalCommand())! as OtaUpdateSetRequireManualApprovalCommand; + case 'OtaUpdateHandleUpdateRequestCommand': return accessor(index, new OtaUpdateHandleUpdateRequestCommand())! as OtaUpdateHandleUpdateRequestCommand; + case 'OtaUpdateCheckForUpdatesCommand': return accessor(index, new OtaUpdateCheckForUpdatesCommand())! as OtaUpdateCheckForUpdatesCommand; + case 'OtaUpdateStartUpdateCommand': return accessor(index, new OtaUpdateStartUpdateCommand())! as OtaUpdateStartUpdateCommand; + case 'AccountLinkCommand': return accessor(index, new AccountLinkCommand())! as AccountLinkCommand; + case 'AccountUnlinkCommand': return accessor(index, new AccountUnlinkCommand())! as AccountUnlinkCommand; + case 'SetRfTxPinCommand': return accessor(index, new SetRfTxPinCommand())! as SetRfTxPinCommand; + default: return null; + } +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/local-to-device-message.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/local-to-device-message.ts index b09eeb42..91a2a4a8 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/local-to-device-message.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/local-to-device-message.ts @@ -1,69 +1,69 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { LocalToDeviceMessagePayload, unionToLocalToDeviceMessagePayload, unionListToLocalToDeviceMessagePayload } from '../../../open-shock/serialization/local/local-to-device-message-payload'; - - -export class LocalToDeviceMessage { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):LocalToDeviceMessage { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsLocalToDeviceMessage(bb:flatbuffers.ByteBuffer, obj?:LocalToDeviceMessage):LocalToDeviceMessage { - return (obj || new LocalToDeviceMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsLocalToDeviceMessage(bb:flatbuffers.ByteBuffer, obj?:LocalToDeviceMessage):LocalToDeviceMessage { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new LocalToDeviceMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -payloadType():LocalToDeviceMessagePayload { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : LocalToDeviceMessagePayload.NONE; -} - -payload(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -static startLocalToDeviceMessage(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addPayloadType(builder:flatbuffers.Builder, payloadType:LocalToDeviceMessagePayload) { - builder.addFieldInt8(0, payloadType, LocalToDeviceMessagePayload.NONE); -} - -static addPayload(builder:flatbuffers.Builder, payloadOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, payloadOffset, 0); -} - -static endLocalToDeviceMessage(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static finishLocalToDeviceMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset); -} - -static finishSizePrefixedLocalToDeviceMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, undefined, true); -} - -static createLocalToDeviceMessage(builder:flatbuffers.Builder, payloadType:LocalToDeviceMessagePayload, payloadOffset:flatbuffers.Offset):flatbuffers.Offset { - LocalToDeviceMessage.startLocalToDeviceMessage(builder); - LocalToDeviceMessage.addPayloadType(builder, payloadType); - LocalToDeviceMessage.addPayload(builder, payloadOffset); - return LocalToDeviceMessage.endLocalToDeviceMessage(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { LocalToDeviceMessagePayload, unionToLocalToDeviceMessagePayload, unionListToLocalToDeviceMessagePayload } from '../../../open-shock/serialization/local/local-to-device-message-payload'; + + +export class LocalToDeviceMessage { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):LocalToDeviceMessage { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsLocalToDeviceMessage(bb:flatbuffers.ByteBuffer, obj?:LocalToDeviceMessage):LocalToDeviceMessage { + return (obj || new LocalToDeviceMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsLocalToDeviceMessage(bb:flatbuffers.ByteBuffer, obj?:LocalToDeviceMessage):LocalToDeviceMessage { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new LocalToDeviceMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +payloadType():LocalToDeviceMessagePayload { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : LocalToDeviceMessagePayload.NONE; +} + +payload(obj:any):any|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; +} + +static startLocalToDeviceMessage(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addPayloadType(builder:flatbuffers.Builder, payloadType:LocalToDeviceMessagePayload) { + builder.addFieldInt8(0, payloadType, LocalToDeviceMessagePayload.NONE); +} + +static addPayload(builder:flatbuffers.Builder, payloadOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, payloadOffset, 0); +} + +static endLocalToDeviceMessage(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishLocalToDeviceMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedLocalToDeviceMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createLocalToDeviceMessage(builder:flatbuffers.Builder, payloadType:LocalToDeviceMessagePayload, payloadOffset:flatbuffers.Offset):flatbuffers.Offset { + LocalToDeviceMessage.startLocalToDeviceMessage(builder); + LocalToDeviceMessage.addPayloadType(builder, payloadType); + LocalToDeviceMessage.addPayload(builder, payloadOffset); + return LocalToDeviceMessage.endLocalToDeviceMessage(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-check-for-updates-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-check-for-updates-command.ts new file mode 100644 index 00000000..d44738a4 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-check-for-updates-command.ts @@ -0,0 +1,50 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class OtaUpdateCheckForUpdatesCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaUpdateCheckForUpdatesCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsOtaUpdateCheckForUpdatesCommand(bb:flatbuffers.ByteBuffer, obj?:OtaUpdateCheckForUpdatesCommand):OtaUpdateCheckForUpdatesCommand { + return (obj || new OtaUpdateCheckForUpdatesCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsOtaUpdateCheckForUpdatesCommand(bb:flatbuffers.ByteBuffer, obj?:OtaUpdateCheckForUpdatesCommand):OtaUpdateCheckForUpdatesCommand { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new OtaUpdateCheckForUpdatesCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +channel():string|null +channel(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +channel(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startOtaUpdateCheckForUpdatesCommand(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addChannel(builder:flatbuffers.Builder, channelOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, channelOffset, 0); +} + +static endOtaUpdateCheckForUpdatesCommand(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createOtaUpdateCheckForUpdatesCommand(builder:flatbuffers.Builder, channelOffset:flatbuffers.Offset):flatbuffers.Offset { + OtaUpdateCheckForUpdatesCommand.startOtaUpdateCheckForUpdatesCommand(builder); + OtaUpdateCheckForUpdatesCommand.addChannel(builder, channelOffset); + return OtaUpdateCheckForUpdatesCommand.endOtaUpdateCheckForUpdatesCommand(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-handle-update-request-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-handle-update-request-command.ts new file mode 100644 index 00000000..82e5cd43 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-handle-update-request-command.ts @@ -0,0 +1,30 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class OtaUpdateHandleUpdateRequestCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaUpdateHandleUpdateRequestCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +accept():boolean { + return !!this.bb!.readInt8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createOtaUpdateHandleUpdateRequestCommand(builder:flatbuffers.Builder, accept: boolean):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(Number(Boolean(accept))); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-allow-backend-management-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-allow-backend-management-command.ts new file mode 100644 index 00000000..239cb149 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-allow-backend-management-command.ts @@ -0,0 +1,30 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class OtaUpdateSetAllowBackendManagementCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaUpdateSetAllowBackendManagementCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +allow():boolean { + return !!this.bb!.readInt8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createOtaUpdateSetAllowBackendManagementCommand(builder:flatbuffers.Builder, allow: boolean):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(Number(Boolean(allow))); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-check-interval-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-check-interval-command.ts new file mode 100644 index 00000000..b7c57545 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-check-interval-command.ts @@ -0,0 +1,30 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class OtaUpdateSetCheckIntervalCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaUpdateSetCheckIntervalCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +interval():number { + return this.bb!.readUint16(this.bb_pos); +} + +static sizeOf():number { + return 2; +} + +static createOtaUpdateSetCheckIntervalCommand(builder:flatbuffers.Builder, interval: number):flatbuffers.Offset { + builder.prep(2, 2); + builder.writeInt16(interval); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-domain-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-domain-command.ts new file mode 100644 index 00000000..f4475a98 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-domain-command.ts @@ -0,0 +1,50 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class OtaUpdateSetDomainCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaUpdateSetDomainCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsOtaUpdateSetDomainCommand(bb:flatbuffers.ByteBuffer, obj?:OtaUpdateSetDomainCommand):OtaUpdateSetDomainCommand { + return (obj || new OtaUpdateSetDomainCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsOtaUpdateSetDomainCommand(bb:flatbuffers.ByteBuffer, obj?:OtaUpdateSetDomainCommand):OtaUpdateSetDomainCommand { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new OtaUpdateSetDomainCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +domain():string|null +domain(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +domain(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startOtaUpdateSetDomainCommand(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addDomain(builder:flatbuffers.Builder, domainOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, domainOffset, 0); +} + +static endOtaUpdateSetDomainCommand(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createOtaUpdateSetDomainCommand(builder:flatbuffers.Builder, domainOffset:flatbuffers.Offset):flatbuffers.Offset { + OtaUpdateSetDomainCommand.startOtaUpdateSetDomainCommand(builder); + OtaUpdateSetDomainCommand.addDomain(builder, domainOffset); + return OtaUpdateSetDomainCommand.endOtaUpdateSetDomainCommand(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-is-enabled-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-is-enabled-command.ts new file mode 100644 index 00000000..eccce2ea --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-is-enabled-command.ts @@ -0,0 +1,30 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class OtaUpdateSetIsEnabledCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaUpdateSetIsEnabledCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +enabled():boolean { + return !!this.bb!.readInt8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createOtaUpdateSetIsEnabledCommand(builder:flatbuffers.Builder, enabled: boolean):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(Number(Boolean(enabled))); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-require-manual-approval-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-require-manual-approval-command.ts new file mode 100644 index 00000000..4df4af6a --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-require-manual-approval-command.ts @@ -0,0 +1,30 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class OtaUpdateSetRequireManualApprovalCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaUpdateSetRequireManualApprovalCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +require():boolean { + return !!this.bb!.readInt8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createOtaUpdateSetRequireManualApprovalCommand(builder:flatbuffers.Builder, require: boolean):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(Number(Boolean(require))); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-update-channel-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-update-channel-command.ts new file mode 100644 index 00000000..039aa734 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-set-update-channel-command.ts @@ -0,0 +1,50 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class OtaUpdateSetUpdateChannelCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaUpdateSetUpdateChannelCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsOtaUpdateSetUpdateChannelCommand(bb:flatbuffers.ByteBuffer, obj?:OtaUpdateSetUpdateChannelCommand):OtaUpdateSetUpdateChannelCommand { + return (obj || new OtaUpdateSetUpdateChannelCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsOtaUpdateSetUpdateChannelCommand(bb:flatbuffers.ByteBuffer, obj?:OtaUpdateSetUpdateChannelCommand):OtaUpdateSetUpdateChannelCommand { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new OtaUpdateSetUpdateChannelCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +channel():string|null +channel(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +channel(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startOtaUpdateSetUpdateChannelCommand(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addChannel(builder:flatbuffers.Builder, channelOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, channelOffset, 0); +} + +static endOtaUpdateSetUpdateChannelCommand(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createOtaUpdateSetUpdateChannelCommand(builder:flatbuffers.Builder, channelOffset:flatbuffers.Offset):flatbuffers.Offset { + OtaUpdateSetUpdateChannelCommand.startOtaUpdateSetUpdateChannelCommand(builder); + OtaUpdateSetUpdateChannelCommand.addChannel(builder, channelOffset); + return OtaUpdateSetUpdateChannelCommand.endOtaUpdateSetUpdateChannelCommand(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-start-update-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-start-update-command.ts new file mode 100644 index 00000000..447711ec --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/ota-update-start-update-command.ts @@ -0,0 +1,62 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class OtaUpdateStartUpdateCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OtaUpdateStartUpdateCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsOtaUpdateStartUpdateCommand(bb:flatbuffers.ByteBuffer, obj?:OtaUpdateStartUpdateCommand):OtaUpdateStartUpdateCommand { + return (obj || new OtaUpdateStartUpdateCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsOtaUpdateStartUpdateCommand(bb:flatbuffers.ByteBuffer, obj?:OtaUpdateStartUpdateCommand):OtaUpdateStartUpdateCommand { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new OtaUpdateStartUpdateCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +channel():string|null +channel(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +channel(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +version():string|null +version(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +version(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startOtaUpdateStartUpdateCommand(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addChannel(builder:flatbuffers.Builder, channelOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, channelOffset, 0); +} + +static addVersion(builder:flatbuffers.Builder, versionOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, versionOffset, 0); +} + +static endOtaUpdateStartUpdateCommand(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createOtaUpdateStartUpdateCommand(builder:flatbuffers.Builder, channelOffset:flatbuffers.Offset, versionOffset:flatbuffers.Offset):flatbuffers.Offset { + OtaUpdateStartUpdateCommand.startOtaUpdateStartUpdateCommand(builder); + OtaUpdateStartUpdateCommand.addChannel(builder, channelOffset); + OtaUpdateStartUpdateCommand.addVersion(builder, versionOffset); + return OtaUpdateStartUpdateCommand.endOtaUpdateStartUpdateCommand(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/ready-message.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/ready-message.ts index 341ea14f..a4402724 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/ready-message.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/ready-message.ts @@ -1,74 +1,74 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { Config } from '../../../open-shock/serialization/configuration/config'; -import { WifiNetwork } from '../../../open-shock/serialization/types/wifi-network'; - - -export class ReadyMessage { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):ReadyMessage { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsReadyMessage(bb:flatbuffers.ByteBuffer, obj?:ReadyMessage):ReadyMessage { - return (obj || new ReadyMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsReadyMessage(bb:flatbuffers.ByteBuffer, obj?:ReadyMessage):ReadyMessage { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new ReadyMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -poggies():boolean { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -} - -connectedWifi(obj?:WifiNetwork):WifiNetwork|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? (obj || new WifiNetwork()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -accountLinked():boolean { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -} - -config(obj?:Config):Config|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? (obj || new Config()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -static startReadyMessage(builder:flatbuffers.Builder) { - builder.startObject(4); -} - -static addPoggies(builder:flatbuffers.Builder, poggies:boolean) { - builder.addFieldInt8(0, +poggies, +false); -} - -static addConnectedWifi(builder:flatbuffers.Builder, connectedWifiOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, connectedWifiOffset, 0); -} - -static addAccountLinked(builder:flatbuffers.Builder, accountLinked:boolean) { - builder.addFieldInt8(2, +accountLinked, +false); -} - -static addConfig(builder:flatbuffers.Builder, configOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, configOffset, 0); -} - -static endReadyMessage(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { Config } from '../../../open-shock/serialization/configuration/config'; +import { WifiNetwork } from '../../../open-shock/serialization/types/wifi-network'; + + +export class ReadyMessage { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):ReadyMessage { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsReadyMessage(bb:flatbuffers.ByteBuffer, obj?:ReadyMessage):ReadyMessage { + return (obj || new ReadyMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsReadyMessage(bb:flatbuffers.ByteBuffer, obj?:ReadyMessage):ReadyMessage { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new ReadyMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +poggies():boolean { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +connectedWifi(obj?:WifiNetwork):WifiNetwork|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new WifiNetwork()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +accountLinked():boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +config(obj?:Config):Config|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? (obj || new Config()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static startReadyMessage(builder:flatbuffers.Builder) { + builder.startObject(4); +} + +static addPoggies(builder:flatbuffers.Builder, poggies:boolean) { + builder.addFieldInt8(0, +poggies, +false); +} + +static addConnectedWifi(builder:flatbuffers.Builder, connectedWifiOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, connectedWifiOffset, 0); +} + +static addAccountLinked(builder:flatbuffers.Builder, accountLinked:boolean) { + builder.addFieldInt8(2, +accountLinked, +false); +} + +static addConfig(builder:flatbuffers.Builder, configOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, configOffset, 0); +} + +static endReadyMessage(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-pin-result-code.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-pin-result-code.ts index a53d0fa3..4e608b12 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-pin-result-code.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-pin-result-code.ts @@ -1,9 +1,9 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export enum SetRfPinResultCode { - Success = 0, - InvalidPin = 1, - InternalError = 2 -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum SetRfPinResultCode { + Success = 0, + InvalidPin = 1, + InternalError = 2 +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-tx-pin-command-result.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-tx-pin-command-result.ts index 83e885de..94ea4a2a 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-tx-pin-command-result.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-tx-pin-command-result.ts @@ -1,38 +1,38 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { SetRfPinResultCode } from '../../../open-shock/serialization/local/set-rf-pin-result-code'; - - -export class SetRfTxPinCommandResult { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):SetRfTxPinCommandResult { - this.bb_pos = i; - this.bb = bb; - return this; -} - -pin():number { - return this.bb!.readUint8(this.bb_pos); -} - -result():SetRfPinResultCode { - return this.bb!.readUint8(this.bb_pos + 1); -} - -static sizeOf():number { - return 2; -} - -static createSetRfTxPinCommandResult(builder:flatbuffers.Builder, pin: number, result: SetRfPinResultCode):flatbuffers.Offset { - builder.prep(1, 2); - builder.writeInt8(result); - builder.writeInt8(pin); - return builder.offset(); -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { SetRfPinResultCode } from '../../../open-shock/serialization/local/set-rf-pin-result-code'; + + +export class SetRfTxPinCommandResult { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):SetRfTxPinCommandResult { + this.bb_pos = i; + this.bb = bb; + return this; +} + +pin():number { + return this.bb!.readUint8(this.bb_pos); +} + +result():SetRfPinResultCode { + return this.bb!.readUint8(this.bb_pos + 1); +} + +static sizeOf():number { + return 2; +} + +static createSetRfTxPinCommandResult(builder:flatbuffers.Builder, pin: number, result: SetRfPinResultCode):flatbuffers.Offset { + builder.prep(1, 2); + builder.writeInt8(result); + builder.writeInt8(pin); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-tx-pin-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-tx-pin-command.ts index c26a396e..7d1e9892 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-tx-pin-command.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/set-rf-tx-pin-command.ts @@ -1,30 +1,30 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class SetRfTxPinCommand { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):SetRfTxPinCommand { - this.bb_pos = i; - this.bb = bb; - return this; -} - -pin():number { - return this.bb!.readUint8(this.bb_pos); -} - -static sizeOf():number { - return 1; -} - -static createSetRfTxPinCommand(builder:flatbuffers.Builder, pin: number):flatbuffers.Offset { - builder.prep(1, 1); - builder.writeInt8(pin); - return builder.offset(); -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class SetRfTxPinCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):SetRfTxPinCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +pin():number { + return this.bb!.readUint8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createSetRfTxPinCommand(builder:flatbuffers.Builder, pin: number):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(pin); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-got-ip-event.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-got-ip-event.ts index ae6296b0..bc8dc682 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-got-ip-event.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-got-ip-event.ts @@ -1,50 +1,50 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class WifiGotIpEvent { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WifiGotIpEvent { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsWifiGotIpEvent(bb:flatbuffers.ByteBuffer, obj?:WifiGotIpEvent):WifiGotIpEvent { - return (obj || new WifiGotIpEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsWifiGotIpEvent(bb:flatbuffers.ByteBuffer, obj?:WifiGotIpEvent):WifiGotIpEvent { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new WifiGotIpEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -ip():string|null -ip(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -ip(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startWifiGotIpEvent(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addIp(builder:flatbuffers.Builder, ipOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, ipOffset, 0); -} - -static endWifiGotIpEvent(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createWifiGotIpEvent(builder:flatbuffers.Builder, ipOffset:flatbuffers.Offset):flatbuffers.Offset { - WifiGotIpEvent.startWifiGotIpEvent(builder); - WifiGotIpEvent.addIp(builder, ipOffset); - return WifiGotIpEvent.endWifiGotIpEvent(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class WifiGotIpEvent { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WifiGotIpEvent { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsWifiGotIpEvent(bb:flatbuffers.ByteBuffer, obj?:WifiGotIpEvent):WifiGotIpEvent { + return (obj || new WifiGotIpEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsWifiGotIpEvent(bb:flatbuffers.ByteBuffer, obj?:WifiGotIpEvent):WifiGotIpEvent { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new WifiGotIpEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +ip():string|null +ip(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +ip(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startWifiGotIpEvent(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addIp(builder:flatbuffers.Builder, ipOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, ipOffset, 0); +} + +static endWifiGotIpEvent(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createWifiGotIpEvent(builder:flatbuffers.Builder, ipOffset:flatbuffers.Offset):flatbuffers.Offset { + WifiGotIpEvent.startWifiGotIpEvent(builder); + WifiGotIpEvent.addIp(builder, ipOffset); + return WifiGotIpEvent.endWifiGotIpEvent(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-lost-ip-event.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-lost-ip-event.ts index 554ddf4a..a6309328 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-lost-ip-event.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-lost-ip-event.ts @@ -1,50 +1,50 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class WifiLostIpEvent { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WifiLostIpEvent { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsWifiLostIpEvent(bb:flatbuffers.ByteBuffer, obj?:WifiLostIpEvent):WifiLostIpEvent { - return (obj || new WifiLostIpEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsWifiLostIpEvent(bb:flatbuffers.ByteBuffer, obj?:WifiLostIpEvent):WifiLostIpEvent { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new WifiLostIpEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -ip():string|null -ip(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -ip(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startWifiLostIpEvent(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addIp(builder:flatbuffers.Builder, ipOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, ipOffset, 0); -} - -static endWifiLostIpEvent(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createWifiLostIpEvent(builder:flatbuffers.Builder, ipOffset:flatbuffers.Offset):flatbuffers.Offset { - WifiLostIpEvent.startWifiLostIpEvent(builder); - WifiLostIpEvent.addIp(builder, ipOffset); - return WifiLostIpEvent.endWifiLostIpEvent(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class WifiLostIpEvent { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WifiLostIpEvent { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsWifiLostIpEvent(bb:flatbuffers.ByteBuffer, obj?:WifiLostIpEvent):WifiLostIpEvent { + return (obj || new WifiLostIpEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsWifiLostIpEvent(bb:flatbuffers.ByteBuffer, obj?:WifiLostIpEvent):WifiLostIpEvent { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new WifiLostIpEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +ip():string|null +ip(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +ip(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startWifiLostIpEvent(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addIp(builder:flatbuffers.Builder, ipOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, ipOffset, 0); +} + +static endWifiLostIpEvent(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createWifiLostIpEvent(builder:flatbuffers.Builder, ipOffset:flatbuffers.Offset):flatbuffers.Offset { + WifiLostIpEvent.startWifiLostIpEvent(builder); + WifiLostIpEvent.addIp(builder, ipOffset); + return WifiLostIpEvent.endWifiLostIpEvent(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-connect-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-connect-command.ts index 37cc5df2..45a66c20 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-connect-command.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-connect-command.ts @@ -1,50 +1,50 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class WifiNetworkConnectCommand { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetworkConnectCommand { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsWifiNetworkConnectCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkConnectCommand):WifiNetworkConnectCommand { - return (obj || new WifiNetworkConnectCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsWifiNetworkConnectCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkConnectCommand):WifiNetworkConnectCommand { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new WifiNetworkConnectCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -ssid():string|null -ssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -ssid(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startWifiNetworkConnectCommand(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addSsid(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, ssidOffset, 0); -} - -static endWifiNetworkConnectCommand(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createWifiNetworkConnectCommand(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset):flatbuffers.Offset { - WifiNetworkConnectCommand.startWifiNetworkConnectCommand(builder); - WifiNetworkConnectCommand.addSsid(builder, ssidOffset); - return WifiNetworkConnectCommand.endWifiNetworkConnectCommand(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class WifiNetworkConnectCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetworkConnectCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsWifiNetworkConnectCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkConnectCommand):WifiNetworkConnectCommand { + return (obj || new WifiNetworkConnectCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsWifiNetworkConnectCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkConnectCommand):WifiNetworkConnectCommand { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new WifiNetworkConnectCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +ssid():string|null +ssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +ssid(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startWifiNetworkConnectCommand(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addSsid(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, ssidOffset, 0); +} + +static endWifiNetworkConnectCommand(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createWifiNetworkConnectCommand(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset):flatbuffers.Offset { + WifiNetworkConnectCommand.startWifiNetworkConnectCommand(builder); + WifiNetworkConnectCommand.addSsid(builder, ssidOffset); + return WifiNetworkConnectCommand.endWifiNetworkConnectCommand(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-disconnect-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-disconnect-command.ts index 0d5851ed..563b9e98 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-disconnect-command.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-disconnect-command.ts @@ -1,30 +1,30 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class WifiNetworkDisconnectCommand { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetworkDisconnectCommand { - this.bb_pos = i; - this.bb = bb; - return this; -} - -placeholder():boolean { - return !!this.bb!.readInt8(this.bb_pos); -} - -static sizeOf():number { - return 1; -} - -static createWifiNetworkDisconnectCommand(builder:flatbuffers.Builder, placeholder: boolean):flatbuffers.Offset { - builder.prep(1, 1); - builder.writeInt8(Number(Boolean(placeholder))); - return builder.offset(); -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class WifiNetworkDisconnectCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetworkDisconnectCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +placeholder():boolean { + return !!this.bb!.readInt8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createWifiNetworkDisconnectCommand(builder:flatbuffers.Builder, placeholder: boolean):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(Number(Boolean(placeholder))); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-event.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-event.ts index 0d4b09ec..9e8d48e6 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-event.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-event.ts @@ -1,56 +1,56 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { WifiNetwork } from '../../../open-shock/serialization/types/wifi-network'; -import { WifiNetworkEventType } from '../../../open-shock/serialization/types/wifi-network-event-type'; - - -export class WifiNetworkEvent { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetworkEvent { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsWifiNetworkEvent(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkEvent):WifiNetworkEvent { - return (obj || new WifiNetworkEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsWifiNetworkEvent(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkEvent):WifiNetworkEvent { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new WifiNetworkEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -eventType():WifiNetworkEventType { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : WifiNetworkEventType.Discovered; -} - -network(obj?:WifiNetwork):WifiNetwork|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? (obj || new WifiNetwork()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -static startWifiNetworkEvent(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addEventType(builder:flatbuffers.Builder, eventType:WifiNetworkEventType) { - builder.addFieldInt8(0, eventType, WifiNetworkEventType.Discovered); -} - -static addNetwork(builder:flatbuffers.Builder, networkOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, networkOffset, 0); -} - -static endWifiNetworkEvent(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { WifiNetwork } from '../../../open-shock/serialization/types/wifi-network'; +import { WifiNetworkEventType } from '../../../open-shock/serialization/types/wifi-network-event-type'; + + +export class WifiNetworkEvent { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetworkEvent { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsWifiNetworkEvent(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkEvent):WifiNetworkEvent { + return (obj || new WifiNetworkEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsWifiNetworkEvent(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkEvent):WifiNetworkEvent { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new WifiNetworkEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +eventType():WifiNetworkEventType { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : WifiNetworkEventType.Discovered; +} + +network(obj?:WifiNetwork):WifiNetwork|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new WifiNetwork()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static startWifiNetworkEvent(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addEventType(builder:flatbuffers.Builder, eventType:WifiNetworkEventType) { + builder.addFieldInt8(0, eventType, WifiNetworkEventType.Discovered); +} + +static addNetwork(builder:flatbuffers.Builder, networkOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, networkOffset, 0); +} + +static endWifiNetworkEvent(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-forget-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-forget-command.ts index 5eb7a4e2..b8bd4bf9 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-forget-command.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-forget-command.ts @@ -1,50 +1,50 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class WifiNetworkForgetCommand { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetworkForgetCommand { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsWifiNetworkForgetCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkForgetCommand):WifiNetworkForgetCommand { - return (obj || new WifiNetworkForgetCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsWifiNetworkForgetCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkForgetCommand):WifiNetworkForgetCommand { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new WifiNetworkForgetCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -ssid():string|null -ssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -ssid(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startWifiNetworkForgetCommand(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addSsid(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, ssidOffset, 0); -} - -static endWifiNetworkForgetCommand(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createWifiNetworkForgetCommand(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset):flatbuffers.Offset { - WifiNetworkForgetCommand.startWifiNetworkForgetCommand(builder); - WifiNetworkForgetCommand.addSsid(builder, ssidOffset); - return WifiNetworkForgetCommand.endWifiNetworkForgetCommand(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class WifiNetworkForgetCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetworkForgetCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsWifiNetworkForgetCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkForgetCommand):WifiNetworkForgetCommand { + return (obj || new WifiNetworkForgetCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsWifiNetworkForgetCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkForgetCommand):WifiNetworkForgetCommand { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new WifiNetworkForgetCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +ssid():string|null +ssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +ssid(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startWifiNetworkForgetCommand(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addSsid(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, ssidOffset, 0); +} + +static endWifiNetworkForgetCommand(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createWifiNetworkForgetCommand(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset):flatbuffers.Offset { + WifiNetworkForgetCommand.startWifiNetworkForgetCommand(builder); + WifiNetworkForgetCommand.addSsid(builder, ssidOffset); + return WifiNetworkForgetCommand.endWifiNetworkForgetCommand(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-save-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-save-command.ts index 91974435..1742227b 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-save-command.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-network-save-command.ts @@ -1,72 +1,72 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class WifiNetworkSaveCommand { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetworkSaveCommand { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsWifiNetworkSaveCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkSaveCommand):WifiNetworkSaveCommand { - return (obj || new WifiNetworkSaveCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsWifiNetworkSaveCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkSaveCommand):WifiNetworkSaveCommand { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new WifiNetworkSaveCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -ssid():string|null -ssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -ssid(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -password():string|null -password(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -password(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -connect():boolean { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -} - -static startWifiNetworkSaveCommand(builder:flatbuffers.Builder) { - builder.startObject(3); -} - -static addSsid(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, ssidOffset, 0); -} - -static addPassword(builder:flatbuffers.Builder, passwordOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, passwordOffset, 0); -} - -static addConnect(builder:flatbuffers.Builder, connect:boolean) { - builder.addFieldInt8(2, +connect, +false); -} - -static endWifiNetworkSaveCommand(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createWifiNetworkSaveCommand(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset, passwordOffset:flatbuffers.Offset, connect:boolean):flatbuffers.Offset { - WifiNetworkSaveCommand.startWifiNetworkSaveCommand(builder); - WifiNetworkSaveCommand.addSsid(builder, ssidOffset); - WifiNetworkSaveCommand.addPassword(builder, passwordOffset); - WifiNetworkSaveCommand.addConnect(builder, connect); - return WifiNetworkSaveCommand.endWifiNetworkSaveCommand(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class WifiNetworkSaveCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetworkSaveCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsWifiNetworkSaveCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkSaveCommand):WifiNetworkSaveCommand { + return (obj || new WifiNetworkSaveCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsWifiNetworkSaveCommand(bb:flatbuffers.ByteBuffer, obj?:WifiNetworkSaveCommand):WifiNetworkSaveCommand { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new WifiNetworkSaveCommand()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +ssid():string|null +ssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +ssid(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +password():string|null +password(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +password(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +connect():boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +static startWifiNetworkSaveCommand(builder:flatbuffers.Builder) { + builder.startObject(3); +} + +static addSsid(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, ssidOffset, 0); +} + +static addPassword(builder:flatbuffers.Builder, passwordOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, passwordOffset, 0); +} + +static addConnect(builder:flatbuffers.Builder, connect:boolean) { + builder.addFieldInt8(2, +connect, +false); +} + +static endWifiNetworkSaveCommand(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createWifiNetworkSaveCommand(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset, passwordOffset:flatbuffers.Offset, connect:boolean):flatbuffers.Offset { + WifiNetworkSaveCommand.startWifiNetworkSaveCommand(builder); + WifiNetworkSaveCommand.addSsid(builder, ssidOffset); + WifiNetworkSaveCommand.addPassword(builder, passwordOffset); + WifiNetworkSaveCommand.addConnect(builder, connect); + return WifiNetworkSaveCommand.endWifiNetworkSaveCommand(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-scan-command.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-scan-command.ts index 3f0df388..ab5b0b95 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-scan-command.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-scan-command.ts @@ -1,30 +1,30 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -export class WifiScanCommand { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WifiScanCommand { - this.bb_pos = i; - this.bb = bb; - return this; -} - -run():boolean { - return !!this.bb!.readInt8(this.bb_pos); -} - -static sizeOf():number { - return 1; -} - -static createWifiScanCommand(builder:flatbuffers.Builder, run: boolean):flatbuffers.Offset { - builder.prep(1, 1); - builder.writeInt8(Number(Boolean(run))); - return builder.offset(); -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class WifiScanCommand { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WifiScanCommand { + this.bb_pos = i; + this.bb = bb; + return this; +} + +run():boolean { + return !!this.bb!.readInt8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createWifiScanCommand(builder:flatbuffers.Builder, run: boolean):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(Number(Boolean(run))); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-scan-status-message.ts b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-scan-status-message.ts index 24c751d3..38547d89 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-scan-status-message.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/local/wifi-scan-status-message.ts @@ -1,33 +1,33 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { WifiScanStatus } from '../../../open-shock/serialization/types/wifi-scan-status'; - - -export class WifiScanStatusMessage { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WifiScanStatusMessage { - this.bb_pos = i; - this.bb = bb; - return this; -} - -status():WifiScanStatus { - return this.bb!.readUint8(this.bb_pos); -} - -static sizeOf():number { - return 1; -} - -static createWifiScanStatusMessage(builder:flatbuffers.Builder, status: WifiScanStatus):flatbuffers.Offset { - builder.prep(1, 1); - builder.writeInt8(status); - return builder.offset(); -} - -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { WifiScanStatus } from '../../../open-shock/serialization/types/wifi-scan-status'; + + +export class WifiScanStatusMessage { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WifiScanStatusMessage { + this.bb_pos = i; + this.bb = bb; + return this; +} + +status():WifiScanStatus { + return this.bb!.readUint8(this.bb_pos); +} + +static sizeOf():number { + return 1; +} + +static createWifiScanStatusMessage(builder:flatbuffers.Builder, status: WifiScanStatus):flatbuffers.Offset { + builder.prep(1, 1); + builder.writeInt8(status); + return builder.offset(); +} + +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/server-to-device-message-payload.ts b/frontend/src/lib/_fbs/open-shock/serialization/server-to-device-message-payload.ts deleted file mode 100644 index 03eca41f..00000000 --- a/frontend/src/lib/_fbs/open-shock/serialization/server-to-device-message-payload.ts +++ /dev/null @@ -1,38 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import { CaptivePortalConfig } from '../../open-shock/serialization/captive-portal-config'; -import { ShockerCommandList } from '../../open-shock/serialization/shocker-command-list'; - - -export enum ServerToDeviceMessagePayload { - NONE = 0, - ShockerCommandList = 1, - CaptivePortalConfig = 2 -} - -export function unionToServerToDeviceMessagePayload( - type: ServerToDeviceMessagePayload, - accessor: (obj:CaptivePortalConfig|ShockerCommandList) => CaptivePortalConfig|ShockerCommandList|null -): CaptivePortalConfig|ShockerCommandList|null { - switch(ServerToDeviceMessagePayload[type]) { - case 'NONE': return null; - case 'ShockerCommandList': return accessor(new ShockerCommandList())! as ShockerCommandList; - case 'CaptivePortalConfig': return accessor(new CaptivePortalConfig())! as CaptivePortalConfig; - default: return null; - } -} - -export function unionListToServerToDeviceMessagePayload( - type: ServerToDeviceMessagePayload, - accessor: (index: number, obj:CaptivePortalConfig|ShockerCommandList) => CaptivePortalConfig|ShockerCommandList|null, - index: number -): CaptivePortalConfig|ShockerCommandList|null { - switch(ServerToDeviceMessagePayload[type]) { - case 'NONE': return null; - case 'ShockerCommandList': return accessor(index, new ShockerCommandList())! as ShockerCommandList; - case 'CaptivePortalConfig': return accessor(index, new CaptivePortalConfig())! as CaptivePortalConfig; - default: return null; - } -} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/server-to-device-message.ts b/frontend/src/lib/_fbs/open-shock/serialization/server-to-device-message.ts deleted file mode 100644 index 3eee79a6..00000000 --- a/frontend/src/lib/_fbs/open-shock/serialization/server-to-device-message.ts +++ /dev/null @@ -1,69 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { ServerToDeviceMessagePayload, unionToServerToDeviceMessagePayload, unionListToServerToDeviceMessagePayload } from '../../open-shock/serialization/server-to-device-message-payload'; - - -export class ServerToDeviceMessage { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):ServerToDeviceMessage { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsServerToDeviceMessage(bb:flatbuffers.ByteBuffer, obj?:ServerToDeviceMessage):ServerToDeviceMessage { - return (obj || new ServerToDeviceMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsServerToDeviceMessage(bb:flatbuffers.ByteBuffer, obj?:ServerToDeviceMessage):ServerToDeviceMessage { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new ServerToDeviceMessage()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -payloadType():ServerToDeviceMessagePayload { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : ServerToDeviceMessagePayload.NONE; -} - -payload(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -static startServerToDeviceMessage(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addPayloadType(builder:flatbuffers.Builder, payloadType:ServerToDeviceMessagePayload) { - builder.addFieldInt8(0, payloadType, ServerToDeviceMessagePayload.NONE); -} - -static addPayload(builder:flatbuffers.Builder, payloadOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, payloadOffset, 0); -} - -static endServerToDeviceMessage(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static finishServerToDeviceMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset); -} - -static finishSizePrefixedServerToDeviceMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, undefined, true); -} - -static createServerToDeviceMessage(builder:flatbuffers.Builder, payloadType:ServerToDeviceMessagePayload, payloadOffset:flatbuffers.Offset):flatbuffers.Offset { - ServerToDeviceMessage.startServerToDeviceMessage(builder); - ServerToDeviceMessage.addPayloadType(builder, payloadType); - ServerToDeviceMessage.addPayload(builder, payloadOffset); - return ServerToDeviceMessage.endServerToDeviceMessage(builder); -} -} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/types.ts b/frontend/src/lib/_fbs/open-shock/serialization/types.ts index efe53f89..6e7cf011 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/types.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/types.ts @@ -1,5 +1,5 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export { WifiScanStatus } from './types/wifi-scan-status'; +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export { WifiScanStatus } from './types/wifi-scan-status'; diff --git a/frontend/src/lib/_fbs/open-shock/serialization/types/firmware-boot-type.ts b/frontend/src/lib/_fbs/open-shock/serialization/types/firmware-boot-type.ts new file mode 100644 index 00000000..fea6e2a8 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/types/firmware-boot-type.ts @@ -0,0 +1,9 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum FirmwareBootType { + Normal = 0, + NewFirmware = 1, + Rollback = 2 +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/types/sem-ver.ts b/frontend/src/lib/_fbs/open-shock/serialization/types/sem-ver.ts new file mode 100644 index 00000000..f141fcb2 --- /dev/null +++ b/frontend/src/lib/_fbs/open-shock/serialization/types/sem-ver.ts @@ -0,0 +1,92 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +export class SemVer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):SemVer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsSemVer(bb:flatbuffers.ByteBuffer, obj?:SemVer):SemVer { + return (obj || new SemVer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsSemVer(bb:flatbuffers.ByteBuffer, obj?:SemVer):SemVer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new SemVer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +major():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +minor():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +patch():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +prerelease():string|null +prerelease(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +prerelease(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +build():string|null +build(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +build(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startSemVer(builder:flatbuffers.Builder) { + builder.startObject(5); +} + +static addMajor(builder:flatbuffers.Builder, major:number) { + builder.addFieldInt16(0, major, 0); +} + +static addMinor(builder:flatbuffers.Builder, minor:number) { + builder.addFieldInt16(1, minor, 0); +} + +static addPatch(builder:flatbuffers.Builder, patch:number) { + builder.addFieldInt16(2, patch, 0); +} + +static addPrerelease(builder:flatbuffers.Builder, prereleaseOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, prereleaseOffset, 0); +} + +static addBuild(builder:flatbuffers.Builder, buildOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, buildOffset, 0); +} + +static endSemVer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createSemVer(builder:flatbuffers.Builder, major:number, minor:number, patch:number, prereleaseOffset:flatbuffers.Offset, buildOffset:flatbuffers.Offset):flatbuffers.Offset { + SemVer.startSemVer(builder); + SemVer.addMajor(builder, major); + SemVer.addMinor(builder, minor); + SemVer.addPatch(builder, patch); + SemVer.addPrerelease(builder, prereleaseOffset); + SemVer.addBuild(builder, buildOffset); + return SemVer.endSemVer(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/types/shocker-command-type.ts b/frontend/src/lib/_fbs/open-shock/serialization/types/shocker-command-type.ts index e911db4b..a6c77901 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/types/shocker-command-type.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/types/shocker-command-type.ts @@ -1,10 +1,10 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export enum ShockerCommandType { - Stop = 0, - Shock = 1, - Vibrate = 2, - Sound = 3 -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum ShockerCommandType { + Stop = 0, + Shock = 1, + Vibrate = 2, + Sound = 3 +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/types/shocker-model-type.ts b/frontend/src/lib/_fbs/open-shock/serialization/types/shocker-model-type.ts index 5d3bca43..e41c5b9d 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/types/shocker-model-type.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/types/shocker-model-type.ts @@ -1,8 +1,8 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export enum ShockerModelType { - CaiXianlin = 0, - Petrainer = 1 -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum ShockerModelType { + CaiXianlin = 0, + Petrainer = 1 +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-auth-mode.ts b/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-auth-mode.ts index ce4f3f82..e048d0e3 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-auth-mode.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-auth-mode.ts @@ -1,16 +1,16 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export enum WifiAuthMode { - Open = 0, - WEP = 1, - WPA_PSK = 2, - WPA2_PSK = 3, - WPA_WPA2_PSK = 4, - WPA2_ENTERPRISE = 5, - WPA3_PSK = 6, - WPA2_WPA3_PSK = 7, - WAPI_PSK = 8, - UNKNOWN = 9 -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum WifiAuthMode { + Open = 0, + WEP = 1, + WPA_PSK = 2, + WPA2_PSK = 3, + WPA_WPA2_PSK = 4, + WPA2_ENTERPRISE = 5, + WPA3_PSK = 6, + WPA2_WPA3_PSK = 7, + WAPI_PSK = 8, + UNKNOWN = 9 +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-network-event-type.ts b/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-network-event-type.ts index 33a821bd..cd7b1ee0 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-network-event-type.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-network-event-type.ts @@ -1,13 +1,13 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export enum WifiNetworkEventType { - Discovered = 0, - Updated = 1, - Lost = 2, - Saved = 3, - Removed = 4, - Connected = 5, - Disconnected = 6 -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum WifiNetworkEventType { + Discovered = 0, + Updated = 1, + Lost = 2, + Saved = 3, + Removed = 4, + Connected = 5, + Disconnected = 6 +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-network.ts b/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-network.ts index 529fb13f..2c2a7b23 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-network.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-network.ts @@ -1,105 +1,105 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -import * as flatbuffers from 'flatbuffers'; - -import { WifiAuthMode } from '../../../open-shock/serialization/types/wifi-auth-mode'; - - -export class WifiNetwork { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetwork { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsWifiNetwork(bb:flatbuffers.ByteBuffer, obj?:WifiNetwork):WifiNetwork { - return (obj || new WifiNetwork()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsWifiNetwork(bb:flatbuffers.ByteBuffer, obj?:WifiNetwork):WifiNetwork { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new WifiNetwork()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -ssid():string|null -ssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -ssid(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -bssid():string|null -bssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -bssid(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -channel():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; -} - -rssi():number { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0; -} - -authMode():WifiAuthMode { - const offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : WifiAuthMode.Open; -} - -saved():boolean { - const offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -} - -static startWifiNetwork(builder:flatbuffers.Builder) { - builder.startObject(6); -} - -static addSsid(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, ssidOffset, 0); -} - -static addBssid(builder:flatbuffers.Builder, bssidOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, bssidOffset, 0); -} - -static addChannel(builder:flatbuffers.Builder, channel:number) { - builder.addFieldInt8(2, channel, 0); -} - -static addRssi(builder:flatbuffers.Builder, rssi:number) { - builder.addFieldInt8(3, rssi, 0); -} - -static addAuthMode(builder:flatbuffers.Builder, authMode:WifiAuthMode) { - builder.addFieldInt8(4, authMode, WifiAuthMode.Open); -} - -static addSaved(builder:flatbuffers.Builder, saved:boolean) { - builder.addFieldInt8(5, +saved, +false); -} - -static endWifiNetwork(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createWifiNetwork(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset, bssidOffset:flatbuffers.Offset, channel:number, rssi:number, authMode:WifiAuthMode, saved:boolean):flatbuffers.Offset { - WifiNetwork.startWifiNetwork(builder); - WifiNetwork.addSsid(builder, ssidOffset); - WifiNetwork.addBssid(builder, bssidOffset); - WifiNetwork.addChannel(builder, channel); - WifiNetwork.addRssi(builder, rssi); - WifiNetwork.addAuthMode(builder, authMode); - WifiNetwork.addSaved(builder, saved); - return WifiNetwork.endWifiNetwork(builder); -} -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +import * as flatbuffers from 'flatbuffers'; + +import { WifiAuthMode } from '../../../open-shock/serialization/types/wifi-auth-mode'; + + +export class WifiNetwork { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):WifiNetwork { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsWifiNetwork(bb:flatbuffers.ByteBuffer, obj?:WifiNetwork):WifiNetwork { + return (obj || new WifiNetwork()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsWifiNetwork(bb:flatbuffers.ByteBuffer, obj?:WifiNetwork):WifiNetwork { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new WifiNetwork()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +ssid():string|null +ssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +ssid(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +bssid():string|null +bssid(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +bssid(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +channel():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +rssi():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0; +} + +authMode():WifiAuthMode { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : WifiAuthMode.Open; +} + +saved():boolean { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +static startWifiNetwork(builder:flatbuffers.Builder) { + builder.startObject(6); +} + +static addSsid(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, ssidOffset, 0); +} + +static addBssid(builder:flatbuffers.Builder, bssidOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, bssidOffset, 0); +} + +static addChannel(builder:flatbuffers.Builder, channel:number) { + builder.addFieldInt8(2, channel, 0); +} + +static addRssi(builder:flatbuffers.Builder, rssi:number) { + builder.addFieldInt8(3, rssi, 0); +} + +static addAuthMode(builder:flatbuffers.Builder, authMode:WifiAuthMode) { + builder.addFieldInt8(4, authMode, WifiAuthMode.Open); +} + +static addSaved(builder:flatbuffers.Builder, saved:boolean) { + builder.addFieldInt8(5, +saved, +false); +} + +static endWifiNetwork(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createWifiNetwork(builder:flatbuffers.Builder, ssidOffset:flatbuffers.Offset, bssidOffset:flatbuffers.Offset, channel:number, rssi:number, authMode:WifiAuthMode, saved:boolean):flatbuffers.Offset { + WifiNetwork.startWifiNetwork(builder); + WifiNetwork.addSsid(builder, ssidOffset); + WifiNetwork.addBssid(builder, bssidOffset); + WifiNetwork.addChannel(builder, channel); + WifiNetwork.addRssi(builder, rssi); + WifiNetwork.addAuthMode(builder, authMode); + WifiNetwork.addSaved(builder, saved); + return WifiNetwork.endWifiNetwork(builder); +} +} diff --git a/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-scan-status.ts b/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-scan-status.ts index 29fe5e64..0037d639 100644 --- a/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-scan-status.ts +++ b/frontend/src/lib/_fbs/open-shock/serialization/types/wifi-scan-status.ts @@ -1,12 +1,12 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ - -export enum WifiScanStatus { - Started = 0, - InProgress = 1, - Completed = 2, - TimedOut = 3, - Aborted = 4, - Error = 5 -} +// automatically generated by the FlatBuffers compiler, do not modify + +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum WifiScanStatus { + Started = 0, + InProgress = 1, + Completed = 2, + TimedOut = 3, + Aborted = 4, + Error = 5 +} diff --git a/frontend/src/lib/mappers/ConfigMapper.ts b/frontend/src/lib/mappers/ConfigMapper.ts new file mode 100644 index 00000000..1c7a4ec8 --- /dev/null +++ b/frontend/src/lib/mappers/ConfigMapper.ts @@ -0,0 +1,180 @@ +import type { OtaUpdateChannel } from '$lib/_fbs/open-shock/serialization/configuration'; +import { Config as FbsConfig } from '$lib/_fbs/open-shock/serialization/configuration/config'; + +export interface RFConfig { + txPin: number; + keepaliveEnabled: boolean; +} + +export interface WifiCredentials { + id: number; + ssid: string; + password: string | null; +} + +export interface WifiConfig { + apSsid: string; + hostname: string; + credentials: WifiCredentials[]; +} + +export interface CaptivePortalConfig { + alwaysEnabled: boolean; +} + +export interface BackendConfig { + domain: string; + authToken: string | null; +} + +export interface SerialInputConfig { + echoEnabled: boolean; +} + +export interface OtaUpdateConfig { + isEnabled: boolean; + cdnDomain: string; + updateChannel: OtaUpdateChannel; + checkOnStartup: boolean; + checkInterval: number; + allowBackendManagement: boolean; + requireManualApproval: boolean; +} + +export interface Config { + rf: RFConfig; + wifi: WifiConfig; + captivePortal: CaptivePortalConfig; + backend: BackendConfig; + serialInput: SerialInputConfig; + otaUpdate: OtaUpdateConfig; +} + +function mapRfConfig(fbsConfig: FbsConfig): RFConfig { + const rf = fbsConfig.rf(); + if (!rf) throw new Error('fbsConfig.rf is null'); + + const txPin = rf.txPin(); + const keepaliveEnabled = rf.keepaliveEnabled(); + + if (!txPin) throw new Error('rf.txPin is null'); + + return { + txPin, + keepaliveEnabled, + }; +} + +function mapWifiConfig(fbsConfig: FbsConfig): WifiConfig { + const wifi = fbsConfig.wifi(); + if (!wifi) throw new Error('fbsConfig.wifi is null'); + + const apSsid = wifi.apSsid(); + const hostname = wifi.hostname(); + + if (!apSsid) throw new Error('wifi.apSsid is null'); + if (!hostname) throw new Error('wifi.hostname is null'); + + const credentials: WifiCredentials[] = []; + const credentialsLength = wifi.credentialsLength(); + for (let i = 0; i < credentialsLength; i++) { + const cred = wifi.credentials(i); + if (!cred) throw new Error('wifi.credentials is null'); + + const id = cred.id(); + const ssid = cred.ssid(); + const password = cred.password(); + + if (!id) throw new Error('cred.id is null'); + if (!ssid) throw new Error('cred.ssid is null'); + if (!password) throw new Error('cred.password is null'); + + credentials.push({ + id, + ssid, + password, + }); + } + + return { + apSsid, + hostname, + credentials, + }; +} + +function mapCaptivePortalConfig(fbsConfig: FbsConfig): CaptivePortalConfig { + const captivePortal = fbsConfig.captivePortal(); + if (!captivePortal) throw new Error('fbsConfig.captivePortal is null'); + + const alwaysEnabled = captivePortal.alwaysEnabled(); + + return { + alwaysEnabled, + }; +} + +function mapBackendConfig(fbsConfig: FbsConfig): BackendConfig { + const backend = fbsConfig.backend(); + if (!backend) throw new Error('fbsConfig.backend is null'); + + const domain = backend.domain(); + const authToken = backend.authToken(); + + if (!domain) throw new Error('backend.domain is null'); + + return { + domain, + authToken, + }; +} + +function mapSerialInputConfig(fbsConfig: FbsConfig): SerialInputConfig { + const serialInput = fbsConfig.serialInput(); + if (!serialInput) throw new Error('fbsConfig.serialInput is null'); + + const echoEnabled = serialInput.echoEnabled(); + + return { + echoEnabled, + }; +} + +function mapOtaUpdateConfig(fbsConfig: FbsConfig): OtaUpdateConfig { + const otaUpdate = fbsConfig.otaUpdate(); + if (!otaUpdate) throw new Error('fbsConfig.otaUpdate is null'); + + const isEnabled = otaUpdate.isEnabled(); + const cdnDomain = otaUpdate.cdnDomain(); + const updateChannel = otaUpdate.updateChannel(); + const checkOnStartup = otaUpdate.checkOnStartup(); + const checkInterval = otaUpdate.checkInterval(); + const allowBackendManagement = otaUpdate.allowBackendManagement(); + const requireManualApproval = otaUpdate.requireManualApproval(); + + if (!cdnDomain) throw new Error('otaUpdate.cdnDomain is null'); + if (!updateChannel) throw new Error('otaUpdate.updateChannel is null'); + + return { + isEnabled, + cdnDomain, + updateChannel, + checkOnStartup, + checkInterval, + allowBackendManagement, + requireManualApproval, + }; +} + +export function mapConfig(fbsConfig: FbsConfig | null): Config | null { + if (!fbsConfig) return null; + + return { + rf: mapRfConfig(fbsConfig), + wifi: mapWifiConfig(fbsConfig), + captivePortal: mapCaptivePortalConfig(fbsConfig), + backend: mapBackendConfig(fbsConfig), + serialInput: mapSerialInputConfig(fbsConfig), + otaUpdate: mapOtaUpdateConfig(fbsConfig), + }; +} diff --git a/frontend/src/lib/stores/DeviceStateStore.ts b/frontend/src/lib/stores/DeviceStateStore.ts index 6bf0fd99..6d0f7cd1 100644 --- a/frontend/src/lib/stores/DeviceStateStore.ts +++ b/frontend/src/lib/stores/DeviceStateStore.ts @@ -9,7 +9,7 @@ const { subscribe, update } = writable({ wifiNetworks: new Map(), wifiNetworkGroups: new Map(), accountLinked: false, - rfTxPin: null, + config: null, }); function insertSorted(array: T[], value: T, compare: (a: T, b: T) => number) { @@ -26,7 +26,7 @@ function insertSorted(array: T[], value: T, compare: (a: T, b: T) => number) array.splice(low, 0, value); } -function SsidMapReducer(groups: Map, [_, value]: [string, WiFiNetwork]): Map { +function SsidMapReducer(groups: Map, [, value]: [string, WiFiNetwork]): Map { const key = `${value.ssid || value.bssid}_${WifiAuthMode[value.security]}`; // Get the group for this SSID, or create a new one @@ -103,7 +103,9 @@ export const DeviceStateStore = { }, setRfTxPin(pin: number) { update((store) => { - store.rfTxPin = pin; + if (store.config) { + store.config.rf.txPin = pin; + } return store; }); }, diff --git a/frontend/src/lib/types/DeviceState.ts b/frontend/src/lib/types/DeviceState.ts index a56dd6b8..6a698394 100644 --- a/frontend/src/lib/types/DeviceState.ts +++ b/frontend/src/lib/types/DeviceState.ts @@ -1,4 +1,5 @@ import type { WifiScanStatus } from '$lib/_fbs/open-shock/serialization/types/wifi-scan-status'; +import type { Config } from '$lib/mappers/ConfigMapper'; import type { WiFiNetwork, WiFiNetworkGroup } from './'; export type DeviceState = { @@ -7,5 +8,5 @@ export type DeviceState = { wifiNetworks: Map; wifiNetworkGroups: Map; accountLinked: boolean; - rfTxPin: number | null; + config: Config | null; }; diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index 9e1f7cd9..719bce77 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -19,7 +19,7 @@ let linkCode: string = ''; $: linkCodeValid = isValidLinkCode(linkCode); - let rfTxPin: number | null = $DeviceStateStore.rfTxPin; + let rfTxPin: number | null = $DeviceStateStore.config?.rf.txPin ?? null; $: rfTxPinValid = rfTxPin !== null && rfTxPin >= 0 && rfTxPin < 255; function linkAccount() { @@ -50,7 +50,7 @@

RF TX Pin

- (Currently {$DeviceStateStore.rfTxPin == null ? ' not set' : $DeviceStateStore.rfTxPin}) + (Currently {$DeviceStateStore.config == null ? ' not set' : $DeviceStateStore.config.rf.txPin})
diff --git a/include/CaptivePortal.h b/include/CaptivePortal.h index f22aee21..392e996e 100644 --- a/include/CaptivePortal.h +++ b/include/CaptivePortal.h @@ -2,12 +2,16 @@ #include "StringView.h" +#include + #include namespace OpenShock::CaptivePortal { void SetAlwaysEnabled(bool alwaysEnabled); bool IsAlwaysEnabled(); + bool ForceClose(std::uint32_t timeoutMs); + bool IsRunning(); void Update(); diff --git a/include/CaptivePortalInstance.h b/include/CaptivePortalInstance.h index 5529a627..7397c579 100644 --- a/include/CaptivePortalInstance.h +++ b/include/CaptivePortalInstance.h @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -33,6 +34,7 @@ namespace OpenShock { AsyncWebServer m_webServer; WebSocketsServer m_socketServer; WebSocketDeFragger m_socketDeFragger; + fs::LittleFSFS m_fileSystem; DNSServer m_dnsServer; TaskHandle_t m_taskHandle; }; diff --git a/include/Constants.h b/include/Constants.h index 9c197a4d..e72a88d2 100644 --- a/include/Constants.h +++ b/include/Constants.h @@ -9,7 +9,15 @@ #define OPENSHOCK_API_BASE_URL "https://" OPENSHOCK_API_DOMAIN #endif +#ifndef OPENSHOCK_FW_CDN_DOMAIN +#error "OPENSHOCK_FW_CDN_DOMAIN must be defined" +#endif +#ifndef OPENSHOCK_FW_CDN_BASE_URL +#define OPENSHOCK_FW_CDN_BASE_URL "https://" OPENSHOCK_FW_CDN_DOMAIN +#endif + #define OPENSHOCK_API_URL(path) OPENSHOCK_API_BASE_URL path +#define OPENSHOCK_FW_CDN_URL(path) OPENSHOCK_FW_CDN_BASE_URL path #ifndef OPENSHOCK_FW_VERSION #error "OPENSHOCK_FW_VERSION must be defined" diff --git a/include/FirmwareBootType.h b/include/FirmwareBootType.h new file mode 100644 index 00000000..f9f48896 --- /dev/null +++ b/include/FirmwareBootType.h @@ -0,0 +1,29 @@ +#pragma once + +#include "serialization/_fbs/FirmwareBootType_generated.h" + +#include +#include + +namespace OpenShock { + typedef OpenShock::Serialization::Types::FirmwareBootType FirmwareBootType; + + inline bool TryParseFirmwareBootType(FirmwareBootType& bootType, const char* str) { + if (strcasecmp(str, "normal") == 0) { + bootType = FirmwareBootType::Normal; + return true; + } + + if (strcasecmp(str, "newfirmware") == 0 || strcasecmp(str, "new_firmware") == 0) { + bootType = FirmwareBootType::NewFirmware; + return true; + } + + if (strcasecmp(str, "rollback") == 0) { + bootType = FirmwareBootType::Rollback; + return true; + } + + return false; + } +} // namespace OpenShock diff --git a/include/GatewayClient.h b/include/GatewayClient.h index 1b4e2002..64c799f5 100644 --- a/include/GatewayClient.h +++ b/include/GatewayClient.h @@ -1,10 +1,12 @@ #pragma once +#include "StringView.h" + #include +#include #include #include -#include namespace OpenShock { class GatewayClient { @@ -24,10 +26,14 @@ namespace OpenShock { void connect(const char* lcgFqdn); void disconnect(); + bool sendMessageTXT(StringView data); + bool sendMessageBIN(const std::uint8_t* data, std::size_t length); + bool loop(); private: void _sendKeepAlive(); + void _sendBootStatus(); void _handleEvent(WStype_t type, std::uint8_t* payload, std::size_t length); WebSocketsClient m_webSocket; diff --git a/include/GatewayConnectionManager.h b/include/GatewayConnectionManager.h index 4205592a..8bd1a9bd 100644 --- a/include/GatewayConnectionManager.h +++ b/include/GatewayConnectionManager.h @@ -1,6 +1,7 @@ #pragma once #include "AccountLinkResultCode.h" +#include "StringView.h" #include #include @@ -14,5 +15,8 @@ namespace OpenShock::GatewayConnectionManager { AccountLinkResultCode Link(const char* linkCode); void UnLink(); + bool SendMessageTXT(StringView data); + bool SendMessageBIN(const std::uint8_t* data, std::size_t length); + void Update(); } // namespace OpenShock::GatewayConnectionManager diff --git a/include/Hashing.h b/include/Hashing.h new file mode 100644 index 00000000..15d880ed --- /dev/null +++ b/include/Hashing.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include + +#include + +namespace OpenShock { +struct MD5 { + MD5() { mbedtls_md5_init(&ctx); } + ~MD5() { mbedtls_md5_free(&ctx); } + + bool begin() { return mbedtls_md5_starts_ret(&ctx) == 0; } + bool update(const std::uint8_t* data, std::size_t dataLen) { return mbedtls_md5_update_ret(&ctx, data, dataLen) == 0; } + bool finish(std::array& hash) { return mbedtls_md5_finish_ret(&ctx, hash.data()) == 0; } + + mbedtls_md5_context ctx; +}; +struct SHA1 { + SHA1() { mbedtls_sha1_init(&ctx); } + ~SHA1() { mbedtls_sha1_free(&ctx); } + + bool begin() { return mbedtls_sha1_starts_ret(&ctx) == 0; } + bool update(const std::uint8_t* data, std::size_t dataLen) { return mbedtls_sha1_update_ret(&ctx, data, dataLen) == 0; } + bool finish(std::array& hash) { return mbedtls_sha1_finish_ret(&ctx, hash.data()) == 0; } + + mbedtls_sha1_context ctx; +}; +struct SHA256 { + SHA256() { mbedtls_sha256_init(&ctx); } + ~SHA256() { mbedtls_sha256_free(&ctx); } + + bool begin() { return mbedtls_sha256_starts_ret(&ctx, 0) == 0; } + bool update(const std::uint8_t* data, std::size_t dataLen) { return mbedtls_sha256_update_ret(&ctx, data, dataLen) == 0; } + bool finish(std::array& hash) { return mbedtls_sha256_finish_ret(&ctx, hash.data()) == 0; } + + mbedtls_sha256_context ctx; +}; +} // namespace OpenShock diff --git a/include/Logging.h b/include/Logging.h index aa87e3b9..422f1a7e 100644 --- a/include/Logging.h +++ b/include/Logging.h @@ -2,12 +2,22 @@ #include #include +#include +#include -#define ESP_PANIC(TAG, format, ...) \ - ESP_LOGE(TAG, "PANIC: " format ", restarting in 5 seconds...", ##__VA_ARGS__); \ - vTaskDelay(pdMS_TO_TICKS(5000)); \ - esp_restart(); +#define ESP_PANIC_PRINT(TAG, format, ...) ESP_LOGE(TAG, "PANIC: " format, ##__VA_ARGS__) -#define ESP_PANIC_INSTANT(TAG, format, ...) \ - ESP_LOGE(TAG, "PANIC: " format ", restarting now...", ##__VA_ARGS__); \ - esp_restart(); +#define ESP_PANIC(TAG, format, ...) \ + ESP_PANIC_PRINT(TAG, format ", restarting in 5 seconds...", ##__VA_ARGS__); \ + vTaskDelay(pdMS_TO_TICKS(5000)); \ + esp_restart() + +#define ESP_PANIC_OTA(TAG, format, ...) \ + ESP_PANIC_PRINT(TAG, format ", invalidating update partition and restarting in 5 seconds...", ##__VA_ARGS__); \ + vTaskDelay(pdMS_TO_TICKS(5000)); \ + esp_ota_mark_app_invalid_rollback_and_reboot(); \ + esp_restart() + +#define ESP_PANIC_INSTANT(TAG, format, ...) \ + ESP_PANIC_PRINT(TAG, format, ##__VA_ARGS__); \ + esp_restart() diff --git a/include/OtaUpdateChannel.h b/include/OtaUpdateChannel.h new file mode 100644 index 00000000..a44ef376 --- /dev/null +++ b/include/OtaUpdateChannel.h @@ -0,0 +1,29 @@ +#pragma once + +#include "serialization/_fbs/ConfigFile_generated.h" + +#include +#include + +namespace OpenShock { + typedef OpenShock::Serialization::Configuration::OtaUpdateChannel OtaUpdateChannel; + + inline bool TryParseOtaUpdateChannel(OtaUpdateChannel& channel, const char* str) { + if (strcasecmp(str, "stable") == 0) { + channel = OtaUpdateChannel::Stable; + return true; + } + + if (strcasecmp(str, "beta") == 0) { + channel = OtaUpdateChannel::Beta; + return true; + } + + if (strcasecmp(str, "develop") == 0 || strcasecmp(str, "dev") == 0) { + channel = OtaUpdateChannel::Develop; + return true; + } + + return false; + } +} // namespace OpenShock diff --git a/include/OtaUpdateManager.h b/include/OtaUpdateManager.h new file mode 100644 index 00000000..bd26434a --- /dev/null +++ b/include/OtaUpdateManager.h @@ -0,0 +1,31 @@ +#pragma once + +#include "OtaUpdateChannel.h" +#include "SemVer.h" +#include "StringView.h" + +#include +#include +#include +#include + +namespace OpenShock::OtaUpdateManager { + bool Init(); + + struct FirmwareRelease { + std::string appBinaryUrl; + std::uint8_t appBinaryHash[32]; + std::string filesystemBinaryUrl; + std::uint8_t filesystemBinaryHash[32]; + }; + + bool TryGetFirmwareVersion(OtaUpdateChannel channel, OpenShock::SemVer& version); + bool TryGetFirmwareBoards(const OpenShock::SemVer& version, std::vector& boards); + bool TryGetFirmwareRelease(const OpenShock::SemVer& version, FirmwareRelease& release); + + bool TryStartFirmwareInstallation(const OpenShock::SemVer& version); + + bool IsValidatingApp(); + void InvalidateAndRollback(); + void ValidateApp(); +} // namespace OpenShock::OtaUpdateManager diff --git a/include/SemVer.h b/include/SemVer.h index 12632e83..dad22c14 100644 --- a/include/SemVer.h +++ b/include/SemVer.h @@ -72,5 +72,5 @@ namespace OpenShock { std::string toString() const; }; - static bool TryParseSemVer(StringView str, SemVer& out); + bool TryParseSemVer(StringView str, SemVer& out); } // namespace OpenShock diff --git a/include/config/Config.h b/include/config/Config.h index bba3dcec..c3b6f2e8 100644 --- a/include/config/Config.h +++ b/include/config/Config.h @@ -2,6 +2,7 @@ #include "config/BackendConfig.h" #include "config/CaptivePortalConfig.h" +#include "config/OtaUpdateConfig.h" #include "config/RFConfig.h" #include "config/SerialInputConfig.h" #include "config/WiFiConfig.h" @@ -35,6 +36,7 @@ namespace OpenShock::Config { bool GetRFConfig(RFConfig& out); bool GetWiFiConfig(WiFiConfig& out); + bool GetOtaUpdateConfig(OtaUpdateConfig& out); bool GetWiFiCredentials(cJSON* array, bool withSensitiveData); bool GetWiFiCredentials(std::vector& out); @@ -62,6 +64,11 @@ namespace OpenShock::Config { bool RemoveWiFiCredentials(std::uint8_t id); bool ClearWiFiCredentials(); + bool GetOtaUpdateId(std::int32_t& out); + bool SetOtaUpdateId(std::int32_t updateId); + bool GetOtaFirmwareBootType(FirmwareBootType& out); + bool SetOtaFirmwareBootType(FirmwareBootType bootType); + bool HasBackendAuthToken(); bool GetBackendAuthToken(std::string& out); bool SetBackendAuthToken(const std::string& token); diff --git a/include/config/OtaUpdateConfig.h b/include/config/OtaUpdateConfig.h new file mode 100644 index 00000000..88e906ea --- /dev/null +++ b/include/config/OtaUpdateConfig.h @@ -0,0 +1,44 @@ +#pragma once + +#include "config/ConfigBase.h" +#include "FirmwareBootType.h" +#include "OtaUpdateChannel.h" + +#include + +namespace OpenShock::Config { + struct OtaUpdateConfig : public ConfigBase { + OtaUpdateConfig(); + OtaUpdateConfig( + bool isEnabled, + std::string cdnDomain, + OtaUpdateChannel updateChannel, + bool checkOnStartup, + bool checkPeriodically, + std::uint16_t checkInterval, + bool allowBackendManagement, + bool requireManualApproval, + std::int32_t updateId, + FirmwareBootType bootType + ); + + bool isEnabled; + std::string cdnDomain; + OtaUpdateChannel updateChannel; + bool checkOnStartup; + bool checkPeriodically; + std::uint16_t checkInterval; + bool allowBackendManagement; + bool requireManualApproval; + std::int32_t updateId; + FirmwareBootType bootType; + + void ToDefault() override; + + bool FromFlatbuffers(const Serialization::Configuration::OtaUpdateConfig* config) override; + flatbuffers::Offset ToFlatbuffers(flatbuffers::FlatBufferBuilder& builder, bool withSensitiveData) const override; + + bool FromJSON(const cJSON* json) override; + cJSON* ToJSON(bool withSensitiveData) const override; + }; +} // namespace OpenShock::Config diff --git a/include/config/RootConfig.h b/include/config/RootConfig.h index 29d95bd5..8a23e179 100644 --- a/include/config/RootConfig.h +++ b/include/config/RootConfig.h @@ -3,6 +3,7 @@ #include "config/BackendConfig.h" #include "config/CaptivePortalConfig.h" #include "config/ConfigBase.h" +#include "config/OtaUpdateConfig.h" #include "config/RFConfig.h" #include "config/SerialInputConfig.h" #include "config/WiFiConfig.h" @@ -14,6 +15,7 @@ namespace OpenShock::Config { OpenShock::Config::CaptivePortalConfig captivePortal; OpenShock::Config::BackendConfig backend; OpenShock::Config::SerialInputConfig serialInput; + OpenShock::Config::OtaUpdateConfig otaUpdate; void ToDefault() override; diff --git a/include/config/internal/utils.h b/include/config/internal/utils.h index 850a21ef..c48d587b 100644 --- a/include/config/internal/utils.h +++ b/include/config/internal/utils.h @@ -13,6 +13,7 @@ namespace OpenShock::Config::Internal::Utils { bool FromJsonBool(bool& val, const cJSON* json, const char* name, bool defaultVal); bool FromJsonU8(std::uint8_t& val, const cJSON* json, const char* name, std::uint8_t defaultVal); bool FromJsonU16(std::uint16_t& val, const cJSON* json, const char* name, std::uint16_t defaultVal); + bool FromJsonI32(std::int32_t& val, const cJSON* json, const char* name, std::int32_t defaultVal); bool FromJsonStr(std::string& str, const cJSON* json, const char* name, const char* defaultStr); template // T inherits from ConfigBase diff --git a/include/event_handlers/impl/WSGateway.h b/include/event_handlers/impl/WSGateway.h index 9f54a8b0..cf0419fd 100644 --- a/include/event_handlers/impl/WSGateway.h +++ b/include/event_handlers/impl/WSGateway.h @@ -1,14 +1,15 @@ #pragma once -#include "serialization/_fbs/ServerToDeviceMessage_generated.h" +#include "serialization/_fbs/GatewayToDeviceMessage_generated.h" #include -#define WS_EVENT_HANDLER_SIGNATURE(NAME) void NAME(const OpenShock::Serialization::ServerToDeviceMessage* msg) +#define WS_EVENT_HANDLER_SIGNATURE(NAME) void NAME(const OpenShock::Serialization::Gateway::GatewayToDeviceMessage* msg) namespace OpenShock::MessageHandlers::Server::_Private { typedef WS_EVENT_HANDLER_SIGNATURE((*HandlerType)); WS_EVENT_HANDLER_SIGNATURE(HandleInvalidMessage); WS_EVENT_HANDLER_SIGNATURE(HandleShockerCommandList); WS_EVENT_HANDLER_SIGNATURE(HandleCaptivePortalConfig); + WS_EVENT_HANDLER_SIGNATURE(HandleOtaInstall); } // namespace OpenShock::MessageHandlers::Server::_Private diff --git a/include/serialization/WSGateway.h b/include/serialization/WSGateway.h index f5269b29..81a304c0 100644 --- a/include/serialization/WSGateway.h +++ b/include/serialization/WSGateway.h @@ -1,5 +1,16 @@ #pragma once +#include "FirmwareBootType.h" +#include "SemVer.h" #include "serialization/CallbackFn.h" +#include "StringView.h" -namespace OpenShock::Serialization::Gateway { } +#include "serialization/_fbs/DeviceToGatewayMessage_generated.h" + +namespace OpenShock::Serialization::Gateway { + bool SerializeKeepAliveMessage(Common::SerializationCallbackFn callback); + bool SerializeBootStatusMessage(std::int32_t otaUpdateId, OpenShock::FirmwareBootType bootType, const OpenShock::SemVer& version, Common::SerializationCallbackFn callback); + bool SerializeOtaInstallStartedMessage(std::int32_t updateId, const OpenShock::SemVer& version, Common::SerializationCallbackFn callback); + bool SerializeOtaInstallProgressMessage(std::int32_t updateId, Gateway::OtaInstallProgressTask task, float progress, Common::SerializationCallbackFn callback); + bool SerializeOtaInstallFailedMessage(std::int32_t updateId, StringView message, bool fatal, Common::SerializationCallbackFn callback); +} // namespace OpenShock::Serialization::Gateway diff --git a/include/serialization/_fbs/ConfigFile_generated.h b/include/serialization/_fbs/ConfigFile_generated.h index 06eeb171..e508be11 100644 --- a/include/serialization/_fbs/ConfigFile_generated.h +++ b/include/serialization/_fbs/ConfigFile_generated.h @@ -13,6 +13,8 @@ static_assert(FLATBUFFERS_VERSION_MAJOR == 23 && FLATBUFFERS_VERSION_REVISION == 26, "Non-compatible flatbuffers version included"); +#include "FirmwareBootType_generated.h" + namespace OpenShock { namespace Serialization { namespace Configuration { @@ -35,9 +37,45 @@ struct BackendConfigBuilder; struct SerialInputConfig; struct SerialInputConfigBuilder; +struct OtaUpdateConfig; +struct OtaUpdateConfigBuilder; + struct Config; struct ConfigBuilder; +enum class OtaUpdateChannel : uint8_t { + Stable = 0, + Beta = 1, + Develop = 2, + MIN = Stable, + MAX = Develop +}; + +inline const OtaUpdateChannel (&EnumValuesOtaUpdateChannel())[3] { + static const OtaUpdateChannel values[] = { + OtaUpdateChannel::Stable, + OtaUpdateChannel::Beta, + OtaUpdateChannel::Develop + }; + return values; +} + +inline const char * const *EnumNamesOtaUpdateChannel() { + static const char * const names[4] = { + "Stable", + "Beta", + "Develop", + nullptr + }; + return names; +} + +inline const char *EnumNameOtaUpdateChannel(OtaUpdateChannel e) { + if (::flatbuffers::IsOutRange(e, OtaUpdateChannel::Stable, OtaUpdateChannel::Develop)) return ""; + const size_t index = static_cast(e); + return EnumNamesOtaUpdateChannel()[index]; +} + struct RFConfig FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { typedef RFConfigBuilder Builder; struct Traits; @@ -460,6 +498,184 @@ struct SerialInputConfig::Traits { static auto constexpr Create = CreateSerialInputConfig; }; +struct OtaUpdateConfig FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef OtaUpdateConfigBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Configuration.OtaUpdateConfig"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_IS_ENABLED = 4, + VT_CDN_DOMAIN = 6, + VT_UPDATE_CHANNEL = 8, + VT_CHECK_ON_STARTUP = 10, + VT_CHECK_PERIODICALLY = 12, + VT_CHECK_INTERVAL = 14, + VT_ALLOW_BACKEND_MANAGEMENT = 16, + VT_REQUIRE_MANUAL_APPROVAL = 18, + VT_UPDATE_ID = 20, + VT_BOOT_TYPE = 22 + }; + /// Indicates whether OTA updates are enabled. + bool is_enabled() const { + return GetField(VT_IS_ENABLED, 0) != 0; + } + /// The domain name of the OTA Content Delivery Network (CDN). + const ::flatbuffers::String *cdn_domain() const { + return GetPointer(VT_CDN_DOMAIN); + } + /// The update channel to use. + OpenShock::Serialization::Configuration::OtaUpdateChannel update_channel() const { + return static_cast(GetField(VT_UPDATE_CHANNEL, 0)); + } + /// Indicates whether to check for updates on startup. + bool check_on_startup() const { + return GetField(VT_CHECK_ON_STARTUP, 0) != 0; + } + /// Indicates whether to check for updates periodically. + bool check_periodically() const { + return GetField(VT_CHECK_PERIODICALLY, 0) != 0; + } + /// The interval in minutes between periodic update checks. + uint16_t check_interval() const { + return GetField(VT_CHECK_INTERVAL, 0); + } + /// Indicates if the backend is authorized to manage the device's update version on behalf of the user. + bool allow_backend_management() const { + return GetField(VT_ALLOW_BACKEND_MANAGEMENT, 0) != 0; + } + /// Indicates if manual approval via serial input or captive portal is required before installing updates. + bool require_manual_approval() const { + return GetField(VT_REQUIRE_MANUAL_APPROVAL, 0) != 0; + } + /// Update process ID, used to track the update process server-side across reboots. + int32_t update_id() const { + return GetField(VT_UPDATE_ID, 0); + } + /// Indicates what kind of firmware boot is happening (normal boot, booting into new firmware, rolling back to old firmware, etc.) + OpenShock::Serialization::Types::FirmwareBootType boot_type() const { + return static_cast(GetField(VT_BOOT_TYPE, 0)); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_IS_ENABLED, 1) && + VerifyOffset(verifier, VT_CDN_DOMAIN) && + verifier.VerifyString(cdn_domain()) && + VerifyField(verifier, VT_UPDATE_CHANNEL, 1) && + VerifyField(verifier, VT_CHECK_ON_STARTUP, 1) && + VerifyField(verifier, VT_CHECK_PERIODICALLY, 1) && + VerifyField(verifier, VT_CHECK_INTERVAL, 2) && + VerifyField(verifier, VT_ALLOW_BACKEND_MANAGEMENT, 1) && + VerifyField(verifier, VT_REQUIRE_MANUAL_APPROVAL, 1) && + VerifyField(verifier, VT_UPDATE_ID, 4) && + VerifyField(verifier, VT_BOOT_TYPE, 1) && + verifier.EndTable(); + } +}; + +struct OtaUpdateConfigBuilder { + typedef OtaUpdateConfig Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_is_enabled(bool is_enabled) { + fbb_.AddElement(OtaUpdateConfig::VT_IS_ENABLED, static_cast(is_enabled), 0); + } + void add_cdn_domain(::flatbuffers::Offset<::flatbuffers::String> cdn_domain) { + fbb_.AddOffset(OtaUpdateConfig::VT_CDN_DOMAIN, cdn_domain); + } + void add_update_channel(OpenShock::Serialization::Configuration::OtaUpdateChannel update_channel) { + fbb_.AddElement(OtaUpdateConfig::VT_UPDATE_CHANNEL, static_cast(update_channel), 0); + } + void add_check_on_startup(bool check_on_startup) { + fbb_.AddElement(OtaUpdateConfig::VT_CHECK_ON_STARTUP, static_cast(check_on_startup), 0); + } + void add_check_periodically(bool check_periodically) { + fbb_.AddElement(OtaUpdateConfig::VT_CHECK_PERIODICALLY, static_cast(check_periodically), 0); + } + void add_check_interval(uint16_t check_interval) { + fbb_.AddElement(OtaUpdateConfig::VT_CHECK_INTERVAL, check_interval, 0); + } + void add_allow_backend_management(bool allow_backend_management) { + fbb_.AddElement(OtaUpdateConfig::VT_ALLOW_BACKEND_MANAGEMENT, static_cast(allow_backend_management), 0); + } + void add_require_manual_approval(bool require_manual_approval) { + fbb_.AddElement(OtaUpdateConfig::VT_REQUIRE_MANUAL_APPROVAL, static_cast(require_manual_approval), 0); + } + void add_update_id(int32_t update_id) { + fbb_.AddElement(OtaUpdateConfig::VT_UPDATE_ID, update_id, 0); + } + void add_boot_type(OpenShock::Serialization::Types::FirmwareBootType boot_type) { + fbb_.AddElement(OtaUpdateConfig::VT_BOOT_TYPE, static_cast(boot_type), 0); + } + explicit OtaUpdateConfigBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateOtaUpdateConfig( + ::flatbuffers::FlatBufferBuilder &_fbb, + bool is_enabled = false, + ::flatbuffers::Offset<::flatbuffers::String> cdn_domain = 0, + OpenShock::Serialization::Configuration::OtaUpdateChannel update_channel = OpenShock::Serialization::Configuration::OtaUpdateChannel::Stable, + bool check_on_startup = false, + bool check_periodically = false, + uint16_t check_interval = 0, + bool allow_backend_management = false, + bool require_manual_approval = false, + int32_t update_id = 0, + OpenShock::Serialization::Types::FirmwareBootType boot_type = OpenShock::Serialization::Types::FirmwareBootType::Normal) { + OtaUpdateConfigBuilder builder_(_fbb); + builder_.add_update_id(update_id); + builder_.add_cdn_domain(cdn_domain); + builder_.add_check_interval(check_interval); + builder_.add_boot_type(boot_type); + builder_.add_require_manual_approval(require_manual_approval); + builder_.add_allow_backend_management(allow_backend_management); + builder_.add_check_periodically(check_periodically); + builder_.add_check_on_startup(check_on_startup); + builder_.add_update_channel(update_channel); + builder_.add_is_enabled(is_enabled); + return builder_.Finish(); +} + +struct OtaUpdateConfig::Traits { + using type = OtaUpdateConfig; + static auto constexpr Create = CreateOtaUpdateConfig; +}; + +inline ::flatbuffers::Offset CreateOtaUpdateConfigDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + bool is_enabled = false, + const char *cdn_domain = nullptr, + OpenShock::Serialization::Configuration::OtaUpdateChannel update_channel = OpenShock::Serialization::Configuration::OtaUpdateChannel::Stable, + bool check_on_startup = false, + bool check_periodically = false, + uint16_t check_interval = 0, + bool allow_backend_management = false, + bool require_manual_approval = false, + int32_t update_id = 0, + OpenShock::Serialization::Types::FirmwareBootType boot_type = OpenShock::Serialization::Types::FirmwareBootType::Normal) { + auto cdn_domain__ = cdn_domain ? _fbb.CreateString(cdn_domain) : 0; + return OpenShock::Serialization::Configuration::CreateOtaUpdateConfig( + _fbb, + is_enabled, + cdn_domain__, + update_channel, + check_on_startup, + check_periodically, + check_interval, + allow_backend_management, + require_manual_approval, + update_id, + boot_type); +} + struct Config FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { typedef ConfigBuilder Builder; struct Traits; @@ -471,7 +687,8 @@ struct Config FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { VT_WIFI = 6, VT_CAPTIVE_PORTAL = 8, VT_BACKEND = 10, - VT_SERIAL_INPUT = 12 + VT_SERIAL_INPUT = 12, + VT_OTA_UPDATE = 14 }; /// RF Transmitter configuration const OpenShock::Serialization::Configuration::RFConfig *rf() const { @@ -493,6 +710,10 @@ struct Config FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { const OpenShock::Serialization::Configuration::SerialInputConfig *serial_input() const { return GetPointer(VT_SERIAL_INPUT); } + /// OTA update configuration + const OpenShock::Serialization::Configuration::OtaUpdateConfig *ota_update() const { + return GetPointer(VT_OTA_UPDATE); + } bool Verify(::flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_RF) && @@ -505,6 +726,8 @@ struct Config FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { verifier.VerifyTable(backend()) && VerifyOffset(verifier, VT_SERIAL_INPUT) && verifier.VerifyTable(serial_input()) && + VerifyOffset(verifier, VT_OTA_UPDATE) && + verifier.VerifyTable(ota_update()) && verifier.EndTable(); } }; @@ -528,6 +751,9 @@ struct ConfigBuilder { void add_serial_input(::flatbuffers::Offset serial_input) { fbb_.AddOffset(Config::VT_SERIAL_INPUT, serial_input); } + void add_ota_update(::flatbuffers::Offset ota_update) { + fbb_.AddOffset(Config::VT_OTA_UPDATE, ota_update); + } explicit ConfigBuilder(::flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); @@ -545,8 +771,10 @@ inline ::flatbuffers::Offset CreateConfig( ::flatbuffers::Offset wifi = 0, ::flatbuffers::Offset captive_portal = 0, ::flatbuffers::Offset backend = 0, - ::flatbuffers::Offset serial_input = 0) { + ::flatbuffers::Offset serial_input = 0, + ::flatbuffers::Offset ota_update = 0) { ConfigBuilder builder_(_fbb); + builder_.add_ota_update(ota_update); builder_.add_serial_input(serial_input); builder_.add_backend(backend); builder_.add_captive_portal(captive_portal); diff --git a/include/serialization/_fbs/DeviceToGatewayMessage_generated.h b/include/serialization/_fbs/DeviceToGatewayMessage_generated.h new file mode 100644 index 00000000..a853d7f2 --- /dev/null +++ b/include/serialization/_fbs/DeviceToGatewayMessage_generated.h @@ -0,0 +1,636 @@ +// automatically generated by the FlatBuffers compiler, do not modify + + +#ifndef FLATBUFFERS_GENERATED_DEVICETOGATEWAYMESSAGE_OPENSHOCK_SERIALIZATION_GATEWAY_H_ +#define FLATBUFFERS_GENERATED_DEVICETOGATEWAYMESSAGE_OPENSHOCK_SERIALIZATION_GATEWAY_H_ + +#include "flatbuffers/flatbuffers.h" + +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 23 && + FLATBUFFERS_VERSION_MINOR == 5 && + FLATBUFFERS_VERSION_REVISION == 26, + "Non-compatible flatbuffers version included"); + +#include "FirmwareBootType_generated.h" +#include "SemVer_generated.h" + +namespace OpenShock { +namespace Serialization { +namespace Gateway { + +struct KeepAlive; + +struct BootStatus; +struct BootStatusBuilder; + +struct OtaInstallStarted; +struct OtaInstallStartedBuilder; + +struct OtaInstallProgress; +struct OtaInstallProgressBuilder; + +struct OtaInstallFailed; +struct OtaInstallFailedBuilder; + +struct DeviceToGatewayMessage; +struct DeviceToGatewayMessageBuilder; + +enum class OtaInstallProgressTask : int8_t { + FetchingMetadata = 0, + PreparingForInstall = 1, + FlashingFilesystem = 2, + VerifyingFilesystem = 3, + FlashingApplication = 4, + MarkingApplicationBootable = 5, + Rebooting = 6, + MIN = FetchingMetadata, + MAX = Rebooting +}; + +inline const OtaInstallProgressTask (&EnumValuesOtaInstallProgressTask())[7] { + static const OtaInstallProgressTask values[] = { + OtaInstallProgressTask::FetchingMetadata, + OtaInstallProgressTask::PreparingForInstall, + OtaInstallProgressTask::FlashingFilesystem, + OtaInstallProgressTask::VerifyingFilesystem, + OtaInstallProgressTask::FlashingApplication, + OtaInstallProgressTask::MarkingApplicationBootable, + OtaInstallProgressTask::Rebooting + }; + return values; +} + +inline const char * const *EnumNamesOtaInstallProgressTask() { + static const char * const names[8] = { + "FetchingMetadata", + "PreparingForInstall", + "FlashingFilesystem", + "VerifyingFilesystem", + "FlashingApplication", + "MarkingApplicationBootable", + "Rebooting", + nullptr + }; + return names; +} + +inline const char *EnumNameOtaInstallProgressTask(OtaInstallProgressTask e) { + if (::flatbuffers::IsOutRange(e, OtaInstallProgressTask::FetchingMetadata, OtaInstallProgressTask::Rebooting)) return ""; + const size_t index = static_cast(e); + return EnumNamesOtaInstallProgressTask()[index]; +} + +enum class DeviceToGatewayMessagePayload : uint8_t { + NONE = 0, + KeepAlive = 1, + BootStatus = 2, + OtaInstallStarted = 3, + OtaInstallProgress = 4, + OtaInstallFailed = 5, + MIN = NONE, + MAX = OtaInstallFailed +}; + +inline const DeviceToGatewayMessagePayload (&EnumValuesDeviceToGatewayMessagePayload())[6] { + static const DeviceToGatewayMessagePayload values[] = { + DeviceToGatewayMessagePayload::NONE, + DeviceToGatewayMessagePayload::KeepAlive, + DeviceToGatewayMessagePayload::BootStatus, + DeviceToGatewayMessagePayload::OtaInstallStarted, + DeviceToGatewayMessagePayload::OtaInstallProgress, + DeviceToGatewayMessagePayload::OtaInstallFailed + }; + return values; +} + +inline const char * const *EnumNamesDeviceToGatewayMessagePayload() { + static const char * const names[7] = { + "NONE", + "KeepAlive", + "BootStatus", + "OtaInstallStarted", + "OtaInstallProgress", + "OtaInstallFailed", + nullptr + }; + return names; +} + +inline const char *EnumNameDeviceToGatewayMessagePayload(DeviceToGatewayMessagePayload e) { + if (::flatbuffers::IsOutRange(e, DeviceToGatewayMessagePayload::NONE, DeviceToGatewayMessagePayload::OtaInstallFailed)) return ""; + const size_t index = static_cast(e); + return EnumNamesDeviceToGatewayMessagePayload()[index]; +} + +template struct DeviceToGatewayMessagePayloadTraits { + static const DeviceToGatewayMessagePayload enum_value = DeviceToGatewayMessagePayload::NONE; +}; + +template<> struct DeviceToGatewayMessagePayloadTraits { + static const DeviceToGatewayMessagePayload enum_value = DeviceToGatewayMessagePayload::KeepAlive; +}; + +template<> struct DeviceToGatewayMessagePayloadTraits { + static const DeviceToGatewayMessagePayload enum_value = DeviceToGatewayMessagePayload::BootStatus; +}; + +template<> struct DeviceToGatewayMessagePayloadTraits { + static const DeviceToGatewayMessagePayload enum_value = DeviceToGatewayMessagePayload::OtaInstallStarted; +}; + +template<> struct DeviceToGatewayMessagePayloadTraits { + static const DeviceToGatewayMessagePayload enum_value = DeviceToGatewayMessagePayload::OtaInstallProgress; +}; + +template<> struct DeviceToGatewayMessagePayloadTraits { + static const DeviceToGatewayMessagePayload enum_value = DeviceToGatewayMessagePayload::OtaInstallFailed; +}; + +bool VerifyDeviceToGatewayMessagePayload(::flatbuffers::Verifier &verifier, const void *obj, DeviceToGatewayMessagePayload type); +bool VerifyDeviceToGatewayMessagePayloadVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset> *values, const ::flatbuffers::Vector *types); + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) KeepAlive FLATBUFFERS_FINAL_CLASS { + private: + uint64_t uptime_; + + public: + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.KeepAlive"; + } + KeepAlive() + : uptime_(0) { + } + KeepAlive(uint64_t _uptime) + : uptime_(::flatbuffers::EndianScalar(_uptime)) { + } + uint64_t uptime() const { + return ::flatbuffers::EndianScalar(uptime_); + } +}; +FLATBUFFERS_STRUCT_END(KeepAlive, 8); + +struct KeepAlive::Traits { + using type = KeepAlive; +}; + +struct BootStatus FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef BootStatusBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.BootStatus"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_BOOT_TYPE = 4, + VT_FIRMWARE_VERSION = 6, + VT_OTA_UPDATE_ID = 8 + }; + OpenShock::Serialization::Types::FirmwareBootType boot_type() const { + return static_cast(GetField(VT_BOOT_TYPE, 0)); + } + const OpenShock::Serialization::Types::SemVer *firmware_version() const { + return GetPointer(VT_FIRMWARE_VERSION); + } + int32_t ota_update_id() const { + return GetField(VT_OTA_UPDATE_ID, 0); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_BOOT_TYPE, 1) && + VerifyOffset(verifier, VT_FIRMWARE_VERSION) && + verifier.VerifyTable(firmware_version()) && + VerifyField(verifier, VT_OTA_UPDATE_ID, 4) && + verifier.EndTable(); + } +}; + +struct BootStatusBuilder { + typedef BootStatus Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_boot_type(OpenShock::Serialization::Types::FirmwareBootType boot_type) { + fbb_.AddElement(BootStatus::VT_BOOT_TYPE, static_cast(boot_type), 0); + } + void add_firmware_version(::flatbuffers::Offset firmware_version) { + fbb_.AddOffset(BootStatus::VT_FIRMWARE_VERSION, firmware_version); + } + void add_ota_update_id(int32_t ota_update_id) { + fbb_.AddElement(BootStatus::VT_OTA_UPDATE_ID, ota_update_id, 0); + } + explicit BootStatusBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateBootStatus( + ::flatbuffers::FlatBufferBuilder &_fbb, + OpenShock::Serialization::Types::FirmwareBootType boot_type = OpenShock::Serialization::Types::FirmwareBootType::Normal, + ::flatbuffers::Offset firmware_version = 0, + int32_t ota_update_id = 0) { + BootStatusBuilder builder_(_fbb); + builder_.add_ota_update_id(ota_update_id); + builder_.add_firmware_version(firmware_version); + builder_.add_boot_type(boot_type); + return builder_.Finish(); +} + +struct BootStatus::Traits { + using type = BootStatus; + static auto constexpr Create = CreateBootStatus; +}; + +struct OtaInstallStarted FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef OtaInstallStartedBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.OtaInstallStarted"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_UPDATE_ID = 4, + VT_VERSION = 6 + }; + int32_t update_id() const { + return GetField(VT_UPDATE_ID, 0); + } + const OpenShock::Serialization::Types::SemVer *version() const { + return GetPointer(VT_VERSION); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_UPDATE_ID, 4) && + VerifyOffset(verifier, VT_VERSION) && + verifier.VerifyTable(version()) && + verifier.EndTable(); + } +}; + +struct OtaInstallStartedBuilder { + typedef OtaInstallStarted Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_update_id(int32_t update_id) { + fbb_.AddElement(OtaInstallStarted::VT_UPDATE_ID, update_id, 0); + } + void add_version(::flatbuffers::Offset version) { + fbb_.AddOffset(OtaInstallStarted::VT_VERSION, version); + } + explicit OtaInstallStartedBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateOtaInstallStarted( + ::flatbuffers::FlatBufferBuilder &_fbb, + int32_t update_id = 0, + ::flatbuffers::Offset version = 0) { + OtaInstallStartedBuilder builder_(_fbb); + builder_.add_version(version); + builder_.add_update_id(update_id); + return builder_.Finish(); +} + +struct OtaInstallStarted::Traits { + using type = OtaInstallStarted; + static auto constexpr Create = CreateOtaInstallStarted; +}; + +struct OtaInstallProgress FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef OtaInstallProgressBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.OtaInstallProgress"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_UPDATE_ID = 4, + VT_TASK = 6, + VT_PROGRESS = 8 + }; + int32_t update_id() const { + return GetField(VT_UPDATE_ID, 0); + } + OpenShock::Serialization::Gateway::OtaInstallProgressTask task() const { + return static_cast(GetField(VT_TASK, 0)); + } + float progress() const { + return GetField(VT_PROGRESS, 0.0f); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_UPDATE_ID, 4) && + VerifyField(verifier, VT_TASK, 1) && + VerifyField(verifier, VT_PROGRESS, 4) && + verifier.EndTable(); + } +}; + +struct OtaInstallProgressBuilder { + typedef OtaInstallProgress Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_update_id(int32_t update_id) { + fbb_.AddElement(OtaInstallProgress::VT_UPDATE_ID, update_id, 0); + } + void add_task(OpenShock::Serialization::Gateway::OtaInstallProgressTask task) { + fbb_.AddElement(OtaInstallProgress::VT_TASK, static_cast(task), 0); + } + void add_progress(float progress) { + fbb_.AddElement(OtaInstallProgress::VT_PROGRESS, progress, 0.0f); + } + explicit OtaInstallProgressBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateOtaInstallProgress( + ::flatbuffers::FlatBufferBuilder &_fbb, + int32_t update_id = 0, + OpenShock::Serialization::Gateway::OtaInstallProgressTask task = OpenShock::Serialization::Gateway::OtaInstallProgressTask::FetchingMetadata, + float progress = 0.0f) { + OtaInstallProgressBuilder builder_(_fbb); + builder_.add_progress(progress); + builder_.add_update_id(update_id); + builder_.add_task(task); + return builder_.Finish(); +} + +struct OtaInstallProgress::Traits { + using type = OtaInstallProgress; + static auto constexpr Create = CreateOtaInstallProgress; +}; + +struct OtaInstallFailed FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef OtaInstallFailedBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.OtaInstallFailed"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_UPDATE_ID = 4, + VT_MESSAGE = 6, + VT_FATAL = 8 + }; + int32_t update_id() const { + return GetField(VT_UPDATE_ID, 0); + } + const ::flatbuffers::String *message() const { + return GetPointer(VT_MESSAGE); + } + bool fatal() const { + return GetField(VT_FATAL, 0) != 0; + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_UPDATE_ID, 4) && + VerifyOffset(verifier, VT_MESSAGE) && + verifier.VerifyString(message()) && + VerifyField(verifier, VT_FATAL, 1) && + verifier.EndTable(); + } +}; + +struct OtaInstallFailedBuilder { + typedef OtaInstallFailed Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_update_id(int32_t update_id) { + fbb_.AddElement(OtaInstallFailed::VT_UPDATE_ID, update_id, 0); + } + void add_message(::flatbuffers::Offset<::flatbuffers::String> message) { + fbb_.AddOffset(OtaInstallFailed::VT_MESSAGE, message); + } + void add_fatal(bool fatal) { + fbb_.AddElement(OtaInstallFailed::VT_FATAL, static_cast(fatal), 0); + } + explicit OtaInstallFailedBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateOtaInstallFailed( + ::flatbuffers::FlatBufferBuilder &_fbb, + int32_t update_id = 0, + ::flatbuffers::Offset<::flatbuffers::String> message = 0, + bool fatal = false) { + OtaInstallFailedBuilder builder_(_fbb); + builder_.add_message(message); + builder_.add_update_id(update_id); + builder_.add_fatal(fatal); + return builder_.Finish(); +} + +struct OtaInstallFailed::Traits { + using type = OtaInstallFailed; + static auto constexpr Create = CreateOtaInstallFailed; +}; + +inline ::flatbuffers::Offset CreateOtaInstallFailedDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + int32_t update_id = 0, + const char *message = nullptr, + bool fatal = false) { + auto message__ = message ? _fbb.CreateString(message) : 0; + return OpenShock::Serialization::Gateway::CreateOtaInstallFailed( + _fbb, + update_id, + message__, + fatal); +} + +struct DeviceToGatewayMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef DeviceToGatewayMessageBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.DeviceToGatewayMessage"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_PAYLOAD_TYPE = 4, + VT_PAYLOAD = 6 + }; + OpenShock::Serialization::Gateway::DeviceToGatewayMessagePayload payload_type() const { + return static_cast(GetField(VT_PAYLOAD_TYPE, 0)); + } + const void *payload() const { + return GetPointer(VT_PAYLOAD); + } + template const T *payload_as() const; + const OpenShock::Serialization::Gateway::KeepAlive *payload_as_KeepAlive() const { + return payload_type() == OpenShock::Serialization::Gateway::DeviceToGatewayMessagePayload::KeepAlive ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Gateway::BootStatus *payload_as_BootStatus() const { + return payload_type() == OpenShock::Serialization::Gateway::DeviceToGatewayMessagePayload::BootStatus ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Gateway::OtaInstallStarted *payload_as_OtaInstallStarted() const { + return payload_type() == OpenShock::Serialization::Gateway::DeviceToGatewayMessagePayload::OtaInstallStarted ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Gateway::OtaInstallProgress *payload_as_OtaInstallProgress() const { + return payload_type() == OpenShock::Serialization::Gateway::DeviceToGatewayMessagePayload::OtaInstallProgress ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Gateway::OtaInstallFailed *payload_as_OtaInstallFailed() const { + return payload_type() == OpenShock::Serialization::Gateway::DeviceToGatewayMessagePayload::OtaInstallFailed ? static_cast(payload()) : nullptr; + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_PAYLOAD_TYPE, 1) && + VerifyOffset(verifier, VT_PAYLOAD) && + VerifyDeviceToGatewayMessagePayload(verifier, payload(), payload_type()) && + verifier.EndTable(); + } +}; + +template<> inline const OpenShock::Serialization::Gateway::KeepAlive *DeviceToGatewayMessage::payload_as() const { + return payload_as_KeepAlive(); +} + +template<> inline const OpenShock::Serialization::Gateway::BootStatus *DeviceToGatewayMessage::payload_as() const { + return payload_as_BootStatus(); +} + +template<> inline const OpenShock::Serialization::Gateway::OtaInstallStarted *DeviceToGatewayMessage::payload_as() const { + return payload_as_OtaInstallStarted(); +} + +template<> inline const OpenShock::Serialization::Gateway::OtaInstallProgress *DeviceToGatewayMessage::payload_as() const { + return payload_as_OtaInstallProgress(); +} + +template<> inline const OpenShock::Serialization::Gateway::OtaInstallFailed *DeviceToGatewayMessage::payload_as() const { + return payload_as_OtaInstallFailed(); +} + +struct DeviceToGatewayMessageBuilder { + typedef DeviceToGatewayMessage Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_payload_type(OpenShock::Serialization::Gateway::DeviceToGatewayMessagePayload payload_type) { + fbb_.AddElement(DeviceToGatewayMessage::VT_PAYLOAD_TYPE, static_cast(payload_type), 0); + } + void add_payload(::flatbuffers::Offset payload) { + fbb_.AddOffset(DeviceToGatewayMessage::VT_PAYLOAD, payload); + } + explicit DeviceToGatewayMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateDeviceToGatewayMessage( + ::flatbuffers::FlatBufferBuilder &_fbb, + OpenShock::Serialization::Gateway::DeviceToGatewayMessagePayload payload_type = OpenShock::Serialization::Gateway::DeviceToGatewayMessagePayload::NONE, + ::flatbuffers::Offset payload = 0) { + DeviceToGatewayMessageBuilder builder_(_fbb); + builder_.add_payload(payload); + builder_.add_payload_type(payload_type); + return builder_.Finish(); +} + +struct DeviceToGatewayMessage::Traits { + using type = DeviceToGatewayMessage; + static auto constexpr Create = CreateDeviceToGatewayMessage; +}; + +inline bool VerifyDeviceToGatewayMessagePayload(::flatbuffers::Verifier &verifier, const void *obj, DeviceToGatewayMessagePayload type) { + switch (type) { + case DeviceToGatewayMessagePayload::NONE: { + return true; + } + case DeviceToGatewayMessagePayload::KeepAlive: { + return verifier.VerifyField(static_cast(obj), 0, 8); + } + case DeviceToGatewayMessagePayload::BootStatus: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } + case DeviceToGatewayMessagePayload::OtaInstallStarted: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } + case DeviceToGatewayMessagePayload::OtaInstallProgress: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } + case DeviceToGatewayMessagePayload::OtaInstallFailed: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } + default: return true; + } +} + +inline bool VerifyDeviceToGatewayMessagePayloadVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset> *values, const ::flatbuffers::Vector *types) { + if (!values || !types) return !values && !types; + if (values->size() != types->size()) return false; + for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { + if (!VerifyDeviceToGatewayMessagePayload( + verifier, values->Get(i), types->GetEnum(i))) { + return false; + } + } + return true; +} + +inline const OpenShock::Serialization::Gateway::DeviceToGatewayMessage *GetDeviceToGatewayMessage(const void *buf) { + return ::flatbuffers::GetRoot(buf); +} + +inline const OpenShock::Serialization::Gateway::DeviceToGatewayMessage *GetSizePrefixedDeviceToGatewayMessage(const void *buf) { + return ::flatbuffers::GetSizePrefixedRoot(buf); +} + +inline bool VerifyDeviceToGatewayMessageBuffer( + ::flatbuffers::Verifier &verifier) { + return verifier.VerifyBuffer(nullptr); +} + +inline bool VerifySizePrefixedDeviceToGatewayMessageBuffer( + ::flatbuffers::Verifier &verifier) { + return verifier.VerifySizePrefixedBuffer(nullptr); +} + +inline void FinishDeviceToGatewayMessageBuffer( + ::flatbuffers::FlatBufferBuilder &fbb, + ::flatbuffers::Offset root) { + fbb.Finish(root); +} + +inline void FinishSizePrefixedDeviceToGatewayMessageBuffer( + ::flatbuffers::FlatBufferBuilder &fbb, + ::flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); +} + +} // namespace Gateway +} // namespace Serialization +} // namespace OpenShock + +#endif // FLATBUFFERS_GENERATED_DEVICETOGATEWAYMESSAGE_OPENSHOCK_SERIALIZATION_GATEWAY_H_ diff --git a/include/serialization/_fbs/DeviceToServerMessage_generated.h b/include/serialization/_fbs/DeviceToServerMessage_generated.h deleted file mode 100644 index 7dc92459..00000000 --- a/include/serialization/_fbs/DeviceToServerMessage_generated.h +++ /dev/null @@ -1,216 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_DEVICETOSERVERMESSAGE_OPENSHOCK_SERIALIZATION_H_ -#define FLATBUFFERS_GENERATED_DEVICETOSERVERMESSAGE_OPENSHOCK_SERIALIZATION_H_ - -#include "flatbuffers/flatbuffers.h" - -// Ensure the included flatbuffers.h is the same version as when this file was -// generated, otherwise it may not be compatible. -static_assert(FLATBUFFERS_VERSION_MAJOR == 23 && - FLATBUFFERS_VERSION_MINOR == 5 && - FLATBUFFERS_VERSION_REVISION == 26, - "Non-compatible flatbuffers version included"); - -namespace OpenShock { -namespace Serialization { - -struct KeepAlive; - -struct DeviceToServerMessage; -struct DeviceToServerMessageBuilder; - -enum class DeviceToServerMessagePayload : uint8_t { - NONE = 0, - KeepAlive = 1, - MIN = NONE, - MAX = KeepAlive -}; - -inline const DeviceToServerMessagePayload (&EnumValuesDeviceToServerMessagePayload())[2] { - static const DeviceToServerMessagePayload values[] = { - DeviceToServerMessagePayload::NONE, - DeviceToServerMessagePayload::KeepAlive - }; - return values; -} - -inline const char * const *EnumNamesDeviceToServerMessagePayload() { - static const char * const names[3] = { - "NONE", - "KeepAlive", - nullptr - }; - return names; -} - -inline const char *EnumNameDeviceToServerMessagePayload(DeviceToServerMessagePayload e) { - if (::flatbuffers::IsOutRange(e, DeviceToServerMessagePayload::NONE, DeviceToServerMessagePayload::KeepAlive)) return ""; - const size_t index = static_cast(e); - return EnumNamesDeviceToServerMessagePayload()[index]; -} - -template struct DeviceToServerMessagePayloadTraits { - static const DeviceToServerMessagePayload enum_value = DeviceToServerMessagePayload::NONE; -}; - -template<> struct DeviceToServerMessagePayloadTraits { - static const DeviceToServerMessagePayload enum_value = DeviceToServerMessagePayload::KeepAlive; -}; - -bool VerifyDeviceToServerMessagePayload(::flatbuffers::Verifier &verifier, const void *obj, DeviceToServerMessagePayload type); -bool VerifyDeviceToServerMessagePayloadVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset> *values, const ::flatbuffers::Vector *types); - -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) KeepAlive FLATBUFFERS_FINAL_CLASS { - private: - uint64_t uptime_; - - public: - struct Traits; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "OpenShock.Serialization.KeepAlive"; - } - KeepAlive() - : uptime_(0) { - } - KeepAlive(uint64_t _uptime) - : uptime_(::flatbuffers::EndianScalar(_uptime)) { - } - uint64_t uptime() const { - return ::flatbuffers::EndianScalar(uptime_); - } -}; -FLATBUFFERS_STRUCT_END(KeepAlive, 8); - -struct KeepAlive::Traits { - using type = KeepAlive; -}; - -struct DeviceToServerMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { - typedef DeviceToServerMessageBuilder Builder; - struct Traits; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "OpenShock.Serialization.DeviceToServerMessage"; - } - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_PAYLOAD_TYPE = 4, - VT_PAYLOAD = 6 - }; - OpenShock::Serialization::DeviceToServerMessagePayload payload_type() const { - return static_cast(GetField(VT_PAYLOAD_TYPE, 0)); - } - const void *payload() const { - return GetPointer(VT_PAYLOAD); - } - template const T *payload_as() const; - const OpenShock::Serialization::KeepAlive *payload_as_KeepAlive() const { - return payload_type() == OpenShock::Serialization::DeviceToServerMessagePayload::KeepAlive ? static_cast(payload()) : nullptr; - } - bool Verify(::flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_PAYLOAD_TYPE, 1) && - VerifyOffset(verifier, VT_PAYLOAD) && - VerifyDeviceToServerMessagePayload(verifier, payload(), payload_type()) && - verifier.EndTable(); - } -}; - -template<> inline const OpenShock::Serialization::KeepAlive *DeviceToServerMessage::payload_as() const { - return payload_as_KeepAlive(); -} - -struct DeviceToServerMessageBuilder { - typedef DeviceToServerMessage Table; - ::flatbuffers::FlatBufferBuilder &fbb_; - ::flatbuffers::uoffset_t start_; - void add_payload_type(OpenShock::Serialization::DeviceToServerMessagePayload payload_type) { - fbb_.AddElement(DeviceToServerMessage::VT_PAYLOAD_TYPE, static_cast(payload_type), 0); - } - void add_payload(::flatbuffers::Offset payload) { - fbb_.AddOffset(DeviceToServerMessage::VT_PAYLOAD, payload); - } - explicit DeviceToServerMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ::flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = ::flatbuffers::Offset(end); - return o; - } -}; - -inline ::flatbuffers::Offset CreateDeviceToServerMessage( - ::flatbuffers::FlatBufferBuilder &_fbb, - OpenShock::Serialization::DeviceToServerMessagePayload payload_type = OpenShock::Serialization::DeviceToServerMessagePayload::NONE, - ::flatbuffers::Offset payload = 0) { - DeviceToServerMessageBuilder builder_(_fbb); - builder_.add_payload(payload); - builder_.add_payload_type(payload_type); - return builder_.Finish(); -} - -struct DeviceToServerMessage::Traits { - using type = DeviceToServerMessage; - static auto constexpr Create = CreateDeviceToServerMessage; -}; - -inline bool VerifyDeviceToServerMessagePayload(::flatbuffers::Verifier &verifier, const void *obj, DeviceToServerMessagePayload type) { - switch (type) { - case DeviceToServerMessagePayload::NONE: { - return true; - } - case DeviceToServerMessagePayload::KeepAlive: { - return verifier.VerifyField(static_cast(obj), 0, 8); - } - default: return true; - } -} - -inline bool VerifyDeviceToServerMessagePayloadVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset> *values, const ::flatbuffers::Vector *types) { - if (!values || !types) return !values && !types; - if (values->size() != types->size()) return false; - for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { - if (!VerifyDeviceToServerMessagePayload( - verifier, values->Get(i), types->GetEnum(i))) { - return false; - } - } - return true; -} - -inline const OpenShock::Serialization::DeviceToServerMessage *GetDeviceToServerMessage(const void *buf) { - return ::flatbuffers::GetRoot(buf); -} - -inline const OpenShock::Serialization::DeviceToServerMessage *GetSizePrefixedDeviceToServerMessage(const void *buf) { - return ::flatbuffers::GetSizePrefixedRoot(buf); -} - -inline bool VerifyDeviceToServerMessageBuffer( - ::flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer(nullptr); -} - -inline bool VerifySizePrefixedDeviceToServerMessageBuffer( - ::flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer(nullptr); -} - -inline void FinishDeviceToServerMessageBuffer( - ::flatbuffers::FlatBufferBuilder &fbb, - ::flatbuffers::Offset root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedDeviceToServerMessageBuffer( - ::flatbuffers::FlatBufferBuilder &fbb, - ::flatbuffers::Offset root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace Serialization -} // namespace OpenShock - -#endif // FLATBUFFERS_GENERATED_DEVICETOSERVERMESSAGE_OPENSHOCK_SERIALIZATION_H_ diff --git a/include/serialization/_fbs/FirmwareBootType_generated.h b/include/serialization/_fbs/FirmwareBootType_generated.h new file mode 100644 index 00000000..331c57a0 --- /dev/null +++ b/include/serialization/_fbs/FirmwareBootType_generated.h @@ -0,0 +1,57 @@ +// automatically generated by the FlatBuffers compiler, do not modify + + +#ifndef FLATBUFFERS_GENERATED_FIRMWAREBOOTTYPE_OPENSHOCK_SERIALIZATION_TYPES_H_ +#define FLATBUFFERS_GENERATED_FIRMWAREBOOTTYPE_OPENSHOCK_SERIALIZATION_TYPES_H_ + +#include "flatbuffers/flatbuffers.h" + +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 23 && + FLATBUFFERS_VERSION_MINOR == 5 && + FLATBUFFERS_VERSION_REVISION == 26, + "Non-compatible flatbuffers version included"); + +namespace OpenShock { +namespace Serialization { +namespace Types { + +enum class FirmwareBootType : uint8_t { + Normal = 0, + NewFirmware = 1, + Rollback = 2, + MIN = Normal, + MAX = Rollback +}; + +inline const FirmwareBootType (&EnumValuesFirmwareBootType())[3] { + static const FirmwareBootType values[] = { + FirmwareBootType::Normal, + FirmwareBootType::NewFirmware, + FirmwareBootType::Rollback + }; + return values; +} + +inline const char * const *EnumNamesFirmwareBootType() { + static const char * const names[4] = { + "Normal", + "NewFirmware", + "Rollback", + nullptr + }; + return names; +} + +inline const char *EnumNameFirmwareBootType(FirmwareBootType e) { + if (::flatbuffers::IsOutRange(e, FirmwareBootType::Normal, FirmwareBootType::Rollback)) return ""; + const size_t index = static_cast(e); + return EnumNamesFirmwareBootType()[index]; +} + +} // namespace Types +} // namespace Serialization +} // namespace OpenShock + +#endif // FLATBUFFERS_GENERATED_FIRMWAREBOOTTYPE_OPENSHOCK_SERIALIZATION_TYPES_H_ diff --git a/include/serialization/_fbs/GatewayToDeviceMessage_generated.h b/include/serialization/_fbs/GatewayToDeviceMessage_generated.h new file mode 100644 index 00000000..2f79f58a --- /dev/null +++ b/include/serialization/_fbs/GatewayToDeviceMessage_generated.h @@ -0,0 +1,432 @@ +// automatically generated by the FlatBuffers compiler, do not modify + + +#ifndef FLATBUFFERS_GENERATED_GATEWAYTODEVICEMESSAGE_OPENSHOCK_SERIALIZATION_GATEWAY_H_ +#define FLATBUFFERS_GENERATED_GATEWAYTODEVICEMESSAGE_OPENSHOCK_SERIALIZATION_GATEWAY_H_ + +#include "flatbuffers/flatbuffers.h" + +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 23 && + FLATBUFFERS_VERSION_MINOR == 5 && + FLATBUFFERS_VERSION_REVISION == 26, + "Non-compatible flatbuffers version included"); + +#include "SemVer_generated.h" +#include "ShockerCommandType_generated.h" +#include "ShockerModelType_generated.h" + +namespace OpenShock { +namespace Serialization { +namespace Gateway { + +struct ShockerCommand; + +struct ShockerCommandList; +struct ShockerCommandListBuilder; + +struct CaptivePortalConfig; + +struct OtaInstall; +struct OtaInstallBuilder; + +struct GatewayToDeviceMessage; +struct GatewayToDeviceMessageBuilder; + +enum class GatewayToDeviceMessagePayload : uint8_t { + NONE = 0, + ShockerCommandList = 1, + CaptivePortalConfig = 2, + OtaInstall = 3, + MIN = NONE, + MAX = OtaInstall +}; + +inline const GatewayToDeviceMessagePayload (&EnumValuesGatewayToDeviceMessagePayload())[4] { + static const GatewayToDeviceMessagePayload values[] = { + GatewayToDeviceMessagePayload::NONE, + GatewayToDeviceMessagePayload::ShockerCommandList, + GatewayToDeviceMessagePayload::CaptivePortalConfig, + GatewayToDeviceMessagePayload::OtaInstall + }; + return values; +} + +inline const char * const *EnumNamesGatewayToDeviceMessagePayload() { + static const char * const names[5] = { + "NONE", + "ShockerCommandList", + "CaptivePortalConfig", + "OtaInstall", + nullptr + }; + return names; +} + +inline const char *EnumNameGatewayToDeviceMessagePayload(GatewayToDeviceMessagePayload e) { + if (::flatbuffers::IsOutRange(e, GatewayToDeviceMessagePayload::NONE, GatewayToDeviceMessagePayload::OtaInstall)) return ""; + const size_t index = static_cast(e); + return EnumNamesGatewayToDeviceMessagePayload()[index]; +} + +template struct GatewayToDeviceMessagePayloadTraits { + static const GatewayToDeviceMessagePayload enum_value = GatewayToDeviceMessagePayload::NONE; +}; + +template<> struct GatewayToDeviceMessagePayloadTraits { + static const GatewayToDeviceMessagePayload enum_value = GatewayToDeviceMessagePayload::ShockerCommandList; +}; + +template<> struct GatewayToDeviceMessagePayloadTraits { + static const GatewayToDeviceMessagePayload enum_value = GatewayToDeviceMessagePayload::CaptivePortalConfig; +}; + +template<> struct GatewayToDeviceMessagePayloadTraits { + static const GatewayToDeviceMessagePayload enum_value = GatewayToDeviceMessagePayload::OtaInstall; +}; + +bool VerifyGatewayToDeviceMessagePayload(::flatbuffers::Verifier &verifier, const void *obj, GatewayToDeviceMessagePayload type); +bool VerifyGatewayToDeviceMessagePayloadVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset> *values, const ::flatbuffers::Vector *types); + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(2) ShockerCommand FLATBUFFERS_FINAL_CLASS { + private: + uint8_t model_; + int8_t padding0__; + uint16_t id_; + uint8_t type_; + uint8_t intensity_; + uint16_t duration_; + + public: + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.ShockerCommand"; + } + ShockerCommand() + : model_(0), + padding0__(0), + id_(0), + type_(0), + intensity_(0), + duration_(0) { + (void)padding0__; + } + ShockerCommand(OpenShock::Serialization::Types::ShockerModelType _model, uint16_t _id, OpenShock::Serialization::Types::ShockerCommandType _type, uint8_t _intensity, uint16_t _duration) + : model_(::flatbuffers::EndianScalar(static_cast(_model))), + padding0__(0), + id_(::flatbuffers::EndianScalar(_id)), + type_(::flatbuffers::EndianScalar(static_cast(_type))), + intensity_(::flatbuffers::EndianScalar(_intensity)), + duration_(::flatbuffers::EndianScalar(_duration)) { + (void)padding0__; + } + OpenShock::Serialization::Types::ShockerModelType model() const { + return static_cast(::flatbuffers::EndianScalar(model_)); + } + uint16_t id() const { + return ::flatbuffers::EndianScalar(id_); + } + OpenShock::Serialization::Types::ShockerCommandType type() const { + return static_cast(::flatbuffers::EndianScalar(type_)); + } + uint8_t intensity() const { + return ::flatbuffers::EndianScalar(intensity_); + } + uint16_t duration() const { + return ::flatbuffers::EndianScalar(duration_); + } +}; +FLATBUFFERS_STRUCT_END(ShockerCommand, 8); + +struct ShockerCommand::Traits { + using type = ShockerCommand; +}; + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) CaptivePortalConfig FLATBUFFERS_FINAL_CLASS { + private: + uint8_t enabled_; + + public: + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.CaptivePortalConfig"; + } + CaptivePortalConfig() + : enabled_(0) { + } + CaptivePortalConfig(bool _enabled) + : enabled_(::flatbuffers::EndianScalar(static_cast(_enabled))) { + } + bool enabled() const { + return ::flatbuffers::EndianScalar(enabled_) != 0; + } +}; +FLATBUFFERS_STRUCT_END(CaptivePortalConfig, 1); + +struct CaptivePortalConfig::Traits { + using type = CaptivePortalConfig; +}; + +struct ShockerCommandList FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef ShockerCommandListBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.ShockerCommandList"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_COMMANDS = 4 + }; + const ::flatbuffers::Vector *commands() const { + return GetPointer *>(VT_COMMANDS); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffsetRequired(verifier, VT_COMMANDS) && + verifier.VerifyVector(commands()) && + verifier.EndTable(); + } +}; + +struct ShockerCommandListBuilder { + typedef ShockerCommandList Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_commands(::flatbuffers::Offset<::flatbuffers::Vector> commands) { + fbb_.AddOffset(ShockerCommandList::VT_COMMANDS, commands); + } + explicit ShockerCommandListBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + fbb_.Required(o, ShockerCommandList::VT_COMMANDS); + return o; + } +}; + +inline ::flatbuffers::Offset CreateShockerCommandList( + ::flatbuffers::FlatBufferBuilder &_fbb, + ::flatbuffers::Offset<::flatbuffers::Vector> commands = 0) { + ShockerCommandListBuilder builder_(_fbb); + builder_.add_commands(commands); + return builder_.Finish(); +} + +struct ShockerCommandList::Traits { + using type = ShockerCommandList; + static auto constexpr Create = CreateShockerCommandList; +}; + +inline ::flatbuffers::Offset CreateShockerCommandListDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + const std::vector *commands = nullptr) { + auto commands__ = commands ? _fbb.CreateVectorOfStructs(*commands) : 0; + return OpenShock::Serialization::Gateway::CreateShockerCommandList( + _fbb, + commands__); +} + +struct OtaInstall FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef OtaInstallBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.OtaInstall"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_VERSION = 4 + }; + const OpenShock::Serialization::Types::SemVer *version() const { + return GetPointer(VT_VERSION); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_VERSION) && + verifier.VerifyTable(version()) && + verifier.EndTable(); + } +}; + +struct OtaInstallBuilder { + typedef OtaInstall Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_version(::flatbuffers::Offset version) { + fbb_.AddOffset(OtaInstall::VT_VERSION, version); + } + explicit OtaInstallBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateOtaInstall( + ::flatbuffers::FlatBufferBuilder &_fbb, + ::flatbuffers::Offset version = 0) { + OtaInstallBuilder builder_(_fbb); + builder_.add_version(version); + return builder_.Finish(); +} + +struct OtaInstall::Traits { + using type = OtaInstall; + static auto constexpr Create = CreateOtaInstall; +}; + +struct GatewayToDeviceMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef GatewayToDeviceMessageBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Gateway.GatewayToDeviceMessage"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_PAYLOAD_TYPE = 4, + VT_PAYLOAD = 6 + }; + OpenShock::Serialization::Gateway::GatewayToDeviceMessagePayload payload_type() const { + return static_cast(GetField(VT_PAYLOAD_TYPE, 0)); + } + const void *payload() const { + return GetPointer(VT_PAYLOAD); + } + template const T *payload_as() const; + const OpenShock::Serialization::Gateway::ShockerCommandList *payload_as_ShockerCommandList() const { + return payload_type() == OpenShock::Serialization::Gateway::GatewayToDeviceMessagePayload::ShockerCommandList ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Gateway::CaptivePortalConfig *payload_as_CaptivePortalConfig() const { + return payload_type() == OpenShock::Serialization::Gateway::GatewayToDeviceMessagePayload::CaptivePortalConfig ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Gateway::OtaInstall *payload_as_OtaInstall() const { + return payload_type() == OpenShock::Serialization::Gateway::GatewayToDeviceMessagePayload::OtaInstall ? static_cast(payload()) : nullptr; + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_PAYLOAD_TYPE, 1) && + VerifyOffset(verifier, VT_PAYLOAD) && + VerifyGatewayToDeviceMessagePayload(verifier, payload(), payload_type()) && + verifier.EndTable(); + } +}; + +template<> inline const OpenShock::Serialization::Gateway::ShockerCommandList *GatewayToDeviceMessage::payload_as() const { + return payload_as_ShockerCommandList(); +} + +template<> inline const OpenShock::Serialization::Gateway::CaptivePortalConfig *GatewayToDeviceMessage::payload_as() const { + return payload_as_CaptivePortalConfig(); +} + +template<> inline const OpenShock::Serialization::Gateway::OtaInstall *GatewayToDeviceMessage::payload_as() const { + return payload_as_OtaInstall(); +} + +struct GatewayToDeviceMessageBuilder { + typedef GatewayToDeviceMessage Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_payload_type(OpenShock::Serialization::Gateway::GatewayToDeviceMessagePayload payload_type) { + fbb_.AddElement(GatewayToDeviceMessage::VT_PAYLOAD_TYPE, static_cast(payload_type), 0); + } + void add_payload(::flatbuffers::Offset payload) { + fbb_.AddOffset(GatewayToDeviceMessage::VT_PAYLOAD, payload); + } + explicit GatewayToDeviceMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateGatewayToDeviceMessage( + ::flatbuffers::FlatBufferBuilder &_fbb, + OpenShock::Serialization::Gateway::GatewayToDeviceMessagePayload payload_type = OpenShock::Serialization::Gateway::GatewayToDeviceMessagePayload::NONE, + ::flatbuffers::Offset payload = 0) { + GatewayToDeviceMessageBuilder builder_(_fbb); + builder_.add_payload(payload); + builder_.add_payload_type(payload_type); + return builder_.Finish(); +} + +struct GatewayToDeviceMessage::Traits { + using type = GatewayToDeviceMessage; + static auto constexpr Create = CreateGatewayToDeviceMessage; +}; + +inline bool VerifyGatewayToDeviceMessagePayload(::flatbuffers::Verifier &verifier, const void *obj, GatewayToDeviceMessagePayload type) { + switch (type) { + case GatewayToDeviceMessagePayload::NONE: { + return true; + } + case GatewayToDeviceMessagePayload::ShockerCommandList: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } + case GatewayToDeviceMessagePayload::CaptivePortalConfig: { + return verifier.VerifyField(static_cast(obj), 0, 1); + } + case GatewayToDeviceMessagePayload::OtaInstall: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } + default: return true; + } +} + +inline bool VerifyGatewayToDeviceMessagePayloadVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset> *values, const ::flatbuffers::Vector *types) { + if (!values || !types) return !values && !types; + if (values->size() != types->size()) return false; + for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { + if (!VerifyGatewayToDeviceMessagePayload( + verifier, values->Get(i), types->GetEnum(i))) { + return false; + } + } + return true; +} + +inline const OpenShock::Serialization::Gateway::GatewayToDeviceMessage *GetGatewayToDeviceMessage(const void *buf) { + return ::flatbuffers::GetRoot(buf); +} + +inline const OpenShock::Serialization::Gateway::GatewayToDeviceMessage *GetSizePrefixedGatewayToDeviceMessage(const void *buf) { + return ::flatbuffers::GetSizePrefixedRoot(buf); +} + +inline bool VerifyGatewayToDeviceMessageBuffer( + ::flatbuffers::Verifier &verifier) { + return verifier.VerifyBuffer(nullptr); +} + +inline bool VerifySizePrefixedGatewayToDeviceMessageBuffer( + ::flatbuffers::Verifier &verifier) { + return verifier.VerifySizePrefixedBuffer(nullptr); +} + +inline void FinishGatewayToDeviceMessageBuffer( + ::flatbuffers::FlatBufferBuilder &fbb, + ::flatbuffers::Offset root) { + fbb.Finish(root); +} + +inline void FinishSizePrefixedGatewayToDeviceMessageBuffer( + ::flatbuffers::FlatBufferBuilder &fbb, + ::flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); +} + +} // namespace Gateway +} // namespace Serialization +} // namespace OpenShock + +#endif // FLATBUFFERS_GENERATED_GATEWAYTODEVICEMESSAGE_OPENSHOCK_SERIALIZATION_GATEWAY_H_ diff --git a/include/serialization/_fbs/LocalToDeviceMessage_generated.h b/include/serialization/_fbs/LocalToDeviceMessage_generated.h index 6f4e0d55..24afa8d6 100644 --- a/include/serialization/_fbs/LocalToDeviceMessage_generated.h +++ b/include/serialization/_fbs/LocalToDeviceMessage_generated.h @@ -30,6 +30,28 @@ struct WifiNetworkConnectCommandBuilder; struct WifiNetworkDisconnectCommand; +struct OtaUpdateSetIsEnabledCommand; + +struct OtaUpdateSetDomainCommand; +struct OtaUpdateSetDomainCommandBuilder; + +struct OtaUpdateSetUpdateChannelCommand; +struct OtaUpdateSetUpdateChannelCommandBuilder; + +struct OtaUpdateSetCheckIntervalCommand; + +struct OtaUpdateSetAllowBackendManagementCommand; + +struct OtaUpdateSetRequireManualApprovalCommand; + +struct OtaUpdateHandleUpdateRequestCommand; + +struct OtaUpdateCheckForUpdatesCommand; +struct OtaUpdateCheckForUpdatesCommandBuilder; + +struct OtaUpdateStartUpdateCommand; +struct OtaUpdateStartUpdateCommandBuilder; + struct AccountLinkCommand; struct AccountLinkCommandBuilder; @@ -47,14 +69,23 @@ enum class LocalToDeviceMessagePayload : uint8_t { WifiNetworkForgetCommand = 3, WifiNetworkConnectCommand = 4, WifiNetworkDisconnectCommand = 5, - AccountLinkCommand = 6, - AccountUnlinkCommand = 7, - SetRfTxPinCommand = 8, + OtaUpdateSetIsEnabledCommand = 6, + OtaUpdateSetDomainCommand = 7, + OtaUpdateSetUpdateChannelCommand = 8, + OtaUpdateSetCheckIntervalCommand = 9, + OtaUpdateSetAllowBackendManagementCommand = 10, + OtaUpdateSetRequireManualApprovalCommand = 11, + OtaUpdateHandleUpdateRequestCommand = 12, + OtaUpdateCheckForUpdatesCommand = 13, + OtaUpdateStartUpdateCommand = 14, + AccountLinkCommand = 15, + AccountUnlinkCommand = 16, + SetRfTxPinCommand = 17, MIN = NONE, MAX = SetRfTxPinCommand }; -inline const LocalToDeviceMessagePayload (&EnumValuesLocalToDeviceMessagePayload())[9] { +inline const LocalToDeviceMessagePayload (&EnumValuesLocalToDeviceMessagePayload())[18] { static const LocalToDeviceMessagePayload values[] = { LocalToDeviceMessagePayload::NONE, LocalToDeviceMessagePayload::WifiScanCommand, @@ -62,6 +93,15 @@ inline const LocalToDeviceMessagePayload (&EnumValuesLocalToDeviceMessagePayload LocalToDeviceMessagePayload::WifiNetworkForgetCommand, LocalToDeviceMessagePayload::WifiNetworkConnectCommand, LocalToDeviceMessagePayload::WifiNetworkDisconnectCommand, + LocalToDeviceMessagePayload::OtaUpdateSetIsEnabledCommand, + LocalToDeviceMessagePayload::OtaUpdateSetDomainCommand, + LocalToDeviceMessagePayload::OtaUpdateSetUpdateChannelCommand, + LocalToDeviceMessagePayload::OtaUpdateSetCheckIntervalCommand, + LocalToDeviceMessagePayload::OtaUpdateSetAllowBackendManagementCommand, + LocalToDeviceMessagePayload::OtaUpdateSetRequireManualApprovalCommand, + LocalToDeviceMessagePayload::OtaUpdateHandleUpdateRequestCommand, + LocalToDeviceMessagePayload::OtaUpdateCheckForUpdatesCommand, + LocalToDeviceMessagePayload::OtaUpdateStartUpdateCommand, LocalToDeviceMessagePayload::AccountLinkCommand, LocalToDeviceMessagePayload::AccountUnlinkCommand, LocalToDeviceMessagePayload::SetRfTxPinCommand @@ -70,13 +110,22 @@ inline const LocalToDeviceMessagePayload (&EnumValuesLocalToDeviceMessagePayload } inline const char * const *EnumNamesLocalToDeviceMessagePayload() { - static const char * const names[10] = { + static const char * const names[19] = { "NONE", "WifiScanCommand", "WifiNetworkSaveCommand", "WifiNetworkForgetCommand", "WifiNetworkConnectCommand", "WifiNetworkDisconnectCommand", + "OtaUpdateSetIsEnabledCommand", + "OtaUpdateSetDomainCommand", + "OtaUpdateSetUpdateChannelCommand", + "OtaUpdateSetCheckIntervalCommand", + "OtaUpdateSetAllowBackendManagementCommand", + "OtaUpdateSetRequireManualApprovalCommand", + "OtaUpdateHandleUpdateRequestCommand", + "OtaUpdateCheckForUpdatesCommand", + "OtaUpdateStartUpdateCommand", "AccountLinkCommand", "AccountUnlinkCommand", "SetRfTxPinCommand", @@ -115,6 +164,42 @@ template<> struct LocalToDeviceMessagePayloadTraits struct LocalToDeviceMessagePayloadTraits { + static const LocalToDeviceMessagePayload enum_value = LocalToDeviceMessagePayload::OtaUpdateSetIsEnabledCommand; +}; + +template<> struct LocalToDeviceMessagePayloadTraits { + static const LocalToDeviceMessagePayload enum_value = LocalToDeviceMessagePayload::OtaUpdateSetDomainCommand; +}; + +template<> struct LocalToDeviceMessagePayloadTraits { + static const LocalToDeviceMessagePayload enum_value = LocalToDeviceMessagePayload::OtaUpdateSetUpdateChannelCommand; +}; + +template<> struct LocalToDeviceMessagePayloadTraits { + static const LocalToDeviceMessagePayload enum_value = LocalToDeviceMessagePayload::OtaUpdateSetCheckIntervalCommand; +}; + +template<> struct LocalToDeviceMessagePayloadTraits { + static const LocalToDeviceMessagePayload enum_value = LocalToDeviceMessagePayload::OtaUpdateSetAllowBackendManagementCommand; +}; + +template<> struct LocalToDeviceMessagePayloadTraits { + static const LocalToDeviceMessagePayload enum_value = LocalToDeviceMessagePayload::OtaUpdateSetRequireManualApprovalCommand; +}; + +template<> struct LocalToDeviceMessagePayloadTraits { + static const LocalToDeviceMessagePayload enum_value = LocalToDeviceMessagePayload::OtaUpdateHandleUpdateRequestCommand; +}; + +template<> struct LocalToDeviceMessagePayloadTraits { + static const LocalToDeviceMessagePayload enum_value = LocalToDeviceMessagePayload::OtaUpdateCheckForUpdatesCommand; +}; + +template<> struct LocalToDeviceMessagePayloadTraits { + static const LocalToDeviceMessagePayload enum_value = LocalToDeviceMessagePayload::OtaUpdateStartUpdateCommand; +}; + template<> struct LocalToDeviceMessagePayloadTraits { static const LocalToDeviceMessagePayload enum_value = LocalToDeviceMessagePayload::AccountLinkCommand; }; @@ -180,6 +265,131 @@ struct WifiNetworkDisconnectCommand::Traits { using type = WifiNetworkDisconnectCommand; }; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) OtaUpdateSetIsEnabledCommand FLATBUFFERS_FINAL_CLASS { + private: + uint8_t enabled_; + + public: + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Local.OtaUpdateSetIsEnabledCommand"; + } + OtaUpdateSetIsEnabledCommand() + : enabled_(0) { + } + OtaUpdateSetIsEnabledCommand(bool _enabled) + : enabled_(::flatbuffers::EndianScalar(static_cast(_enabled))) { + } + bool enabled() const { + return ::flatbuffers::EndianScalar(enabled_) != 0; + } +}; +FLATBUFFERS_STRUCT_END(OtaUpdateSetIsEnabledCommand, 1); + +struct OtaUpdateSetIsEnabledCommand::Traits { + using type = OtaUpdateSetIsEnabledCommand; +}; + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(2) OtaUpdateSetCheckIntervalCommand FLATBUFFERS_FINAL_CLASS { + private: + uint16_t interval_; + + public: + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Local.OtaUpdateSetCheckIntervalCommand"; + } + OtaUpdateSetCheckIntervalCommand() + : interval_(0) { + } + OtaUpdateSetCheckIntervalCommand(uint16_t _interval) + : interval_(::flatbuffers::EndianScalar(_interval)) { + } + uint16_t interval() const { + return ::flatbuffers::EndianScalar(interval_); + } +}; +FLATBUFFERS_STRUCT_END(OtaUpdateSetCheckIntervalCommand, 2); + +struct OtaUpdateSetCheckIntervalCommand::Traits { + using type = OtaUpdateSetCheckIntervalCommand; +}; + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) OtaUpdateSetAllowBackendManagementCommand FLATBUFFERS_FINAL_CLASS { + private: + uint8_t allow_; + + public: + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Local.OtaUpdateSetAllowBackendManagementCommand"; + } + OtaUpdateSetAllowBackendManagementCommand() + : allow_(0) { + } + OtaUpdateSetAllowBackendManagementCommand(bool _allow) + : allow_(::flatbuffers::EndianScalar(static_cast(_allow))) { + } + bool allow() const { + return ::flatbuffers::EndianScalar(allow_) != 0; + } +}; +FLATBUFFERS_STRUCT_END(OtaUpdateSetAllowBackendManagementCommand, 1); + +struct OtaUpdateSetAllowBackendManagementCommand::Traits { + using type = OtaUpdateSetAllowBackendManagementCommand; +}; + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) OtaUpdateSetRequireManualApprovalCommand FLATBUFFERS_FINAL_CLASS { + private: + uint8_t require_; + + public: + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Local.OtaUpdateSetRequireManualApprovalCommand"; + } + OtaUpdateSetRequireManualApprovalCommand() + : require_(0) { + } + OtaUpdateSetRequireManualApprovalCommand(bool _require) + : require_(::flatbuffers::EndianScalar(static_cast(_require))) { + } + bool require() const { + return ::flatbuffers::EndianScalar(require_) != 0; + } +}; +FLATBUFFERS_STRUCT_END(OtaUpdateSetRequireManualApprovalCommand, 1); + +struct OtaUpdateSetRequireManualApprovalCommand::Traits { + using type = OtaUpdateSetRequireManualApprovalCommand; +}; + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) OtaUpdateHandleUpdateRequestCommand FLATBUFFERS_FINAL_CLASS { + private: + uint8_t accept_; + + public: + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Local.OtaUpdateHandleUpdateRequestCommand"; + } + OtaUpdateHandleUpdateRequestCommand() + : accept_(0) { + } + OtaUpdateHandleUpdateRequestCommand(bool _accept) + : accept_(::flatbuffers::EndianScalar(static_cast(_accept))) { + } + bool accept() const { + return ::flatbuffers::EndianScalar(accept_) != 0; + } +}; +FLATBUFFERS_STRUCT_END(OtaUpdateHandleUpdateRequestCommand, 1); + +struct OtaUpdateHandleUpdateRequestCommand::Traits { + using type = OtaUpdateHandleUpdateRequestCommand; +}; + FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) AccountUnlinkCommand FLATBUFFERS_FINAL_CLASS { private: uint8_t placeholder_; @@ -436,6 +646,260 @@ inline ::flatbuffers::Offset CreateWifiNetworkConnect ssid__); } +struct OtaUpdateSetDomainCommand FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef OtaUpdateSetDomainCommandBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Local.OtaUpdateSetDomainCommand"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_DOMAIN = 4 + }; + const ::flatbuffers::String *domain() const { + return GetPointer(VT_DOMAIN); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_DOMAIN) && + verifier.VerifyString(domain()) && + verifier.EndTable(); + } +}; + +struct OtaUpdateSetDomainCommandBuilder { + typedef OtaUpdateSetDomainCommand Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_domain(::flatbuffers::Offset<::flatbuffers::String> domain) { + fbb_.AddOffset(OtaUpdateSetDomainCommand::VT_DOMAIN, domain); + } + explicit OtaUpdateSetDomainCommandBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateOtaUpdateSetDomainCommand( + ::flatbuffers::FlatBufferBuilder &_fbb, + ::flatbuffers::Offset<::flatbuffers::String> domain = 0) { + OtaUpdateSetDomainCommandBuilder builder_(_fbb); + builder_.add_domain(domain); + return builder_.Finish(); +} + +struct OtaUpdateSetDomainCommand::Traits { + using type = OtaUpdateSetDomainCommand; + static auto constexpr Create = CreateOtaUpdateSetDomainCommand; +}; + +inline ::flatbuffers::Offset CreateOtaUpdateSetDomainCommandDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + const char *domain = nullptr) { + auto domain__ = domain ? _fbb.CreateString(domain) : 0; + return OpenShock::Serialization::Local::CreateOtaUpdateSetDomainCommand( + _fbb, + domain__); +} + +struct OtaUpdateSetUpdateChannelCommand FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef OtaUpdateSetUpdateChannelCommandBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Local.OtaUpdateSetUpdateChannelCommand"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_CHANNEL = 4 + }; + const ::flatbuffers::String *channel() const { + return GetPointer(VT_CHANNEL); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_CHANNEL) && + verifier.VerifyString(channel()) && + verifier.EndTable(); + } +}; + +struct OtaUpdateSetUpdateChannelCommandBuilder { + typedef OtaUpdateSetUpdateChannelCommand Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_channel(::flatbuffers::Offset<::flatbuffers::String> channel) { + fbb_.AddOffset(OtaUpdateSetUpdateChannelCommand::VT_CHANNEL, channel); + } + explicit OtaUpdateSetUpdateChannelCommandBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateOtaUpdateSetUpdateChannelCommand( + ::flatbuffers::FlatBufferBuilder &_fbb, + ::flatbuffers::Offset<::flatbuffers::String> channel = 0) { + OtaUpdateSetUpdateChannelCommandBuilder builder_(_fbb); + builder_.add_channel(channel); + return builder_.Finish(); +} + +struct OtaUpdateSetUpdateChannelCommand::Traits { + using type = OtaUpdateSetUpdateChannelCommand; + static auto constexpr Create = CreateOtaUpdateSetUpdateChannelCommand; +}; + +inline ::flatbuffers::Offset CreateOtaUpdateSetUpdateChannelCommandDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + const char *channel = nullptr) { + auto channel__ = channel ? _fbb.CreateString(channel) : 0; + return OpenShock::Serialization::Local::CreateOtaUpdateSetUpdateChannelCommand( + _fbb, + channel__); +} + +struct OtaUpdateCheckForUpdatesCommand FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef OtaUpdateCheckForUpdatesCommandBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Local.OtaUpdateCheckForUpdatesCommand"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_CHANNEL = 4 + }; + const ::flatbuffers::String *channel() const { + return GetPointer(VT_CHANNEL); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_CHANNEL) && + verifier.VerifyString(channel()) && + verifier.EndTable(); + } +}; + +struct OtaUpdateCheckForUpdatesCommandBuilder { + typedef OtaUpdateCheckForUpdatesCommand Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_channel(::flatbuffers::Offset<::flatbuffers::String> channel) { + fbb_.AddOffset(OtaUpdateCheckForUpdatesCommand::VT_CHANNEL, channel); + } + explicit OtaUpdateCheckForUpdatesCommandBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateOtaUpdateCheckForUpdatesCommand( + ::flatbuffers::FlatBufferBuilder &_fbb, + ::flatbuffers::Offset<::flatbuffers::String> channel = 0) { + OtaUpdateCheckForUpdatesCommandBuilder builder_(_fbb); + builder_.add_channel(channel); + return builder_.Finish(); +} + +struct OtaUpdateCheckForUpdatesCommand::Traits { + using type = OtaUpdateCheckForUpdatesCommand; + static auto constexpr Create = CreateOtaUpdateCheckForUpdatesCommand; +}; + +inline ::flatbuffers::Offset CreateOtaUpdateCheckForUpdatesCommandDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + const char *channel = nullptr) { + auto channel__ = channel ? _fbb.CreateString(channel) : 0; + return OpenShock::Serialization::Local::CreateOtaUpdateCheckForUpdatesCommand( + _fbb, + channel__); +} + +struct OtaUpdateStartUpdateCommand FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef OtaUpdateStartUpdateCommandBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Local.OtaUpdateStartUpdateCommand"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_CHANNEL = 4, + VT_VERSION = 6 + }; + const ::flatbuffers::String *channel() const { + return GetPointer(VT_CHANNEL); + } + const ::flatbuffers::String *version() const { + return GetPointer(VT_VERSION); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_CHANNEL) && + verifier.VerifyString(channel()) && + VerifyOffset(verifier, VT_VERSION) && + verifier.VerifyString(version()) && + verifier.EndTable(); + } +}; + +struct OtaUpdateStartUpdateCommandBuilder { + typedef OtaUpdateStartUpdateCommand Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_channel(::flatbuffers::Offset<::flatbuffers::String> channel) { + fbb_.AddOffset(OtaUpdateStartUpdateCommand::VT_CHANNEL, channel); + } + void add_version(::flatbuffers::Offset<::flatbuffers::String> version) { + fbb_.AddOffset(OtaUpdateStartUpdateCommand::VT_VERSION, version); + } + explicit OtaUpdateStartUpdateCommandBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateOtaUpdateStartUpdateCommand( + ::flatbuffers::FlatBufferBuilder &_fbb, + ::flatbuffers::Offset<::flatbuffers::String> channel = 0, + ::flatbuffers::Offset<::flatbuffers::String> version = 0) { + OtaUpdateStartUpdateCommandBuilder builder_(_fbb); + builder_.add_version(version); + builder_.add_channel(channel); + return builder_.Finish(); +} + +struct OtaUpdateStartUpdateCommand::Traits { + using type = OtaUpdateStartUpdateCommand; + static auto constexpr Create = CreateOtaUpdateStartUpdateCommand; +}; + +inline ::flatbuffers::Offset CreateOtaUpdateStartUpdateCommandDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + const char *channel = nullptr, + const char *version = nullptr) { + auto channel__ = channel ? _fbb.CreateString(channel) : 0; + auto version__ = version ? _fbb.CreateString(version) : 0; + return OpenShock::Serialization::Local::CreateOtaUpdateStartUpdateCommand( + _fbb, + channel__, + version__); +} + struct AccountLinkCommand FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { typedef AccountLinkCommandBuilder Builder; struct Traits; @@ -528,6 +992,33 @@ struct LocalToDeviceMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Tab const OpenShock::Serialization::Local::WifiNetworkDisconnectCommand *payload_as_WifiNetworkDisconnectCommand() const { return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::WifiNetworkDisconnectCommand ? static_cast(payload()) : nullptr; } + const OpenShock::Serialization::Local::OtaUpdateSetIsEnabledCommand *payload_as_OtaUpdateSetIsEnabledCommand() const { + return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::OtaUpdateSetIsEnabledCommand ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Local::OtaUpdateSetDomainCommand *payload_as_OtaUpdateSetDomainCommand() const { + return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::OtaUpdateSetDomainCommand ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Local::OtaUpdateSetUpdateChannelCommand *payload_as_OtaUpdateSetUpdateChannelCommand() const { + return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::OtaUpdateSetUpdateChannelCommand ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Local::OtaUpdateSetCheckIntervalCommand *payload_as_OtaUpdateSetCheckIntervalCommand() const { + return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::OtaUpdateSetCheckIntervalCommand ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Local::OtaUpdateSetAllowBackendManagementCommand *payload_as_OtaUpdateSetAllowBackendManagementCommand() const { + return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::OtaUpdateSetAllowBackendManagementCommand ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Local::OtaUpdateSetRequireManualApprovalCommand *payload_as_OtaUpdateSetRequireManualApprovalCommand() const { + return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::OtaUpdateSetRequireManualApprovalCommand ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Local::OtaUpdateHandleUpdateRequestCommand *payload_as_OtaUpdateHandleUpdateRequestCommand() const { + return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::OtaUpdateHandleUpdateRequestCommand ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Local::OtaUpdateCheckForUpdatesCommand *payload_as_OtaUpdateCheckForUpdatesCommand() const { + return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::OtaUpdateCheckForUpdatesCommand ? static_cast(payload()) : nullptr; + } + const OpenShock::Serialization::Local::OtaUpdateStartUpdateCommand *payload_as_OtaUpdateStartUpdateCommand() const { + return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::OtaUpdateStartUpdateCommand ? static_cast(payload()) : nullptr; + } const OpenShock::Serialization::Local::AccountLinkCommand *payload_as_AccountLinkCommand() const { return payload_type() == OpenShock::Serialization::Local::LocalToDeviceMessagePayload::AccountLinkCommand ? static_cast(payload()) : nullptr; } @@ -566,6 +1057,42 @@ template<> inline const OpenShock::Serialization::Local::WifiNetworkDisconnectCo return payload_as_WifiNetworkDisconnectCommand(); } +template<> inline const OpenShock::Serialization::Local::OtaUpdateSetIsEnabledCommand *LocalToDeviceMessage::payload_as() const { + return payload_as_OtaUpdateSetIsEnabledCommand(); +} + +template<> inline const OpenShock::Serialization::Local::OtaUpdateSetDomainCommand *LocalToDeviceMessage::payload_as() const { + return payload_as_OtaUpdateSetDomainCommand(); +} + +template<> inline const OpenShock::Serialization::Local::OtaUpdateSetUpdateChannelCommand *LocalToDeviceMessage::payload_as() const { + return payload_as_OtaUpdateSetUpdateChannelCommand(); +} + +template<> inline const OpenShock::Serialization::Local::OtaUpdateSetCheckIntervalCommand *LocalToDeviceMessage::payload_as() const { + return payload_as_OtaUpdateSetCheckIntervalCommand(); +} + +template<> inline const OpenShock::Serialization::Local::OtaUpdateSetAllowBackendManagementCommand *LocalToDeviceMessage::payload_as() const { + return payload_as_OtaUpdateSetAllowBackendManagementCommand(); +} + +template<> inline const OpenShock::Serialization::Local::OtaUpdateSetRequireManualApprovalCommand *LocalToDeviceMessage::payload_as() const { + return payload_as_OtaUpdateSetRequireManualApprovalCommand(); +} + +template<> inline const OpenShock::Serialization::Local::OtaUpdateHandleUpdateRequestCommand *LocalToDeviceMessage::payload_as() const { + return payload_as_OtaUpdateHandleUpdateRequestCommand(); +} + +template<> inline const OpenShock::Serialization::Local::OtaUpdateCheckForUpdatesCommand *LocalToDeviceMessage::payload_as() const { + return payload_as_OtaUpdateCheckForUpdatesCommand(); +} + +template<> inline const OpenShock::Serialization::Local::OtaUpdateStartUpdateCommand *LocalToDeviceMessage::payload_as() const { + return payload_as_OtaUpdateStartUpdateCommand(); +} + template<> inline const OpenShock::Serialization::Local::AccountLinkCommand *LocalToDeviceMessage::payload_as() const { return payload_as_AccountLinkCommand(); } @@ -637,6 +1164,37 @@ inline bool VerifyLocalToDeviceMessagePayload(::flatbuffers::Verifier &verifier, case LocalToDeviceMessagePayload::WifiNetworkDisconnectCommand: { return verifier.VerifyField(static_cast(obj), 0, 1); } + case LocalToDeviceMessagePayload::OtaUpdateSetIsEnabledCommand: { + return verifier.VerifyField(static_cast(obj), 0, 1); + } + case LocalToDeviceMessagePayload::OtaUpdateSetDomainCommand: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } + case LocalToDeviceMessagePayload::OtaUpdateSetUpdateChannelCommand: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } + case LocalToDeviceMessagePayload::OtaUpdateSetCheckIntervalCommand: { + return verifier.VerifyField(static_cast(obj), 0, 2); + } + case LocalToDeviceMessagePayload::OtaUpdateSetAllowBackendManagementCommand: { + return verifier.VerifyField(static_cast(obj), 0, 1); + } + case LocalToDeviceMessagePayload::OtaUpdateSetRequireManualApprovalCommand: { + return verifier.VerifyField(static_cast(obj), 0, 1); + } + case LocalToDeviceMessagePayload::OtaUpdateHandleUpdateRequestCommand: { + return verifier.VerifyField(static_cast(obj), 0, 1); + } + case LocalToDeviceMessagePayload::OtaUpdateCheckForUpdatesCommand: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } + case LocalToDeviceMessagePayload::OtaUpdateStartUpdateCommand: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } case LocalToDeviceMessagePayload::AccountLinkCommand: { auto ptr = reinterpret_cast(obj); return verifier.VerifyTable(ptr); diff --git a/include/serialization/_fbs/SemVer_generated.h b/include/serialization/_fbs/SemVer_generated.h new file mode 100644 index 00000000..f26346fb --- /dev/null +++ b/include/serialization/_fbs/SemVer_generated.h @@ -0,0 +1,137 @@ +// automatically generated by the FlatBuffers compiler, do not modify + + +#ifndef FLATBUFFERS_GENERATED_SEMVER_OPENSHOCK_SERIALIZATION_TYPES_H_ +#define FLATBUFFERS_GENERATED_SEMVER_OPENSHOCK_SERIALIZATION_TYPES_H_ + +#include "flatbuffers/flatbuffers.h" + +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 23 && + FLATBUFFERS_VERSION_MINOR == 5 && + FLATBUFFERS_VERSION_REVISION == 26, + "Non-compatible flatbuffers version included"); + +namespace OpenShock { +namespace Serialization { +namespace Types { + +struct SemVer; +struct SemVerBuilder; + +struct SemVer FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef SemVerBuilder Builder; + struct Traits; + static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { + return "OpenShock.Serialization.Types.SemVer"; + } + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_MAJOR = 4, + VT_MINOR = 6, + VT_PATCH = 8, + VT_PRERELEASE = 10, + VT_BUILD = 12 + }; + uint16_t major() const { + return GetField(VT_MAJOR, 0); + } + uint16_t minor() const { + return GetField(VT_MINOR, 0); + } + uint16_t patch() const { + return GetField(VT_PATCH, 0); + } + const ::flatbuffers::String *prerelease() const { + return GetPointer(VT_PRERELEASE); + } + const ::flatbuffers::String *build() const { + return GetPointer(VT_BUILD); + } + bool Verify(::flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_MAJOR, 2) && + VerifyField(verifier, VT_MINOR, 2) && + VerifyField(verifier, VT_PATCH, 2) && + VerifyOffset(verifier, VT_PRERELEASE) && + verifier.VerifyString(prerelease()) && + VerifyOffset(verifier, VT_BUILD) && + verifier.VerifyString(build()) && + verifier.EndTable(); + } +}; + +struct SemVerBuilder { + typedef SemVer Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_major(uint16_t major) { + fbb_.AddElement(SemVer::VT_MAJOR, major, 0); + } + void add_minor(uint16_t minor) { + fbb_.AddElement(SemVer::VT_MINOR, minor, 0); + } + void add_patch(uint16_t patch) { + fbb_.AddElement(SemVer::VT_PATCH, patch, 0); + } + void add_prerelease(::flatbuffers::Offset<::flatbuffers::String> prerelease) { + fbb_.AddOffset(SemVer::VT_PRERELEASE, prerelease); + } + void add_build(::flatbuffers::Offset<::flatbuffers::String> build) { + fbb_.AddOffset(SemVer::VT_BUILD, build); + } + explicit SemVerBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateSemVer( + ::flatbuffers::FlatBufferBuilder &_fbb, + uint16_t major = 0, + uint16_t minor = 0, + uint16_t patch = 0, + ::flatbuffers::Offset<::flatbuffers::String> prerelease = 0, + ::flatbuffers::Offset<::flatbuffers::String> build = 0) { + SemVerBuilder builder_(_fbb); + builder_.add_build(build); + builder_.add_prerelease(prerelease); + builder_.add_patch(patch); + builder_.add_minor(minor); + builder_.add_major(major); + return builder_.Finish(); +} + +struct SemVer::Traits { + using type = SemVer; + static auto constexpr Create = CreateSemVer; +}; + +inline ::flatbuffers::Offset CreateSemVerDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + uint16_t major = 0, + uint16_t minor = 0, + uint16_t patch = 0, + const char *prerelease = nullptr, + const char *build = nullptr) { + auto prerelease__ = prerelease ? _fbb.CreateString(prerelease) : 0; + auto build__ = build ? _fbb.CreateString(build) : 0; + return OpenShock::Serialization::Types::CreateSemVer( + _fbb, + major, + minor, + patch, + prerelease__, + build__); +} + +} // namespace Types +} // namespace Serialization +} // namespace OpenShock + +#endif // FLATBUFFERS_GENERATED_SEMVER_OPENSHOCK_SERIALIZATION_TYPES_H_ diff --git a/include/serialization/_fbs/ServerToDeviceMessage_generated.h b/include/serialization/_fbs/ServerToDeviceMessage_generated.h deleted file mode 100644 index 7c66c420..00000000 --- a/include/serialization/_fbs/ServerToDeviceMessage_generated.h +++ /dev/null @@ -1,357 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_SERVERTODEVICEMESSAGE_OPENSHOCK_SERIALIZATION_H_ -#define FLATBUFFERS_GENERATED_SERVERTODEVICEMESSAGE_OPENSHOCK_SERIALIZATION_H_ - -#include "flatbuffers/flatbuffers.h" - -// Ensure the included flatbuffers.h is the same version as when this file was -// generated, otherwise it may not be compatible. -static_assert(FLATBUFFERS_VERSION_MAJOR == 23 && - FLATBUFFERS_VERSION_MINOR == 5 && - FLATBUFFERS_VERSION_REVISION == 26, - "Non-compatible flatbuffers version included"); - -#include "ShockerCommandType_generated.h" -#include "ShockerModelType_generated.h" - -namespace OpenShock { -namespace Serialization { - -struct ShockerCommand; - -struct ShockerCommandList; -struct ShockerCommandListBuilder; - -struct CaptivePortalConfig; - -struct ServerToDeviceMessage; -struct ServerToDeviceMessageBuilder; - -enum class ServerToDeviceMessagePayload : uint8_t { - NONE = 0, - ShockerCommandList = 1, - CaptivePortalConfig = 2, - MIN = NONE, - MAX = CaptivePortalConfig -}; - -inline const ServerToDeviceMessagePayload (&EnumValuesServerToDeviceMessagePayload())[3] { - static const ServerToDeviceMessagePayload values[] = { - ServerToDeviceMessagePayload::NONE, - ServerToDeviceMessagePayload::ShockerCommandList, - ServerToDeviceMessagePayload::CaptivePortalConfig - }; - return values; -} - -inline const char * const *EnumNamesServerToDeviceMessagePayload() { - static const char * const names[4] = { - "NONE", - "ShockerCommandList", - "CaptivePortalConfig", - nullptr - }; - return names; -} - -inline const char *EnumNameServerToDeviceMessagePayload(ServerToDeviceMessagePayload e) { - if (::flatbuffers::IsOutRange(e, ServerToDeviceMessagePayload::NONE, ServerToDeviceMessagePayload::CaptivePortalConfig)) return ""; - const size_t index = static_cast(e); - return EnumNamesServerToDeviceMessagePayload()[index]; -} - -template struct ServerToDeviceMessagePayloadTraits { - static const ServerToDeviceMessagePayload enum_value = ServerToDeviceMessagePayload::NONE; -}; - -template<> struct ServerToDeviceMessagePayloadTraits { - static const ServerToDeviceMessagePayload enum_value = ServerToDeviceMessagePayload::ShockerCommandList; -}; - -template<> struct ServerToDeviceMessagePayloadTraits { - static const ServerToDeviceMessagePayload enum_value = ServerToDeviceMessagePayload::CaptivePortalConfig; -}; - -bool VerifyServerToDeviceMessagePayload(::flatbuffers::Verifier &verifier, const void *obj, ServerToDeviceMessagePayload type); -bool VerifyServerToDeviceMessagePayloadVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset> *values, const ::flatbuffers::Vector *types); - -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(2) ShockerCommand FLATBUFFERS_FINAL_CLASS { - private: - uint8_t model_; - int8_t padding0__; - uint16_t id_; - uint8_t type_; - uint8_t intensity_; - uint16_t duration_; - - public: - struct Traits; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "OpenShock.Serialization.ShockerCommand"; - } - ShockerCommand() - : model_(0), - padding0__(0), - id_(0), - type_(0), - intensity_(0), - duration_(0) { - (void)padding0__; - } - ShockerCommand(OpenShock::Serialization::Types::ShockerModelType _model, uint16_t _id, OpenShock::Serialization::Types::ShockerCommandType _type, uint8_t _intensity, uint16_t _duration) - : model_(::flatbuffers::EndianScalar(static_cast(_model))), - padding0__(0), - id_(::flatbuffers::EndianScalar(_id)), - type_(::flatbuffers::EndianScalar(static_cast(_type))), - intensity_(::flatbuffers::EndianScalar(_intensity)), - duration_(::flatbuffers::EndianScalar(_duration)) { - (void)padding0__; - } - OpenShock::Serialization::Types::ShockerModelType model() const { - return static_cast(::flatbuffers::EndianScalar(model_)); - } - uint16_t id() const { - return ::flatbuffers::EndianScalar(id_); - } - OpenShock::Serialization::Types::ShockerCommandType type() const { - return static_cast(::flatbuffers::EndianScalar(type_)); - } - uint8_t intensity() const { - return ::flatbuffers::EndianScalar(intensity_); - } - uint16_t duration() const { - return ::flatbuffers::EndianScalar(duration_); - } -}; -FLATBUFFERS_STRUCT_END(ShockerCommand, 8); - -struct ShockerCommand::Traits { - using type = ShockerCommand; -}; - -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) CaptivePortalConfig FLATBUFFERS_FINAL_CLASS { - private: - uint8_t enabled_; - - public: - struct Traits; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "OpenShock.Serialization.CaptivePortalConfig"; - } - CaptivePortalConfig() - : enabled_(0) { - } - CaptivePortalConfig(bool _enabled) - : enabled_(::flatbuffers::EndianScalar(static_cast(_enabled))) { - } - bool enabled() const { - return ::flatbuffers::EndianScalar(enabled_) != 0; - } -}; -FLATBUFFERS_STRUCT_END(CaptivePortalConfig, 1); - -struct CaptivePortalConfig::Traits { - using type = CaptivePortalConfig; -}; - -struct ShockerCommandList FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { - typedef ShockerCommandListBuilder Builder; - struct Traits; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "OpenShock.Serialization.ShockerCommandList"; - } - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_COMMANDS = 4 - }; - const ::flatbuffers::Vector *commands() const { - return GetPointer *>(VT_COMMANDS); - } - bool Verify(::flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_COMMANDS) && - verifier.VerifyVector(commands()) && - verifier.EndTable(); - } -}; - -struct ShockerCommandListBuilder { - typedef ShockerCommandList Table; - ::flatbuffers::FlatBufferBuilder &fbb_; - ::flatbuffers::uoffset_t start_; - void add_commands(::flatbuffers::Offset<::flatbuffers::Vector> commands) { - fbb_.AddOffset(ShockerCommandList::VT_COMMANDS, commands); - } - explicit ShockerCommandListBuilder(::flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ::flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = ::flatbuffers::Offset(end); - fbb_.Required(o, ShockerCommandList::VT_COMMANDS); - return o; - } -}; - -inline ::flatbuffers::Offset CreateShockerCommandList( - ::flatbuffers::FlatBufferBuilder &_fbb, - ::flatbuffers::Offset<::flatbuffers::Vector> commands = 0) { - ShockerCommandListBuilder builder_(_fbb); - builder_.add_commands(commands); - return builder_.Finish(); -} - -struct ShockerCommandList::Traits { - using type = ShockerCommandList; - static auto constexpr Create = CreateShockerCommandList; -}; - -inline ::flatbuffers::Offset CreateShockerCommandListDirect( - ::flatbuffers::FlatBufferBuilder &_fbb, - const std::vector *commands = nullptr) { - auto commands__ = commands ? _fbb.CreateVectorOfStructs(*commands) : 0; - return OpenShock::Serialization::CreateShockerCommandList( - _fbb, - commands__); -} - -struct ServerToDeviceMessage FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { - typedef ServerToDeviceMessageBuilder Builder; - struct Traits; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "OpenShock.Serialization.ServerToDeviceMessage"; - } - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_PAYLOAD_TYPE = 4, - VT_PAYLOAD = 6 - }; - OpenShock::Serialization::ServerToDeviceMessagePayload payload_type() const { - return static_cast(GetField(VT_PAYLOAD_TYPE, 0)); - } - const void *payload() const { - return GetPointer(VT_PAYLOAD); - } - template const T *payload_as() const; - const OpenShock::Serialization::ShockerCommandList *payload_as_ShockerCommandList() const { - return payload_type() == OpenShock::Serialization::ServerToDeviceMessagePayload::ShockerCommandList ? static_cast(payload()) : nullptr; - } - const OpenShock::Serialization::CaptivePortalConfig *payload_as_CaptivePortalConfig() const { - return payload_type() == OpenShock::Serialization::ServerToDeviceMessagePayload::CaptivePortalConfig ? static_cast(payload()) : nullptr; - } - bool Verify(::flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_PAYLOAD_TYPE, 1) && - VerifyOffset(verifier, VT_PAYLOAD) && - VerifyServerToDeviceMessagePayload(verifier, payload(), payload_type()) && - verifier.EndTable(); - } -}; - -template<> inline const OpenShock::Serialization::ShockerCommandList *ServerToDeviceMessage::payload_as() const { - return payload_as_ShockerCommandList(); -} - -template<> inline const OpenShock::Serialization::CaptivePortalConfig *ServerToDeviceMessage::payload_as() const { - return payload_as_CaptivePortalConfig(); -} - -struct ServerToDeviceMessageBuilder { - typedef ServerToDeviceMessage Table; - ::flatbuffers::FlatBufferBuilder &fbb_; - ::flatbuffers::uoffset_t start_; - void add_payload_type(OpenShock::Serialization::ServerToDeviceMessagePayload payload_type) { - fbb_.AddElement(ServerToDeviceMessage::VT_PAYLOAD_TYPE, static_cast(payload_type), 0); - } - void add_payload(::flatbuffers::Offset payload) { - fbb_.AddOffset(ServerToDeviceMessage::VT_PAYLOAD, payload); - } - explicit ServerToDeviceMessageBuilder(::flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ::flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = ::flatbuffers::Offset(end); - return o; - } -}; - -inline ::flatbuffers::Offset CreateServerToDeviceMessage( - ::flatbuffers::FlatBufferBuilder &_fbb, - OpenShock::Serialization::ServerToDeviceMessagePayload payload_type = OpenShock::Serialization::ServerToDeviceMessagePayload::NONE, - ::flatbuffers::Offset payload = 0) { - ServerToDeviceMessageBuilder builder_(_fbb); - builder_.add_payload(payload); - builder_.add_payload_type(payload_type); - return builder_.Finish(); -} - -struct ServerToDeviceMessage::Traits { - using type = ServerToDeviceMessage; - static auto constexpr Create = CreateServerToDeviceMessage; -}; - -inline bool VerifyServerToDeviceMessagePayload(::flatbuffers::Verifier &verifier, const void *obj, ServerToDeviceMessagePayload type) { - switch (type) { - case ServerToDeviceMessagePayload::NONE: { - return true; - } - case ServerToDeviceMessagePayload::ShockerCommandList: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case ServerToDeviceMessagePayload::CaptivePortalConfig: { - return verifier.VerifyField(static_cast(obj), 0, 1); - } - default: return true; - } -} - -inline bool VerifyServerToDeviceMessagePayloadVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset> *values, const ::flatbuffers::Vector *types) { - if (!values || !types) return !values && !types; - if (values->size() != types->size()) return false; - for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { - if (!VerifyServerToDeviceMessagePayload( - verifier, values->Get(i), types->GetEnum(i))) { - return false; - } - } - return true; -} - -inline const OpenShock::Serialization::ServerToDeviceMessage *GetServerToDeviceMessage(const void *buf) { - return ::flatbuffers::GetRoot(buf); -} - -inline const OpenShock::Serialization::ServerToDeviceMessage *GetSizePrefixedServerToDeviceMessage(const void *buf) { - return ::flatbuffers::GetSizePrefixedRoot(buf); -} - -inline bool VerifyServerToDeviceMessageBuffer( - ::flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer(nullptr); -} - -inline bool VerifySizePrefixedServerToDeviceMessageBuffer( - ::flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer(nullptr); -} - -inline void FinishServerToDeviceMessageBuffer( - ::flatbuffers::FlatBufferBuilder &fbb, - ::flatbuffers::Offset root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedServerToDeviceMessageBuffer( - ::flatbuffers::FlatBufferBuilder &fbb, - ::flatbuffers::Offset root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace Serialization -} // namespace OpenShock - -#endif // FLATBUFFERS_GENERATED_SERVERTODEVICEMESSAGE_OPENSHOCK_SERIALIZATION_H_ diff --git a/include/util/HexUtils.h b/include/util/HexUtils.h index d5344abe..d723fa91 100644 --- a/include/util/HexUtils.h +++ b/include/util/HexUtils.h @@ -28,6 +28,19 @@ namespace OpenShock::HexUtils { output[N * 2] = '\0'; } + /// @brief Converts a byte array to a hex string. + /// @param data The byte array to convert. + /// @param output The output buffer to write to. + /// @param upper Whether to use uppercase hex characters. + /// @remark To use this you must specify the size of the array in the template parameter. (e.g. ToHexMac<6>(...)) + template + constexpr void ToHex(const std::uint8_t (&data)[N], std::array& output, bool upper = true) noexcept { + for (std::size_t i = 0; i < N; ++i) { + ToHex(data[i], &output[i * 2], upper); + } + output[N * 2] = '\0'; + } + /// @brief Converts a byte array to a hex string. /// @param data The byte array to convert. /// @param upper Whether to use uppercase hex characters. @@ -36,7 +49,7 @@ namespace OpenShock::HexUtils { template constexpr std::array ToHex(const std::uint8_t (&data)[N], bool upper = true) noexcept { std::array output {}; - ToHex(data, output, upper); + ToHex(data, output, upper); return output; } @@ -127,4 +140,27 @@ namespace OpenShock::HexUtils { inline std::size_t TryParseHexMac(const char* str, std::uint8_t* out, std::size_t outLen) noexcept { return TryParseHexMac(str, strlen(str), out, outLen); } + + constexpr std::size_t TryParseHex(const char* str, std::size_t strLen, std::uint8_t* out, std::size_t outLen) noexcept { + std::size_t parsedLength = strLen / 2; + + if (parsedLength * 2 != strLen) { + return 0; // Invalid hex string length. + } + + if (parsedLength > outLen) { + return 0; // Output buffer is too small. + } + + for (std::size_t i = 0; i < parsedLength; ++i) { + if (!TryParseHexPair(str[i * 2], str[i * 2 + 1], out[i])) { + return 0; // Invalid hex pair. + } + } + + return parsedLength; + } + inline std::size_t TryParseHex(const char* str, std::uint8_t* out, std::size_t outLen) noexcept { + return TryParseHex(str, strlen(str), out, outLen); + } } // namespace OpenShock::HexUtils diff --git a/include/util/PartitionUtils.h b/include/util/PartitionUtils.h new file mode 100644 index 00000000..0ff32a5a --- /dev/null +++ b/include/util/PartitionUtils.h @@ -0,0 +1,13 @@ +#pragma once + +#include "StringView.h" + +#include + +#include +#include + +namespace OpenShock { + bool TryGetPartitionHash(const esp_partition_t* partition, char (&hash)[65]); + bool FlashPartitionFromUrl(const esp_partition_t* partition, StringView remoteUrl, const std::uint8_t (&remoteHash)[32], std::function progressCallback = nullptr); +} diff --git a/include/util/StringUtils.h b/include/util/StringUtils.h new file mode 100644 index 00000000..1b2cc8c0 --- /dev/null +++ b/include/util/StringUtils.h @@ -0,0 +1,8 @@ +#pragma once + +#include +#include + +namespace OpenShock { + bool FormatToString(std::string& out, const char* format, ...); +} // namespace OpenShock diff --git a/schemas/ConfigFile.fbs b/schemas/ConfigFile.fbs index 94b656c2..b71c156e 100644 --- a/schemas/ConfigFile.fbs +++ b/schemas/ConfigFile.fbs @@ -1,3 +1,5 @@ +include "./Types/FirmwareBootType.fbs"; + namespace OpenShock.Serialization.Configuration; table RFConfig { @@ -49,6 +51,45 @@ table SerialInputConfig { echo_enabled:bool = true; } +enum OtaUpdateChannel:uint8 { + Stable = 0, + Beta = 1, + Develop = 2 +} + +// Represents configuration for Over-The-Air (OTA) updates. +table OtaUpdateConfig { + /// Indicates whether OTA updates are enabled. + is_enabled:bool; + + /// The domain name of the OTA Content Delivery Network (CDN). + cdn_domain:string; + + /// The update channel to use. + update_channel:OtaUpdateChannel; + + /// Indicates whether to check for updates on startup. + check_on_startup:bool; + + /// Indicates whether to check for updates periodically. + check_periodically:bool; + + /// The interval in minutes between periodic update checks. + check_interval:uint16; + + /// Indicates if the backend is authorized to manage the device's update version on behalf of the user. + allow_backend_management:bool; + + /// Indicates if manual approval via serial input or captive portal is required before installing updates. + require_manual_approval:bool; + + /// Update process ID, used to track the update process server-side across reboots. + update_id:int32; + + /// Indicates what kind of firmware boot is happening (normal boot, booting into new firmware, rolling back to old firmware, etc.) + boot_type:Types.FirmwareBootType; +} + table Config { /// RF Transmitter configuration rf:RFConfig; @@ -64,4 +105,7 @@ table Config { /// Serial input configuration serial_input:SerialInputConfig; + + /// OTA update configuration + ota_update:OtaUpdateConfig; } diff --git a/schemas/DeviceToGatewayMessage.fbs b/schemas/DeviceToGatewayMessage.fbs new file mode 100644 index 00000000..e2e7e252 --- /dev/null +++ b/schemas/DeviceToGatewayMessage.fbs @@ -0,0 +1,57 @@ +include "./Types/SemVer.fbs"; +include "./Types/FirmwareBootType.fbs"; + +attribute "fs_serializer"; + +namespace OpenShock.Serialization.Gateway; + +struct KeepAlive { + uptime:ulong; +} + +table BootStatus { + boot_type:Types.FirmwareBootType; + firmware_version:Types.SemVer; + ota_update_id:int32; +} + +table OtaInstallStarted { + update_id:int32; + version:Types.SemVer; +} + +enum OtaInstallProgressTask:byte { + FetchingMetadata, + PreparingForInstall, + FlashingFilesystem, + VerifyingFilesystem, + FlashingApplication, + MarkingApplicationBootable, + Rebooting +} + +table OtaInstallProgress { + update_id:int32; + task:OtaInstallProgressTask; + progress:float; +} + +table OtaInstallFailed { + update_id:int32; + message:string; + fatal:bool; +} + +union DeviceToGatewayMessagePayload { + KeepAlive, + BootStatus, + OtaInstallStarted, + OtaInstallProgress, + OtaInstallFailed +} + +table DeviceToGatewayMessage (fs_serializer) { + payload:DeviceToGatewayMessagePayload; +} + +root_type DeviceToGatewayMessage; diff --git a/schemas/DeviceToServerMessage.fbs b/schemas/DeviceToServerMessage.fbs deleted file mode 100644 index 5d42b1a8..00000000 --- a/schemas/DeviceToServerMessage.fbs +++ /dev/null @@ -1,17 +0,0 @@ -attribute "fs_serializer"; - -namespace OpenShock.Serialization; - -struct KeepAlive { - uptime:ulong; -} - -union DeviceToServerMessagePayload { - KeepAlive -} - -table DeviceToServerMessage (fs_serializer) { - payload:DeviceToServerMessagePayload; -} - -root_type DeviceToServerMessage; diff --git a/schemas/ServerToDeviceMessage.fbs b/schemas/GatewayToDeviceMessage.fbs similarity index 53% rename from schemas/ServerToDeviceMessage.fbs rename to schemas/GatewayToDeviceMessage.fbs index 0936c673..141d483d 100644 --- a/schemas/ServerToDeviceMessage.fbs +++ b/schemas/GatewayToDeviceMessage.fbs @@ -1,9 +1,10 @@ include "./Types/ShockerCommandType.fbs"; include "./Types/ShockerModelType.fbs"; +include "./Types/SemVer.fbs"; attribute "fs_serializer"; -namespace OpenShock.Serialization; +namespace OpenShock.Serialization.Gateway; struct ShockerCommand { model:Types.ShockerModelType; @@ -21,13 +22,19 @@ struct CaptivePortalConfig { enabled:bool; } -union ServerToDeviceMessagePayload { +// Begin installing an OTA update +table OtaInstall { + version:Types.SemVer; +} + +union GatewayToDeviceMessagePayload { ShockerCommandList, - CaptivePortalConfig + CaptivePortalConfig, + OtaInstall } -table ServerToDeviceMessage (fs_serializer) { - payload:ServerToDeviceMessagePayload; +table GatewayToDeviceMessage (fs_serializer) { + payload:GatewayToDeviceMessagePayload; } -root_type ServerToDeviceMessage; +root_type GatewayToDeviceMessage; diff --git a/schemas/LocalToDeviceMessage.fbs b/schemas/LocalToDeviceMessage.fbs index 609ea198..12964936 100644 --- a/schemas/LocalToDeviceMessage.fbs +++ b/schemas/LocalToDeviceMessage.fbs @@ -20,6 +20,35 @@ struct WifiNetworkDisconnectCommand { placeholder:bool; } +struct OtaUpdateSetIsEnabledCommand { + enabled:bool; +} +table OtaUpdateSetDomainCommand { + domain:string; +} +table OtaUpdateSetUpdateChannelCommand { + channel:string; +} +struct OtaUpdateSetCheckIntervalCommand { + interval:uint16; +} +struct OtaUpdateSetAllowBackendManagementCommand { + allow:bool; +} +struct OtaUpdateSetRequireManualApprovalCommand { + require:bool; +} +struct OtaUpdateHandleUpdateRequestCommand { + accept:bool; +} +table OtaUpdateCheckForUpdatesCommand { + channel:string; +} +table OtaUpdateStartUpdateCommand { + channel:string; + version:string; +} + table AccountLinkCommand { code:string; } @@ -39,6 +68,17 @@ union LocalToDeviceMessagePayload { WifiNetworkConnectCommand, WifiNetworkDisconnectCommand, + // OTA stuff + OtaUpdateSetIsEnabledCommand, + OtaUpdateSetDomainCommand, + OtaUpdateSetUpdateChannelCommand, + OtaUpdateSetCheckIntervalCommand, + OtaUpdateSetAllowBackendManagementCommand, + OtaUpdateSetRequireManualApprovalCommand, + OtaUpdateHandleUpdateRequestCommand, + OtaUpdateCheckForUpdatesCommand, + OtaUpdateStartUpdateCommand, + // Account linking stuff AccountLinkCommand, AccountUnlinkCommand, diff --git a/schemas/Types/FirmwareBootType.fbs b/schemas/Types/FirmwareBootType.fbs new file mode 100644 index 00000000..2055b6dc --- /dev/null +++ b/schemas/Types/FirmwareBootType.fbs @@ -0,0 +1,7 @@ +namespace OpenShock.Serialization.Types; + +enum FirmwareBootType : uint8 { + Normal = 0, + NewFirmware = 1, + Rollback = 2, +} diff --git a/schemas/Types/SemVer.fbs b/schemas/Types/SemVer.fbs new file mode 100644 index 00000000..733f952e --- /dev/null +++ b/schemas/Types/SemVer.fbs @@ -0,0 +1,9 @@ +namespace OpenShock.Serialization.Types; + +table SemVer { + major: uint16; + minor: uint16; + patch: uint16; + prerelease: string; + build: string; +} diff --git a/src/CaptivePortal.cpp b/src/CaptivePortal.cpp index 2ce4ad16..b26a2d7b 100644 --- a/src/CaptivePortal.cpp +++ b/src/CaptivePortal.cpp @@ -5,6 +5,7 @@ #include "config/Config.h" #include "GatewayConnectionManager.h" #include "Logging.h" +#include "Time.h" #include #include @@ -19,6 +20,7 @@ static const char* TAG = "CaptivePortal"; using namespace OpenShock; static bool s_alwaysEnabled = false; +static bool s_forceClosed = false; static std::unique_ptr s_instance = nullptr; bool _startCaptive() { @@ -92,18 +94,38 @@ bool CaptivePortal::IsAlwaysEnabled() { return s_alwaysEnabled; } +bool CaptivePortal::ForceClose(std::uint32_t timeoutMs) { + s_forceClosed = true; + + if (s_instance == nullptr) return true; + + while (timeoutMs > 0) { + std::uint32_t delay = std::min(timeoutMs, 10U); + + vTaskDelay(pdMS_TO_TICKS(delay)); + + timeoutMs -= delay; + + if (s_instance == nullptr) return true; + } + + return false; +} + bool CaptivePortal::IsRunning() { return s_instance != nullptr; } + void CaptivePortal::Update() { bool gatewayConnected = GatewayConnectionManager::IsConnected(); bool commandHandlerOk = CommandHandler::Ok(); - bool shouldBeRunning = s_alwaysEnabled || !gatewayConnected || !commandHandlerOk; + bool shouldBeRunning = (s_alwaysEnabled || !gatewayConnected || !commandHandlerOk) && !s_forceClosed; if (s_instance == nullptr) { if (shouldBeRunning) { ESP_LOGD(TAG, "Starting captive portal"); ESP_LOGD(TAG, " alwaysEnabled: %s", s_alwaysEnabled ? "true" : "false"); + ESP_LOGD(TAG, " forceClosed: %s", s_forceClosed ? "true" : "false"); ESP_LOGD(TAG, " isConnected: %s", gatewayConnected ? "true" : "false"); ESP_LOGD(TAG, " commandHandlerOk: %s", commandHandlerOk ? "true" : "false"); _startCaptive(); @@ -114,6 +136,7 @@ void CaptivePortal::Update() { if (!shouldBeRunning) { ESP_LOGD(TAG, "Stopping captive portal"); ESP_LOGD(TAG, " alwaysEnabled: %s", s_alwaysEnabled ? "true" : "false"); + ESP_LOGD(TAG, " forceClosed: %s", s_forceClosed ? "true" : "false"); ESP_LOGD(TAG, " isConnected: %s", gatewayConnected ? "true" : "false"); ESP_LOGD(TAG, " commandHandlerOk: %s", commandHandlerOk ? "true" : "false"); _stopCaptive(); diff --git a/src/CaptivePortalInstance.cpp b/src/CaptivePortalInstance.cpp index 440540e0..7581c716 100644 --- a/src/CaptivePortalInstance.cpp +++ b/src/CaptivePortalInstance.cpp @@ -6,12 +6,12 @@ #include "Logging.h" #include "serialization/WSLocal.h" #include "util/HexUtils.h" +#include "util/PartitionUtils.h" #include "util/TaskUtils.h" #include "wifi/WiFiManager.h" #include "serialization/_fbs/DeviceToLocalMessage_generated.h" -#include #include static const char* TAG = "CaptivePortalInstance"; @@ -40,44 +40,25 @@ const esp_partition_t* _getStaticPartition() { return nullptr; } -bool _tryGetPartitionHash(char (&buffer)[65]) { - static bool initialized = false; - static std::uint8_t staticSha256[32] = {0}; - - if (!initialized) { - initialized = true; - - ESP_LOGD(TAG, "Looking for static partition"); - - // Get the static partition - const esp_partition_t* partition = _getStaticPartition(); - if (partition == nullptr) { - ESP_LOGE(TAG, "Failed to find static partition"); - return false; - } - - ESP_LOGD(TAG, "Found static partition, getting hash..."); - - // Get the hash of the partition - esp_err_t err = esp_partition_get_sha256(partition, staticSha256); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to get partition hash: %s", esp_err_to_name(err)); - return false; - } - - ESP_LOGD(TAG, "Got partition hash"); +const char* _getPartitionHash() { + const esp_partition_t* partition = _getStaticPartition(); + if (partition == nullptr) { + return nullptr; } - // Copy the hash to the output buffer - HexUtils::ToHex<32>(staticSha256, buffer, false); + static char hash[65]; + if (!OpenShock::TryGetPartitionHash(partition, hash)) { + return nullptr; + } - return true; + return hash; } CaptivePortalInstance::CaptivePortalInstance() : m_webServer(HTTP_PORT) , m_socketServer(WEBSOCKET_PORT, "/ws", "json") , m_socketDeFragger(std::bind(&CaptivePortalInstance::handleWebSocketEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)) + , m_fileSystem() , m_dnsServer() , m_taskHandle(nullptr) { m_socketServer.onEvent(std::bind(&WebSocketDeFragger::handler, &m_socketDeFragger, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); @@ -87,14 +68,25 @@ CaptivePortalInstance::CaptivePortalInstance() ESP_LOGI(TAG, "Setting up DNS server"); m_dnsServer.start(DNS_PORT, "*", WiFi.softAPIP()); - // Check if the www folder exists and is populated - bool indexExists = LittleFS.exists("/www/index.html.gz"); + bool fsOk = true; // Get the hash of the filesystem - char fsHash[65]; - bool gotFsHash = _tryGetPartitionHash(fsHash); + const char* fsHash = _getPartitionHash(); + if (fsHash == nullptr) { + ESP_LOGE(TAG, "Failed to get filesystem hash"); + fsOk = false; + } + + if (fsOk) { + // Mounting LittleFS + if (!m_fileSystem.begin(false, "/static", 10U, "static0")) { + ESP_LOGE(TAG, "Failed to mount LittleFS"); + fsOk = false; + } else { + fsOk = m_fileSystem.exists("/www/index.html.gz"); + } + } - bool fsOk = indexExists && gotFsHash; if (fsOk) { ESP_LOGI(TAG, "Serving files from LittleFS"); ESP_LOGI(TAG, "Filesystem hash: %s", fsHash); @@ -103,7 +95,7 @@ CaptivePortalInstance::CaptivePortalInstance() snprintf(softAPURL, sizeof(softAPURL), "http://%s", WiFi.softAPIP().toString().c_str()); // Serving the captive portal files from LittleFS - m_webServer.serveStatic("/", LittleFS, "/www/", "max-age=3600").setDefaultFile("index.html").setSharedEtag(fsHash); + m_webServer.serveStatic("/", m_fileSystem, "/www/", "max-age=3600").setDefaultFile("index.html").setSharedEtag(fsHash); // Redirecting connection tests to the captive portal, triggering the "login to network" prompt m_webServer.onNotFound([softAPURL](AsyncWebServerRequest* request) { request->redirect(softAPURL); }); @@ -142,6 +134,7 @@ CaptivePortalInstance::~CaptivePortalInstance() { } m_webServer.end(); m_socketServer.close(); + m_fileSystem.end(); m_dnsServer.stop(); } @@ -150,7 +143,7 @@ void CaptivePortalInstance::task(void* arg) { while (true) { instance->m_socketServer.loop(); - instance->m_dnsServer.processNextRequest(); + // instance->m_dnsServer.processNextRequest(); vTaskDelay(pdMS_TO_TICKS(WEBSOCKET_UPDATE_INTERVAL)); } } diff --git a/src/GatewayClient.cpp b/src/GatewayClient.cpp index eedfa9fe..2e9d7303 100644 --- a/src/GatewayClient.cpp +++ b/src/GatewayClient.cpp @@ -1,16 +1,18 @@ #include "GatewayClient.h" +#include "config/Config.h" #include "event_handlers/WebSocket.h" #include "Logging.h" +#include "serialization/WSGateway.h" #include "Time.h" #include "util/CertificateUtils.h" -#include "serialization/_fbs/DeviceToServerMessage_generated.h" - const char* const TAG = "GatewayClient"; using namespace OpenShock; +static bool s_bootStatusSent = false; + GatewayClient::GatewayClient(const std::string& authToken) : m_webSocket(), m_lastKeepAlive(0), m_state(State::Disconnected) { ESP_LOGD(TAG, "Creating GatewayClient"); @@ -58,6 +60,22 @@ void GatewayClient::disconnect() { m_webSocket.disconnect(); } +bool GatewayClient::sendMessageTXT(StringView data) { + if (m_state != State::Connected) { + return false; + } + + return m_webSocket.sendTXT(data.data(), data.length()); +} + +bool GatewayClient::sendMessageBIN(const std::uint8_t* data, std::size_t length) { + if (m_state != State::Connected) { + return false; + } + + return m_webSocket.sendBIN(data, length); +} + bool GatewayClient::loop() { if (m_state == State::Disconnected) { return false; @@ -85,24 +103,38 @@ bool GatewayClient::loop() { void GatewayClient::_sendKeepAlive() { ESP_LOGV(TAG, "Sending Gateway keep-alive message"); + Serialization::Gateway::SerializeKeepAliveMessage([this](const std::uint8_t* data, std::size_t len) { return m_webSocket.sendBIN(data, len); }); +} - // Casting to uint64 here is safe since millis is guaranteed to return a positive value - OpenShock::Serialization::KeepAlive keepAlive(static_cast(OpenShock::millis())); +void GatewayClient::_sendBootStatus() { + if (s_bootStatusSent) return; - flatbuffers::FlatBufferBuilder builder(64); + ESP_LOGV(TAG, "Sending Gateway boot status message"); - auto keepAliveOffset = builder.CreateStruct(keepAlive); + std::int32_t updateId; + if (!Config::GetOtaUpdateId(updateId)) { + ESP_LOGE(TAG, "Failed to get OTA update ID"); + return; + } - auto msg = OpenShock::Serialization::CreateDeviceToServerMessage(builder, OpenShock::Serialization::DeviceToServerMessagePayload::KeepAlive, keepAliveOffset.Union()); + OpenShock::FirmwareBootType bootType; + if (!Config::GetOtaFirmwareBootType(bootType)) { + ESP_LOGE(TAG, "Failed to get OTA firmware boot type"); + return; + } - builder.Finish(msg); + OpenShock::SemVer version; + if (!OpenShock::TryParseSemVer(OPENSHOCK_FW_VERSION, version)) { + ESP_LOGE(TAG, "Failed to parse firmware version"); + return; + } - m_webSocket.sendBIN(builder.GetBufferPointer(), builder.GetSize()); + s_bootStatusSent = Serialization::Gateway::SerializeBootStatusMessage(updateId, bootType, version, [this](const std::uint8_t* data, std::size_t len) { return m_webSocket.sendBIN(data, len); }); } void GatewayClient::_handleEvent(WStype_t type, std::uint8_t* payload, std::size_t length) { (void)payload; - + switch (type) { case WStype_DISCONNECTED: ESP_LOGI(TAG, "Disconnected from API"); @@ -112,6 +144,7 @@ void GatewayClient::_handleEvent(WStype_t type, std::uint8_t* payload, std::size ESP_LOGI(TAG, "Connected to API"); m_state = State::Connected; _sendKeepAlive(); + _sendBootStatus(); break; case WStype_TEXT: ESP_LOGW(TAG, "Received text from API, JSON parsing is not supported anymore :D"); diff --git a/src/GatewayConnectionManager.cpp b/src/GatewayConnectionManager.cpp index 1330cdd0..cd8c4471 100644 --- a/src/GatewayConnectionManager.cpp +++ b/src/GatewayConnectionManager.cpp @@ -120,6 +120,22 @@ void GatewayConnectionManager::UnLink() { Config::ClearBackendAuthToken(); } +bool GatewayConnectionManager::SendMessageTXT(StringView data) { + if (s_wsClient == nullptr) { + return false; + } + + return s_wsClient->sendMessageTXT(data); +} + +bool GatewayConnectionManager::SendMessageBIN(const std::uint8_t* data, std::size_t length) { + if (s_wsClient == nullptr) { + return false; + } + + return s_wsClient->sendMessageBIN(data, length); +} + bool FetchDeviceInfo(const String& authToken) { // TODO: this function is very slow, should be optimized! if ((s_flags & FLAG_HAS_IP) == 0) { diff --git a/src/OtaUpdateManager.cpp b/src/OtaUpdateManager.cpp new file mode 100644 index 00000000..a6da621a --- /dev/null +++ b/src/OtaUpdateManager.cpp @@ -0,0 +1,655 @@ +#include "OtaUpdateManager.h" + +#include "CaptivePortal.h" +#include "config/Config.h" +#include "Constants.h" +#include "GatewayConnectionManager.h" +#include "Hashing.h" +#include "http/HTTPRequestManager.h" +#include "Logging.h" +#include "SemVer.h" +#include "serialization/WSGateway.h" +#include "StringView.h" +#include "Time.h" +#include "util/HexUtils.h" +#include "util/PartitionUtils.h" +#include "util/StringUtils.h" +#include "util/TaskUtils.h" +#include "wifi/WiFiManager.h" + +#include + +#include +#include + +#include + +#define OPENSHOCK_FW_CDN_CHANNEL_URL(ch) OPENSHOCK_FW_CDN_URL("/version-" ch ".txt") + +#define OPENSHOCK_FW_CDN_STABLE_URL OPENSHOCK_FW_CDN_CHANNEL_URL("stable") +#define OPENSHOCK_FW_CDN_BETA_URL OPENSHOCK_FW_CDN_CHANNEL_URL("beta") +#define OPENSHOCK_FW_CDN_DEVELOP_URL OPENSHOCK_FW_CDN_CHANNEL_URL("develop") + +#define OPENSHOCK_FW_CDN_BOARDS_BASE_URL_FORMAT OPENSHOCK_FW_CDN_URL("/%s") +#define OPENSHOCK_FW_CDN_BOARDS_INDEX_URL_FORMAT OPENSHOCK_FW_CDN_BOARDS_BASE_URL_FORMAT "/boards.txt" + +#define OPENSHOCK_FW_CDN_VERSION_BASE_URL_FORMAT OPENSHOCK_FW_CDN_BOARDS_BASE_URL_FORMAT "/" OPENSHOCK_FW_BOARD + +#define OPENSHOCK_FW_CDN_APP_URL_FORMAT OPENSHOCK_FW_CDN_VERSION_BASE_URL_FORMAT "/app.bin" +#define OPENSHOCK_FW_CDN_FILESYSTEM_URL_FORMAT OPENSHOCK_FW_CDN_VERSION_BASE_URL_FORMAT "/staticfs.bin" +#define OPENSHOCK_FW_CDN_SHA256_HASHES_URL_FORMAT OPENSHOCK_FW_CDN_VERSION_BASE_URL_FORMAT "/hashes.sha256.txt" + +const char* const TAG = "OtaUpdateManager"; + +/// @brief Stops initArduino() from handling OTA rollbacks +/// @todo Get rid of Arduino entirely. >:( +/// +/// @see .platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-misc.c +/// @return true +bool verifyRollbackLater() { + return true; +} + +using namespace OpenShock; + +enum OtaTaskEventFlag : std::uint32_t { + OTA_TASK_EVENT_UPDATE_REQUESTED = 1 << 0, + OTA_TASK_EVENT_WIFI_DISCONNECTED = 1 << 1, // If both connected and disconnected are set, disconnected takes priority. + OTA_TASK_EVENT_WIFI_CONNECTED = 1 << 2, +}; + +static bool _otaValidatingApp = false; +static TaskHandle_t _taskHandle; +static OpenShock::SemVer _requestedVersion; +static SemaphoreHandle_t _requestedVersionMutex = xSemaphoreCreateMutex(); + +bool _tryQueueUpdateRequest(const OpenShock::SemVer& version) { + if (xSemaphoreTake(_requestedVersionMutex, pdMS_TO_TICKS(1000)) != pdTRUE) { + ESP_LOGE(TAG, "Failed to take requested version mutex"); + return false; + } + + _requestedVersion = version; + + xSemaphoreGive(_requestedVersionMutex); + + xTaskNotify(_taskHandle, OTA_TASK_EVENT_UPDATE_REQUESTED, eSetBits); + + return true; +} + +bool _tryGetRequestedVersion(OpenShock::SemVer& version) { + if (xSemaphoreTake(_requestedVersionMutex, pdMS_TO_TICKS(1000)) != pdTRUE) { + ESP_LOGE(TAG, "Failed to take requested version mutex"); + return false; + } + + version = _requestedVersion; + + xSemaphoreGive(_requestedVersionMutex); + + return true; +} + +void _otaEvGotIPHandler(arduino_event_t* event) { + (void)event; + xTaskNotify(_taskHandle, OTA_TASK_EVENT_WIFI_CONNECTED, eSetBits); +} +void _otaEvWiFiDisconnectedHandler(arduino_event_t* event) { + (void)event; + xTaskNotify(_taskHandle, OTA_TASK_EVENT_WIFI_DISCONNECTED, eSetBits); +} + +bool _sendProgressMessage(Serialization::Gateway::OtaInstallProgressTask task, float progress) { + std::int32_t updateId; + if (!Config::GetOtaUpdateId(updateId)) { + ESP_LOGE(TAG, "Failed to get OTA update ID"); + return false; + } + + if (!Serialization::Gateway::SerializeOtaInstallProgressMessage(updateId, task, progress, GatewayConnectionManager::SendMessageBIN)) { + ESP_LOGE(TAG, "Failed to send OTA install progress message"); + return false; + } + + return true; +} +bool _sendFailureMessage(StringView message, bool fatal = false) { + std::int32_t updateId; + if (!Config::GetOtaUpdateId(updateId)) { + ESP_LOGE(TAG, "Failed to get OTA update ID"); + return false; + } + + if (!Serialization::Gateway::SerializeOtaInstallFailedMessage(updateId, message, fatal, GatewayConnectionManager::SendMessageBIN)) { + ESP_LOGE(TAG, "Failed to send OTA install failed message"); + return false; + } + + return true; +} + +bool _flashAppPartition(const esp_partition_t* partition, StringView remoteUrl, const std::uint8_t (&remoteHash)[32]) { + ESP_LOGD(TAG, "Flashing app partition"); + + if (!_sendProgressMessage(Serialization::Gateway::OtaInstallProgressTask::FlashingApplication, 0.0f)) { + return false; + } + + auto onProgress = [](std::size_t current, std::size_t total, float progress) -> bool { + ESP_LOGD(TAG, "Flashing app partition: %u / %u (%.2f%%)", current, total, progress * 100.0f); + + _sendProgressMessage(Serialization::Gateway::OtaInstallProgressTask::FlashingApplication, progress); + + return true; + }; + + if (!OpenShock::FlashPartitionFromUrl(partition, remoteUrl, remoteHash, onProgress)) { + ESP_LOGE(TAG, "Failed to flash app partition"); + _sendFailureMessage("Failed to flash app partition"); + return false; + } + + if (!_sendProgressMessage(Serialization::Gateway::OtaInstallProgressTask::MarkingApplicationBootable, 0.0f)) { + return false; + } + + // Set app partition bootable. + if (esp_ota_set_boot_partition(partition) != ESP_OK) { + ESP_LOGE(TAG, "Failed to set app partition bootable"); + _sendFailureMessage("Failed to set app partition bootable"); + return false; + } + + return true; +} + +bool _flashFilesystemPartition(const esp_partition_t* parition, StringView remoteUrl, const std::uint8_t (&remoteHash)[32]) { + if (!_sendProgressMessage(Serialization::Gateway::OtaInstallProgressTask::PreparingForInstall, 0.0f)) { + return false; + } + + // Make sure captive portal is stopped, timeout after 5 seconds. + if (!CaptivePortal::ForceClose(5000U)) { + ESP_LOGE(TAG, "Failed to force close captive portal (timed out)"); + _sendFailureMessage("Failed to force close captive portal (timed out)"); + return false; + } + + ESP_LOGD(TAG, "Flashing filesystem partition"); + + if (!_sendProgressMessage(Serialization::Gateway::OtaInstallProgressTask::FlashingFilesystem, 0.0f)) { + return false; + } + + auto onProgress = [](std::size_t current, std::size_t total, float progress) -> bool { + ESP_LOGD(TAG, "Flashing filesystem partition: %u / %u (%.2f%%)", current, total, progress * 100.0f); + + _sendProgressMessage(Serialization::Gateway::OtaInstallProgressTask::FlashingFilesystem, progress); + + return true; + }; + + if (!OpenShock::FlashPartitionFromUrl(parition, remoteUrl, remoteHash, onProgress)) { + ESP_LOGE(TAG, "Failed to flash filesystem partition"); + _sendFailureMessage("Failed to flash filesystem partition"); + return false; + } + + if (!_sendProgressMessage(Serialization::Gateway::OtaInstallProgressTask::VerifyingFilesystem, 0.0f)) { + return false; + } + + // Attempt to mount filesystem. + fs::LittleFSFS test; + if (!test.begin(false, "/static", 10, "static0")) { + ESP_LOGE(TAG, "Failed to mount filesystem"); + _sendFailureMessage("Failed to mount filesystem"); + return false; + } + test.end(); + + OpenShock::CaptivePortal::ForceClose(false); + + return true; +} + +void _otaUpdateTask(void* arg) { + (void)arg; + + ESP_LOGD(TAG, "OTA update task started"); + + bool connected = false; + bool updateRequested = false; + std::int64_t lastUpdateCheck = 0; + + // Update task loop. + while (true) { + // Wait for event. + uint32_t eventBits = 0; + xTaskNotifyWait(0, UINT32_MAX, &eventBits, pdMS_TO_TICKS(5000)); // TODO: wait for rest time + + updateRequested |= (eventBits & OTA_TASK_EVENT_UPDATE_REQUESTED) != 0; + + if ((eventBits & OTA_TASK_EVENT_WIFI_DISCONNECTED) != 0) { + ESP_LOGD(TAG, "WiFi disconnected"); + connected = false; + continue; // No further processing needed. + } + + if ((eventBits & OTA_TASK_EVENT_WIFI_CONNECTED) != 0 && !connected) { + ESP_LOGD(TAG, "WiFi connected"); + connected = true; + } + + // If we're not connected, continue. + if (!connected) { + ESP_LOGD(TAG, "Not connected, skipping update check"); + continue; + } + + std::int64_t now = OpenShock::millis(); + + Config::OtaUpdateConfig config; + if (!Config::GetOtaUpdateConfig(config)) { + ESP_LOGE(TAG, "Failed to get OTA update config"); + continue; + } + + if (!config.isEnabled) { + ESP_LOGD(TAG, "OTA updates are disabled, skipping update check"); + continue; + } + + bool firstCheck = lastUpdateCheck == 0; + std::int64_t diff = now - lastUpdateCheck; + std::int64_t diffMins = diff / 60'000LL; + + bool check = false; + check |= config.checkOnStartup && firstCheck; // On startup + check |= config.checkPeriodically && diffMins >= config.checkInterval; // Periodically + check |= updateRequested && (firstCheck || diffMins >= 1); // Update requested + + if (!check) { + continue; + } + + lastUpdateCheck = now; + + if (config.requireManualApproval) { + ESP_LOGD(TAG, "Manual approval required, skipping update check"); + // TODO: IMPLEMENT + continue; + } + + OpenShock::SemVer version; + if (updateRequested) { + updateRequested = false; + + if (!_tryGetRequestedVersion(version)) { + ESP_LOGE(TAG, "Failed to get requested version"); + continue; + } + + ESP_LOGD(TAG, "Update requested for version %s", version.toString().c_str()); // TODO: This is abusing the SemVer::toString() method causing alot of string copies, fix this + } else { + ESP_LOGD(TAG, "Checking for updates"); + + // Fetch current version. + if (!OtaUpdateManager::TryGetFirmwareVersion(config.updateChannel, version)) { + ESP_LOGE(TAG, "Failed to fetch firmware version"); + continue; + } + + ESP_LOGD(TAG, "Remote version: %s", version.toString().c_str()); // TODO: This is abusing the SemVer::toString() method causing alot of string copies, fix this + } + + if (version.toString() == OPENSHOCK_FW_VERSION) { // TODO: This is abusing the SemVer::toString() method causing alot of string copies, fix this + ESP_LOGI(TAG, "Requested version is already installed"); + continue; + } + + // Generate random int32_t for this update. + std::int32_t updateId = static_cast(esp_random()); + if (!Config::SetOtaUpdateId(updateId)) { + ESP_LOGE(TAG, "Failed to set OTA update ID"); + continue; + } + + if (!Serialization::Gateway::SerializeOtaInstallStartedMessage(updateId, version, GatewayConnectionManager::SendMessageBIN)) { + ESP_LOGE(TAG, "Failed to serialize OTA install started message"); + continue; + } + + if (!_sendProgressMessage(Serialization::Gateway::OtaInstallProgressTask::FetchingMetadata, 0.0f)) { + continue; + } + + // Fetch current release. + OtaUpdateManager::FirmwareRelease release; + if (!OtaUpdateManager::TryGetFirmwareRelease(version, release)) { + ESP_LOGE(TAG, "Failed to fetch firmware release"); // TODO: Send error message to server + _sendFailureMessage("Failed to fetch firmware release"); + continue; + } + + // Print release. + ESP_LOGD(TAG, "Firmware release:"); + ESP_LOGD(TAG, " Version: %s", version.toString().c_str()); // TODO: This is abusing the SemVer::toString() method causing alot of string copies, fix this + ESP_LOGD(TAG, " App binary URL: %s", release.appBinaryUrl.c_str()); + ESP_LOGD(TAG, " App binary hash: %s", HexUtils::ToHex<32>(release.appBinaryHash).data()); + ESP_LOGD(TAG, " Filesystem binary URL: %s", release.filesystemBinaryUrl.c_str()); + ESP_LOGD(TAG, " Filesystem binary hash: %s", HexUtils::ToHex<32>(release.filesystemBinaryHash).data()); + + // Get available app update partition. + const esp_partition_t* appPartition = esp_ota_get_next_update_partition(nullptr); + if (appPartition == nullptr) { + ESP_LOGE(TAG, "Failed to get app update partition"); // TODO: Send error message to server + _sendFailureMessage("Failed to get app update partition"); + continue; + } + + // Get filesystem partition. + const esp_partition_t* filesystemPartition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, "static0"); + if (filesystemPartition == nullptr) { + ESP_LOGE(TAG, "Failed to find filesystem partition"); // TODO: Send error message to server + _sendFailureMessage("Failed to find filesystem partition"); + continue; + } + + // Flash app and filesystem partitions. + if (!_flashFilesystemPartition(filesystemPartition, release.filesystemBinaryUrl, release.filesystemBinaryHash)) continue; + if (!_flashAppPartition(appPartition, release.appBinaryUrl, release.appBinaryHash)) continue; + + // Set OTA boot type in config. + if (!Config::SetOtaFirmwareBootType(OpenShock::FirmwareBootType::NewFirmware)) { + ESP_LOGE(TAG, "Failed to set OTA firmware boot type"); + _sendFailureMessage("Failed to set OTA firmware boot type"); + continue; + } + + // Send reboot message. + _sendProgressMessage(Serialization::Gateway::OtaInstallProgressTask::Rebooting, 0.0f); + + // Restart. + ESP_LOGI(TAG, "Restarting in 1 seconds..."); + vTaskDelay(pdMS_TO_TICKS(1000)); + esp_restart(); + + _sendFailureMessage("Well, this is awkward..."); + } +} + +bool _tryGetStringList(StringView url, std::vector& list) { + auto response = OpenShock::HTTP::GetString( + url, + { + {"Accept", "text/plain"} + }, + {200, 304} + ); + if (response.result != OpenShock::HTTP::RequestResult::Success) { + ESP_LOGE(TAG, "Failed to fetch list: [%u] %s", response.code, response.data.c_str()); + return false; + } + + list.clear(); + + OpenShock::StringView data = response.data; + + for (auto line : data.splitLines()) { + line = line.trim(); + + if (line.isNullOrEmpty()) { + continue; + } + + list.push_back(line.toString()); + } + + return true; +} + +bool OtaUpdateManager::Init() { + ESP_LOGD(TAG, "Fetching current partition"); + + // Fetch current partition info. + const esp_partition_t* partition = esp_ota_get_running_partition(); + if (partition == nullptr) { + ESP_PANIC(TAG, "Failed to get currently running partition"); + return false; // This will never be reached, but the compiler doesn't know that. + } + + ESP_LOGD(TAG, "Fetching partition state"); + + // Get OTA state for said partition. + esp_ota_img_states_t states; + esp_err_t err = esp_ota_get_state_partition(partition, &states); + if (err != ESP_OK) { + ESP_PANIC(TAG, "Failed to get partition state: %s", esp_err_to_name(err)); + return false; // This will never be reached, but the compiler doesn't know that. + } + + ESP_LOGD(TAG, "Partition state: %u", states); + + // If the currently booting partition is being verified, set correct state. + _otaValidatingApp = states == ESP_OTA_IMG_PENDING_VERIFY; + + // Configure event triggers. + Config::OtaUpdateConfig otaUpdateConfig; + if (!Config::GetOtaUpdateConfig(otaUpdateConfig)) { + ESP_LOGE(TAG, "Failed to get OTA update config"); + return false; + } + + WiFi.onEvent(_otaEvGotIPHandler, ARDUINO_EVENT_WIFI_STA_GOT_IP); + WiFi.onEvent(_otaEvGotIPHandler, ARDUINO_EVENT_WIFI_STA_GOT_IP6); + WiFi.onEvent(_otaEvWiFiDisconnectedHandler, ARDUINO_EVENT_WIFI_STA_DISCONNECTED); + + // Start OTA update task. + TaskUtils::TaskCreateExpensive(_otaUpdateTask, "OTA Update", 8192, nullptr, 1, &_taskHandle); + + return true; +} + +bool OtaUpdateManager::TryGetFirmwareVersion(OtaUpdateChannel channel, OpenShock::SemVer& version) { + const char* channelIndexUrl = nullptr; + switch (channel) { + case OtaUpdateChannel::Stable: + channelIndexUrl = OPENSHOCK_FW_CDN_STABLE_URL; + break; + case OtaUpdateChannel::Beta: + channelIndexUrl = OPENSHOCK_FW_CDN_BETA_URL; + break; + case OtaUpdateChannel::Develop: + channelIndexUrl = OPENSHOCK_FW_CDN_DEVELOP_URL; + break; + default: + ESP_LOGE(TAG, "Unknown channel: %u", channel); + return false; + } + + ESP_LOGD(TAG, "Fetching firmware version from %s", channelIndexUrl); + + auto response = OpenShock::HTTP::GetString( + channelIndexUrl, + { + {"Accept", "text/plain"} + }, + {200, 304} + ); + if (response.result != OpenShock::HTTP::RequestResult::Success) { + ESP_LOGE(TAG, "Failed to fetch firmware version: [%u] %s", response.code, response.data.c_str()); + return false; + } + + if (!OpenShock::TryParseSemVer(response.data, version)) { + ESP_LOGE(TAG, "Failed to parse firmware version: %.*s", response.data.size(), response.data.data()); + return false; + } + + return true; +} + +bool OtaUpdateManager::TryGetFirmwareBoards(const OpenShock::SemVer& version, std::vector& boards) { + std::string channelIndexUrl; + if (!FormatToString(channelIndexUrl, OPENSHOCK_FW_CDN_BOARDS_INDEX_URL_FORMAT, version.toString().c_str())) { // TODO: This is abusing the SemVer::toString() method causing alot of string copies, fix this + ESP_LOGE(TAG, "Failed to format URL"); + return false; + } + + ESP_LOGD(TAG, "Fetching firmware boards from %s", channelIndexUrl.c_str()); + + if (!_tryGetStringList(channelIndexUrl.c_str(), boards)) { + ESP_LOGE(TAG, "Failed to fetch firmware boards"); + return false; + } + + return true; +} + +bool _tryParseIntoHash(const std::string& hash, std::uint8_t (&hashBytes)[32]) { + if (!HexUtils::TryParseHex(hash.data(), hash.size(), hashBytes, 32)) { + ESP_LOGE(TAG, "Failed to parse hash: %.*s", hash.size(), hash.data()); + return false; + } + + return true; +} + +bool OtaUpdateManager::TryGetFirmwareRelease(const OpenShock::SemVer& version, FirmwareRelease& release) { + auto versionStr = version.toString(); // TODO: This is abusing the SemVer::toString() method causing alot of string copies, fix this + + if (!FormatToString(release.appBinaryUrl, OPENSHOCK_FW_CDN_APP_URL_FORMAT, versionStr.c_str())) { + ESP_LOGE(TAG, "Failed to format URL"); + return false; + } + + if (!FormatToString(release.filesystemBinaryUrl, OPENSHOCK_FW_CDN_FILESYSTEM_URL_FORMAT, versionStr.c_str())) { + ESP_LOGE(TAG, "Failed to format URL"); + return false; + } + + // Construct hash URLs. + std::string sha256HashesUrl; + if (!FormatToString(sha256HashesUrl, OPENSHOCK_FW_CDN_SHA256_HASHES_URL_FORMAT, versionStr.c_str())) { + ESP_LOGE(TAG, "Failed to format URL"); + return false; + } + + // Fetch hashes. + auto sha256HashesResponse = OpenShock::HTTP::GetString( + sha256HashesUrl.c_str(), + { + {"Accept", "text/plain"} + }, + {200, 304} + ); + if (sha256HashesResponse.result != OpenShock::HTTP::RequestResult::Success) { + ESP_LOGE(TAG, "Failed to fetch hashes: [%u] %s", sha256HashesResponse.code, sha256HashesResponse.data.c_str()); + return false; + } + + auto hashesLines = OpenShock::StringView(sha256HashesResponse.data).splitLines(); + + // Parse hashes. + bool foundAppHash = false, foundFilesystemHash = false; + for (auto line : hashesLines) { + auto parts = line.splitWhitespace(); + if (parts.size() != 2) { + ESP_LOGE(TAG, "Invalid hashes entry: %.*s", line.size(), line.data()); + return false; + } + + auto hash = parts[0].trim(); + auto file = parts[1].trim(); + + if (file.startsWith("./")) { + file = file.substr(2); + } + + if (hash.size() != 64) { + ESP_LOGE(TAG, "Invalid hash: %.*s", hash.size(), hash.data()); + return false; + } + + if (file == "app.bin") { + if (foundAppHash) { + ESP_LOGE(TAG, "Duplicate hash for app.bin"); + return false; + } + + if (!_tryParseIntoHash(hash.toString(), release.appBinaryHash)) { + return false; + } + + foundAppHash = true; + } else if (file == "staticfs.bin") { + if (foundFilesystemHash) { + ESP_LOGE(TAG, "Duplicate hash for staticfs.bin"); + return false; + } + + if (!_tryParseIntoHash(hash.toString(), release.filesystemBinaryHash)) { + return false; + } + + foundFilesystemHash = true; + } + } + + return true; +} + +bool OtaUpdateManager::TryStartFirmwareInstallation(const OpenShock::SemVer& version) { + ESP_LOGD(TAG, "Requesting firmware version %s", version.toString().c_str()); // TODO: This is abusing the SemVer::toString() method causing alot of string copies, fix this + + return _tryQueueUpdateRequest(version); +} + +bool OtaUpdateManager::IsValidatingApp() { + return _otaValidatingApp; +} + +void OtaUpdateManager::InvalidateAndRollback() { + // Set OTA boot type in config. + if (!Config::SetOtaFirmwareBootType(OpenShock::FirmwareBootType::Rollback)) { + ESP_PANIC(TAG, "Failed to set OTA firmware boot type in critical section"); // TODO: THIS IS A CRITICAL SECTION, WHAT DO WE DO? + return; + } + + switch (esp_ota_mark_app_invalid_rollback_and_reboot()) { + case ESP_FAIL: + ESP_LOGE(TAG, "Rollback failed (ESP_FAIL)"); + break; + case ESP_ERR_OTA_ROLLBACK_FAILED: + ESP_LOGE(TAG, "Rollback failed (ESP_ERR_OTA_ROLLBACK_FAILED)"); + break; + default: + ESP_LOGE(TAG, "Rollback failed (Unknown)"); + break; + } + + // Set OTA boot type in config. + if (!Config::SetOtaFirmwareBootType(OpenShock::FirmwareBootType::Normal)) { + ESP_LOGE(TAG, "Failed to set OTA firmware boot type"); + } + + esp_restart(); +} + +void OtaUpdateManager::ValidateApp() { + if (esp_ota_mark_app_valid_cancel_rollback() != ESP_OK) { + // Set OTA boot type in config. + if (!Config::SetOtaFirmwareBootType(OpenShock::FirmwareBootType::Rollback)) { // TODO: Check if we are in new firmware, if so set to rollback, else set to normal + ESP_LOGE(TAG, "Failed to set OTA firmware boot type"); + } + + ESP_PANIC(TAG, "Unable to mark app as valid, WTF?"); // TODO: Wtf do we do here? + } + + // Set OTA boot type in config. + if (!Config::SetOtaFirmwareBootType(OpenShock::FirmwareBootType::Normal)) { + ESP_PANIC(TAG, "Failed to set OTA firmware boot type in critical section"); // TODO: THIS IS A CRITICAL SECTION, WHAT DO WE DO? + } +} diff --git a/src/config/Config.cpp b/src/config/Config.cpp index 7d276f9c..ed7eaf4e 100644 --- a/src/config/Config.cpp +++ b/src/config/Config.cpp @@ -272,6 +272,18 @@ bool Config::GetWiFiConfig(Config::WiFiConfig& out) { return true; } +bool Config::GetOtaUpdateConfig(Config::OtaUpdateConfig& out) { + ScopedReadLock lock(&_configMutex); + if (!lock.isLocked()) { + ESP_LOGE(TAG, "Failed to acquire read lock"); + return false; + } + + out = _configData.otaUpdate; + + return true; +} + bool Config::GetWiFiCredentials(cJSON* array, bool withSensitiveData) { ScopedReadLock lock(&_configMutex); if (!lock.isLocked()) { @@ -567,6 +579,56 @@ bool Config::ClearWiFiCredentials() { return _trySaveConfig(); } +bool Config::GetOtaUpdateId(std::int32_t& out) { + ScopedReadLock lock(&_configMutex); + if (!lock.isLocked()) { + ESP_LOGE(TAG, "Failed to acquire read lock"); + } + + out = _configData.otaUpdate.updateId; + + return true; +} + +bool Config::SetOtaUpdateId(std::int32_t updateId) { + ScopedWriteLock lock(&_configMutex); + if (!lock.isLocked()) { + ESP_LOGE(TAG, "Failed to acquire write lock"); + } + + if (_configData.otaUpdate.updateId == updateId) { + return true; + } + + _configData.otaUpdate.updateId = updateId; + return _trySaveConfig(); +} + +bool Config::GetOtaFirmwareBootType(FirmwareBootType& out) { + ScopedReadLock lock(&_configMutex); + if (!lock.isLocked()) { + ESP_LOGE(TAG, "Failed to acquire read lock"); + } + + out = _configData.otaUpdate.bootType; + + return true; +} + +bool Config::SetOtaFirmwareBootType(FirmwareBootType bootType) { + ScopedWriteLock lock(&_configMutex); + if (!lock.isLocked()) { + ESP_LOGE(TAG, "Failed to acquire write lock"); + } + + if (_configData.otaUpdate.bootType == bootType) { + return true; + } + + _configData.otaUpdate.bootType = bootType; + return _trySaveConfig(); +} + bool Config::HasBackendAuthToken() { ScopedReadLock lock(&_configMutex); if (!lock.isLocked()) { diff --git a/src/config/OtaUpdateConfig.cpp b/src/config/OtaUpdateConfig.cpp new file mode 100644 index 00000000..af8d8acf --- /dev/null +++ b/src/config/OtaUpdateConfig.cpp @@ -0,0 +1,115 @@ +#include "config/OtaUpdateConfig.h" + +#include "config/internal/utils.h" +#include "Logging.h" + +const char* const TAG = "Config::OtaUpdateConfig"; + +using namespace OpenShock::Config; + +OtaUpdateConfig::OtaUpdateConfig() { + ToDefault(); +} + +OtaUpdateConfig::OtaUpdateConfig( + bool isEnabled, + std::string cdnDomain, + OtaUpdateChannel updateChannel, + bool checkOnStartup, + bool checkPeriodically, + std::uint16_t checkInterval, + bool allowBackendManagement, + bool requireManualApproval, + std::int32_t updateId, + FirmwareBootType bootType +) { + this->isEnabled = isEnabled; + this->cdnDomain = cdnDomain; + this->updateChannel = updateChannel; + this->checkOnStartup = checkOnStartup; + this->checkPeriodically = checkPeriodically; + this->checkInterval = checkInterval; + this->allowBackendManagement = allowBackendManagement; + this->requireManualApproval = requireManualApproval; + this->updateId = updateId; + this->bootType = bootType; +} + +void OtaUpdateConfig::ToDefault() { + isEnabled = true; + cdnDomain = OPENSHOCK_FW_CDN_DOMAIN; + updateChannel = OtaUpdateChannel::Stable; + checkOnStartup = false; + checkPeriodically = false; + checkInterval = 30; // 30 minutes + allowBackendManagement = true; + requireManualApproval = false; + updateId = 0; + bootType = FirmwareBootType::Normal; +} + +bool OtaUpdateConfig::FromFlatbuffers(const Serialization::Configuration::OtaUpdateConfig* config) { + if (config == nullptr) { + ESP_LOGE(TAG, "config is null"); + return false; + } + + isEnabled = config->is_enabled(); + Internal::Utils::FromFbsStr(cdnDomain, config->cdn_domain(), OPENSHOCK_FW_CDN_DOMAIN); + updateChannel = config->update_channel(); + checkOnStartup = config->check_on_startup(); + checkPeriodically = config->check_periodically(); + checkInterval = config->check_interval(); + allowBackendManagement = config->allow_backend_management(); + requireManualApproval = config->require_manual_approval(); + updateId = config->update_id(); + bootType = config->boot_type(); + + return true; +} + +flatbuffers::Offset OtaUpdateConfig::ToFlatbuffers(flatbuffers::FlatBufferBuilder& builder, bool withSensitiveData) const { + return Serialization::Configuration::CreateOtaUpdateConfig(builder, isEnabled, builder.CreateString(cdnDomain), updateChannel, checkPeriodically, checkInterval, allowBackendManagement, requireManualApproval); +} + +bool OtaUpdateConfig::FromJSON(const cJSON* json) { + if (json == nullptr) { + ESP_LOGE(TAG, "json is null"); + return false; + } + + if (!cJSON_IsObject(json)) { + ESP_LOGE(TAG, "json is not an object"); + return false; + } + + Internal::Utils::FromJsonBool(isEnabled, json, "isEnabled", true); + Internal::Utils::FromJsonStr(cdnDomain, json, "cdnDomain", OPENSHOCK_FW_CDN_DOMAIN); + Internal::Utils::FromJsonStrParsed(updateChannel, json, "updateChannel", OpenShock::TryParseOtaUpdateChannel, OpenShock::OtaUpdateChannel::Stable); + Internal::Utils::FromJsonBool(checkOnStartup, json, "checkOnStartup", true); + Internal::Utils::FromJsonBool(checkPeriodically, json, "checkPeriodically", false); + Internal::Utils::FromJsonU16(checkInterval, json, "checkInterval", 0); + Internal::Utils::FromJsonBool(allowBackendManagement, json, "allowBackendManagement", true); + Internal::Utils::FromJsonBool(requireManualApproval, json, "requireManualApproval", false); + Internal::Utils::FromJsonI32(updateId, json, "updateId", 0); + Internal::Utils::FromJsonStrParsed(bootType, json, "bootType", OpenShock::TryParseFirmwareBootType, OpenShock::FirmwareBootType::Normal); + + return true; +} + +cJSON* OtaUpdateConfig::ToJSON(bool withSensitiveData) const { + cJSON* root = cJSON_CreateObject(); + + cJSON_AddBoolToObject(root, "isEnabled", isEnabled); + cJSON_AddStringToObject(root, "cdnDomain", cdnDomain.c_str()); + cJSON_AddStringToObject(root, "updateChannel", OpenShock::Serialization::Configuration::EnumNameOtaUpdateChannel(updateChannel)); + cJSON_AddBoolToObject(root, "checkOnStartup", checkOnStartup); + cJSON_AddBoolToObject(root, "checkPeriodically", checkPeriodically); + cJSON_AddNumberToObject(root, "checkInterval", checkInterval); + cJSON_AddBoolToObject(root, "allowBackendManagement", allowBackendManagement); + cJSON_AddBoolToObject(root, "requireManualApproval", requireManualApproval); + cJSON_AddNumberToObject(root, "updateId", updateId); + cJSON_AddStringToObject(root, "bootType", OpenShock::Serialization::Types::EnumNameFirmwareBootType(bootType)); + + return root; +} diff --git a/src/config/RootConfig.cpp b/src/config/RootConfig.cpp index 60f030f2..20e8ba41 100644 --- a/src/config/RootConfig.cpp +++ b/src/config/RootConfig.cpp @@ -45,6 +45,11 @@ bool RootConfig::FromFlatbuffers(const Serialization::Configuration::Config* con return false; } + if (!otaUpdate.FromFlatbuffers(config->ota_update())) { + ESP_LOGE(TAG, "Unable to load ota update config"); + return false; + } + return true; } @@ -54,8 +59,9 @@ flatbuffers::Offset RootConfig: auto captivePortalOffset = captivePortal.ToFlatbuffers(builder, withSensitiveData); auto backendOffset = backend.ToFlatbuffers(builder, withSensitiveData); auto serialInputOffset = serialInput.ToFlatbuffers(builder, withSensitiveData); + auto otaUpdateOffset = otaUpdate.ToFlatbuffers(builder, withSensitiveData); - return Serialization::Configuration::CreateConfig(builder, rfOffset, wifiOffset, captivePortalOffset, backendOffset, serialInputOffset); + return Serialization::Configuration::CreateConfig(builder, rfOffset, wifiOffset, captivePortalOffset, backendOffset, serialInputOffset, otaUpdateOffset); } bool RootConfig::FromJSON(const cJSON* json) { @@ -94,6 +100,11 @@ bool RootConfig::FromJSON(const cJSON* json) { return false; } + if (!otaUpdate.FromJSON(cJSON_GetObjectItemCaseSensitive(json, "otaUpdate"))) { + ESP_LOGE(TAG, "Unable to load ota update config"); + return false; + } + return true; } @@ -105,6 +116,7 @@ cJSON* RootConfig::ToJSON(bool withSensitiveData) const { cJSON_AddItemToObject(root, "captivePortal", captivePortal.ToJSON(withSensitiveData)); cJSON_AddItemToObject(root, "backend", backend.ToJSON(withSensitiveData)); cJSON_AddItemToObject(root, "serialInput", serialInput.ToJSON(withSensitiveData)); + cJSON_AddItemToObject(root, "otaUpdate", otaUpdate.ToJSON(withSensitiveData)); return root; } diff --git a/src/config/internal/utils.cpp b/src/config/internal/utils.cpp index 3c7e4913..8b3d014f 100644 --- a/src/config/internal/utils.cpp +++ b/src/config/internal/utils.cpp @@ -71,6 +71,10 @@ bool Config::Internal::Utils::FromJsonU16(std::uint16_t& val, const cJSON* json, return _utilFromJsonInt(val, json, name, defaultVal, 0, UINT16_MAX); } +bool Config::Internal::Utils::FromJsonI32(std::int32_t& val, const cJSON* json, const char* name, std::int32_t defaultVal) { + return _utilFromJsonInt(val, json, name, defaultVal, INT32_MIN, INT32_MAX); +} + bool Config::Internal::Utils::FromJsonStr(std::string& str, const cJSON* json, const char* name, const char* defaultStr) { const cJSON* jsonVal = cJSON_GetObjectItemCaseSensitive(json, name); if (jsonVal == nullptr) { diff --git a/src/event_handlers/websocket/Gateway.cpp b/src/event_handlers/websocket/Gateway.cpp index 4c9ef0f7..2d3849ef 100644 --- a/src/event_handlers/websocket/Gateway.cpp +++ b/src/event_handlers/websocket/Gateway.cpp @@ -4,7 +4,7 @@ #include "Logging.h" -#include "serialization/_fbs/ServerToDeviceMessage_generated.h" +#include "serialization/_fbs/GatewayToDeviceMessage_generated.h" #include @@ -13,9 +13,9 @@ static const char* TAG = "ServerMessageHandlers"; -namespace Schemas = OpenShock::Serialization; +namespace Schemas = OpenShock::Serialization::Gateway; namespace Handlers = OpenShock::MessageHandlers::Server::_Private; -typedef Schemas::ServerToDeviceMessagePayload PayloadType; +typedef Schemas::GatewayToDeviceMessagePayload PayloadType; using namespace OpenShock; @@ -29,13 +29,14 @@ static std::array s_serverHandlers = []() SET_HANDLER(PayloadType::ShockerCommandList, Handlers::HandleShockerCommandList); SET_HANDLER(PayloadType::CaptivePortalConfig, Handlers::HandleCaptivePortalConfig); + SET_HANDLER(PayloadType::OtaInstall, Handlers::HandleOtaInstall); return handlers; }(); void EventHandlers::WebSocket::HandleGatewayBinary(const std::uint8_t* data, std::size_t len) { // Deserialize - auto msg = flatbuffers::GetRoot(data); + auto msg = flatbuffers::GetRoot(data); if (msg == nullptr) { ESP_LOGE(TAG, "Failed to deserialize message"); return; diff --git a/src/event_handlers/websocket/gateway/CaptivePortalConfig.cpp b/src/event_handlers/websocket/gateway/CaptivePortalConfig.cpp index 60616e30..b29216d3 100644 --- a/src/event_handlers/websocket/gateway/CaptivePortalConfig.cpp +++ b/src/event_handlers/websocket/gateway/CaptivePortalConfig.cpp @@ -9,7 +9,7 @@ const char* const TAG = "ServerMessageHandlers"; using namespace OpenShock::MessageHandlers::Server; -void _Private::HandleCaptivePortalConfig(const OpenShock::Serialization::ServerToDeviceMessage* root) { +void _Private::HandleCaptivePortalConfig(const OpenShock::Serialization::Gateway::GatewayToDeviceMessage* root) { auto msg = root->payload_as_CaptivePortalConfig(); if (msg == nullptr) { ESP_LOGE(TAG, "Payload cannot be parsed as CaptivePortalConfig"); diff --git a/src/event_handlers/websocket/gateway/OtaInstall.cpp b/src/event_handlers/websocket/gateway/OtaInstall.cpp new file mode 100644 index 00000000..18634fee --- /dev/null +++ b/src/event_handlers/websocket/gateway/OtaInstall.cpp @@ -0,0 +1,42 @@ +#include "event_handlers/impl/WSGateway.h" + +#include "CaptivePortal.h" +#include "Logging.h" +#include "OtaUpdateManager.h" + +#include + +const char* const TAG = "ServerMessageHandlers"; + +using namespace OpenShock::MessageHandlers::Server; + +void _Private::HandleOtaInstall(const OpenShock::Serialization::Gateway::GatewayToDeviceMessage* root) { + auto msg = root->payload_as_OtaInstall(); + if (msg == nullptr) { + ESP_LOGE(TAG, "Payload cannot be parsed as OtaInstall"); + return; + } + + auto semver = msg->version(); + if (semver == nullptr) { + ESP_LOGE(TAG, "Version cannot be parsed"); + return; + } + + StringView prerelease, build; + if (semver->prerelease() != nullptr) { + prerelease = StringView(semver->prerelease()->c_str(), semver->prerelease()->size()); + } + if (semver->build() != nullptr) { + build = StringView(semver->build()->c_str(), semver->build()->size()); + } + + OpenShock::SemVer version(semver->major(), semver->minor(), semver->patch(), prerelease, build); + + ESP_LOGI(TAG, "OTA install requested for version %s", version.toString().c_str()); // TODO: This is abusing the SemVer::toString() method causing alot of string copies, fix this + + if (!OpenShock::OtaUpdateManager::TryStartFirmwareInstallation(version)) { + ESP_LOGE(TAG, "Failed to install firmware"); // TODO: Send error message to server + return; + } +} diff --git a/src/event_handlers/websocket/gateway/ShockerCommandList.cpp b/src/event_handlers/websocket/gateway/ShockerCommandList.cpp index 55cdd99e..6145c16d 100644 --- a/src/event_handlers/websocket/gateway/ShockerCommandList.cpp +++ b/src/event_handlers/websocket/gateway/ShockerCommandList.cpp @@ -10,7 +10,7 @@ const char* const TAG = "ServerMessageHandlers"; using namespace OpenShock::MessageHandlers::Server; -void _Private::HandleShockerCommandList(const OpenShock::Serialization::ServerToDeviceMessage* root) { +void _Private::HandleShockerCommandList(const OpenShock::Serialization::Gateway::GatewayToDeviceMessage* root) { auto msg = root->payload_as_ShockerCommandList(); if (msg == nullptr) { ESP_LOGE(TAG, "Payload cannot be parsed as ShockerCommandList"); diff --git a/src/event_handlers/websocket/gateway/_InvalidMessage.cpp b/src/event_handlers/websocket/gateway/_InvalidMessage.cpp index 68ef41b1..f5eb97d8 100644 --- a/src/event_handlers/websocket/gateway/_InvalidMessage.cpp +++ b/src/event_handlers/websocket/gateway/_InvalidMessage.cpp @@ -7,7 +7,7 @@ const char* const TAG = "ServerMessageHandlers"; using namespace OpenShock::MessageHandlers::Server; -void _Private::HandleInvalidMessage(const OpenShock::Serialization::ServerToDeviceMessage* root) { +void _Private::HandleInvalidMessage(const OpenShock::Serialization::Gateway::GatewayToDeviceMessage* root) { if (root == nullptr) { ESP_LOGE(TAG, "Message cannot be parsed"); return; diff --git a/src/main.cpp b/src/main.cpp index a5bb283e..66569565 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,26 +6,22 @@ #include "event_handlers/Init.h" #include "GatewayConnectionManager.h" #include "Logging.h" +#include "OtaUpdateManager.h" #include "serial/SerialInputHandler.h" +#include "util/TaskUtils.h" #include "VisualStateManager.h" #include "wifi/WiFiManager.h" #include "wifi/WiFiScanManager.h" -#include +#include #include const char* const TAG = "OpenShock"; -void setup() { - Serial.begin(115'200); - - if (!LittleFS.begin(true, "/static", 10, "static0")) { - ESP_PANIC(TAG, "Unable to mount LittleFS"); - } - +// Internal setup function, returns true if setup succeeded, false otherwise. +bool trySetup() { OpenShock::EventHandlers::Init(); - OpenShock::VisualStateManager::Init(); OpenShock::EStopManager::Init(100); // 100ms update interval @@ -33,25 +29,80 @@ void setup() { OpenShock::Config::Init(); if (!OpenShock::SerialInputHandler::Init()) { - ESP_PANIC(TAG, "Unable to initialize SerialInputHandler"); + ESP_LOGE(TAG, "Unable to initialize SerialInputHandler"); + return false; } if (!OpenShock::CommandHandler::Init()) { ESP_LOGW(TAG, "Unable to initialize CommandHandler"); + return false; } if (!OpenShock::WiFiManager::Init()) { - ESP_PANIC(TAG, "Unable to initialize WiFiManager"); + ESP_LOGE(TAG, "Unable to initialize WiFiManager"); + return false; } if (!OpenShock::GatewayConnectionManager::Init()) { - ESP_PANIC(TAG, "Unable to initialize GatewayConnectionManager"); + ESP_LOGE(TAG, "Unable to initialize GatewayConnectionManager"); + return false; + } + + return true; +} + +// OTA setup is the same as normal setup, but we invalidate the currently running app, and roll back if it fails. +void otaSetup() { + ESP_LOGI(TAG, "Validating OTA app"); + + if (!trySetup()) { + ESP_LOGE(TAG, "Unable to validate OTA app, rolling back"); + OpenShock::OtaUpdateManager::InvalidateAndRollback(); + } + + ESP_LOGI(TAG, "Marking OTA app as valid"); + + OpenShock::OtaUpdateManager::ValidateApp(); + + ESP_LOGI(TAG, "Done validating OTA app"); +} + +// App setup is the same as normal setup, but we restart if it fails. +void appSetup() { + if (!trySetup()) { + ESP_LOGI(TAG, "Restarting in 5 seconds..."); + vTaskDelay(pdMS_TO_TICKS(5000)); + esp_restart(); + } +} + +// Arduino setup function +void setup() { + Serial.begin(115'200); + + OpenShock::OtaUpdateManager::Init(); + if (OpenShock::OtaUpdateManager::IsValidatingApp()) { + otaSetup(); + } else { + appSetup(); + } +} + +void main_app(void* arg) { + while (true) { + OpenShock::SerialInputHandler::Update(); + OpenShock::CaptivePortal::Update(); + OpenShock::GatewayConnectionManager::Update(); + OpenShock::WiFiManager::Update(); + + vTaskDelay(5); // 5 ticks update interval } } void loop() { - OpenShock::SerialInputHandler::Update(); - OpenShock::CaptivePortal::Update(); - OpenShock::GatewayConnectionManager::Update(); - OpenShock::WiFiManager::Update(); + // Start the main task + OpenShock::TaskUtils::TaskCreateExpensive(main_app, "main_app", 8192, nullptr, 1, nullptr); + + // Kill the loop task (Arduino is stinky) + vTaskDelete(nullptr); } diff --git a/src/serialization/WSGateway.cpp b/src/serialization/WSGateway.cpp index eed037bb..5fec63f1 100644 --- a/src/serialization/WSGateway.cpp +++ b/src/serialization/WSGateway.cpp @@ -1 +1,92 @@ #include "serialization/WSGateway.h" + +#include "config/Config.h" +#include "Logging.h" +#include "Time.h" + +const char* const TAG = "WSGateway"; + +using namespace OpenShock::Serialization; + +bool Gateway::SerializeKeepAliveMessage(Common::SerializationCallbackFn callback) { + flatbuffers::FlatBufferBuilder builder(256); // TODO: Profile this and adjust the size accordingly + + std::int64_t uptime = OpenShock::millis(); + if (uptime < 0) { + ESP_LOGE(TAG, "Failed to get uptime"); + return false; + } + + Gateway::KeepAlive keepAlive(static_cast(uptime)); + auto keepAliveOffset = builder.CreateStruct(keepAlive); + + auto msg = Gateway::CreateDeviceToGatewayMessage(builder, Gateway::DeviceToGatewayMessagePayload::KeepAlive, keepAliveOffset.Union()); + + builder.Finish(msg); + + auto span = builder.GetBufferSpan(); + + return callback(span.data(), span.size()); +} + +bool Gateway::SerializeBootStatusMessage(std::int32_t updateId, OpenShock::FirmwareBootType bootType, const OpenShock::SemVer& version, Common::SerializationCallbackFn callback) { + flatbuffers::FlatBufferBuilder builder(256); // TODO: Profile this and adjust the size accordingly + + auto fbsVersion = Types::CreateSemVerDirect(builder, version.major, version.minor, version.patch, version.prerelease.data(), version.build.data()); + + auto fbsBootStatus = Gateway::CreateBootStatus(builder, bootType, fbsVersion); + + auto msg = Gateway::CreateDeviceToGatewayMessage(builder, Gateway::DeviceToGatewayMessagePayload::BootStatus, fbsBootStatus.Union()); + + builder.Finish(msg); + + auto span = builder.GetBufferSpan(); + + return callback(span.data(), span.size()); +} + +bool Gateway::SerializeOtaInstallStartedMessage(std::int32_t updateId, const OpenShock::SemVer& version, Common::SerializationCallbackFn callback) { + flatbuffers::FlatBufferBuilder builder(256); // TODO: Profile this and adjust the size accordingly + + auto versionOffset = Types::CreateSemVerDirect(builder, version.major, version.minor, version.patch, version.prerelease.data(), version.build.data()); + + auto otaInstallStartedOffset = Gateway::CreateOtaInstallStarted(builder, updateId, versionOffset); + + auto msg = Gateway::CreateDeviceToGatewayMessage(builder, Gateway::DeviceToGatewayMessagePayload::OtaInstallStarted, otaInstallStartedOffset.Union()); + + builder.Finish(msg); + + auto span = builder.GetBufferSpan(); + + return callback(span.data(), span.size()); +} + +bool Gateway::SerializeOtaInstallProgressMessage(std::int32_t updateId, Gateway::OtaInstallProgressTask task, float progress, Common::SerializationCallbackFn callback) { + flatbuffers::FlatBufferBuilder builder(256); // TODO: Profile this and adjust the size accordingly + + auto otaInstallProgressOffset = Gateway::CreateOtaInstallProgress(builder, updateId, task, progress); + + auto msg = Gateway::CreateDeviceToGatewayMessage(builder, Gateway::DeviceToGatewayMessagePayload::OtaInstallProgress, otaInstallProgressOffset.Union()); + + builder.Finish(msg); + + auto span = builder.GetBufferSpan(); + + return callback(span.data(), span.size()); +} + +bool Gateway::SerializeOtaInstallFailedMessage(std::int32_t updateId, StringView message, bool fatal, Common::SerializationCallbackFn callback) { + flatbuffers::FlatBufferBuilder builder(256); // TODO: Profile this and adjust the size accordingly + + auto messageOffset = builder.CreateString(message.data(), message.size()); + + auto otaInstallFailedOffset = Gateway::CreateOtaInstallFailed(builder, updateId, messageOffset, fatal); + + auto msg = Gateway::CreateDeviceToGatewayMessage(builder, Gateway::DeviceToGatewayMessagePayload::OtaInstallFailed, otaInstallFailedOffset.Union()); + + builder.Finish(msg); + + auto span = builder.GetBufferSpan(); + + return callback(span.data(), span.size()); +} diff --git a/src/util/ParitionUtils.cpp b/src/util/ParitionUtils.cpp new file mode 100644 index 00000000..422bb7b7 --- /dev/null +++ b/src/util/ParitionUtils.cpp @@ -0,0 +1,110 @@ +#include "util/PartitionUtils.h" + +#include "Hashing.h" +#include "http/HTTPRequestManager.h" +#include "Time.h" +#include "util/HexUtils.h" + +#include + +const char* const TAG = "PartitionUtils"; + +bool OpenShock::TryGetPartitionHash(const esp_partition_t* partition, char (&hash)[65]) { + std::uint8_t buffer[32]; + esp_err_t err = esp_partition_get_sha256(partition, buffer); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to get partition hash: %s", esp_err_to_name(err)); + return false; + } + + // Copy the hash to the output buffer + HexUtils::ToHex<32>(buffer, hash, false); + + return true; +} + +bool OpenShock::FlashPartitionFromUrl(const esp_partition_t* partition, StringView remoteUrl, const std::uint8_t (&remoteHash)[32], std::function progressCallback) { + OpenShock::SHA256 sha256; + if (!sha256.begin()) { + ESP_LOGE(TAG, "Failed to initialize SHA256 hash"); + return false; + } + + std::size_t contentLength = 0; + std::size_t contentWritten = 0; + std::int64_t lastProgress = 0; + + auto sizeValidator = [partition, &contentLength, progressCallback, &lastProgress](std::size_t size) -> bool { + if (size > partition->size) { + ESP_LOGE(TAG, "Remote partition binary is too large"); + return false; + } + + // Erase app partition. + if (esp_partition_erase_range(partition, 0, partition->size) != ESP_OK) { + ESP_LOGE(TAG, "Failed to erase partition in preparation for update"); + return false; + } + + contentLength = size; + + lastProgress = OpenShock::millis(); + progressCallback(0, contentLength, 0.0f); + + return true; + }; + auto dataWriter = [partition, &sha256, &contentLength, &contentWritten, progressCallback, &lastProgress](std::size_t offset, const std::uint8_t* data, std::size_t length) -> bool { + if (esp_partition_write(partition, offset, data, length) != ESP_OK) { + ESP_LOGE(TAG, "Failed to write to partition"); + return false; + } + + if (!sha256.update(data, length)) { + ESP_LOGE(TAG, "Failed to update SHA256 hash"); + return false; + } + + contentWritten += length; + + std::int64_t now = OpenShock::millis(); + if (now - lastProgress >= 1000) { // Once per second + lastProgress = now; + progressCallback(contentWritten, contentLength, static_cast(contentWritten) / static_cast(contentLength)); + } + + return true; + }; + + // Start streaming binary to app partition. + auto appBinaryResponse = OpenShock::HTTP::Download( + remoteUrl, + { + {"Accept", "application/octet-stream"} + }, + sizeValidator, + dataWriter, + {200, 304}, + 180'000 + ); // 3 minutes + if (appBinaryResponse.result != OpenShock::HTTP::RequestResult::Success) { + ESP_LOGE(TAG, "Failed to download remote partition binary: [%u]", appBinaryResponse.code); + return false; + } + + progressCallback(contentLength, contentLength, 1.0f); + ESP_LOGD(TAG, "Wrote %u bytes to partition", appBinaryResponse.data); + + std::array localHash; + if (!sha256.finish(localHash)) { + ESP_LOGE(TAG, "Failed to finish SHA256 hash"); + return false; + } + + // Compare hashes. + if (memcmp(localHash.data(), remoteHash, 32) != 0) { + ESP_LOGE(TAG, "App binary hash mismatch"); + return false; + } + + return true; +} diff --git a/src/util/StringUtils.cpp b/src/util/StringUtils.cpp new file mode 100644 index 00000000..3d7603d2 --- /dev/null +++ b/src/util/StringUtils.cpp @@ -0,0 +1,59 @@ +#include "util/StringUtils.h" + +#include "Logging.h" + +#include +#include + +static const char* TAG = "StringUtils"; + +bool OpenShock::FormatToString(std::string& out, const char* format, ...) { + constexpr std::size_t STACK_BUFFER_SIZE = 128; + + char buffer[STACK_BUFFER_SIZE]; + char* bufferPtr = buffer; + + va_list args; + + // Try format with stack buffer. + va_start(args, format); + int result = vsnprintf(buffer, STACK_BUFFER_SIZE, format, args); + va_end(args); + + // If result is negative, something went wrong. + if (result < 0) { + ESP_LOGE(TAG, "Failed to format string"); + return false; + } + + if (result >= STACK_BUFFER_SIZE) { + // Account for null terminator. + result += 1; + + // Allocate heap buffer. + bufferPtr = new char[result]; + + // Try format with heap buffer. + va_start(args, format); + result = vsnprintf(bufferPtr, result, format, args); + va_end(args); + + // If we still fail, something is wrong. + // Free heap buffer and return false. + if (result < 0) { + delete[] bufferPtr; + ESP_LOGE(TAG, "Failed to format string"); + return false; + } + } + + // Set output string. + out = std::string(bufferPtr, result); + + // Free heap buffer if we used it. + if (bufferPtr != buffer) { + delete[] bufferPtr; + } + + return true; +} From d53787d3a1f9c50f5a749462c706d2dd2f668f4d Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Tue, 9 Jan 2024 07:46:53 +0100 Subject: [PATCH 09/24] Implement some code QOL stuffz (#179) --- include/{Constants.h => Common.h} | 8 ++++++++ include/PinPatternManager.h | 3 +++ include/RGBPatternManager.h | 3 +++ include/WebSocketDeFragger.h | 5 ++--- src/CommandHandler.cpp | 2 +- src/CompatibilityChecks.cpp | 2 +- src/config/Config.cpp | 2 +- src/config/RFConfig.cpp | 2 +- src/event_handlers/websocket/local/SetRfTxPinCommand.cpp | 2 +- src/http/JsonAPI.cpp | 2 +- src/main.cpp | 2 +- 11 files changed, 23 insertions(+), 10 deletions(-) rename include/{Constants.h => Common.h} (78%) diff --git a/include/Constants.h b/include/Common.h similarity index 78% rename from include/Constants.h rename to include/Common.h index e72a88d2..5a487fae 100644 --- a/include/Constants.h +++ b/include/Common.h @@ -2,6 +2,14 @@ #include +#define DISABLE_COPY(TypeName) \ + TypeName(const TypeName&) = delete; \ + void operator=(const TypeName&) = delete +#define DISABLE_MOVE(TypeName) \ + TypeName(TypeName&&) = delete; \ + void operator=(TypeName&&) = delete + + #ifndef OPENSHOCK_API_DOMAIN #error "OPENSHOCK_API_DOMAIN must be defined" #endif diff --git a/include/PinPatternManager.h b/include/PinPatternManager.h index eee7edf6..a61550fe 100644 --- a/include/PinPatternManager.h +++ b/include/PinPatternManager.h @@ -1,5 +1,7 @@ #pragma once +#include "Common.h" + #include #include #include @@ -9,6 +11,7 @@ namespace OpenShock { class PinPatternManager { + DISABLE_COPY(PinPatternManager); public: PinPatternManager(std::uint8_t gpioPin); ~PinPatternManager(); diff --git a/include/RGBPatternManager.h b/include/RGBPatternManager.h index 94b696c0..81231677 100644 --- a/include/RGBPatternManager.h +++ b/include/RGBPatternManager.h @@ -1,5 +1,7 @@ #pragma once +#include "Common.h" + #include #include #include @@ -11,6 +13,7 @@ namespace OpenShock { class RGBPatternManager { + DISABLE_COPY(RGBPatternManager); public: RGBPatternManager(std::uint8_t gpioPin); ~RGBPatternManager(); diff --git a/include/WebSocketDeFragger.h b/include/WebSocketDeFragger.h index 025ea98c..85d464af 100644 --- a/include/WebSocketDeFragger.h +++ b/include/WebSocketDeFragger.h @@ -1,5 +1,6 @@ #pragma once +#include "Common.h" #include "WebSocketMessageType.h" #include @@ -10,20 +11,18 @@ namespace OpenShock { class WebSocketDeFragger { + DISABLE_COPY(WebSocketDeFragger); public: typedef std::function EventCallback; WebSocketDeFragger(EventCallback callback); - WebSocketDeFragger(const WebSocketDeFragger&) = delete; ~WebSocketDeFragger(); void handler(std::uint8_t socketId, WStype_t type, const std::uint8_t* payload, std::size_t length); void onEvent(const EventCallback& callback); void clear(std::uint8_t socketId); void clear(); - - WebSocketDeFragger& operator=(const WebSocketDeFragger&) = delete; private: void start(std::uint8_t socketId, WebSocketMessageType type, const std::uint8_t* data, std::uint32_t length); void append(std::uint8_t socketId, const std::uint8_t* data, std::uint32_t length); diff --git a/src/CommandHandler.cpp b/src/CommandHandler.cpp index e9837a96..059c8c42 100644 --- a/src/CommandHandler.cpp +++ b/src/CommandHandler.cpp @@ -2,7 +2,7 @@ #include "Chipset.h" #include "config/Config.h" -#include "Constants.h" +#include "Common.h" #include "Logging.h" #include "radio/RFTransmitter.h" #include "Time.h" diff --git a/src/CompatibilityChecks.cpp b/src/CompatibilityChecks.cpp index 92edac14..7d06a571 100644 --- a/src/CompatibilityChecks.cpp +++ b/src/CompatibilityChecks.cpp @@ -1,4 +1,4 @@ -#include "Constants.h" +#include "Common.h" #include "Chipset.h" constexpr bool kIsValidRfTxPin = OpenShock::IsValidOutputPin(OPENSHOCK_RF_TX_GPIO) || OPENSHOCK_RF_TX_GPIO == UINT8_MAX; diff --git a/src/config/Config.cpp b/src/config/Config.cpp index ed7eaf4e..f45e3f35 100644 --- a/src/config/Config.cpp +++ b/src/config/Config.cpp @@ -1,7 +1,7 @@ #include "config/Config.h" #include "config/RootConfig.h" -#include "Constants.h" +#include "Common.h" #include "Logging.h" #include "ReadWriteMutex.h" diff --git a/src/config/RFConfig.cpp b/src/config/RFConfig.cpp index b9897520..be8007be 100644 --- a/src/config/RFConfig.cpp +++ b/src/config/RFConfig.cpp @@ -1,7 +1,7 @@ #include "config/RFConfig.h" #include "config/internal/utils.h" -#include "Constants.h" +#include "Common.h" #include "Logging.h" const char* const TAG = "Config::RFConfig"; diff --git a/src/event_handlers/websocket/local/SetRfTxPinCommand.cpp b/src/event_handlers/websocket/local/SetRfTxPinCommand.cpp index 2fbdd148..d7456a13 100644 --- a/src/event_handlers/websocket/local/SetRfTxPinCommand.cpp +++ b/src/event_handlers/websocket/local/SetRfTxPinCommand.cpp @@ -2,7 +2,7 @@ #include "CaptivePortal.h" #include "CommandHandler.h" -#include "Constants.h" +#include "Common.h" #include "Logging.h" #include diff --git a/src/http/JsonAPI.cpp b/src/http/JsonAPI.cpp index c8e6b9a9..c85444d4 100644 --- a/src/http/JsonAPI.cpp +++ b/src/http/JsonAPI.cpp @@ -1,6 +1,6 @@ #include "http/JsonAPI.h" -#include "Constants.h" +#include "Common.h" using namespace OpenShock; diff --git a/src/main.cpp b/src/main.cpp index 66569565..d60a5c9f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ #include "CaptivePortal.h" #include "CommandHandler.h" #include "config/Config.h" -#include "Constants.h" +#include "Common.h" #include "EStopManager.h" #include "event_handlers/Init.h" #include "GatewayConnectionManager.h" From ec9c650b2b88cb097e0c321c3cb28b5f328ee7ff Mon Sep 17 00:00:00 2001 From: hhvrc Date: Tue, 9 Jan 2024 07:49:56 +0100 Subject: [PATCH 10/24] Constants.h was moved to Common.h --- src/OtaUpdateManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OtaUpdateManager.cpp b/src/OtaUpdateManager.cpp index a6da621a..2a14fde0 100644 --- a/src/OtaUpdateManager.cpp +++ b/src/OtaUpdateManager.cpp @@ -1,8 +1,8 @@ #include "OtaUpdateManager.h" #include "CaptivePortal.h" +#include "Common.h" #include "config/Config.h" -#include "Constants.h" #include "GatewayConnectionManager.h" #include "Hashing.h" #include "http/HTTPRequestManager.h" From c83a30b37e80012bd2c8c2b67ba1804594bf580c Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 11 Jan 2024 16:45:58 +0100 Subject: [PATCH 11/24] Improve CI/CD workflows (#180) * Add new workflows * Add RELEASE.md to get-vars output * Remove VERSION * Code abstraction and stuff * More simplification * Fix some stuff and publish on master and develop * Sanitize ref names in semver * Better release notes * Fix typo * Update CHANGELOG.md * Update get-vars.js * Update CHANGELOG.md * Attempt to fix CI/CD tag issue * debug * Fix bug * fix other typo * More simplifications * Finishing touches * Fix dev channel and semver naming * Attempt to fix stuck progress * Scope and clean up variables --- .github/actions/build-firmware/action.yml | 14 +- .github/scripts/.gitignore | 1 + .github/scripts/get-vars.js | 221 ++++++++++++++++++ .github/scripts/package-lock.json | 267 ++++++++++++++++++++++ .github/scripts/package.json | 17 ++ .github/workflows/build-all.yml | 85 +++++++ .github/workflows/ci-build.yml | 103 +++------ .github/workflows/ci-tag.yml | 203 ---------------- .github/workflows/codeql.yml | 25 +- .github/workflows/get-targets.yml | 73 ------ .github/workflows/get-vars.yml | 105 +++++++++ .github/workflows/publish-all.yml | 130 +++++++++++ CHANGELOG.md | 25 ++ RELEASE.md | 2 +- scripts/embed_env_vars.py | 10 +- src/http/HTTPRequestManager.cpp | 2 +- src/serial/SerialInputHandler.cpp | 2 +- 17 files changed, 910 insertions(+), 375 deletions(-) create mode 100644 .github/scripts/.gitignore create mode 100644 .github/scripts/get-vars.js create mode 100644 .github/scripts/package-lock.json create mode 100644 .github/scripts/package.json create mode 100644 .github/workflows/build-all.yml delete mode 100644 .github/workflows/ci-tag.yml delete mode 100644 .github/workflows/get-targets.yml create mode 100644 .github/workflows/get-vars.yml create mode 100644 .github/workflows/publish-all.yml create mode 100644 CHANGELOG.md diff --git a/.github/actions/build-firmware/action.yml b/.github/actions/build-firmware/action.yml index 16bf54d3..47bcd8f7 100644 --- a/.github/actions/build-firmware/action.yml +++ b/.github/actions/build-firmware/action.yml @@ -1,13 +1,15 @@ - name: build-firmware description: Builds the firmware partitions and uploads them as an artifact inputs: python-version: - description: 'Python version to use' required: true + description: 'Python version to use' board: + required: true description: 'Board name to build' + version: required: true + description: 'Current firmware version' skip-checkout: description: 'If true, skips checkout' required: false @@ -30,7 +32,7 @@ runs: - uses: actions/setup-python@v4 with: python-version: ${{ inputs.python-version }} - cache: "pip" + cache: 'pip' - name: Install python dependencies shell: bash @@ -40,6 +42,12 @@ runs: working-directory: . shell: bash run: pio run -e ${{ inputs.board }} + env: + OPENSHOCK_API_DOMAIN: api.openshock.net + OPENSHOCK_FW_VERSION: ${{ inputs.version }} + OPENSHOCK_FW_GIT_REF: ${{ github.ref }} + OPENSHOCK_FW_GIT_COMMIT: ${{ github.sha }} + OPENSHOCK_FW_BUILD_DATE: ${{ github.event.head_commit.timestamp }} - name: Upload build artifacts uses: actions/upload-artifact@v3 diff --git a/.github/scripts/.gitignore b/.github/scripts/.gitignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/.github/scripts/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/.github/scripts/get-vars.js b/.github/scripts/get-vars.js new file mode 100644 index 00000000..38482a49 --- /dev/null +++ b/.github/scripts/get-vars.js @@ -0,0 +1,221 @@ +const fs = require('fs'); +const ini = require('ini'); +const semver = require('semver'); +const core = require('@actions/core'); +const child_process = require('child_process'); + +// Get branch name +const gitRef = process.env.GITHUB_REF; +if (gitRef === undefined) { + core.setFailed('Environment variable "GITHUB_REF" not found'); + process.exit(); +} + +const isGitTag = gitRef.startsWith('refs/tags/'); +const isGitBranch = gitRef.startsWith('refs/heads/'); +const isGitPullRequest = gitRef.startsWith('refs/pull/') && gitRef.endsWith('/merge'); + +if (!isGitTag && !isGitBranch && !isGitPullRequest) { + core.setFailed(`Git ref "${gitRef}" is not a valid branch, tag or pull request`); + process.exit(); +} + +const gitCommitHash = process.env.GITHUB_SHA; +const gitShortCommitHash = child_process.execSync('git rev-parse --short HEAD').toString().trim(); + +if (gitCommitHash === undefined) { + core.setFailed('Environment variable "GITHUB_SHA" not found'); + process.exit(); +} + +const gitHeadRefName = isGitPullRequest ? process.env.GITHUB_HEAD_REF : gitRef.split('/')[2]; +if (gitHeadRefName === undefined) { + core.setFailed('Failed to get git head ref name'); + process.exit(); +} + +const gitTagsList = child_process.execSync('git for-each-ref --sort=-creatordate --format "%(refname:short)" refs/tags').toString().trim(); +if (gitTagsList === undefined) { + core.setFailed('Failed to get latest git tag'); + process.exit(); +} + +function convertGitTagToSemver(tag) { + const parsed = semver.parse(tag === '' ? '0.0.0' : tag); + if (parsed === null || parsed.loose) { + core.setFailed(`Git tag "${tag}" is not a valid semver version`); + process.exit(); + } + + return parsed; +} + +const gitTagsArray = gitTagsList.split('\n').map((tag) => tag.trim()); +const releasesArray = gitTagsArray.map(convertGitTagToSemver); +const latestRelease = isGitTag ? convertGitTagToSemver(gitRef.split('/')[2]) : releasesArray[0]; + +const stableReleasesArray = releasesArray.filter((release) => release.prerelease.length === 0 || release.prerelease[0] === 'stable'); +const betaReleasesArray = releasesArray.filter((release) => release.prerelease.length > 0 && ['rc', 'beta'].includes(release.prerelease[0])); +const devReleasesArray = releasesArray.filter((release) => release.prerelease.length > 0 && ['dev', 'develop'].includes(release.prerelease[0])); + +// Build version string +let currentVersion = `${latestRelease.major}.${latestRelease.minor}.${latestRelease.patch}`; +if (!isGitTag) { + // Get last part of branch name and replace all non-alphanumeric characters with dashes + let sanitizedGitHeadRefName = gitHeadRefName + .split('/') + .pop() + .replace(/[^a-zA-Z0-9-]/g, '-'); + + // Remove leading and trailing dashes + sanitizedGitHeadRefName = sanitizedGitHeadRefName.replace(/^\-+|\-+$/g, ''); + + if (sanitizedGitHeadRefName.length > 0) { + currentVersion += `-${sanitizedGitHeadRefName}`; + } + + // Add the git commit hash to the version string + currentVersion += `+${gitShortCommitHash}`; +} + +// Get the channel to deploy to +let currentChannel; +if (gitHeadRefName === 'master') { + currentChannel = 'stable'; +} else if (gitHeadRefName === 'develop') { + currentChannel = 'develop'; +} else if (gitHeadRefName === 'beta') { + currentChannel = 'beta'; +} else { + currentChannel = gitHeadRefName.replace(/[^a-zA-Z0-9-]/g, '-').replace(/^\-+|\-+$/g, ''); +} + +function getVersionChangeLog(lines) { + const emptyChangelog = lines.length === 0; + + // Enforce that the changelog is not empty if we are on the master branch + if (isGitTag && emptyChangelog) { + core.setFailed('File "CHANGELOG.md" is empty, this must be populated in the master branch'); + process.exit(); + } + + if (emptyChangelog) { + return ''; + } + + // Simple validation of the changelog + if (!lines[0].startsWith('# Version ')) { + core.setFailed('File "CHANGELOG.md" must start with "# Version " followed by a changelog entry'); + process.exit(); + } + + // Get the start of the entry + const changeLogBegin = lines.findIndex((line) => line.startsWith(`# Version ${currentVersion}`)); + if (isGitTag && changeLogBegin === -1) { + core.setFailed(`File "CHANGELOG.md" does not contain a changelog entry for version "${currentVersion}", this must be added in the master branch`); + process.exit(); + } + + // Enforce that the changelog entry is at the top of the file if we are on the master branch + if (isGitTag && changeLogBegin !== 0) { + core.setFailed(`Changelog entry for version "${currentVersion}" is not at the top of the file, you tag is either out of date or you have not updated the changelog`); + process.exit(); + } + + // Get the end of the entry + let changeLogEnd = lines.slice(changeLogBegin + 1).findIndex((line) => line.startsWith('# Version ')); + if (changeLogEnd === -1) { + changeLogEnd = lines.length; + } else { + changeLogEnd += changeLogBegin + 1; + } + + const emptyChangelogEntry = lines.slice(changeLogBegin + 1, changeLogEnd).filter((line) => line.trim() !== '').length === 0; + + // Enforce that the changelog entry is not empty if we are on the master branch + if (isGitTag && emptyChangelogEntry) { + core.setFailed(`Changelog entry for version "${currentVersion}" is empty, this must be populated in the master branch`); + process.exit(); + } + + return lines.slice(changeLogBegin + 1, changeLogEnd).join('\n'); +} + +// Make sure we have all the files we need +for (const file of ['RELEASE.md', 'CHANGELOG.md', 'platformio.ini']) { + if (!fs.existsSync(file)) { + core.setFailed(`File "${file}" not found`); + process.exit(); + } +} + +// Read files +let releaseNotes = fs.readFileSync('RELEASE.md', 'utf8'); +const fullChangelog = fs.readFileSync('CHANGELOG.md', 'utf8').trim(); +const platformioIniStr = fs.readFileSync('platformio.ini', 'utf8').trim(); + +const fullChangelogLines = fullChangelog.split('\n'); + +// Get all versions from the changelog +const changelogVersions = fullChangelogLines.filter((line) => line.startsWith('# Version ')).map((line) => line.substring(10).split(' ')[0].trim()); + +// Get the changelog for the current version +const versionChangeLog = getVersionChangeLog(fullChangelogLines); + +// Enforce that all tags exist in the changelog +let missingTags = []; +for (const tag of gitTagsArray) { + if (!changelogVersions.includes(tag)) { + missingTags.push(tag); + } +} +if (missingTags.length > 0) { + core.setFailed(`Changelog is missing the following tags: ${missingTags.join(', ')}`); + process.exit(); +} + +// Finish building the release string +if (versionChangeLog !== '') { + releaseNotes = `# OpenShock Firmware ${currentVersion}\n\n${versionChangeLog}\n\n${releaseNotes}`.trim(); +} else { + releaseNotes = `# OpenShock Firmware ${currentVersion}\n\n${releaseNotes}`.trim(); +} + +// Parse platformio.ini and extract the different boards +const platformioIni = ini.parse(platformioIniStr); + +// Get every key that starts with "env:", and that isnt "env:fs" (which is the filesystem) +const boards = Object.keys(platformioIni) + .filter((key) => key.startsWith('env:') && key !== 'env:fs') + .reduce((arr, key) => { + arr.push(key.substring(4)); + return arr; + }, []); + +const shouldDeploy = isGitTag || (isGitBranch && gitHeadRefName === 'develop'); + +console.log('Version: ' + currentVersion); +console.log('Channel: ' + currentChannel); +console.log('Boards: ' + boards.join(', ')); +console.log('Deploy: ' + shouldDeploy); +console.log('Tags: ' + gitTagsArray.join(', ')); +console.log('Stable: ' + stableReleasesArray.join(', ')); +console.log('Beta: ' + betaReleasesArray.join(', ')); +console.log('Dev: ' + devReleasesArray.join(', ')); + +// Set outputs +core.setOutput('version', currentVersion); +core.setOutput('changelog', versionChangeLog); +core.setOutput('release-notes', releaseNotes); +core.setOutput('release-channel', currentChannel); +core.setOutput('full-changelog', fullChangelog); +core.setOutput('board-list', boards.join('\n')); +core.setOutput('board-array', JSON.stringify(boards)); +core.setOutput('board-matrix', JSON.stringify({ board: boards })); +core.setOutput('should-deploy', shouldDeploy); +core.setOutput('release-stable-list', stableReleasesArray.join('\n')); +core.setOutput('release-stable-array', JSON.stringify(stableReleasesArray)); +core.setOutput('release-beta-list', betaReleasesArray.join('\n')); +core.setOutput('release-beta-array', JSON.stringify(betaReleasesArray)); +core.setOutput('release-dev-list', devReleasesArray.join('\n')); +core.setOutput('release-dev-array', JSON.stringify(devReleasesArray)); diff --git a/.github/scripts/package-lock.json b/.github/scripts/package-lock.json new file mode 100644 index 00000000..1c71ab3e --- /dev/null +++ b/.github/scripts/package-lock.json @@ -0,0 +1,267 @@ +{ + "name": "get-variables", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "get-variables", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@actions/core": "^1.10.1", + "@actions/github": "^6.0.0", + "ini": "^4.1.1", + "semver": "^7.5.4" + } + }, + "node_modules/@actions/core": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz", + "integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==", + "dependencies": { + "@actions/http-client": "^2.0.1", + "uuid": "^8.3.2" + } + }, + "node_modules/@actions/github": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@actions/github/-/github-6.0.0.tgz", + "integrity": "sha512-alScpSVnYmjNEXboZjarjukQEzgCRmjMv6Xj47fsdnqGS73bjJNDpiiXmp8jr0UZLdUB6d9jW63IcmddUP+l0g==", + "dependencies": { + "@actions/http-client": "^2.2.0", + "@octokit/core": "^5.0.1", + "@octokit/plugin-paginate-rest": "^9.0.0", + "@octokit/plugin-rest-endpoint-methods": "^10.0.0" + } + }, + "node_modules/@actions/http-client": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.0.tgz", + "integrity": "sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==", + "dependencies": { + "tunnel": "^0.0.6", + "undici": "^5.25.4" + } + }, + "node_modules/@fastify/busboy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz", + "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==", + "engines": { + "node": ">=14" + } + }, + "node_modules/@octokit/auth-token": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", + "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/core": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.2.tgz", + "integrity": "sha512-cZUy1gUvd4vttMic7C0lwPed8IYXWYp8kHIMatyhY8t8n3Cpw2ILczkV5pGMPqef7v0bLo0pOHrEHarsau2Ydg==", + "dependencies": { + "@octokit/auth-token": "^4.0.0", + "@octokit/graphql": "^7.0.0", + "@octokit/request": "^8.0.2", + "@octokit/request-error": "^5.0.0", + "@octokit/types": "^12.0.0", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/endpoint": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.4.tgz", + "integrity": "sha512-DWPLtr1Kz3tv8L0UvXTDP1fNwM0S+z6EJpRcvH66orY6Eld4XBMCSYsaWp4xIm61jTWxK68BrR7ibO+vSDnZqw==", + "dependencies": { + "@octokit/types": "^12.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/graphql": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.2.tgz", + "integrity": "sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==", + "dependencies": { + "@octokit/request": "^8.0.1", + "@octokit/types": "^12.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/openapi-types": { + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-19.1.0.tgz", + "integrity": "sha512-6G+ywGClliGQwRsjvqVYpklIfa7oRPA0vyhPQG/1Feh+B+wU0vGH1JiJ5T25d3g1JZYBHzR2qefLi9x8Gt+cpw==" + }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "9.1.5", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.1.5.tgz", + "integrity": "sha512-WKTQXxK+bu49qzwv4qKbMMRXej1DU2gq017euWyKVudA6MldaSSQuxtz+vGbhxV4CjxpUxjZu6rM2wfc1FiWVg==", + "dependencies": { + "@octokit/types": "^12.4.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=5" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.2.0.tgz", + "integrity": "sha512-ePbgBMYtGoRNXDyKGvr9cyHjQ163PbwD0y1MkDJCpkO2YH4OeXX40c4wYHKikHGZcpGPbcRLuy0unPUuafco8Q==", + "dependencies": { + "@octokit/types": "^12.3.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=5" + } + }, + "node_modules/@octokit/request": { + "version": "8.1.6", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.1.6.tgz", + "integrity": "sha512-YhPaGml3ncZC1NfXpP3WZ7iliL1ap6tLkAp6MvbK2fTTPytzVUyUesBBogcdMm86uRYO5rHaM1xIWxigWZ17MQ==", + "dependencies": { + "@octokit/endpoint": "^9.0.0", + "@octokit/request-error": "^5.0.0", + "@octokit/types": "^12.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/request-error": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz", + "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==", + "dependencies": { + "@octokit/types": "^12.0.0", + "deprecation": "^2.0.0", + "once": "^1.4.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/types": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.4.0.tgz", + "integrity": "sha512-FLWs/AvZllw/AGVs+nJ+ELCDZZJk+kY0zMen118xhL2zD0s1etIUHm1odgjP7epxYU1ln7SZxEUWYop5bhsdgQ==", + "dependencies": { + "@octokit/openapi-types": "^19.1.0" + } + }, + "node_modules/before-after-hook": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", + "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" + }, + "node_modules/deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" + }, + "node_modules/ini": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.1.tgz", + "integrity": "sha512-QQnnxNyfvmHFIsj7gkPcYymR8Jdw/o7mp5ZFihxn6h8Ci6fh3Dx4E1gPjpQEpIuPo9XVNY/ZUwh4BPMjGyL01g==", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, + "node_modules/undici": { + "version": "5.28.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz", + "integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==", + "dependencies": { + "@fastify/busboy": "^2.0.0" + }, + "engines": { + "node": ">=14.0" + } + }, + "node_modules/universal-user-agent": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", + "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==" + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } +} diff --git a/.github/scripts/package.json b/.github/scripts/package.json new file mode 100644 index 00000000..65b9030e --- /dev/null +++ b/.github/scripts/package.json @@ -0,0 +1,17 @@ +{ + "name": "get-variables", + "version": "1.0.0", + "description": "", + "main": "src/index.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "@actions/core": "^1.10.1", + "@actions/github": "^6.0.0", + "ini": "^4.1.1", + "semver": "^7.5.4" + } +} diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml new file mode 100644 index 00000000..70dea7b1 --- /dev/null +++ b/.github/workflows/build-all.yml @@ -0,0 +1,85 @@ +name: build-all + +on: + workflow_call: + inputs: + node-version: + type: string + default: '18' + description: 'The version of Node.js to use' + python-version: + type: string + default: '3.12' + description: 'The version of Python to use' + version: + type: string + required: true + description: 'The version of the firmware' + board-matrix: + type: string + required: true + description: 'A JSON matrix of boards to build for' + +jobs: + build-frontend: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + frontend + + - uses: ./.github/actions/build-frontend + with: + node-version: ${{ inputs.node-version }} + + build-staticfs: + runs-on: ubuntu-latest + needs: build-frontend + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/build-staticfs + with: + python-version: ${{ inputs.python-version }} + skip-checkout: true + + build-firmware: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{ fromJSON(inputs.board-matrix) }} + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/build-firmware + with: + python-version: ${{ inputs.python-version }} + board: ${{ matrix.board }} + version: ${{ inputs.version }} + skip-checkout: true + + merge-partitions: + runs-on: ubuntu-latest + needs: [build-staticfs, build-firmware] + strategy: + fail-fast: false + matrix: ${{ fromJSON(inputs.board-matrix) }} + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + scripts + boards + chips + + - uses: ./.github/actions/merge-partitions + with: + python-version: ${{ inputs.python-version }} + board: ${{ matrix.board }} + skip-checkout: true diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 4999b859..5b338b31 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -2,95 +2,46 @@ on: push: branches: - master + - beta - develop + tags: + - '[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+-*' pull_request: branches: + - master + - beta - develop types: [opened, reopened, synchronize] workflow_dispatch: # Manually invoked by user. name: ci-build -env: - NODE_VERSION: 18 - PYTHON_VERSION: 3.12 - OPENSHOCK_API_DOMAIN: api.shocklink.net - # OPENSHOCK_FW_VERSION: - # - If this is branch "master" or "develop", we use "0.0.0-master" or "0.0.0-develop" respectively. - # - All other scenarios we use "0.0.0-unknown", as we cannot guarantee SemVer compliance by accepting any branch name. So this is the safe option. - OPENSHOCK_FW_VERSION: ${{ (contains(fromJSON('["master","develop"]'), github.ref_name) && format('0.0.0-{0}', github.ref_name)) || '0.0.0-unknown' }} - OPENSHOCK_FW_COMMIT: ${{ github.sha }} - jobs: - # Read platformio.ini and extract all specific targets. See the referenced file for more info. - get-targets: - uses: ./.github/workflows/get-targets.yml - - build-frontend: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - frontend + getvars: + uses: ./.github/workflows/get-vars.yml - - uses: ./.github/actions/build-frontend - with: - node-version: ${{ env.NODE_VERSION }} - - build-staticfs: - runs-on: ubuntu-latest - needs: build-frontend - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/build-staticfs - with: - python-version: ${{ env.PYTHON_VERSION }} - skip-checkout: true - - build-firmware: - runs-on: ubuntu-latest - needs: get-targets - strategy: - fail-fast: false - matrix: ${{ fromJSON(needs.get-targets.outputs.matrix) }} - - steps: - - uses: actions/checkout@v4 - - - uses: ./.github/actions/build-firmware - with: - python-version: ${{ env.PYTHON_VERSION }} - board: ${{ matrix.board }} - skip-checkout: true - - merge-partitions: - runs-on: ubuntu-latest - needs: [get-targets, build-staticfs, build-firmware] - strategy: - fail-fast: false - matrix: ${{ fromJSON(needs.get-targets.outputs.matrix )}} - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - scripts - boards - chips - - - uses: ./.github/actions/merge-partitions - with: - python-version: ${{ env.PYTHON_VERSION }} - board: ${{ matrix.board }} - skip-checkout: true + build: + needs: getvars + uses: ./.github/workflows/build-all.yml + with: + version: ${{ needs.getvars.outputs.version }} + board-matrix: ${{ needs.getvars.outputs.board-matrix }} checkpoint-build: runs-on: ubuntu-latest - needs: [build-staticfs, merge-partitions] + needs: [getvars, build] steps: - run: echo "Builds checkpoint reached" + + publish: + if: ${{ needs.getvars.outputs.should-deploy == 'true' }} + needs: [getvars, checkpoint-build] + uses: ./.github/workflows/publish-all.yml + with: + version: ${{ needs.getvars.outputs.version }} + release-channel: ${{ needs.getvars.outputs.release-channel }} + is-prerelease: ${{ needs.getvars.outputs.release-channel != 'stable' }} + board-list: ${{ needs.getvars.outputs.board-list }} + board-matrix: ${{ needs.getvars.outputs.board-matrix }} + release-notes: ${{ needs.getvars.outputs.release-notes }} diff --git a/.github/workflows/ci-tag.yml b/.github/workflows/ci-tag.yml deleted file mode 100644 index c4b9cb13..00000000 --- a/.github/workflows/ci-tag.yml +++ /dev/null @@ -1,203 +0,0 @@ -on: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+-*' - workflow_dispatch: - -name: ci-tag -run-name: 'ci-tag: ${{ github.ref_name }}' - -env: - NODE_VERSION: 18 - PYTHON_VERSION: 3.12 - OPENSHOCK_API_DOMAIN: api.shocklink.net - # OPENSHOCK_FW_VERSION: - # - Since this is a tag push, we can use ref_name to get the tag name. - OPENSHOCK_FW_VERSION: ${{ github.ref_name }} - OPENSHOCK_FW_COMMIT: ${{ github.sha }} - -jobs: - # Read platformio.ini and extract all specific targets. See the referenced file for more info. - get-targets: - uses: ./.github/workflows/get-targets.yml - - build-frontend: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - frontend - - - uses: ./.github/actions/build-frontend - with: - node-version: ${{ env.NODE_VERSION }} - skip-checkout: true - - build-staticfs: - runs-on: ubuntu-latest - needs: build-frontend - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/build-staticfs - with: - python-version: ${{ env.PYTHON_VERSION }} - skip-checkout: true - - build-firmware: - runs-on: ubuntu-latest - needs: get-targets - strategy: - fail-fast: false - matrix: ${{ fromJSON(needs.get-targets.outputs.matrix) }} - - steps: - - uses: actions/checkout@v4 - - - uses: ./.github/actions/build-firmware - with: - python-version: ${{ env.PYTHON_VERSION }} - board: ${{ matrix.board }} - skip-checkout: true - - merge-partitions: - runs-on: ubuntu-latest - needs: [get-targets, build-staticfs, build-firmware] - strategy: - fail-fast: false - matrix: ${{ fromJSON(needs.get-targets.outputs.matrix )}} - - steps: - - uses: actions/checkout@v4 - with: - path: . - sparse-checkout: | - .github - scripts - boards - chips - - - name: Merge images - uses: ./.github/actions/merge-partitions - with: - python-version: ${{ env.PYTHON_VERSION }} - board: ${{ matrix.board }} - skip-checkout: true - - checkpoint-build: - runs-on: ubuntu-latest - needs: [build-staticfs, merge-partitions] - steps: - - run: echo "Builds checkpoint reached" - - cdn-upload-firmware: - runs-on: ubuntu-latest - needs: [get-targets, checkpoint-build] - environment: cdn-firmware-r2 - strategy: - fail-fast: true - matrix: ${{ fromJson(needs.get-targets.outputs.matrix )}} - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - - # Set up rclone for CDN uploads. - - uses: ./.github/actions/cdn-prepare - with: - cf-account-id: ${{ vars.S3_ACCOUNT_ID }} - cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} - cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} - - # Upload firmware to CDN. - - uses: ./.github/actions/cdn-upload-firmware - with: - cf-bucket: ${{ vars.S3_BUCKET }} - board: ${{ matrix.board }} - version: ${{ github.ref_name }} - release-channel: ${{ contains(github.ref_name, '-') && 'stable' || 'beta' }} - - cdn-upload-version-info: - runs-on: ubuntu-latest - needs: [get-targets, checkpoint-build] - environment: cdn-firmware-r2 - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - - # Set up rclone for CDN uploads. - - uses: ./.github/actions/cdn-prepare - with: - cf-account-id: ${{ vars.S3_ACCOUNT_ID }} - cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} - cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} - - # Upload firmware to CDN. - - uses: ./.github/actions/cdn-upload-version-info - with: - cf-bucket: ${{ vars.S3_BUCKET }} - version: ${{ github.ref_name }} - boards: ${{ needs.get-targets.outputs.board-list }} - - cdn-bump-version: - runs-on: ubuntu-latest - needs: [cdn-upload-firmware] # only after version is complete - environment: cdn-firmware-r2 - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - - # Set up rclone for CDN uploads. - - uses: ./.github/actions/cdn-prepare - with: - cf-account-id: ${{ vars.S3_ACCOUNT_ID }} - cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} - cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} - - # Upload firmware to CDN. - - uses: ./.github/actions/cdn-bump-version - with: - cf-bucket: ${{ vars.S3_BUCKET }} - version: ${{ github.ref_name }} - release-channel: ${{ !contains(github.ref_name, '-') && 'stable' || 'beta' }} - - checkpoint-cdn: - runs-on: ubuntu-latest - needs: [checkpoint-build, cdn-upload-firmware, cdn-upload-version-info, cdn-bump-version] - steps: - - run: echo "CDN checkpoint reached" - - release: - runs-on: ubuntu-latest - needs: [checkpoint-cdn] - - steps: - - name: Download release notes - uses: actions/checkout@v4 - with: - sparse-checkout: | - RELEASE.md - - - name: Download release artifacts - uses: actions/download-artifact@v4 - - - name: Release - uses: ncipollo/release-action@v1 - with: - artifacts: '**/OpenShock_*.bin' - tag: ${{ github.ref_name }} - prerelease: ${{ contains(github.ref_name, '-') }} - artifactErrorsFailBuild: true - bodyFile: RELEASE.md diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4df561a4..dccdd083 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,28 +9,28 @@ on: - cron: '0 6 * * 1' env: - NODE_VERSION: 18 - PYTHON_VERSION: 3.12 OPENSHOCK_API_DOMAIN: api.shocklink.net - # OPENSHOCK_FW_VERSION: - # - If this is branch "master" or "develop", we use "0.0.0-master" or "0.0.0-develop" respectively. - # - All other scenarios we use "0.0.0-unknown", as we cannot guarantee SemVer compliance by accepting any branch name. So this is the safe option. - OPENSHOCK_FW_VERSION: ${{ (contains(fromJSON('["master","develop"]'), github.ref_name) && format('0.0.0-{0}', github.ref_name)) || '0.0.0-unknown' }} - OPENSHOCK_FW_COMMIT: ${{ github.sha }} + OPENSHOCK_FW_GIT_REF: ${{ github.ref }} + OPENSHOCK_FW_GIT_COMMIT: ${{ github.sha }} + OPENSHOCK_FW_BUILD_DATE: ${{ github.event.head_commit.timestamp }} jobs: - get-targets: - uses: ./.github/workflows/get-targets.yml + get-vars: + uses: ./.github/workflows/get-vars.yml analyze-js-py: name: Analyze JS/PY runs-on: 'ubuntu-latest' + needs: get-vars timeout-minutes: 360 permissions: actions: read contents: read security-events: write + env: + OPENSHOCK_FW_VERSION: ${{ needs.get-vars.outputs.version }} + strategy: fail-fast: false matrix: @@ -59,7 +59,7 @@ jobs: analyze-cpp: name: Analyze C/C++ runs-on: 'ubuntu-latest' - needs: [get-targets] + needs: get-vars timeout-minutes: 360 permissions: actions: read @@ -68,11 +68,12 @@ jobs: env: language: 'c-cpp' + OPENSHOCK_FW_VERSION: ${{ needs.get-vars.outputs.version }} strategy: fail-fast: false matrix: - board: ${{ fromJson(needs.get-targets.outputs.board-array) }} + board: ${{ fromJson(needs.get-vars.outputs.board-array) }} steps: - name: Checkout repository @@ -85,7 +86,7 @@ jobs: - uses: ./.github/actions/build-firmware with: - python-version: ${{ env.PYTHON_VERSION }} + python-version: 3.12 board: ${{ matrix.board }} skip-checkout: true diff --git a/.github/workflows/get-targets.yml b/.github/workflows/get-targets.yml deleted file mode 100644 index 6da6a31c..00000000 --- a/.github/workflows/get-targets.yml +++ /dev/null @@ -1,73 +0,0 @@ - -# This is a bit of a silly workflow, but Github Workflow definitions -# do not let us easily reuse the strategy matrix used to trigger jobs -# per-board. This is a workaround to define everything in one file, and -# use the output in the multiple places we need it. -# -# Source: https://github.com/orgs/community/discussions/26284#discussioncomment-6701976 - -on: - workflow_call: - outputs: - board-list: - description: "Newline-separated list of boards" - value: ${{ jobs.get-targets.outputs.board-list }} - board-array: - description: "JSON array of boards" - value: ${{ jobs.get-targets.outputs.board-array }} - matrix: - description: "Strategy matrix with a single key 'board', containing a list of all boards." - value: ${{ jobs.get-targets.outputs.matrix }} - -name: targets - -jobs: - get-targets: - runs-on: ubuntu-latest - outputs: - board-array: ${{ steps.board-array.outputs.array }} - board-list: ${{ steps.board-list.outputs.list }} - matrix: ${{ steps.matrix.outputs.matrix }} - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: platformio.ini - - # There's a lot going on here, so bear with me. - # - # sed: - # -n Suppresses normal output, - # "s/^\[env:\(.*\)]$/\1 Substitutes "[env:...]" with whatever value is at "..." - # /p" Prints out the substituted value (i.e. the value of "...") - # platformio.ini Reading from this file. - # - # jq: - # "--raw-input --slurp" Takes the previous output, - # -c Output in compact mode (no newlines or unnecessary spaces), - # split("\n") Splits it by line, turning it into an array, - # [ .[] | select(length > 0) Filters out empty lines (there is an empty trailing line usually), - # | select(. != "fs") ] Filters out the "fs" entry since that's only for building the static filesystem, - # { board: ... } Wraps the whole thing into a JSON object with only a "board" key - # and the array in question as value. - # - # echo "matrix=$(...)" >> $GITHUB_OUTPUT Sets the value as job output with name "matrix". - # - # Referenced: https://unix.stackexchange.com/a/278377 - # Referenced: https://github.com/jqlang/jq/issues/563 - - name: Extract board array - id: board-array - run: | - echo "array=$(sed -n "s/^\[env:\(.*\)]$/\1/p" platformio.ini | jq --raw-input --slurp -c 'split("\n") | [ .[] | select(length > 0) | select(. != "fs") ]')" >> $GITHUB_OUTPUT - - - name: Build strategy matrix - id: matrix - run: | - echo "matrix=$(echo '${{ steps.board-array.outputs.array }}' | jq -c '{ board: . }')" >> $GITHUB_OUTPUT - - - name: Build board list - id: board-list - run: | - echo "list<> $GITHUB_OUTPUT - echo "$(echo '${{ steps.board-array.outputs.array }}' | jq -r '. | join("\n")' | sed 's|\\n|\n|g')" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT diff --git a/.github/workflows/get-vars.yml b/.github/workflows/get-vars.yml new file mode 100644 index 00000000..5ab44530 --- /dev/null +++ b/.github/workflows/get-vars.yml @@ -0,0 +1,105 @@ +# This is a bit of a silly workflow, but Github Workflow definitions +# do not let us easily reuse the strategy matrix used to trigger jobs +# per-board. This is a workaround to define everything in one file, and +# use the output in the multiple places we need it. +# +# Source: https://github.com/orgs/community/discussions/26284#discussioncomment-6701976 + +on: + workflow_call: + inputs: + node-version: + type: string + default: '18' + description: 'The Node.js version to use' + outputs: + version: + description: 'The current version of the project, e.g. 1.0.0-rc.1+build.1' + value: ${{ jobs.get-vars.outputs.version }} + changelog: + description: 'The changelog for the current version' + value: ${{ jobs.get-vars.outputs.changelog }} + release-notes: + description: 'The release notes for the current version (changelog + contents of RELEASE.md)' + value: ${{ jobs.get-vars.outputs.release-notes }} + release-channel: + description: 'The release channel for the current version (stable, beta, dev)' + value: ${{ jobs.get-vars.outputs.release-channel }} + full-changelog: + description: 'The complete changelog for all versions ever released' + value: ${{ jobs.get-vars.outputs.full-changelog }} + board-list: + description: 'Newline-separated list of boards to build' + value: ${{ jobs.get-vars.outputs.board-list }} + board-array: + description: 'JSON array of boards to build' + value: ${{ jobs.get-vars.outputs.board-array }} + board-matrix: + description: 'JSON matrix of boards to build' + value: ${{ jobs.get-vars.outputs.board-matrix }} + should-deploy: + description: 'Whether to deploy the current version' + value: ${{ jobs.get-vars.outputs.should-deploy }} + release-stable-list: + description: 'Newline-separated list of stable releases' + value: ${{ jobs.get-vars.outputs.release-stable-list }} + release-stable-array: + description: 'JSON array of stable releases' + value: ${{ jobs.get-vars.outputs.release-stable-array }} + release-beta-list: + description: 'Newline-separated list of beta releases' + value: ${{ jobs.get-vars.outputs.release-beta-list }} + release-beta-array: + description: 'JSON array of beta releases' + value: ${{ jobs.get-vars.outputs.release-beta-array }} + release-dev-list: + description: 'Newline-separated list of dev releases' + value: ${{ jobs.get-vars.outputs.release-dev-list }} + release-dev-array: + description: 'JSON array of dev releases' + value: ${{ jobs.get-vars.outputs.release-dev-array }} + +name: get-vars + +jobs: + get-vars: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get-vars.outputs.version }} + changelog: ${{ steps.get-vars.outputs.changelog }} + release-notes: ${{ steps.get-vars.outputs.release-notes }} + release-channel: ${{ steps.get-vars.outputs.release-channel }} + full-changelog: ${{ steps.get-vars.outputs.full-changelog }} + board-list: ${{ steps.get-vars.outputs.board-list }} + board-array: ${{ steps.get-vars.outputs.board-array }} + board-matrix: ${{ steps.get-vars.outputs.board-matrix }} + should-deploy: ${{ steps.get-vars.outputs.should-deploy }} + release-stable-list: ${{ steps.get-vars.outputs.release-stable-list }} + release-stable-array: ${{ steps.get-vars.outputs.release-stable-array }} + release-beta-list: ${{ steps.get-vars.outputs.release-beta-list }} + release-beta-array: ${{ steps.get-vars.outputs.release-beta-array }} + release-dev-list: ${{ steps.get-vars.outputs.release-dev-list }} + release-dev-array: ${{ steps.get-vars.outputs.release-dev-array }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + sparse-checkout: | + .github + + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + cache: 'npm' + cache-dependency-path: ./.github/scripts/package-lock.json + + - name: Install dependencies + working-directory: ./.github/scripts + shell: bash + run: npm ci + + - name: Get variables + id: get-vars + shell: bash + run: node ./.github/scripts/get-vars.js diff --git a/.github/workflows/publish-all.yml b/.github/workflows/publish-all.yml new file mode 100644 index 00000000..772966ba --- /dev/null +++ b/.github/workflows/publish-all.yml @@ -0,0 +1,130 @@ +on: + workflow_call: + inputs: + version: + type: string + required: true + description: 'Firmware version to publish' + release-channel: + type: string + required: true + description: 'Release channel to publish to' + is-prerelease: + type: boolean + required: true + description: 'Whether this is a prerelease' + board-list: + type: string + required: true + description: 'JSON list of boards to publish' + board-matrix: + type: string + required: true + description: 'JSON matrix of boards to publish' + release-notes: + type: string + required: true + description: 'Release notes for this release' + +name: Publish release + +jobs: + cdn-upload-firmware: + runs-on: ubuntu-latest + environment: cdn-firmware-r2 + strategy: + fail-fast: true + matrix: ${{ fromJson(inputs.board-matrix) }} + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + + # Set up rclone for CDN uploads. + - uses: ./.github/actions/cdn-prepare + with: + cf-account-id: ${{ vars.S3_ACCOUNT_ID }} + cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} + cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} + + # Upload firmware to CDN. + - uses: ./.github/actions/cdn-upload-firmware + with: + cf-bucket: ${{ vars.S3_BUCKET }} + board: ${{ matrix.board }} + version: ${{ inputs.version }} + release-channel: ${{ inputs.release-channel }} + + cdn-upload-version-info: + runs-on: ubuntu-latest + environment: cdn-firmware-r2 + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + + # Set up rclone for CDN uploads. + - uses: ./.github/actions/cdn-prepare + with: + cf-account-id: ${{ vars.S3_ACCOUNT_ID }} + cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} + cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} + + # Upload firmware to CDN. + - uses: ./.github/actions/cdn-upload-version-info + with: + cf-bucket: ${{ vars.S3_BUCKET }} + version: ${{ inputs.version }} + boards: ${{ inputs.board-list }} + + cdn-bump-version: + runs-on: ubuntu-latest + needs: [cdn-upload-firmware] # only after version is complete + environment: cdn-firmware-r2 + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + + # Set up rclone for CDN uploads. + - uses: ./.github/actions/cdn-prepare + with: + cf-account-id: ${{ vars.S3_ACCOUNT_ID }} + cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} + cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} + + # Upload firmware to CDN. + - uses: ./.github/actions/cdn-bump-version + with: + cf-bucket: ${{ vars.S3_BUCKET }} + version: ${{ inputs.version }} + release-channel: ${{ inputs.release-channel }} + + checkpoint-cdn: + runs-on: ubuntu-latest + needs: [cdn-upload-firmware, cdn-upload-version-info, cdn-bump-version] + steps: + - run: echo "CDN checkpoint reached" + + release: + runs-on: ubuntu-latest + needs: [checkpoint-cdn] + + steps: + - name: Download release artifacts + uses: actions/download-artifact@v4 + + - name: Release + uses: ncipollo/release-action@v1 + with: + artifacts: '**/OpenShock_*.bin' + tag: ${{ inputs.version }} + prerelease: ${{ inputs.is-prerelease }} + artifactErrorsFailBuild: true + body: ${{ inputs.release-notes }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..cb7b69e7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,25 @@ +# Version 1.0.0 + +- We now support **six different boards**: + - Pishock (2023) + - Pishock Lite (2021) + - Seeed Xiao ESP32S3 + - Wemos D1 Mini ESP32 + - Wemos Lolin S2 Mini + - Wemos Lolin S3 +- All communication is now **websocket based** and using flatbuffers, allowing for even lower latency between the server and the ESP, with lower resource consumption. +- The **Captive Portal** got a MASSIVE overhaul; +- Serial commands have gotten alot better. +- Improved board stability and configurability. +- Added support for having a E-Stop (emergency stop) connected to ESP as a panic button. Thanks to @nullstalgia ❤️ +- And _much, much_ more behind the scenes, including bugfixes and code cleanup. + +# Version 1.0.0-rc.4 + +# Version 1.0.0-rc.3 + +# Version 1.0.0-rc.2 + +# Version 1.0.0-rc.1 + +# Version v0.8.1 diff --git a/RELEASE.md b/RELEASE.md index de132a1a..fe4b9ade 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,4 +1,4 @@ -# OpenShock Firmware +## Flashing the firmware Download `OpenShock_[board]_[version].bin` and flash it to your microcontroller: diff --git a/scripts/embed_env_vars.py b/scripts/embed_env_vars.py index 2c605e4b..c73ca571 100644 --- a/scripts/embed_env_vars.py +++ b/scripts/embed_env_vars.py @@ -59,7 +59,7 @@ def macroify(s: str) -> str: vars['OPENSHOCK_FW_MODE'] = pio_build_type git_commit = get_git_commit() if git_commit is not None: - vars['OPENSHOCK_FW_COMMIT'] = git_commit + vars['OPENSHOCK_FW_GIT_COMMIT'] = git_commit return vars @@ -92,16 +92,16 @@ def transform_cpp_define_string(k: str, v: str) -> str: if v.startswith('"') and v.endswith('"'): v = v[1:-1] - # Special case for OPENSHOCK_FW_COMMIT. - if k == 'OPENSHOCK_FW_COMMIT' and len(v) > 7: + # Special case for OPENSHOCK_FW_GIT_COMMIT. + if k == 'OPENSHOCK_FW_GIT_COMMIT' and len(v) > 7: v = v[0:7] return env.StringifyMacro(v) def serialize_cpp_define(k: str, v: str | int | bool) -> str | int: - # Special case for OPENSHOCK_FW_COMMIT. - if k == 'OPENSHOCK_FW_COMMIT': + # Special case for OPENSHOCK_FW_GIT_COMMIT. + if k == 'OPENSHOCK_FW_GIT_COMMIT': return transform_cpp_define_string(k, str(v)) try: diff --git a/src/http/HTTPRequestManager.cpp b/src/http/HTTPRequestManager.cpp index 93220db9..1bc4a22e 100644 --- a/src/http/HTTPRequestManager.cpp +++ b/src/http/HTTPRequestManager.cpp @@ -14,7 +14,7 @@ constexpr std::size_t HTTP_BUFFER_SIZE = 4096LLU; constexpr int HTTP_DOWNLOAD_SIZE_LIMIT = 200 * 1024 * 1024; // 200 MB const char* const TAG = "HTTPRequestManager"; -const char* const OPENSHOCK_FW_USERAGENT = OPENSHOCK_FW_HOSTNAME "/" OPENSHOCK_FW_VERSION " (Espressif; " OPENSHOCK_FW_CHIP "; " OPENSHOCK_FW_BOARD ") " OPENSHOCK_FW_COMMIT; +const char* const OPENSHOCK_FW_USERAGENT = OPENSHOCK_FW_HOSTNAME "/" OPENSHOCK_FW_VERSION " (Espressif; " OPENSHOCK_FW_CHIP "; " OPENSHOCK_FW_BOARD ") " OPENSHOCK_FW_GIT_COMMIT; struct RateLimit { RateLimit() : m_blockUntilMs(0), m_limits(), m_requests() { } diff --git a/src/serial/SerialInputHandler.cpp b/src/serial/SerialInputHandler.cpp index 27716545..b0500969 100644 --- a/src/serial/SerialInputHandler.cpp +++ b/src/serial/SerialInputHandler.cpp @@ -868,7 +868,7 @@ void SerialInputHandler::PrintVersionInfo() { Serial.print("\ Version: " OPENSHOCK_FW_VERSION "\n\ Build: " OPENSHOCK_FW_MODE "\n\ - Commit: " OPENSHOCK_FW_COMMIT "\n\ + Commit: " OPENSHOCK_FW_GIT_COMMIT "\n\ Board: " OPENSHOCK_FW_BOARD "\n\ Chip: " OPENSHOCK_FW_CHIP "\n\ "); From f99d8b0bb48bb2ef1b14429710c76ec92b1b39a5 Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 11 Jan 2024 17:03:59 +0100 Subject: [PATCH 12/24] Fix some CI/CD bugs/lookovers --- .github/actions/cdn-bump-version/action.yml | 11 +++++------ .github/actions/cdn-prepare/action.yml | 2 +- .github/actions/cdn-upload-firmware/action.yml | 10 +++------- .github/actions/cdn-upload-version-info/action.yml | 8 ++++---- .github/actions/merge-partitions/action.yml | 5 ++++- .github/workflows/build-all.yml | 5 +++++ .github/workflows/ci-build.yml | 1 + .github/workflows/publish-all.yml | 5 ++--- 8 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.github/actions/cdn-bump-version/action.yml b/.github/actions/cdn-bump-version/action.yml index ea0effd4..e273fd7f 100644 --- a/.github/actions/cdn-bump-version/action.yml +++ b/.github/actions/cdn-bump-version/action.yml @@ -1,16 +1,15 @@ -name: cnd-bump-version +name: cdn-bump-version description: Uploads version file to CDN inputs: cf-bucket: description: Name of the S3 bucket required: true - version: - description: Version to upload + version-list: + description: 'List of versions, separated by newlines' required: true release-channel: description: 'Release channel that describes this upload' - required: false - default: 'none' + required: true runs: using: composite @@ -20,5 +19,5 @@ runs: shell: bash run: | mkdir upload - echo "${{ inputs.version }}" >> upload/version-${{ inputs.release-channel }}.txt + echo "${{ inputs.version-list }}" >> upload/version-${{ inputs.release-channel }}.txt rclone copy upload cdn:${{ inputs.cf-bucket }}/ diff --git a/.github/actions/cdn-prepare/action.yml b/.github/actions/cdn-prepare/action.yml index 9c3e8d59..3f70b0c1 100644 --- a/.github/actions/cdn-prepare/action.yml +++ b/.github/actions/cdn-prepare/action.yml @@ -1,4 +1,4 @@ -name: cnd-prepare +name: cdn-prepare description: Prepares the CDN for firmware uploads inputs: cf-account-id: diff --git a/.github/actions/cdn-upload-firmware/action.yml b/.github/actions/cdn-upload-firmware/action.yml index 1dbdbcb8..3b2d9f81 100644 --- a/.github/actions/cdn-upload-firmware/action.yml +++ b/.github/actions/cdn-upload-firmware/action.yml @@ -1,16 +1,12 @@ -name: cnd-upload-firmware +name: cdn-upload-firmware description: Uploads firmware partitions and merged binaries to CDN along with SHA256 checksums inputs: cf-bucket: description: Name of the S3 bucket required: true - version: - description: Version to upload - required: true release-channel: description: 'Release channel that describes this upload' - required: false - default: 'none' + required: true board: description: 'Board to upload' required: true @@ -53,4 +49,4 @@ runs: mkdir upload mv *.bin upload/ mv hashes.*.txt upload/ - rclone copy upload cdn:${{ inputs.cf-bucket }}/${{ inputs.version }}/${{ inputs.board }}/ + rclone copy upload cdn:${{ inputs.cf-bucket }}/${{ inputs.release-channel }}/${{ inputs.board }}/ diff --git a/.github/actions/cdn-upload-version-info/action.yml b/.github/actions/cdn-upload-version-info/action.yml index 5df039f8..65db5699 100644 --- a/.github/actions/cdn-upload-version-info/action.yml +++ b/.github/actions/cdn-upload-version-info/action.yml @@ -1,11 +1,11 @@ -name: cnd-upload-version-info +name: cdn-upload-version-info description: Uploads version specific info to CDN inputs: cf-bucket: description: Name of the S3 bucket required: true - version: - description: Version to upload + release-channel: + description: 'Release channel that describes this upload' required: true boards: description: 'List of boards, separated by newlines' @@ -24,4 +24,4 @@ runs: run: | mkdir upload mv boards.txt upload/ - rclone copy upload cdn:${{ inputs.cf-bucket }}/${{ inputs.version }}/${{ inputs.board }}/ + rclone copy upload cdn:${{ inputs.cf-bucket }}/${{ inputs.release-channel }}/${{ inputs.board }}/ diff --git a/.github/actions/merge-partitions/action.yml b/.github/actions/merge-partitions/action.yml index 75d279da..6093dde1 100644 --- a/.github/actions/merge-partitions/action.yml +++ b/.github/actions/merge-partitions/action.yml @@ -4,6 +4,9 @@ inputs: python-version: description: 'Python version to use' required: true + release-channel: + description: 'Release channel that describes this upload' + required: true board: description: 'Board name to merge partitions for' required: true @@ -46,7 +49,7 @@ runs: shell: bash run: | python scripts/merge_image.py ${{ inputs.board }} - mv merged.bin OpenShock_${{ inputs.board }}_${{ !contains(github.ref_name, '/') && github.ref_name || 'unknown' }}.bin + mv merged.bin OpenShock_${{ inputs.board }}_${{ inputs.release-channel }}.bin - name: Upload merged firmware binary uses: actions/upload-artifact@v3 diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml index 70dea7b1..2b1aca27 100644 --- a/.github/workflows/build-all.yml +++ b/.github/workflows/build-all.yml @@ -15,6 +15,10 @@ on: type: string required: true description: 'The version of the firmware' + release-channel: + type: string + required: true + description: 'The release channel to use' board-matrix: type: string required: true @@ -81,5 +85,6 @@ jobs: - uses: ./.github/actions/merge-partitions with: python-version: ${{ inputs.python-version }} + release-channel: ${{ inputs.release-channel }} board: ${{ matrix.board }} skip-checkout: true diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 5b338b31..fcfd0f44 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -26,6 +26,7 @@ jobs: uses: ./.github/workflows/build-all.yml with: version: ${{ needs.getvars.outputs.version }} + release-channel: ${{ needs.getvars.outputs.release-channel }} board-matrix: ${{ needs.getvars.outputs.board-matrix }} checkpoint-build: diff --git a/.github/workflows/publish-all.yml b/.github/workflows/publish-all.yml index 772966ba..3cff39c9 100644 --- a/.github/workflows/publish-all.yml +++ b/.github/workflows/publish-all.yml @@ -53,9 +53,8 @@ jobs: - uses: ./.github/actions/cdn-upload-firmware with: cf-bucket: ${{ vars.S3_BUCKET }} - board: ${{ matrix.board }} - version: ${{ inputs.version }} release-channel: ${{ inputs.release-channel }} + board: ${{ matrix.board }} cdn-upload-version-info: runs-on: ubuntu-latest @@ -78,7 +77,7 @@ jobs: - uses: ./.github/actions/cdn-upload-version-info with: cf-bucket: ${{ vars.S3_BUCKET }} - version: ${{ inputs.version }} + release-channel: ${{ inputs.release-channel }} boards: ${{ inputs.board-list }} cdn-bump-version: From 65150c1e9860be5d72fbe41373d58e491c3f1985 Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 11 Jan 2024 17:30:21 +0100 Subject: [PATCH 13/24] Attempt to fix R2 uploads --- .github/actions/cdn-upload-firmware/action.yml | 2 +- .github/actions/cdn-upload-version-info/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/cdn-upload-firmware/action.yml b/.github/actions/cdn-upload-firmware/action.yml index 3b2d9f81..96b98d66 100644 --- a/.github/actions/cdn-upload-firmware/action.yml +++ b/.github/actions/cdn-upload-firmware/action.yml @@ -49,4 +49,4 @@ runs: mkdir upload mv *.bin upload/ mv hashes.*.txt upload/ - rclone copy upload cdn:${{ inputs.cf-bucket }}/${{ inputs.release-channel }}/${{ inputs.board }}/ + rclone copy upload 'cdn:${{ inputs.cf-bucket }}/${{ inputs.release-channel }}/${{ inputs.board }}/' diff --git a/.github/actions/cdn-upload-version-info/action.yml b/.github/actions/cdn-upload-version-info/action.yml index 65db5699..fde44fa7 100644 --- a/.github/actions/cdn-upload-version-info/action.yml +++ b/.github/actions/cdn-upload-version-info/action.yml @@ -24,4 +24,4 @@ runs: run: | mkdir upload mv boards.txt upload/ - rclone copy upload cdn:${{ inputs.cf-bucket }}/${{ inputs.release-channel }}/${{ inputs.board }}/ + rclone copy upload 'cdn:${{ inputs.cf-bucket }}/${{ inputs.release-channel }}/${{ inputs.board }}/' From fe01f4ed97f4f58d2004f19288b44b2cccd86032 Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 11 Jan 2024 17:52:30 +0100 Subject: [PATCH 14/24] Couple more fixes --- .github/workflows/ci-build.yml | 1 + .github/workflows/publish-all.yml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index fcfd0f44..39652a74 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -46,3 +46,4 @@ jobs: board-list: ${{ needs.getvars.outputs.board-list }} board-matrix: ${{ needs.getvars.outputs.board-matrix }} release-notes: ${{ needs.getvars.outputs.release-notes }} + secrets: inherit diff --git a/.github/workflows/publish-all.yml b/.github/workflows/publish-all.yml index 3cff39c9..de8e3936 100644 --- a/.github/workflows/publish-all.yml +++ b/.github/workflows/publish-all.yml @@ -25,6 +25,9 @@ on: type: string required: true description: 'Release notes for this release' + secrets: + S3_SECRET_ACCESS_KEY: + required: true name: Publish release @@ -112,6 +115,7 @@ jobs: - run: echo "CDN checkpoint reached" release: + if: (inputs.release-channel == 'stable' || inputs.release-channel == 'beta') runs-on: ubuntu-latest needs: [checkpoint-cdn] From ef774c31d2c4c0695841d58b96fd81a8ac69d44d Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 11 Jan 2024 18:04:54 +0100 Subject: [PATCH 15/24] Fix version upload --- .github/actions/cdn-bump-version/action.yml | 1 - .github/workflows/ci-build.yml | 3 +++ .github/workflows/publish-all.yml | 30 +++++++++++++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.github/actions/cdn-bump-version/action.yml b/.github/actions/cdn-bump-version/action.yml index e273fd7f..57c6bca6 100644 --- a/.github/actions/cdn-bump-version/action.yml +++ b/.github/actions/cdn-bump-version/action.yml @@ -14,7 +14,6 @@ inputs: runs: using: composite steps: - - name: Upload version file shell: bash run: | diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 39652a74..c9a3568e 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -46,4 +46,7 @@ jobs: board-list: ${{ needs.getvars.outputs.board-list }} board-matrix: ${{ needs.getvars.outputs.board-matrix }} release-notes: ${{ needs.getvars.outputs.release-notes }} + release-stable-list: ${{ needs.getvars.outputs.release-stable-list }} + release-beta-list: ${{ needs.getvars.outputs.release-beta-list }} + release-dev-list: ${{ needs.getvars.outputs.release-dev-list }} secrets: inherit diff --git a/.github/workflows/publish-all.yml b/.github/workflows/publish-all.yml index de8e3936..c2ad1dce 100644 --- a/.github/workflows/publish-all.yml +++ b/.github/workflows/publish-all.yml @@ -25,6 +25,18 @@ on: type: string required: true description: 'Release notes for this release' + release-stable-list: + type: string + required: true + description: Newline-separated list of all stable releases + release-beta-list: + type: string + required: true + description: Newline-separated list of all beta releases + release-dev-list: + type: string + required: true + description: Newline-separated list of all dev releases secrets: S3_SECRET_ACCESS_KEY: required: true @@ -105,8 +117,22 @@ jobs: - uses: ./.github/actions/cdn-bump-version with: cf-bucket: ${{ vars.S3_BUCKET }} - version: ${{ inputs.version }} - release-channel: ${{ inputs.release-channel }} + version-list: ${{ inputs.release-stable-list }} + release-channel: stable + + # Upload firmware to CDN. + - uses: ./.github/actions/cdn-bump-version + with: + cf-bucket: ${{ vars.S3_BUCKET }} + version-list: ${{ inputs.release-beta-list }} + release-channel: beta + + # Upload firmware to CDN. + - uses: ./.github/actions/cdn-bump-version + with: + cf-bucket: ${{ vars.S3_BUCKET }} + version-list: ${{ inputs.release-dev-list }} + release-channel: dev checkpoint-cdn: runs-on: ubuntu-latest From ab619e687424a7df9524f16fdefaac6e4ecfbb31 Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 11 Jan 2024 18:06:29 +0100 Subject: [PATCH 16/24] Use md5sum for md5's :eyes: --- .github/actions/cdn-upload-firmware/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/cdn-upload-firmware/action.yml b/.github/actions/cdn-upload-firmware/action.yml index 96b98d66..066d7612 100644 --- a/.github/actions/cdn-upload-firmware/action.yml +++ b/.github/actions/cdn-upload-firmware/action.yml @@ -40,7 +40,7 @@ runs: - name: Generate SHA256 checksums shell: bash run: | - find . -type f -name '*.bin' -exec sha256sum {} \; > hashes.md5.txt + find . -type f -name '*.bin' -exec md5sum {} \; > hashes.md5.txt find . -type f -name '*.bin' -exec sha256sum {} \; > hashes.sha256.txt - name: Upload artifacts to CDN From c447858bfbd46f51574a01b41ed4d917b0ea9b8c Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 11 Jan 2024 18:12:08 +0100 Subject: [PATCH 17/24] Final fix --- .github/actions/cdn-bump-version/action.yml | 2 +- .github/actions/cdn-upload-firmware/action.yml | 2 +- .github/actions/cdn-upload-version-info/action.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/cdn-bump-version/action.yml b/.github/actions/cdn-bump-version/action.yml index 57c6bca6..f343e73c 100644 --- a/.github/actions/cdn-bump-version/action.yml +++ b/.github/actions/cdn-bump-version/action.yml @@ -17,6 +17,6 @@ runs: - name: Upload version file shell: bash run: | - mkdir upload + mkdir -p upload echo "${{ inputs.version-list }}" >> upload/version-${{ inputs.release-channel }}.txt rclone copy upload cdn:${{ inputs.cf-bucket }}/ diff --git a/.github/actions/cdn-upload-firmware/action.yml b/.github/actions/cdn-upload-firmware/action.yml index 066d7612..7efe7b2e 100644 --- a/.github/actions/cdn-upload-firmware/action.yml +++ b/.github/actions/cdn-upload-firmware/action.yml @@ -46,7 +46,7 @@ runs: - name: Upload artifacts to CDN shell: bash run: | - mkdir upload + mkdir -p upload mv *.bin upload/ mv hashes.*.txt upload/ rclone copy upload 'cdn:${{ inputs.cf-bucket }}/${{ inputs.release-channel }}/${{ inputs.board }}/' diff --git a/.github/actions/cdn-upload-version-info/action.yml b/.github/actions/cdn-upload-version-info/action.yml index fde44fa7..b5df22fd 100644 --- a/.github/actions/cdn-upload-version-info/action.yml +++ b/.github/actions/cdn-upload-version-info/action.yml @@ -22,6 +22,6 @@ runs: - name: Upload artifacts to CDN shell: bash run: | - mkdir upload + mkdir -p upload mv boards.txt upload/ rclone copy upload 'cdn:${{ inputs.cf-bucket }}/${{ inputs.release-channel }}/${{ inputs.board }}/' From 5080066a24ff473ff50593e0459f6c0f31cc3c99 Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 11 Jan 2024 18:24:35 +0100 Subject: [PATCH 18/24] Fix secret complaining --- .github/workflows/ci-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index c9a3568e..7ed4795a 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -49,4 +49,5 @@ jobs: release-stable-list: ${{ needs.getvars.outputs.release-stable-list }} release-beta-list: ${{ needs.getvars.outputs.release-beta-list }} release-dev-list: ${{ needs.getvars.outputs.release-dev-list }} - secrets: inherit + secrets: + S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }} From 151f83ac9f4f1c47d1cae16d32821e6f986744f0 Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Thu, 11 Jan 2024 18:34:05 +0100 Subject: [PATCH 19/24] Revert multiline version.txt --- .github/actions/cdn-bump-version/action.yml | 6 ++--- .github/workflows/ci-build.yml | 3 --- .github/workflows/publish-all.yml | 30 ++------------------- 3 files changed, 5 insertions(+), 34 deletions(-) diff --git a/.github/actions/cdn-bump-version/action.yml b/.github/actions/cdn-bump-version/action.yml index f343e73c..6f76f067 100644 --- a/.github/actions/cdn-bump-version/action.yml +++ b/.github/actions/cdn-bump-version/action.yml @@ -4,8 +4,8 @@ inputs: cf-bucket: description: Name of the S3 bucket required: true - version-list: - description: 'List of versions, separated by newlines' + version: + description: 'Version of the release' required: true release-channel: description: 'Release channel that describes this upload' @@ -18,5 +18,5 @@ runs: shell: bash run: | mkdir -p upload - echo "${{ inputs.version-list }}" >> upload/version-${{ inputs.release-channel }}.txt + echo "${{ inputs.version }}" >> upload/version-${{ inputs.release-channel }}.txt rclone copy upload cdn:${{ inputs.cf-bucket }}/ diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 7ed4795a..812d63c5 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -46,8 +46,5 @@ jobs: board-list: ${{ needs.getvars.outputs.board-list }} board-matrix: ${{ needs.getvars.outputs.board-matrix }} release-notes: ${{ needs.getvars.outputs.release-notes }} - release-stable-list: ${{ needs.getvars.outputs.release-stable-list }} - release-beta-list: ${{ needs.getvars.outputs.release-beta-list }} - release-dev-list: ${{ needs.getvars.outputs.release-dev-list }} secrets: S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/publish-all.yml b/.github/workflows/publish-all.yml index c2ad1dce..de8e3936 100644 --- a/.github/workflows/publish-all.yml +++ b/.github/workflows/publish-all.yml @@ -25,18 +25,6 @@ on: type: string required: true description: 'Release notes for this release' - release-stable-list: - type: string - required: true - description: Newline-separated list of all stable releases - release-beta-list: - type: string - required: true - description: Newline-separated list of all beta releases - release-dev-list: - type: string - required: true - description: Newline-separated list of all dev releases secrets: S3_SECRET_ACCESS_KEY: required: true @@ -117,22 +105,8 @@ jobs: - uses: ./.github/actions/cdn-bump-version with: cf-bucket: ${{ vars.S3_BUCKET }} - version-list: ${{ inputs.release-stable-list }} - release-channel: stable - - # Upload firmware to CDN. - - uses: ./.github/actions/cdn-bump-version - with: - cf-bucket: ${{ vars.S3_BUCKET }} - version-list: ${{ inputs.release-beta-list }} - release-channel: beta - - # Upload firmware to CDN. - - uses: ./.github/actions/cdn-bump-version - with: - cf-bucket: ${{ vars.S3_BUCKET }} - version-list: ${{ inputs.release-dev-list }} - release-channel: dev + version: ${{ inputs.version }} + release-channel: ${{ inputs.release-channel }} checkpoint-cdn: runs-on: ubuntu-latest From 6204b75fdb1954057e38d70bad391cbcecf75cd9 Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Fri, 12 Jan 2024 17:08:37 +0100 Subject: [PATCH 20/24] Fix remaining problems with cicd pipeline --- .github/actions/build-firmware/action.yml | 2 +- .github/actions/build-frontend/action.yml | 2 +- .github/actions/build-staticfs/action.yml | 4 +- .../actions/cdn-upload-firmware/action.yml | 6 +- .github/actions/merge-partitions/action.yml | 6 +- .github/scripts/get-vars.js | 31 ++- .github/workflows/build-all.yml | 90 -------- .github/workflows/ci-build.yml | 192 ++++++++++++++++-- .github/workflows/publish-all.yml | 133 ------------ 9 files changed, 207 insertions(+), 259 deletions(-) delete mode 100644 .github/workflows/build-all.yml delete mode 100644 .github/workflows/publish-all.yml diff --git a/.github/actions/build-firmware/action.yml b/.github/actions/build-firmware/action.yml index 47bcd8f7..8d70b167 100644 --- a/.github/actions/build-firmware/action.yml +++ b/.github/actions/build-firmware/action.yml @@ -50,7 +50,7 @@ runs: OPENSHOCK_FW_BUILD_DATE: ${{ github.event.head_commit.timestamp }} - name: Upload build artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware_build_${{ inputs.board }} path: .pio/build/${{ inputs.board }}/*.bin diff --git a/.github/actions/build-frontend/action.yml b/.github/actions/build-frontend/action.yml index dbab2ce2..d1b2e2ac 100644 --- a/.github/actions/build-frontend/action.yml +++ b/.github/actions/build-frontend/action.yml @@ -35,7 +35,7 @@ runs: run: npm run build - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: frontend path: frontend/build/* diff --git a/.github/actions/build-staticfs/action.yml b/.github/actions/build-staticfs/action.yml index 5f9d1791..7e0b9a55 100644 --- a/.github/actions/build-staticfs/action.yml +++ b/.github/actions/build-staticfs/action.yml @@ -33,7 +33,7 @@ runs: run: pip install -r requirements.txt - name: Download built frontend - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: frontend path: frontend/build/ @@ -47,7 +47,7 @@ runs: run: mv .pio/build/fs/littlefs.bin staticfs.bin - name: Upload internal filesystem artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware_staticfs path: staticfs.bin diff --git a/.github/actions/cdn-upload-firmware/action.yml b/.github/actions/cdn-upload-firmware/action.yml index 7efe7b2e..3d01c485 100644 --- a/.github/actions/cdn-upload-firmware/action.yml +++ b/.github/actions/cdn-upload-firmware/action.yml @@ -15,19 +15,19 @@ runs: using: composite steps: - name: Download static filesystem partition - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: firmware_staticfs path: . - name: Download firmware partitions - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: firmware_build_${{ inputs.board }} path: . - name: Download merged firmware binary - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: firmware_merged_${{ inputs.board }} path: . diff --git a/.github/actions/merge-partitions/action.yml b/.github/actions/merge-partitions/action.yml index 6093dde1..6ec3fc03 100644 --- a/.github/actions/merge-partitions/action.yml +++ b/.github/actions/merge-partitions/action.yml @@ -36,12 +36,12 @@ runs: run: pip install esptool - name: Download static filesystem partition - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: firmware_staticfs - name: Download firmware partitions - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: firmware_build_${{ inputs.board }} @@ -52,7 +52,7 @@ runs: mv merged.bin OpenShock_${{ inputs.board }}_${{ inputs.release-channel }}.bin - name: Upload merged firmware binary - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware_merged_${{ inputs.board }} path: OpenShock_${{ inputs.board }}_*.bin diff --git a/.github/scripts/get-vars.js b/.github/scripts/get-vars.js index 38482a49..90cb22f2 100644 --- a/.github/scripts/get-vars.js +++ b/.github/scripts/get-vars.js @@ -54,9 +54,19 @@ const gitTagsArray = gitTagsList.split('\n').map((tag) => tag.trim()); const releasesArray = gitTagsArray.map(convertGitTagToSemver); const latestRelease = isGitTag ? convertGitTagToSemver(gitRef.split('/')[2]) : releasesArray[0]; -const stableReleasesArray = releasesArray.filter((release) => release.prerelease.length === 0 || release.prerelease[0] === 'stable'); -const betaReleasesArray = releasesArray.filter((release) => release.prerelease.length > 0 && ['rc', 'beta'].includes(release.prerelease[0])); -const devReleasesArray = releasesArray.filter((release) => release.prerelease.length > 0 && ['dev', 'develop'].includes(release.prerelease[0])); +function isStableRelease(release) { + return release.prerelease.length === 0 || release.prerelease[0] === 'stable'; +} +function isBetaRelease(release) { + return release.prerelease.length > 0 && ['rc', 'beta'].includes(release.prerelease[0]); +} +function isDevRelease(release) { + return release.prerelease.length > 0 && ['dev', 'develop'].includes(release.prerelease[0]); +} + +const stableReleasesArray = releasesArray.filter(isStableRelease); +const betaReleasesArray = releasesArray.filter(isBetaRelease); +const devReleasesArray = releasesArray.filter(isDevRelease); // Build version string let currentVersion = `${latestRelease.major}.${latestRelease.minor}.${latestRelease.patch}`; @@ -76,16 +86,23 @@ if (!isGitTag) { // Add the git commit hash to the version string currentVersion += `+${gitShortCommitHash}`; +} else { + if (latestRelease.prerelease.length > 0) { + currentVersion += `-${latestRelease.prerelease.join('.')}`; + } + if (latestRelease.build.length > 0) { + currentVersion += `+${latestRelease.build.join('.')}`; + } } // Get the channel to deploy to let currentChannel; -if (gitHeadRefName === 'master') { +if (gitHeadRefName === 'master' || (isGitTag && isStableRelease(latestRelease))) { currentChannel = 'stable'; -} else if (gitHeadRefName === 'develop') { - currentChannel = 'develop'; -} else if (gitHeadRefName === 'beta') { +} else if (gitHeadRefName === 'beta' || (isGitTag && isBetaRelease(latestRelease))) { currentChannel = 'beta'; +} else if (gitHeadRefName === 'develop' || (isGitTag && isDevRelease(latestRelease))) { + currentChannel = 'develop'; } else { currentChannel = gitHeadRefName.replace(/[^a-zA-Z0-9-]/g, '-').replace(/^\-+|\-+$/g, ''); } diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml deleted file mode 100644 index 2b1aca27..00000000 --- a/.github/workflows/build-all.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: build-all - -on: - workflow_call: - inputs: - node-version: - type: string - default: '18' - description: 'The version of Node.js to use' - python-version: - type: string - default: '3.12' - description: 'The version of Python to use' - version: - type: string - required: true - description: 'The version of the firmware' - release-channel: - type: string - required: true - description: 'The release channel to use' - board-matrix: - type: string - required: true - description: 'A JSON matrix of boards to build for' - -jobs: - build-frontend: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - frontend - - - uses: ./.github/actions/build-frontend - with: - node-version: ${{ inputs.node-version }} - - build-staticfs: - runs-on: ubuntu-latest - needs: build-frontend - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/build-staticfs - with: - python-version: ${{ inputs.python-version }} - skip-checkout: true - - build-firmware: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{ fromJSON(inputs.board-matrix) }} - - steps: - - uses: actions/checkout@v4 - - - uses: ./.github/actions/build-firmware - with: - python-version: ${{ inputs.python-version }} - board: ${{ matrix.board }} - version: ${{ inputs.version }} - skip-checkout: true - - merge-partitions: - runs-on: ubuntu-latest - needs: [build-staticfs, build-firmware] - strategy: - fail-fast: false - matrix: ${{ fromJSON(inputs.board-matrix) }} - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - scripts - boards - chips - - - uses: ./.github/actions/merge-partitions - with: - python-version: ${{ inputs.python-version }} - release-channel: ${{ inputs.release-channel }} - board: ${{ matrix.board }} - skip-checkout: true diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 812d63c5..8e5584a4 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -17,34 +17,188 @@ on: name: ci-build +env: + NODE_VERSION: 18 + PYTHON_VERSION: 3.12 + jobs: getvars: uses: ./.github/workflows/get-vars.yml - build: - needs: getvars - uses: ./.github/workflows/build-all.yml - with: - version: ${{ needs.getvars.outputs.version }} - release-channel: ${{ needs.getvars.outputs.release-channel }} - board-matrix: ${{ needs.getvars.outputs.board-matrix }} + build-frontend: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + frontend + + - uses: ./.github/actions/build-frontend + with: + node-version: ${{ env.NODE_VERSION }} + + build-staticfs: + runs-on: ubuntu-latest + needs: build-frontend + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/build-staticfs + with: + python-version: ${{ env.PYTHON_VERSION }} + skip-checkout: true + + build-firmware: + needs: [getvars] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.getvars.outputs.board-matrix) }} + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/build-firmware + with: + python-version: ${{ env.PYTHON_VERSION }} + board: ${{ matrix.board }} + version: ${{ needs.getvars.outputs.version }} + skip-checkout: true + + merge-partitions: + needs: [getvars, build-staticfs, build-firmware] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.getvars.outputs.board-matrix) }} + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + scripts + boards + chips + + - uses: ./.github/actions/merge-partitions + with: + python-version: ${{ env.PYTHON_VERSION }} + release-channel: ${{ needs.getvars.outputs.release-channel }} + board: ${{ matrix.board }} + skip-checkout: true checkpoint-build: runs-on: ubuntu-latest - needs: [getvars, build] + needs: [merge-partitions] steps: - run: echo "Builds checkpoint reached" - publish: + cdn-upload-firmware: + needs: [getvars, checkpoint-build] if: ${{ needs.getvars.outputs.should-deploy == 'true' }} + runs-on: ubuntu-latest + environment: cdn-firmware-r2 + strategy: + fail-fast: true + matrix: ${{ fromJson(needs.getvars.outputs.board-matrix) }} + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + + # Set up rclone for CDN uploads. + - uses: ./.github/actions/cdn-prepare + with: + cf-account-id: ${{ vars.S3_ACCOUNT_ID }} + cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} + cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} + + # Upload firmware to CDN. + - uses: ./.github/actions/cdn-upload-firmware + with: + cf-bucket: ${{ vars.S3_BUCKET }} + release-channel: ${{ inputs.release-channel }} + board: ${{ matrix.board }} + + cdn-upload-version-info: needs: [getvars, checkpoint-build] - uses: ./.github/workflows/publish-all.yml - with: - version: ${{ needs.getvars.outputs.version }} - release-channel: ${{ needs.getvars.outputs.release-channel }} - is-prerelease: ${{ needs.getvars.outputs.release-channel != 'stable' }} - board-list: ${{ needs.getvars.outputs.board-list }} - board-matrix: ${{ needs.getvars.outputs.board-matrix }} - release-notes: ${{ needs.getvars.outputs.release-notes }} - secrets: - S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }} + if: ${{ needs.getvars.outputs.should-deploy == 'true' }} + runs-on: ubuntu-latest + environment: cdn-firmware-r2 + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + + # Set up rclone for CDN uploads. + - uses: ./.github/actions/cdn-prepare + with: + cf-account-id: ${{ vars.S3_ACCOUNT_ID }} + cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} + cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} + + # Upload firmware to CDN. + - uses: ./.github/actions/cdn-upload-version-info + with: + cf-bucket: ${{ vars.S3_BUCKET }} + release-channel: ${{ needs.getvars.outputs.release-channel }} + boards: ${{ needs.getvars.outputs.board-list }} + + cdn-bump-version: + runs-on: ubuntu-latest + needs: [getvars, cdn-upload-firmware] # only after version is complete + environment: cdn-firmware-r2 + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + + # Set up rclone for CDN uploads. + - uses: ./.github/actions/cdn-prepare + with: + cf-account-id: ${{ vars.S3_ACCOUNT_ID }} + cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} + cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} + + # Upload firmware to CDN. + - uses: ./.github/actions/cdn-bump-version + with: + cf-bucket: ${{ vars.S3_BUCKET }} + version: ${{ needs.getvars.outputs.version }} + release-channel: ${{ needs.getvars.outputs.release-channel }} + + checkpoint-cdn: + runs-on: ubuntu-latest + needs: [cdn-upload-firmware, cdn-upload-version-info, cdn-bump-version] + steps: + - run: echo "CDN checkpoint reached" + + release: + needs: [getvars, checkpoint-cdn] + if: (needs.getvars.outputs.release-channel == 'stable' || needs.getvars.outputs.release-channel == 'beta') + runs-on: ubuntu-latest + + steps: + - name: Download release artifacts + uses: actions/download-artifact@v4 + + - name: Display artifacts + run: ls -R + + - name: Release + uses: ncipollo/release-action@v1 + with: + artifacts: '**/OpenShock_*.bin' + tag: ${{ needs.getvars.outputs.version }} + prerelease: ${{ needs.getvars.outputs.is-prerelease }} + artifactErrorsFailBuild: true + body: ${{ needs.getvars.outputs.release-notes }} diff --git a/.github/workflows/publish-all.yml b/.github/workflows/publish-all.yml deleted file mode 100644 index de8e3936..00000000 --- a/.github/workflows/publish-all.yml +++ /dev/null @@ -1,133 +0,0 @@ -on: - workflow_call: - inputs: - version: - type: string - required: true - description: 'Firmware version to publish' - release-channel: - type: string - required: true - description: 'Release channel to publish to' - is-prerelease: - type: boolean - required: true - description: 'Whether this is a prerelease' - board-list: - type: string - required: true - description: 'JSON list of boards to publish' - board-matrix: - type: string - required: true - description: 'JSON matrix of boards to publish' - release-notes: - type: string - required: true - description: 'Release notes for this release' - secrets: - S3_SECRET_ACCESS_KEY: - required: true - -name: Publish release - -jobs: - cdn-upload-firmware: - runs-on: ubuntu-latest - environment: cdn-firmware-r2 - strategy: - fail-fast: true - matrix: ${{ fromJson(inputs.board-matrix) }} - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - - # Set up rclone for CDN uploads. - - uses: ./.github/actions/cdn-prepare - with: - cf-account-id: ${{ vars.S3_ACCOUNT_ID }} - cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} - cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} - - # Upload firmware to CDN. - - uses: ./.github/actions/cdn-upload-firmware - with: - cf-bucket: ${{ vars.S3_BUCKET }} - release-channel: ${{ inputs.release-channel }} - board: ${{ matrix.board }} - - cdn-upload-version-info: - runs-on: ubuntu-latest - environment: cdn-firmware-r2 - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - - # Set up rclone for CDN uploads. - - uses: ./.github/actions/cdn-prepare - with: - cf-account-id: ${{ vars.S3_ACCOUNT_ID }} - cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} - cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} - - # Upload firmware to CDN. - - uses: ./.github/actions/cdn-upload-version-info - with: - cf-bucket: ${{ vars.S3_BUCKET }} - release-channel: ${{ inputs.release-channel }} - boards: ${{ inputs.board-list }} - - cdn-bump-version: - runs-on: ubuntu-latest - needs: [cdn-upload-firmware] # only after version is complete - environment: cdn-firmware-r2 - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - - # Set up rclone for CDN uploads. - - uses: ./.github/actions/cdn-prepare - with: - cf-account-id: ${{ vars.S3_ACCOUNT_ID }} - cf-access-key-id: ${{ vars.S3_ACCESS_KEY_ID }} - cf-secret-access-key: ${{ secrets.S3_SECRET_ACCESS_KEY }} - - # Upload firmware to CDN. - - uses: ./.github/actions/cdn-bump-version - with: - cf-bucket: ${{ vars.S3_BUCKET }} - version: ${{ inputs.version }} - release-channel: ${{ inputs.release-channel }} - - checkpoint-cdn: - runs-on: ubuntu-latest - needs: [cdn-upload-firmware, cdn-upload-version-info, cdn-bump-version] - steps: - - run: echo "CDN checkpoint reached" - - release: - if: (inputs.release-channel == 'stable' || inputs.release-channel == 'beta') - runs-on: ubuntu-latest - needs: [checkpoint-cdn] - - steps: - - name: Download release artifacts - uses: actions/download-artifact@v4 - - - name: Release - uses: ncipollo/release-action@v1 - with: - artifacts: '**/OpenShock_*.bin' - tag: ${{ inputs.version }} - prerelease: ${{ inputs.is-prerelease }} - artifactErrorsFailBuild: true - body: ${{ inputs.release-notes }} From a256eee1c4247b320b72f097c8f87a7e93aadc17 Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Fri, 12 Jan 2024 17:33:29 +0100 Subject: [PATCH 21/24] Fix prerelease and release-channel vars --- .github/workflows/ci-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 8e5584a4..4282e924 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -122,7 +122,7 @@ jobs: - uses: ./.github/actions/cdn-upload-firmware with: cf-bucket: ${{ vars.S3_BUCKET }} - release-channel: ${{ inputs.release-channel }} + release-channel: ${{ needs.getvars.outputs.release-channel }} board: ${{ matrix.board }} cdn-upload-version-info: @@ -199,6 +199,6 @@ jobs: with: artifacts: '**/OpenShock_*.bin' tag: ${{ needs.getvars.outputs.version }} - prerelease: ${{ needs.getvars.outputs.is-prerelease }} + prerelease: ${{ needs.getvars.outputs.release-channel != 'stable' }} artifactErrorsFailBuild: true body: ${{ needs.getvars.outputs.release-notes }} From eda98843e92ebf6d0cfc2ac2d56cf8f7a41c5e94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 16:34:34 +0000 Subject: [PATCH 22/24] build(deps): Bump actions/setup-node from 3 to 4 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/get-vars.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/get-vars.yml b/.github/workflows/get-vars.yml index 5ab44530..857b0452 100644 --- a/.github/workflows/get-vars.yml +++ b/.github/workflows/get-vars.yml @@ -88,7 +88,7 @@ jobs: sparse-checkout: | .github - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: ${{ inputs.node-version }} cache: 'npm' From a2d27b80ea056f08d2d3d6dfc82e77b17ef3e38f Mon Sep 17 00:00:00 2001 From: HentaiHeavenVR Date: Sun, 14 Jan 2024 07:23:33 -0800 Subject: [PATCH 23/24] Fix everything (#182) * Correct User-Agent format * Add all OtaUpdateConfig fields on fbs serialize * Don't null check a enum lmao --- frontend/src/lib/mappers/ConfigMapper.ts | 1 - src/config/OtaUpdateConfig.cpp | 2 +- src/http/HTTPRequestManager.cpp | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/mappers/ConfigMapper.ts b/frontend/src/lib/mappers/ConfigMapper.ts index 1c7a4ec8..2263d1f6 100644 --- a/frontend/src/lib/mappers/ConfigMapper.ts +++ b/frontend/src/lib/mappers/ConfigMapper.ts @@ -153,7 +153,6 @@ function mapOtaUpdateConfig(fbsConfig: FbsConfig): OtaUpdateConfig { const requireManualApproval = otaUpdate.requireManualApproval(); if (!cdnDomain) throw new Error('otaUpdate.cdnDomain is null'); - if (!updateChannel) throw new Error('otaUpdate.updateChannel is null'); return { isEnabled, diff --git a/src/config/OtaUpdateConfig.cpp b/src/config/OtaUpdateConfig.cpp index af8d8acf..35383d3f 100644 --- a/src/config/OtaUpdateConfig.cpp +++ b/src/config/OtaUpdateConfig.cpp @@ -69,7 +69,7 @@ bool OtaUpdateConfig::FromFlatbuffers(const Serialization::Configuration::OtaUpd } flatbuffers::Offset OtaUpdateConfig::ToFlatbuffers(flatbuffers::FlatBufferBuilder& builder, bool withSensitiveData) const { - return Serialization::Configuration::CreateOtaUpdateConfig(builder, isEnabled, builder.CreateString(cdnDomain), updateChannel, checkPeriodically, checkInterval, allowBackendManagement, requireManualApproval); + return Serialization::Configuration::CreateOtaUpdateConfig(builder, isEnabled, builder.CreateString(cdnDomain), updateChannel, checkOnStartup, checkPeriodically, checkInterval, allowBackendManagement, requireManualApproval, updateId, bootType); } bool OtaUpdateConfig::FromJSON(const cJSON* json) { diff --git a/src/http/HTTPRequestManager.cpp b/src/http/HTTPRequestManager.cpp index 1bc4a22e..8f75f6d4 100644 --- a/src/http/HTTPRequestManager.cpp +++ b/src/http/HTTPRequestManager.cpp @@ -14,7 +14,7 @@ constexpr std::size_t HTTP_BUFFER_SIZE = 4096LLU; constexpr int HTTP_DOWNLOAD_SIZE_LIMIT = 200 * 1024 * 1024; // 200 MB const char* const TAG = "HTTPRequestManager"; -const char* const OPENSHOCK_FW_USERAGENT = OPENSHOCK_FW_HOSTNAME "/" OPENSHOCK_FW_VERSION " (Espressif; " OPENSHOCK_FW_CHIP "; " OPENSHOCK_FW_BOARD ") " OPENSHOCK_FW_GIT_COMMIT; +const char* const OPENSHOCK_FW_USERAGENT = OPENSHOCK_FW_HOSTNAME "/" OPENSHOCK_FW_VERSION " (" OPENSHOCK_FW_BOARD "; " OPENSHOCK_FW_CHIP "; Espressif) " OPENSHOCK_FW_GIT_COMMIT; struct RateLimit { RateLimit() : m_blockUntilMs(0), m_limits(), m_requests() { } From ea4e2b4266c94810538677ee05b4bb288afccc7c Mon Sep 17 00:00:00 2001 From: hhvrc Date: Sun, 14 Jan 2024 16:26:39 +0100 Subject: [PATCH 24/24] maybe fix --- .github/actions/build-frontend/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-frontend/action.yml b/.github/actions/build-frontend/action.yml index d1b2e2ac..b7a9be66 100644 --- a/.github/actions/build-frontend/action.yml +++ b/.github/actions/build-frontend/action.yml @@ -18,7 +18,7 @@ runs: frontend path: ${{ github.repository }} - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: ${{ inputs.node-version }} cache: 'npm'