From: Scott Worley Date: Tue, 10 Oct 2023 21:48:33 +0000 (-0700) Subject: client: New epoch if seq wraps X-Git-Tag: v0.1.0~17 X-Git-Url: http://git.scottworley.com/tattlekey/commitdiff_plain/c13b90631df5a49239a321369b406fc9b56af501?ds=sidebyside client: New epoch if seq wraps --- diff --git a/client/net.c b/client/net.c index fa5d07b..3d4be8c 100644 --- a/client/net.c +++ b/client/net.c @@ -34,7 +34,7 @@ static void net_local_init() { if (the_pcb) return; - epoch = get_rand_32(); + new_epoch(); the_pcb = udp_new(); if (!the_pcb) @@ -48,6 +48,8 @@ static void net_local_init() { signal_error_by_blinking(); } +void new_epoch() { epoch = get_rand_32(); } + struct tattle_message_wire_format { u32_t epoch; u16_t sender; diff --git a/client/net.h b/client/net.h index 9b8fc1f..31e5cc4 100644 --- a/client/net.h +++ b/client/net.h @@ -22,4 +22,6 @@ void send_report_packet(u16_t seq, u32_t ago); +void new_epoch(); + #endif diff --git a/client/tattlekey.c b/client/tattlekey.c index f9b74c1..5e829d1 100644 --- a/client/tattlekey.c +++ b/client/tattlekey.c @@ -119,6 +119,8 @@ void service_queue() { switch (e.type) { case NEW_BUTTON_PRESS: { add_press(pp, &(press_t){e.buttonpress.timestamp, seq++, 0}); + if (seq == 0) + new_epoch(); } break; case RESEND_TIME: { /* OK, we're awake. Cool. Thanks! (We actually do the sends in the