5 #include "pico/cyw43_arch.h"
10 /* We only ever send to one address, and we only ever have one thread, so just
12 static struct udp_pcb
*the_pcb
= NULL
;
14 static void initialize_the_pcb() {
20 signal_error_by_blinking();
23 if (ip4addr_aton(config_tattle_server_ip_address
, &ipaddr
) == 0)
24 signal_error_by_blinking();
26 if (udp_connect(the_pcb
, &ipaddr
, config_tattle_port
) != ERR_OK
)
27 signal_error_by_blinking();
30 struct tattle_message_wire_format
{
36 void send_report_packet(u16_t seq
, u16_t ago
) {
37 cyw43_arch_lwip_begin();
41 struct pbuf
*p
= pbuf_alloc(
42 PBUF_TRANSPORT
, sizeof(struct tattle_message_wire_format
), PBUF_RAM
);
44 signal_error_by_blinking();
46 struct tattle_message_wire_format
*msg
=
47 (struct tattle_message_wire_format
*)(p
->payload
);
48 msg
->sender
= htons(config_this_tattler_identity
);
49 msg
->seq
= htons(seq
);
50 msg
->ago
= htons(ago
);
52 if (udp_send(the_pcb
, p
) != ERR_OK
)
53 signal_error_by_blinking();
57 cyw43_arch_lwip_end();