This helps the server de-dupe: Records with the same sequence number but
different epochs do not describe the same event.
#include "config.h"
#include "pico/cyw43_arch.h"
#include "config.h"
#include "pico/cyw43_arch.h"
#include "lwip/pbuf.h"
#include "lwip/udp.h"
#include "lwip/pbuf.h"
#include "lwip/udp.h"
/* We only ever send to one address, and we only ever have one thread, so just
* use one udp_pcb */
static struct udp_pcb *the_pcb = NULL;
/* We only ever send to one address, and we only ever have one thread, so just
* use one udp_pcb */
static struct udp_pcb *the_pcb = NULL;
+static uint32_t epoch = 0;
-static void initialize_the_pcb() {
+static void net_local_init() {
+ epoch = get_rand_32();
+
the_pcb = udp_new();
if (!the_pcb)
signal_error_by_blinking();
the_pcb = udp_new();
if (!the_pcb)
signal_error_by_blinking();
}
struct tattle_message_wire_format {
}
struct tattle_message_wire_format {
u16_t sender;
u16_t seq;
u32_t ago;
u16_t sender;
u16_t seq;
u32_t ago;
void send_report_packet(u16_t seq, u32_t ago) {
cyw43_arch_lwip_begin();
void send_report_packet(u16_t seq, u32_t ago) {
cyw43_arch_lwip_begin();
struct pbuf *p = pbuf_alloc(
PBUF_TRANSPORT, sizeof(struct tattle_message_wire_format), PBUF_RAM);
struct pbuf *p = pbuf_alloc(
PBUF_TRANSPORT, sizeof(struct tattle_message_wire_format), PBUF_RAM);
struct tattle_message_wire_format *msg =
(struct tattle_message_wire_format *)(p->payload);
struct tattle_message_wire_format *msg =
(struct tattle_message_wire_format *)(p->payload);
+ msg->epoch = htonl(epoch);
msg->sender = htons(config_this_tattler_identity);
msg->seq = htons(seq);
msg->ago = htonl(ago);
msg->sender = htons(config_this_tattler_identity);
msg->seq = htons(seq);
msg->ago = htonl(ago);