Live upload progress of data being sent to a display. Protocol: {"upload":{"src":"<16 hex MAC>","current":N,"total":M}} The frontend shows "P% (N/M)" on the tag card; current >= total means done.
| 59 | // Protocol: {"upload":{"src":"<16 hex MAC>","current":N,"total":M}} |
| 60 | // The frontend shows "P% (N/M)" on the tag card; current >= total means done. |
| 61 | void wsSendUploadProgress(const uint8_t *mac, uint16_t current, uint16_t total) { |
| 62 | if (wsClientCount() == 0) return; // nobody is listening, skip the work |
| 63 | char hexmac[17]; |
| 64 | mac2hex(mac, hexmac); |
| 65 | JsonDocument doc; |
| 66 | JsonObject up = doc["upload"].to<JsonObject>(); |
| 67 | up["src"] = hexmac; |
| 68 | up["current"] = current; |
| 69 | up["total"] = total; |
| 70 | if (wsMutex) xSemaphoreTake(wsMutex, portMAX_DELAY); |
| 71 | ws.textAll(doc.as<String>()); |
| 72 | if (wsMutex) xSemaphoreGive(wsMutex); |
| 73 | } |
| 74 | |
| 75 | // Sends the real touch positions to all connected websocket clients. |
| 76 | // Protocol: {"touch":{"count":N,"points":[{"id":..,"x":..,"y":..,"size":..}, ...]}} |
no test coverage detected