stale detection and retry
This commit is contained in:
1 parent
393d390853
commit
1585fa39ca
1 file changed
+7
-1
@@ -126,14 +126,20 @@ void loop() {
|
|||||||
// Chunk to stay under Bridge RPC MsgPack limits (~4KB limit)
|
// Chunk to stay under Bridge RPC MsgPack limits (~4KB limit)
|
||||||
size_t len = strlen(jsonBuf);
|
size_t len = strlen(jsonBuf);
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
bool write_ok = true;
|
||||||
while (pos < len && client.connected()) {
|
while (pos < len && client.connected()) {
|
||||||
size_t chunk = min((size_t)512, len - pos);
|
size_t chunk = min((size_t)512, len - pos);
|
||||||
size_t sent = client.write((const uint8_t*)(jsonBuf + pos), chunk);
|
size_t sent = client.write((const uint8_t*)(jsonBuf + pos), chunk);
|
||||||
if (sent == 0) break;
|
if (sent == 0) { write_ok = false; break; }
|
||||||
pos += sent;
|
pos += sent;
|
||||||
}
|
}
|
||||||
|
if (write_ok && client.connected()) {
|
||||||
client.write((uint8_t)'\n');
|
client.write((uint8_t)'\n');
|
||||||
DBG.println(jsonBuf);
|
DBG.println(jsonBuf);
|
||||||
|
} else {
|
||||||
|
DBG.println("[cultivar] write failed — breaking connection");
|
||||||
|
break;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
DBG.println("[WARN] collect failed — BME690 read returned false");
|
DBG.println("[WARN] collect failed — BME690 read returned false");
|
||||||
|
|||||||
Reference in new issue
Block a user