From 0af4346e07312df2085547ab40e327d3feb73101 Mon Sep 17 00:00:00 2001 From: HeavenVR Date: Sun, 21 Dec 2025 02:41:40 +0100 Subject: [PATCH 1/3] Fix LCG connection issues --- src/GatewayConnectionManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GatewayConnectionManager.cpp b/src/GatewayConnectionManager.cpp index 3204373c..90b45f0f 100644 --- a/src/GatewayConnectionManager.cpp +++ b/src/GatewayConnectionManager.cpp @@ -283,7 +283,7 @@ void GatewayConnectionManager::Update() } // Fetch hub info - if (!FetchHubInfo(std::move(authToken))) { + if (!FetchHubInfo(authToken)) { return; } From 37d846d1b77faf0c44fbd353e5aa86536fa90a93 Mon Sep 17 00:00:00 2001 From: HeavenVR Date: Sun, 21 Dec 2025 02:52:04 +0100 Subject: [PATCH 2/3] fix: Miscellaneous warnings (#401) * Some minor cleanup * Fix panic loggers * Disable runtime type information and exceptions * Fix more potential bus and warnings * Add C++ flags for C++ only * Fix some other warnings --- include/Logging.h | 34 ++++++++++++++++++------------- include/TinyVec.h | 5 +++-- include/radio/rmt/Sequence.h | 2 +- platformio.ini | 23 +++++++++++++-------- scripts/embed_env_vars.py | 2 +- src/CommandHandler.cpp | 5 ++++- src/GatewayConnectionManager.cpp | 2 +- src/radio/RFTransmitter.cpp | 7 +++++-- src/serial/SerialInputHandler.cpp | 2 +- src/serialization/JsonAPI.cpp | 2 +- 10 files changed, 51 insertions(+), 33 deletions(-) diff --git a/include/Logging.h b/include/Logging.h index a79ef3d5..c4044012 100644 --- a/include/Logging.h +++ b/include/Logging.h @@ -69,17 +69,23 @@ constexpr const char* openshockPathToFileName(const char (&path)[N]) { #define OS_PANIC_PRINT(TAG, format, ...) OS_LOGE(TAG, "PANIC: " format, ##__VA_ARGS__) -#define OS_PANIC(TAG, format, ...) \ - OS_PANIC_PRINT(TAG, format ", restarting in 5 seconds...", ##__VA_ARGS__); \ - vTaskDelay(pdMS_TO_TICKS(5000)); \ - esp_restart() - -#define OS_PANIC_OTA(TAG, format, ...) \ - OS_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 OS_PANIC_INSTANT(TAG, format, ...) \ - OS_PANIC_PRINT(TAG, format, ##__VA_ARGS__); \ - esp_restart() +#define OS_PANIC(TAG, format, ...) \ + { \ + OS_PANIC_PRINT(TAG, format ", restarting in 5 seconds...", ##__VA_ARGS__); \ + vTaskDelay(pdMS_TO_TICKS(5000)); \ + esp_restart(); \ + } + +#define OS_PANIC_OTA(TAG, format, ...) \ + { \ + OS_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 OS_PANIC_INSTANT(TAG, format, ...) \ + { \ + OS_PANIC_PRINT(TAG, format, ##__VA_ARGS__); \ + esp_restart(); \ + } diff --git a/include/TinyVec.h b/include/TinyVec.h index 6581a374..0ff12834 100644 --- a/include/TinyVec.h +++ b/include/TinyVec.h @@ -1,6 +1,7 @@ #pragma once #include "Common.h" +#include "Logging.h" #include #include @@ -69,10 +70,10 @@ class TinyVec { void reserve(SizeType new_cap) { if (new_cap <= _cap) return; - if (sizeof(T) && new_cap > std::numeric_limits::max() / sizeof(T)) throw std::bad_alloc(); + if (sizeof(T) && new_cap > std::numeric_limits::max() / sizeof(T)) OS_PANIC_INSTANT("TVEC", "Cannot allocate a buffer of given size!"); void* newbuf = malloc(size_t(new_cap) * sizeof(T)); - if (!newbuf) throw std::bad_alloc(); + if (!newbuf) OS_PANIC_INSTANT("TVEC", "Could not allocate a buffer of given size!"); if (_data) { memcpy(newbuf, _data, size_t(_len) * sizeof(T)); free(_data); diff --git a/include/radio/rmt/Sequence.h b/include/radio/rmt/Sequence.h index 39107805..ba043258 100644 --- a/include/radio/rmt/Sequence.h +++ b/include/radio/rmt/Sequence.h @@ -73,7 +73,7 @@ namespace OpenShock::Rmt { m_size = 0; m_transmitEnd = 0; m_shockerId = 0; - m_shockerModel = (ShockerModelType)0; + m_shockerModel = static_cast(0); } rmt_data_t* m_data; diff --git a/platformio.ini b/platformio.ini index a4500629..f64c29b7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,13 +13,20 @@ platform = espressif32 @ 6.12.0 board = az-delivery-devkit-v4 ; Overridden per board framework = arduino -; Most warnings here are commented out because the compiler detects warnings outside own code, if we can disable external files for warnings that would be amazing! build_flags = -std=c++2a -std=gnu++2a + -fno-exceptions + -DCONFIG_ASYNC_TCP_QUEUE_SIZE=256 +build_unflags = + -std=gnu++11 + +; Most warnings here are commented out because the compiler detects warnings outside own code, build_src_flags is meant to only be for our code but doesnt seem to work in this instance... +build_src_flags = -Wall -Wextra ;-Wpedantic + ;-Werror ;-Wcast-align ;-Wcast-qual ;-Wctor-dtor-privacy @@ -29,23 +36,21 @@ build_flags = -Wlogical-op ;-Wmissing-declarations -Wmissing-include-dirs - ;-Wnoexcept + -Wnoexcept ;-Wold-style-cast ;-Woverloaded-virtual ;-Wredundant-decls ;-Wshadow ;-Wsign-conversion - ;-Wsign-promo - ;-Wstrict-null-sentinel - ;-Wstrict-overflow=5 + -Wsign-promo + -Wstrict-null-sentinel + -Wstrict-overflow=5 -Wswitch-default ;-Wundef - ;-Werror -Wno-unused -Wno-unknown-pragmas - -DCONFIG_ASYNC_TCP_QUEUE_SIZE=256 -build_unflags = - -std=gnu++11 + ;-Weffc++ + lib_deps = https://github.com/google/flatbuffers#8b02fe6178427b96aea25396b53ea4ae8cadd7d8 https://github.com/OpenShock/ESPAsyncWebServer#469816c6bd287e3ecdda9e519c2532db019aa3c1 diff --git a/scripts/embed_env_vars.py b/scripts/embed_env_vars.py index 65fbef97..3c924a2c 100644 --- a/scripts/embed_env_vars.py +++ b/scripts/embed_env_vars.py @@ -245,12 +245,12 @@ def print_dump(name: str, map: Mapping[str, str | int | bool]) -> None: cpp_defines = serialize_cpp_defines(cpp_defines) print('Build type: ' + pio_build_type) -print('Build defines: ' + str(cpp_defines)) # Set PIO variables. env['BUILD_TYPE'] = pio_build_type env['BUILD_FLAGS'] = remaining_build_flags env.Append(CPPDEFINES=list(cpp_defines.items())) +env.Append(CXXFLAGS=['-fno-rtti', '-fno-threadsafe-statics', '-fno-use-cxa-atexit']) # Rename the firmware.bin to app.bin. env.Replace(PROGNAME='app') diff --git a/src/CommandHandler.cpp b/src/CommandHandler.cpp index edd92efc..e0ef0c77 100644 --- a/src/CommandHandler.cpp +++ b/src/CommandHandler.cpp @@ -134,7 +134,10 @@ bool _internalSetKeepAliveEnabled(bool enabled) OS_LOGV(TAG, "Disabling keep-alive task"); if (s_keepAliveTaskHandle != nullptr && s_keepAliveQueue != nullptr) { // Wait for the task to stop - KnownShocker cmd {.killTask = true}; + KnownShocker cmd; + memset(&cmd, 0, sizeof(cmd)); + cmd.killTask = true; + while (eTaskGetState(s_keepAliveTaskHandle) != eDeleted) { vTaskDelay(pdMS_TO_TICKS(10)); diff --git a/src/GatewayConnectionManager.cpp b/src/GatewayConnectionManager.cpp index 90b45f0f..fb00f5c7 100644 --- a/src/GatewayConnectionManager.cpp +++ b/src/GatewayConnectionManager.cpp @@ -262,7 +262,7 @@ bool StartConnectingToLCG() return false; } - OS_LOGD(TAG, "Connecting to LCG endpoint { host: '%s', port: %hu, path: '%s' } in country %s", response.data.host.c_str(), response.data.port, response.data.path.c_str(), response.data.country.c_str()); + OS_LOGI(TAG, "Connecting to LCG endpoint { host: '%s', port: %hu, path: '%s' } in country %s", response.data.host.c_str(), response.data.port, response.data.path.c_str(), response.data.country.c_str()); s_wsClient->connect(response.data.host, response.data.port, response.data.path); return true; diff --git a/src/radio/RFTransmitter.cpp b/src/radio/RFTransmitter.cpp index f08112b9..95b510fe 100644 --- a/src/radio/RFTransmitter.cpp +++ b/src/radio/RFTransmitter.cpp @@ -122,7 +122,10 @@ void RFTransmitter::destroy() OS_LOGD(TAG, "[pin-%hhi] Stopping task", m_txPin); // Wait for the task to stop - Command cmd {.flags = kFlagDeleteTask}; + Command cmd; + memset(&cmd, 0, sizeof(cmd)); + cmd.flags = kFlagDeleteTask; + while (eTaskGetState(m_taskHandle) != eDeleted) { vTaskDelay(pdMS_TO_TICKS(10)); @@ -183,7 +186,7 @@ static void writeSequences(rmt_obj_t* rmt_handle, std::vector& se rmtWriteBlocking(rmt_handle, seq->payload(), seq->size()); } else { // Remove command if it has sent out its termination sequence for long enough - if (timeToLive + kTerminatorDurationMs <= 0) { + if (timeToLive <= -kTerminatorDurationMs) { seq = sequences.erase(seq); continue; } diff --git a/src/serial/SerialInputHandler.cpp b/src/serial/SerialInputHandler.cpp index 5bd0acca..5a0c5023 100644 --- a/src/serial/SerialInputHandler.cpp +++ b/src/serial/SerialInputHandler.cpp @@ -33,7 +33,7 @@ const char* const TAG = "SerialInputHandler"; namespace std { struct hash_ci { - std::size_t operator()(std::string_view str) const + std::size_t operator()(std::string_view str) const noexcept { std::size_t hash = 7; diff --git a/src/serialization/JsonAPI.cpp b/src/serialization/JsonAPI.cpp index 1a412ae2..3e403316 100644 --- a/src/serialization/JsonAPI.cpp +++ b/src/serialization/JsonAPI.cpp @@ -245,7 +245,7 @@ bool JsonAPI::ParseAssignLcgJsonResponse(int code, const cJSON* root, JsonAPI::A out = {}; out.host = host->valuestring; - out.port = (uint16_t)portInt; + out.port = static_cast(portInt); out.path = path->valuestring; out.country = country->valuestring; From f89eda21f8af95a3b9054d493d6edb262ecb419a Mon Sep 17 00:00:00 2001 From: HeavenVR Date: Sun, 21 Dec 2025 03:04:35 +0100 Subject: [PATCH 3/3] Bump version to 1.5.0-rc.3 (#402) --- CHANGELOG.md | 4 ++++ frontend/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa342481..991788a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Version 1.5.0-rc.3 Release Notes + +Fixed a critical bug where the firmware could never connect to LCG, and addressed code correctness issues (variable initialization and type casting) along with compiler warning cleanups. + # Version 1.5.0-rc.2 Release Notes This release candidate focuses on **E-Stop reliability**, **rate limiting behavior**, and **general internal cleanup and correctness improvements**. diff --git a/frontend/package.json b/frontend/package.json index 10c8b45f..66624623 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "1.5.0-rc.2", + "version": "1.5.0-rc.3", "private": true, "type": "module", "scripts": {