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.
/* 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;
* 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
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);
+ }
}
}