Skip to content

Commit bdc369b

Browse files
author
Scott Powell
committed
* repeater & room server: new SERVER_RESPONSE_DELAY and TXT_ACK_DELAY defines.
1 parent 2204cb3 commit bdc369b

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

examples/simple_repeater/main.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@
5959
#define ADMIN_PASSWORD "password"
6060
#endif
6161

62+
#ifndef SERVER_RESPONSE_DELAY
63+
#define SERVER_RESPONSE_DELAY 300
64+
#endif
65+
66+
#ifndef TXT_ACK_DELAY
67+
#define TXT_ACK_DELAY 200
68+
#endif
69+
6270
#ifdef DISPLAY_CLASS
6371
#include "UITask.h"
6472
static UITask ui_task(display);
@@ -112,8 +120,7 @@ struct NeighbourInfo {
112120
int8_t snr; // multiplied by 4, user should divide to get float value
113121
};
114122

115-
// NOTE: need to space the ACK and the reply text apart (in CLI)
116-
#define CLI_REPLY_DELAY_MILLIS 1500
123+
#define CLI_REPLY_DELAY_MILLIS 1000
117124

118125
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
119126
FILESYSTEM* _fs;
@@ -446,14 +453,14 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
446453
// let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
447454
mesh::Packet* path = createPathReturn(client->id, secret, packet->path, packet->path_len,
448455
PAYLOAD_TYPE_RESPONSE, reply_data, reply_len);
449-
if (path) sendFlood(path);
456+
if (path) sendFlood(path, SERVER_RESPONSE_DELAY);
450457
} else {
451458
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, client->id, secret, reply_data, reply_len);
452459
if (reply) {
453460
if (client->out_path_len >= 0) { // we have an out_path, so send DIRECT
454-
sendDirect(reply, client->out_path, client->out_path_len);
461+
sendDirect(reply, client->out_path, client->out_path_len, SERVER_RESPONSE_DELAY);
455462
} else {
456-
sendFlood(reply);
463+
sendFlood(reply, SERVER_RESPONSE_DELAY);
457464
}
458465
}
459466
}
@@ -482,9 +489,9 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
482489
mesh::Packet* ack = createAck(ack_hash);
483490
if (ack) {
484491
if (client->out_path_len < 0) {
485-
sendFlood(ack);
492+
sendFlood(ack, TXT_ACK_DELAY);
486493
} else {
487-
sendDirect(ack, client->out_path, client->out_path_len);
494+
sendDirect(ack, client->out_path, client->out_path_len, TXT_ACK_DELAY);
488495
}
489496
}
490497
}

examples/simple_room_server/main.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@
6767
#define MAX_UNSYNCED_POSTS 32
6868
#endif
6969

70+
#ifndef SERVER_RESPONSE_DELAY
71+
#define SERVER_RESPONSE_DELAY 300
72+
#endif
73+
74+
#ifndef TXT_ACK_DELAY
75+
#define TXT_ACK_DELAY 200
76+
#endif
77+
7078
#ifdef DISPLAY_CLASS
7179
#include "UITask.h"
7280
static UITask ui_task(display);
@@ -568,12 +576,12 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
568576
mesh::Packet* ack = createAck(ack_hash);
569577
if (ack) {
570578
if (client->out_path_len < 0) {
571-
sendFlood(ack);
579+
sendFlood(ack, TXT_ACK_DELAY);
572580
} else {
573-
sendDirect(ack, client->out_path, client->out_path_len);
581+
sendDirect(ack, client->out_path, client->out_path_len, TXT_ACK_DELAY);
574582
}
575583
}
576-
delay_millis = REPLY_DELAY_MILLIS;
584+
delay_millis = TXT_ACK_DELAY + REPLY_DELAY_MILLIS;
577585
} else {
578586
delay_millis = 0;
579587
}
@@ -592,9 +600,9 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
592600
auto reply = createDatagram(PAYLOAD_TYPE_TXT_MSG, client->id, secret, temp, 5 + text_len);
593601
if (reply) {
594602
if (client->out_path_len < 0) {
595-
sendFlood(reply, delay_millis);
603+
sendFlood(reply, delay_millis + SERVER_RESPONSE_DELAY);
596604
} else {
597-
sendDirect(reply, client->out_path, client->out_path_len, delay_millis);
605+
sendDirect(reply, client->out_path, client->out_path_len, delay_millis + SERVER_RESPONSE_DELAY);
598606
}
599607
}
600608
}
@@ -637,7 +645,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
637645
auto reply = createAck(ack_hash);
638646
if (reply) {
639647
reply->payload[reply->payload_len++] = getUnsyncedCount(client); // NEW: add unsynced counter to end of ACK packet
640-
sendDirect(reply, client->out_path, client->out_path_len);
648+
sendDirect(reply, client->out_path, client->out_path_len, SERVER_RESPONSE_DELAY);
641649
}
642650
}
643651
} else {
@@ -647,14 +655,14 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
647655
// let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
648656
mesh::Packet* path = createPathReturn(client->id, secret, packet->path, packet->path_len,
649657
PAYLOAD_TYPE_RESPONSE, reply_data, reply_len);
650-
if (path) sendFlood(path);
658+
if (path) sendFlood(path, SERVER_RESPONSE_DELAY);
651659
} else {
652660
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, client->id, secret, reply_data, reply_len);
653661
if (reply) {
654662
if (client->out_path_len >= 0) { // we have an out_path, so send DIRECT
655-
sendDirect(reply, client->out_path, client->out_path_len);
663+
sendDirect(reply, client->out_path, client->out_path_len, SERVER_RESPONSE_DELAY);
656664
} else {
657-
sendFlood(reply);
665+
sendFlood(reply, SERVER_RESPONSE_DELAY);
658666
}
659667
}
660668
}

0 commit comments

Comments
 (0)