From f58d105bedc6e7a7cc9a3080c750cbb83832df37 Mon Sep 17 00:00:00 2001 From: SpookyDervish Date: Sun, 1 Mar 2026 06:50:54 +1100 Subject: [PATCH] started planning packet struct while i wait for money to buy parts --- include/packet.h | 13 +++++++++++++ relay/main.c | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 include/packet.h diff --git a/include/packet.h b/include/packet.h new file mode 100644 index 0000000..d045efe --- /dev/null +++ b/include/packet.h @@ -0,0 +1,13 @@ +#pragma once +#include + +typedef struct { + uint8_t version; // version number to prevent breaking older packet formats + uint8_t ttl; // the number of hops left in the lifespan of the packet, prevents infinite hopping + uint8_t packetType; // packet type (message is the only type right now) + uint32_t senderId; // unique id of the person who sent the packet + uint32_t targetId; // 0xFFFFFFFF = broadcast + uint32_t messageId; // we can ignore packets if we've seen them twice + uint16_t payloadLength; // length of data + uint8_t payload[]; // actual data +} __attribute__((packed)) Packet; \ No newline at end of file diff --git a/relay/main.c b/relay/main.c index 1aed12a..bdfc784 100644 --- a/relay/main.c +++ b/relay/main.c @@ -1,3 +1,5 @@ +#include "../include/packet.h" + #include "pico/stdlib.h" #define LED_PIN 25