Speicherreserve fuer HA/WLAN, max. 2 KDE-Verbindungen, Fehlercode + freier Speicher in der Kopfzeile
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
a3805a1777
commit
17a0ef0ef3
2 files changed
+15
-6
No files matched your search
+3
-3
@@ -27,7 +27,7 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static constexpr int KDE_PORT = 1716;
|
static constexpr int KDE_PORT = 1716;
|
||||||
static constexpr int MAX_PEERS = 3;
|
static constexpr int MAX_PEERS = 2;
|
||||||
static constexpr int MAX_PLAYERS = 4;
|
static constexpr int MAX_PLAYERS = 4;
|
||||||
static constexpr int MAX_TRUSTED = 8;
|
static constexpr int MAX_TRUSTED = 8;
|
||||||
static constexpr size_t MAX_RX = 16384;
|
static constexpr size_t MAX_RX = 16384;
|
||||||
@@ -521,7 +521,7 @@ static const char* downloadArt(Peer& p, int port, int64_t size) {
|
|||||||
// A TLS connection needs two ~16.7 KB buffers plus some KB for the handshake.
|
// A TLS connection needs two ~16.7 KB buffers plus some KB for the handshake.
|
||||||
uint32_t freeHeap = ESP.getFreeHeap(), block = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
|
uint32_t freeHeap = ESP.getFreeHeap(), block = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
|
||||||
Serial.printf("KDE: lade Cover (%u Bytes), Heap %u, groesster Block %u\n", (unsigned)size, freeHeap, block);
|
Serial.printf("KDE: lade Cover (%u Bytes), Heap %u, groesster Block %u\n", (unsigned)size, freeHeap, block);
|
||||||
if (freeHeap < 46000 || block < 17500) return "Zu wenig Speicher";
|
if (freeHeap < 62000 || block < 17500) return "Zu wenig Speicher";
|
||||||
int fd = socket(AF_INET, SOCK_STREAM, 0);
|
int fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (fd < 0) return "Keine Verbindung";
|
if (fd < 0) return "Keine Verbindung";
|
||||||
struct timeval tv = {5, 0};
|
struct timeval tv = {5, 0};
|
||||||
@@ -676,7 +676,7 @@ static void acceptPeer(int fd) {
|
|||||||
Peer* slot = nullptr;
|
Peer* slot = nullptr;
|
||||||
for (auto& p : peers) if (p.used && p.id == id) closePeer(p); // reconnect replaces the old link
|
for (auto& p : peers) if (p.used && p.id == id) closePeer(p); // reconnect replaces the old link
|
||||||
for (auto& p : peers) if (!p.used) { slot = &p; break; }
|
for (auto& p : peers) if (!p.used) { slot = &p; break; }
|
||||||
if (!slot || ESP.getFreeHeap() < 45000) {
|
if (!slot || ESP.getFreeHeap() < 62000 || heap_caps_get_largest_free_block(MALLOC_CAP_8BIT) < 17500) {
|
||||||
Serial.printf("KDE: kein Platz fuer weitere Verbindung (Heap %u)\n", ESP.getFreeHeap());
|
Serial.printf("KDE: kein Platz fuer weitere Verbindung (Heap %u)\n", ESP.getFreeHeap());
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+12
-3
@@ -219,6 +219,15 @@ static void setStatus(const char* txt, lv_color_t col) {
|
|||||||
lv_obj_set_style_text_color(statusLabel, col, 0);
|
lv_obj_set_style_text_color(statusLabel, col, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shows the HTTP error code and the free memory, e.g. "HA -1 38K" (-1 = no connection, 401 = token).
|
||||||
|
static void haError(int code) {
|
||||||
|
char buf[32];
|
||||||
|
snprintf(buf, sizeof buf, LV_SYMBOL_WARNING " HA %d %uK", code, (unsigned)(ESP.getFreeHeap() / 1024));
|
||||||
|
setStatus(buf, lv_palette_main(LV_PALETTE_RED));
|
||||||
|
Serial.printf("HA-Fehler %d, Heap %u, groesster Block %u\n", code, ESP.getFreeHeap(),
|
||||||
|
heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
|
||||||
|
}
|
||||||
|
|
||||||
static void callService(const char* domain, const char* service, JsonDocument& doc,
|
static void callService(const char* domain, const char* service, JsonDocument& doc,
|
||||||
std::function<void()> onOk = nullptr) {
|
std::function<void()> onOk = nullptr) {
|
||||||
String body;
|
String body;
|
||||||
@@ -341,7 +350,7 @@ static void pollEntity(size_t idx) {
|
|||||||
JsonDocument doc;
|
JsonDocument doc;
|
||||||
if (code != 200 || deserializeJson(doc, resp)) {
|
if (code != 200 || deserializeJson(doc, resp)) {
|
||||||
Serial.printf("GET %s -> %d\n", entity.c_str(), code);
|
Serial.printf("GET %s -> %d\n", entity.c_str(), code);
|
||||||
setStatus(LV_SYMBOL_WARNING " HA", lv_palette_main(LV_PALETTE_RED));
|
haError(code);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isClimate) applyClimate(idx, doc);
|
if (isClimate) applyClimate(idx, doc);
|
||||||
@@ -683,7 +692,7 @@ static void discoverDevices() {
|
|||||||
haAsync(true, "/api/template", body, [](int code, String& resp) {
|
haAsync(true, "/api/template", body, [](int code, String& resp) {
|
||||||
if (code != 200) {
|
if (code != 200) {
|
||||||
Serial.printf("Geraete-Abfrage fehlgeschlagen: %d\n", code);
|
Serial.printf("Geraete-Abfrage fehlgeschlagen: %d\n", code);
|
||||||
setStatus(LV_SYMBOL_WARNING " HA", lv_palette_main(LV_PALETTE_RED));
|
haError(code);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JsonDocument doc;
|
JsonDocument doc;
|
||||||
@@ -1402,7 +1411,7 @@ void setup() {
|
|||||||
|
|
||||||
haJobs = xQueueCreate(16, sizeof(HaJob*));
|
haJobs = xQueueCreate(16, sizeof(HaJob*));
|
||||||
haResults = xQueueCreate(16, sizeof(HaJob*));
|
haResults = xQueueCreate(16, sizeof(HaJob*));
|
||||||
xTaskCreatePinnedToCore(haTask, "ha", 10240, nullptr, 1, nullptr, 0);
|
xTaskCreatePinnedToCore(haTask, "ha", 8192, nullptr, 1, nullptr, 0);
|
||||||
|
|
||||||
buildUi();
|
buildUi();
|
||||||
buildMusicUi();
|
buildMusicUi();
|
||||||
|
|||||||
Reference in new issue
Block a user