still wip

This commit is contained in:
2025-12-22 23:02:29 +01:00
parent 627acef32c
commit a48ef9d5e0
60 changed files with 6993 additions and 4939 deletions

View File

@@ -6,6 +6,21 @@
#define PAYLOAD_TYPE_MASK 0x3C
#define PAYLOAD_VERSION_MASK 0xC0
#define DONT_RETRANSMIT_HEADER 0xFF
#define RESP_SERVER_LOGIN_OK 0
#define FIRMWARE_VER_LEVEL 1
#define PERM_ACL_ROLE_MASK 3 // lower 2 bits
#define PERM_ACL_GUEST 0
#define PERM_ACL_READ_ONLY 1
#define PERM_ACL_READ_WRITE 2
#define PERM_ACL_ADMIN 3
#define MAX_PATH_LEN 64
typedef enum RouteType {
ROUTE_TYPE_TRANSPORT_FLOOD = 0x00,
ROUTE_TYPE_FLOOD = 0x01,
@@ -13,7 +28,6 @@ typedef enum RouteType {
ROUTE_TYPE_TRANSPORT_DIRECT = 0x03,
} RouteType;
typedef enum PayloadType {
PAYLOAD_TYPE_REQ = 0x00 << 2,
PAYLOAD_TYPE_RESPONSE = 0x01 << 2,
@@ -26,9 +40,31 @@ typedef enum PayloadType {
PAYLOAD_TYPE_PATH = 0x08 << 2,
PAYLOAD_TYPE_TRACE = 0x09 << 2,
PAYLOAD_TYPE_MULTIPART = 0x0A << 2,
PAYLOAD_TYPE_CONTROL = 0x0B << 2,
PAYLOAD_TYPE_RAW_CUSTOM = 0x0F << 2,
} PayloadType;
typedef struct DiscoverRequestPayload {
uint8_t prefixOnly;
uint8_t typeFilter;
uint32_t tag;
uint32_t since;
} DiscoverRequestPayload;
typedef struct DiscoverResponsePayload {
uint8_t nodeType;
int8_t snr;
uint32_t tag;
uint8_t pubkey[32];
} DiscoverResponsePayload;
typedef struct AnonymousRequestPayload {
uint8_t destinationHash;
uint8_t pubKey[32];
uint16_t cipherMAC;
uint8_t payloadLen;
uint8_t payload[149];
} AnonymousRequestPayload;
typedef enum PayloadVersion {
PAYLOAD_VERSION_0 = 0 << 6,
@@ -37,14 +73,17 @@ typedef enum PayloadVersion {
PAYLOAD_VERSION_3 = 3 << 6,
} PayloadVersion;
typedef struct Path {
uint8_t pathLen;
uint8_t path[MAX_PATH_LEN];
} Path;
typedef struct FrameStruct {
unsigned char header;
unsigned char transportCodes[4];
unsigned char pathLen;
unsigned char path[64];
unsigned char payloadLen;
unsigned char payload[184];
uint8_t header;
uint8_t transportCodes[4];
Path path;
uint8_t payloadLen;
uint8_t payload[184];
} FrameStruct;
typedef enum RequestType {
@@ -55,14 +94,50 @@ typedef enum RequestType {
REQUEST_GET_ACCESS_LIST = 0x05,
} RequestType;
typedef struct Request {
uint32_t timestamp;
uint8_t requestType;
uint8_t dataLen;
uint8_t data[180]; // hopefully correct len
} Request;
typedef struct Response {
uint32_t tag; // sender timestamp
uint8_t dataLen;
uint8_t data[180]; // hopefully correct len
} Response;
typedef struct Node {
uint8_t pubKey[32];
char name[32];
int32_t latitude;
int32_t longitude;
int32_t lastSeen;
char flags;
} Node;
typedef struct EncryptedPayloadStruct {
FrameStruct rawFrame;
unsigned char destinationHash;
unsigned char sourceHash;
unsigned char payload[180];
uint8_t destinationHash;
uint8_t sourceHash;
uint16_t cipherMAC;
uint8_t payloadLen;
uint8_t payload[180];
uint8_t type;
NodeEntry *remNode;
} EncryptedPayloadStruct;
typedef enum NodeType {
NODE_TYPE_CHAT_NODE = 1,
NODE_TYPE_REPEATER = 2,
NODE_TYPE_ROOM_SERVER = 3,
NODE_TYPE_SENSOR = 4
} NodeType;
typedef enum ControlDataFlags {
CONTROL_DATA_FLAG_TYPE_NODE_DISCOVER_REQ = 0x80,
CONTROL_DATA_FLAG_DISCOVER_RESP = 0x90
} ControlDataFlags;
typedef enum AdvertisementPayloadFlags {
ADVERTISEMENT_FLAG_IS_CHAT_NODE = 0x01,
ADVERTISEMENT_FLAG_IS_REAPEATER = 0x02,
@@ -75,46 +150,58 @@ typedef enum AdvertisementPayloadFlags {
} AdvertisementPayloadFlags;
typedef struct AdvertisementPayload {
unsigned char pubKey[32];
uint8_t pubKey[32];
int32_t timestamp;
unsigned char signature[64];
unsigned char dataFlags;
uint8_t signature[64];
uint8_t dataFlags;
int32_t latitude;
int32_t longitude;
int16_t rfu1;
int16_t rfu2;
char nodeName[128];
char nodeName[32];
} AdvertisementPayload;
typedef struct ReturnedPathPayload {
unsigned char destinationHash;
unsigned char sourceHash;
unsigned char pathLen;
typedef struct Extra {
uint8_t type;
uint8_t data[180]; // hopefully long enough
} Extra;
typedef struct ReturnedPathPayload {
Path path;
Extra extra;
} ReturnedPathPayload;
typedef struct RequestPayload {
unsigned char destinationHash;
unsigned char sourceHash;
} RequestPayload;
typedef struct ResponsePayload {
unsigned char destinationHash;
unsigned char sourceHash;
} ResponsePayload;
typedef struct PlainTextMessagePayload {
unsigned char destinationHash;
unsigned char sourceHash;
uint32_t timestamp;
uint8_t textType;
uint8_t attempt;
uint8_t message[180]; // hopefully long enough
} PlainTextMessagePayload;
typedef struct GroupTextMessage {
unsigned char channelHash;
unsigned char keyIndex;
uint8_t channelHash;
uint8_t keyIndex;
int32_t timestamp;
unsigned char flags;
unsigned char text[190];
uint8_t flags;
uint8_t text[190];
} GroupTextMessage;
typedef struct RepeaterStats {
uint16_t millivolts;
uint16_t txQueueLength;
int16_t noiseFloor;
int16_t lastRSSI;
uint32_t packetsReceivedCount;
uint32_t packetsSentCount;
uint32_t totalAirTimeSeconds;
uint32_t totalUpTimeSeconds;
uint32_t sentFloodCount, sentDirectCount;
uint32_t receivedFloodCount, receivedDirectCount;
uint16_t err_events; // was 'n_full_events'
int16_t lastSNR; // x 4
uint16_t n_direct_dups, n_flood_dups;
uint32_t total_rx_air_time_secs;
} RepeaterStats;
#endif