PR review fixes (#384)

This commit is contained in:
Ken Van Hoeylandt
2025-10-25 13:47:43 +02:00
committed by GitHub
parent f660550f86
commit d0d05c67ca
12 changed files with 56 additions and 28 deletions
@@ -11,7 +11,7 @@ class EspHttpClient {
static constexpr auto* TAG = "EspHttpClient";
std::unique_ptr<esp_http_client_config_t> config = nullptr;
esp_http_client_handle_t client;
esp_http_client_handle_t client = nullptr;
bool isOpen = false;
public:
@@ -87,11 +87,15 @@ public:
bool close() {
assert(client != nullptr);
TT_LOG_I(TAG, "close()");
return esp_http_client_close(client) == ESP_OK;
if (esp_http_client_close(client) == ESP_OK) {
isOpen = false;
}
return !isOpen;
}
bool cleanup() {
assert(client != nullptr);
assert(!isOpen);
TT_LOG_I(TAG, "cleanup()");
const auto result = esp_http_client_cleanup(client);
client = nullptr;
+11 -2
View File
@@ -1,10 +1,19 @@
#pragma once
#include <string>
#include <functional>
namespace tt::network::http {
void download(
/**
* Download a file from a URL.
* The server must send the Content-Length header.
* @param url download source URL
* @param certFilePath the path to the .pem file
* @param downloadFilePath The path to downloadd the file to. The parent directories must exist.
* @param onSuccess the success result callback
* @param onError the error result callback
*/
void download(
const std::string& url,
const std::string& certFilePath,
const std::string &downloadFilePath,