final chunking

This commit is contained in:
grove5_admin committed 2026-05-01 17:50:58 -07:00
1 parent 9a8a07b17d
commit 393d390853
1 file changed
+4 -8
+4 -8
View File
@@ -123,19 +123,15 @@ void loop() {
if (env.collect(payload)) {
env.toJSON(payload, jsonBuf, sizeof(jsonBuf));
#ifdef ARDUINO_ARCH_ZEPHYR
// Chunk writes to stay under Bridge RPC message size limit (~1KB)
// Chunk to stay under Bridge RPC MsgPack limits (~4KB limit)
size_t len = strlen(jsonBuf);
size_t pos = 0;
while (pos < len) {
size_t chunk = min((size_t)256, len - pos);
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) {
DBG.println("[cultivar] TCP write failed!");
break;
}
if (sent == 0) break;
pos += sent;
}
// Send newline separately (readline() needs this delimiter)
client.write((uint8_t)'\n');
DBG.println(jsonBuf);
#endif