From: Scott Worley Date: Mon, 9 Oct 2023 03:49:43 +0000 (-0700) Subject: client: Send each report multiple times X-Git-Tag: v0.1.0~54 X-Git-Url: http://git.scottworley.com/tattlekey/commitdiff_plain/ff379463e38b1cebd43d5c2ab8a0a0ae8e7a9b53?ds=inline;hp=38d971ac5039ae385ceed19e9f02722b60913f15 client: Send each report multiple times UDP is unreliable. It would be better to re-send over a much longer interval, interleaving re-sends from different presses. Do this simple re-sending for now. --- diff --git a/client/config.c b/client/config.c index c5a38b4..de300ea 100644 --- a/client/config.c +++ b/client/config.c @@ -21,3 +21,7 @@ uint button_pin = 18; /* Don't bother reporting each separate button press when it is pressed many * times in short succession. (We also use this to de-bounce. :) */ u32_t minimum_microseconds_between_button_presses = 1000000; + +/* Send each report multiple times. */ +uint resend_count = 5; +u32_t resend_interval_ms = 1000; diff --git a/client/config.h b/client/config.h index 5ce0baf..fefe7e9 100644 --- a/client/config.h +++ b/client/config.h @@ -25,4 +25,8 @@ extern uint button_pin; * times in short succession. (We also use this to de-bounce. :) */ extern u32_t minimum_microseconds_between_button_presses; +/* Send each report multiple times. */ +extern uint resend_count; +extern u32_t resend_interval_ms; + #endif diff --git a/client/tattlekey.c b/client/tattlekey.c index 3a1f7b7..9e7b4b5 100644 --- a/client/tattlekey.c +++ b/client/tattlekey.c @@ -42,7 +42,11 @@ int main() { while (1) { char _; queue_remove_blocking(&queue, &_); - send_report(seq++, 0); - signal(2, 100); + seq++; + for (int i = 0; i < resend_count; i++) { + send_report(seq, i); + signal(i == 0 ? 2 : 1, 100); + sleep_ms(resend_interval_ms); + } } }