Files
meshcore-wch/User/lib/config.h
2025-12-22 23:02:29 +01:00

55 lines
1.1 KiB
C

#ifndef CONFIG_HEADER
#define CONFIG_HEADER
#include "stdint.h"
#include "string.h"
#include "meshcore/packetstructs.h"
#define FLASH_USER_PAGE_ADDR ((const void *)(0x08077F00))
#define AESKeyCount 8
#define CONTACT_COUNT 100
typedef struct {
char name[32];
unsigned char pubKey[32];
unsigned char secret[32];
int32_t gps_latitude;
int32_t gps_longitude;
Path path;
uint8_t flags;
uint8_t type;
uint8_t authenticated;
uint32_t last_seen_rt; //remote timestamp
uint32_t last_seen_lt; //local timestamp
uint32_t sync_timestamp;
} NodeEntry;
typedef struct {
uint32_t magic; // e.g. 0xDEADBEEF
uint8_t privkey[32]; // Ed25519 private
uint8_t pubkey[32]; // Ed25519 public
uint8_t nodeType;
uint8_t aesKeys[AESKeyCount][17];
uint8_t password[16];
char nodeName[32];
NodeEntry contacts[CONTACT_COUNT];
uint32_t crc32; // integrity check
} PersistentData_t;
extern PersistentData_t persistent;
void saveConfig();
void loadConfig();
void printNodeDB();
NodeEntry * getNextNode();
NodeEntry * getNode(uint8_t hash);
#endif