Device info endpoint + richer node summaries (GET /api/device, MCP device_info) (#13)
CI / build + unit (push) Successful in 36s
CI / build + unit (push) Successful in 36s
This commit was merged in pull request #13.
This commit is contained in:
@@ -46,6 +46,64 @@ export interface NodeInfoFields {
|
||||
position?: { latitudeI?: number; longitudeI?: number; altitude?: number };
|
||||
lastHeard?: number;
|
||||
deviceMetrics?: { batteryLevel?: number };
|
||||
snr?: number;
|
||||
viaMqtt?: boolean;
|
||||
hopsAway?: number;
|
||||
}
|
||||
|
||||
// init shape for create(): all fields optional (protobuf-es' MessageInit is not exported)
|
||||
type Init<T> = {
|
||||
[P in keyof T as P extends '$unknown' | '$typeName' ? never : P]?: T[P];
|
||||
};
|
||||
|
||||
/** DeviceMetadata frame as streamed once during the initial sync. */
|
||||
export function metadataFrame(md: Init<P.Mesh.DeviceMetadata>): Uint8Array {
|
||||
const fr = create(P.Mesh.FromRadioSchema, {
|
||||
payloadVariant: { case: 'metadata', value: md },
|
||||
});
|
||||
return frame(toBinary(P.Mesh.FromRadioSchema, fr));
|
||||
}
|
||||
|
||||
// Config/ModuleConfig section frames as streamed one-per-section during the initial sync.
|
||||
// (meshtastic.Config / meshtastic.ModuleConfig live in their own root namespaces, not under Mesh)
|
||||
export function configSectionFrame(
|
||||
sectionCase: P.Config.Config['payloadVariant']['case'],
|
||||
value: unknown,
|
||||
): Uint8Array {
|
||||
const cfg = create(P.Config.ConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: sectionCase,
|
||||
value,
|
||||
} as P.Config.Config['payloadVariant'],
|
||||
});
|
||||
return frame(
|
||||
toBinary(
|
||||
P.Mesh.FromRadioSchema,
|
||||
create(P.Mesh.FromRadioSchema, {
|
||||
payloadVariant: { case: 'config', value: cfg },
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function moduleConfigSectionFrame(
|
||||
sectionCase: P.ModuleConfig.ModuleConfig['payloadVariant']['case'],
|
||||
value: unknown,
|
||||
): Uint8Array {
|
||||
const mc = create(P.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: sectionCase,
|
||||
value,
|
||||
} as P.ModuleConfig.ModuleConfig['payloadVariant'],
|
||||
});
|
||||
return frame(
|
||||
toBinary(
|
||||
P.Mesh.FromRadioSchema,
|
||||
create(P.Mesh.FromRadioSchema, {
|
||||
payloadVariant: { case: 'moduleConfig', value: mc },
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function nodeInfoFrame(
|
||||
|
||||
Reference in New Issue
Block a user