Merge develop into main (#348)
## App state Improved app state management in `LoaderService` and `GuiService`: - Re-ordered some of the state transitions - Hardened `GuiService` for repeated events (that might trigger a re-render of an app that's already rendered) - Validate state transitions in `LoaderService` and crash if an app transitions from the wrong state to the next one. ## LoaderService - Removed `tt::loader::` functions and expose `LoaderService` interface publicly. - Implement `stopAll()` and `stopAll(id)` which stops all instances of an app, including any apps that were launched by it. - Rename `stop()` functions to `stopTop()` - Created `stopTop(id)` which only stops the top-most app when the app id matches. - Moved `loader::LoaderEvent` to `loader::LoaderService::Event` - Changed app instance `std::stack` to `std::vector` ## Improvements - `ElfApp`: error 22 now shows a hint that `main()` might be missing - Starting, installing and uninstalling apps now stops any running app (and its children) on the stack ## Bugfixes - `HttpdReq` out of memory issue now shows an error message and doesn't crash anymore (this would happen on devices without PSRAM with WiFi active, when an app was installed) - `GuiService::hideApp()` lock should not wait for timeout and now waits indefinitely - `Buildscript/release-sdk-current.sh` deletes the previous local release before building a new one ## Code correctness - App classes were made `final` - Apps that had a `void start()` now have a `LaunchId start()` - `tt::app::State`: renamed `Started` to `Created` and `Stopped` to `Destroyed` to properly reflect earlier name changes
This commit is contained in:
committed by
GitHub
parent
dcf28d0868
commit
f6cdabf3c0
@@ -1,4 +1,4 @@
|
||||
#include "Tactility/network/HttpdReq.h"
|
||||
#include <Tactility/network/HttpdReq.h>
|
||||
|
||||
#include <memory>
|
||||
#include <ranges>
|
||||
@@ -8,10 +8,10 @@
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#define TAG "network"
|
||||
|
||||
namespace tt::network {
|
||||
|
||||
constexpr auto* TAG = "HttpdReq";
|
||||
|
||||
bool getHeaderOrSendError(httpd_req_t* request, const std::string& name, std::string& value) {
|
||||
size_t header_size = httpd_req_get_hdr_value_len(request, name.c_str());
|
||||
if (header_size == 0) {
|
||||
@@ -73,11 +73,17 @@ std::unique_ptr<char[]> receiveByteArray(httpd_req_t* request, size_t length, si
|
||||
assert(length > 0);
|
||||
bytesRead = 0;
|
||||
|
||||
auto result = std::make_unique<char[]>(length);
|
||||
// We have to use malloc() because make_unique() throws an exception
|
||||
// and we don't have exceptions enabled in the compiler settings
|
||||
auto* buffer = static_cast<char*>(malloc(length));
|
||||
if (buffer == nullptr) {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_ALLOC_FAILED_FMT, length);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
while (bytesRead < length) {
|
||||
size_t read_size = length - bytesRead;
|
||||
size_t bytes_received = httpd_req_recv(request, result.get() + bytesRead, read_size);
|
||||
size_t bytes_received = httpd_req_recv(request, buffer + bytesRead, read_size);
|
||||
if (bytes_received <= 0) {
|
||||
TT_LOG_W(TAG, "Received %zu / %zu", bytesRead + bytes_received, length);
|
||||
return nullptr;
|
||||
@@ -86,7 +92,7 @@ std::unique_ptr<char[]> receiveByteArray(httpd_req_t* request, size_t length, si
|
||||
bytesRead += bytes_received;
|
||||
}
|
||||
|
||||
return result;
|
||||
return std::unique_ptr<char[]>(std::move(buffer));
|
||||
}
|
||||
|
||||
std::string receiveTextUntil(httpd_req_t* request, const std::string& terminator) {
|
||||
|
||||
Reference in New Issue
Block a user