stale detection and retry

This commit is contained in:
grove5_admin committed 2026-05-01 20:23:19 -07:00
1 parent 393d390853
commit 1585fa39ca
1 file changed
+9 -3
+9 -3
View File
@@ -126,14 +126,20 @@ void loop() {
// Chunk to stay under Bridge RPC MsgPack limits (~4KB limit)
size_t len = strlen(jsonBuf);
size_t pos = 0;
bool write_ok = true;
while (pos < len && client.connected()) {
size_t chunk = min((size_t)512, len - pos);
size_t sent = client.write((const uint8_t*)(jsonBuf + pos), chunk);
if (sent == 0) break;
if (sent == 0) { write_ok = false; break; }
pos += sent;
}
client.write((uint8_t)'\n');
DBG.println(jsonBuf);
if (write_ok && client.connected()) {
client.write((uint8_t)'\n');
DBG.println(jsonBuf);
} else {
DBG.println("[cultivar] write failed — breaking connection");
break;
}
#endif
} else {
DBG.println("[WARN] collect failed — BME690 read returned false");