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