Disconnection detection added

PC checks for connection
Esp32 send Heartbeat
This commit is contained in:
2026-11-05 10:37:24 +01:00
parent 4e991a71b5
commit 3531430661
6 changed files with 212 additions and 32 deletions
@@ -53,6 +53,19 @@ void BotNetwork::parsePacket(uint8_t *buffer, size_t size, QueueHandle_t motionQ
if (header->version != PACKET_VERSION) return;
if (header->payload_len > size - sizeof(PacketHeader)) return;
if (header->packet_id == PKT_PING && header->payload_len == 0) {
PacketHeader response = {
PKT_PONG,
PACKET_VERSION,
0,
millis()
};
_udp.beginPacket(_udp.remoteIP(), _udp.remotePort());
_udp.write((const uint8_t *)&response, sizeof(response));
_udp.endPacket();
return;
}
uint8_t *payload = buffer + sizeof(PacketHeader);
size_t pos = 0;
@@ -5,6 +5,8 @@
#define PKT_COMMAND 1
#define PKT_CONFIG 2
#define PKT_DISPLAY 3
#define PKT_PING 4
#define PKT_PONG 5
#define FT_ARRAY_F32 1
#define FT_STRING 2