Node database: collect nodes during sync, expose GET /api/nodes (#7)
CI / build + unit (push) Successful in 39s

This commit was merged in pull request #7.
This commit is contained in:
2026-09-24 15:37:03 +02:00
parent adfbc9800b
commit 5292303786
9 changed files with 468 additions and 12 deletions
+25
View File
@@ -10,6 +10,8 @@ async function loadProto(): Promise<typeof import('@meshtastic/protobufs')> {
export const BROADCAST_ADDR = 0xffffffff;
// official portnums.proto: TEXT_MESSAGE_APP=1 (task spec draft said 3 — the enum value wins)
export const PORT_TEXT_MESSAGE_APP = 1;
// verified against installed @meshtastic/protobufs Portnums.PortNum.POSITION_APP
export const PORT_POSITION_APP = 3;
const START1 = 0x94;
const START2 = 0xc3;
@@ -61,6 +63,29 @@ export async function decodeFromRadio(
return fromBinary(P.Mesh.FromRadioSchema, bytes);
}
/** POSITION_APP packets carry a serialized meshtastic.Position in Data.payload. */
export async function decodePosition(
bytes: Uint8Array,
): Promise<import('@meshtastic/protobufs').Mesh.Position> {
const P = await loadProto();
return fromBinary(P.Mesh.PositionSchema, bytes);
}
let hwModelNames: Map<number, string> | null = null;
/** Reverse lookup of meshtastic.HardwareModel (enum value -> name), loaded once. */
export async function loadHwModelNames(): Promise<Map<number, string>> {
if (!hwModelNames) {
const P = await loadProto();
hwModelNames = new Map(
Object.entries(P.Mesh.HardwareModel).map(([k, v]) => [
Number(k),
String(v),
]),
);
}
return hwModelNames;
}
export async function buildTextToRadio(
to: number,
text: string,