Files
mesh-network-project/include/packet.h

13 lines
683 B
C

#pragma once
#include <stdint.h>
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;