#pragma once #include /* This is the struct that gets packed and then sent over LoRa. It's packed and uses stdint types because different hardware or compilers may attempt to optimize it or change the size of different things, completely stuffing up and corrupting our data. Endianess also matters. Version 1: Message Types: - message: send a message via plain text to someone - hello: announce yourself to other nodes, payload should include: bytes 1-4: node id byte 5: battery level or 255 for unkown byte 6: name length continuing bytes: name */ 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;