From 5d15a68d0d8f62dc21aeac4ce2a4cd993f8dd0d6 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Wed, 4 Jun 2025 18:10:47 +1000 Subject: [PATCH] * SERVER_RESPONSE_DELAY now applied to: login responses, companion telemetry responses --- examples/simple_repeater/main.cpp | 6 +++--- examples/simple_room_server/main.cpp | 6 +++--- src/helpers/BaseChatMesh.cpp | 10 +++++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index d8ae9556..c2a8ae92 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -383,14 +383,14 @@ protected: // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response mesh::Packet* path = createPathReturn(sender, client->secret, packet->path, packet->path_len, PAYLOAD_TYPE_RESPONSE, reply_data, 12); - if (path) sendFlood(path); + if (path) sendFlood(path, SERVER_RESPONSE_DELAY); } else { mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, client->secret, reply_data, 12); if (reply) { if (client->out_path_len >= 0) { // we have an out_path, so send DIRECT - sendDirect(reply, client->out_path, client->out_path_len); + sendDirect(reply, client->out_path, client->out_path_len, SERVER_RESPONSE_DELAY); } else { - sendFlood(reply); + sendFlood(reply, SERVER_RESPONSE_DELAY); } } } diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 9f2149fe..32fe4a04 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -479,14 +479,14 @@ protected: // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response mesh::Packet* path = createPathReturn(sender, client->secret, packet->path, packet->path_len, PAYLOAD_TYPE_RESPONSE, reply_data, 8 + 2); - if (path) sendFlood(path); + if (path) sendFlood(path, SERVER_RESPONSE_DELAY); } else { mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, client->secret, reply_data, 8 + 2); if (reply) { if (client->out_path_len >= 0) { // we have an out_path, so send DIRECT - sendDirect(reply, client->out_path, client->out_path_len); + sendDirect(reply, client->out_path, client->out_path_len, SERVER_RESPONSE_DELAY); } else { - sendFlood(reply); + sendFlood(reply, SERVER_RESPONSE_DELAY); } } } diff --git a/src/helpers/BaseChatMesh.cpp b/src/helpers/BaseChatMesh.cpp index bcf83f8b..ba8c3e28 100644 --- a/src/helpers/BaseChatMesh.cpp +++ b/src/helpers/BaseChatMesh.cpp @@ -1,6 +1,10 @@ #include #include +#ifndef SERVER_RESPONSE_DELAY + #define SERVER_RESPONSE_DELAY 300 +#endif + #ifndef TXT_ACK_DELAY #define TXT_ACK_DELAY 200 #endif @@ -191,14 +195,14 @@ void BaseChatMesh::onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response mesh::Packet* path = createPathReturn(from.id, secret, packet->path, packet->path_len, PAYLOAD_TYPE_RESPONSE, temp_buf, reply_len); - if (path) sendFlood(path); + if (path) sendFlood(path, SERVER_RESPONSE_DELAY); } else { mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, from.id, secret, temp_buf, reply_len); if (reply) { if (from.out_path_len >= 0) { // we have an out_path, so send DIRECT - sendDirect(reply, from.out_path, from.out_path_len); + sendDirect(reply, from.out_path, from.out_path_len, SERVER_RESPONSE_DELAY); } else { - sendFlood(reply); + sendFlood(reply, SERVER_RESPONSE_DELAY); } } }