New logging and more (#446)

- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>`
- Changed default timezone to Europe/Amsterdam
- Fix for logic bug in unPhone hardware
- Fix for init/deinit in DRV2605 driver
- Other fixes
- Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
This commit is contained in:
Ken Van Hoeylandt
2026-01-06 22:35:39 +01:00
committed by GitHub
parent 719f7bcece
commit f620255c41
188 changed files with 1973 additions and 1755 deletions
@@ -7,6 +7,7 @@
#include <Tactility/file/File.h>
#include <Tactility/network/HttpdReq.h>
#include <Tactility/network/Url.h>
#include <Tactility/Logger.h>
#include <Tactility/Paths.h>
#include <Tactility/service/development/DevelopmentSettings.h>
#include <Tactility/service/ServiceRegistration.h>
@@ -19,7 +20,7 @@ namespace tt::service::development {
extern const ServiceManifest manifest;
constexpr const char* TAG = "DevService";
static const auto LOGGER = Logger("DevService");
bool DevelopmentService::onStart(ServiceContext& service) {
std::stringstream stream;
@@ -65,26 +66,26 @@ bool DevelopmentService::isEnabled() const {
// region endpoints
esp_err_t DevelopmentService::handleGetInfo(httpd_req_t* request) {
TT_LOG_I(TAG, "GET /device");
LOGGER.info("GET /device");
if (httpd_resp_set_type(request, "application/json") != ESP_OK) {
TT_LOG_W(TAG, "Failed to send header");
LOGGER.warn("Failed to send header");
return ESP_FAIL;
}
auto* service = static_cast<DevelopmentService*>(request->user_ctx);
if (httpd_resp_sendstr(request, service->deviceResponse.c_str()) != ESP_OK) {
TT_LOG_W(TAG, "Failed to send response body");
LOGGER.warn("Failed to send response body");
return ESP_FAIL;
}
TT_LOG_I(TAG, "[200] /device");
LOGGER.info("[200] /device");
return ESP_OK;
}
esp_err_t DevelopmentService::handleAppRun(httpd_req_t* request) {
TT_LOG_I(TAG, "POST /app/run");
LOGGER.info("POST /app/run");
std::string query;
if (!network::getQueryOrSendError(request, query)) {
@@ -94,7 +95,7 @@ esp_err_t DevelopmentService::handleAppRun(httpd_req_t* request) {
auto parameters = network::parseUrlQuery(query);
auto id_key_pos = parameters.find("id");
if (id_key_pos == parameters.end()) {
TT_LOG_W(TAG, "[400] /app/run id not specified");
LOGGER.warn("[400] /app/run id not specified");
httpd_resp_send_err(request, HTTPD_400_BAD_REQUEST, "id not specified");
return ESP_FAIL;
}
@@ -106,14 +107,14 @@ esp_err_t DevelopmentService::handleAppRun(httpd_req_t* request) {
app::start(app_id);
TT_LOG_I(TAG, "[200] /app/run %s", id_key_pos->second.c_str());
LOGGER.info("[200] /app/run {}", id_key_pos->second);
httpd_resp_send(request, nullptr, 0);
return ESP_OK;
}
esp_err_t DevelopmentService::handleAppInstall(httpd_req_t* request) {
TT_LOG_I(TAG, "PUT /app/install");
LOGGER.info("PUT /app/install");
std::string boundary;
if (!network::getMultiPartBoundaryOrSendError(request, boundary)) {
@@ -174,7 +175,7 @@ esp_err_t DevelopmentService::handleAppInstall(httpd_req_t* request) {
content_left -= boundary_and_newlines_after_file.length();
if (content_left != 0) {
TT_LOG_W(TAG, "We have more bytes at the end of the request parsing?!");
LOGGER.warn("We have more bytes at the end of the request parsing?!");
}
if (!app::install(file_path)) {
@@ -182,11 +183,11 @@ esp_err_t DevelopmentService::handleAppInstall(httpd_req_t* request) {
return ESP_FAIL;
}
if (!file::deleteFile(file_path.c_str())) {
TT_LOG_W(TAG, "Failed to delete %s", file_path.c_str());
if (!file::deleteFile(file_path)) {
LOGGER.warn("Failed to delete {}", file_path);
}
TT_LOG_I(TAG, "[200] /app/install -> %s", file_path.c_str());
LOGGER.info("[200] /app/install -> {}", file_path);
httpd_resp_send(request, nullptr, 0);
@@ -194,7 +195,7 @@ esp_err_t DevelopmentService::handleAppInstall(httpd_req_t* request) {
}
esp_err_t DevelopmentService::handleAppUninstall(httpd_req_t* request) {
TT_LOG_I(TAG, "PUT /app/uninstall");
LOGGER.info("PUT /app/uninstall");
std::string query;
if (!network::getQueryOrSendError(request, query)) {
@@ -204,23 +205,23 @@ esp_err_t DevelopmentService::handleAppUninstall(httpd_req_t* request) {
auto parameters = network::parseUrlQuery(query);
auto id_key_pos = parameters.find("id");
if (id_key_pos == parameters.end()) {
TT_LOG_W(TAG, "[400] /app/uninstall id not specified");
LOGGER.warn("[400] /app/uninstall id not specified");
httpd_resp_send_err(request, HTTPD_400_BAD_REQUEST, "id not specified");
return ESP_FAIL;
}
if (!app::findAppManifestById(id_key_pos->second)) {
TT_LOG_I(TAG, "[200] /app/uninstall %s (app wasn't installed)", id_key_pos->second.c_str());
LOGGER.info("[200] /app/uninstall {} (app wasn't installed)", id_key_pos->second);
httpd_resp_send(request, nullptr, 0);
return ESP_OK;
}
if (app::uninstall(id_key_pos->second)) {
TT_LOG_I(TAG, "[200] /app/uninstall %s", id_key_pos->second.c_str());
LOGGER.info("[200] /app/uninstall {}", id_key_pos->second);
httpd_resp_send(request, nullptr, 0);
return ESP_OK;
} else {
TT_LOG_W(TAG, "[500] /app/uninstall %s", id_key_pos->second.c_str());
LOGGER.warn("[500] /app/uninstall {}", id_key_pos->second);
httpd_resp_send_err(request, HTTPD_500_INTERNAL_SERVER_ERROR, "Failed to uninstall");
return ESP_FAIL;
}