Device info endpoint + richer node summaries (GET /api/device, MCP device_info) (#13)
CI / build + unit (push) Successful in 36s

This commit was merged in pull request #13.
This commit is contained in:
2026-09-24 22:46:40 +02:00
parent b31fb35464
commit 4beaa377c4
10 changed files with 369 additions and 10 deletions
+50 -1
View File
@@ -13,6 +13,7 @@ import {
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import type { DeviceInfo } from './mesh.service.js';
import { MeshService } from './mesh.service.js';
export class SendTextDto {
@@ -104,6 +105,51 @@ export class MeshController {
return this.mesh.channels();
}
@Get('device')
@ApiOperation({
summary: 'Device info (metadata + config, keys redacted)',
description:
'This device\'s node number, firmware version and metadata, plus per-section config and module-config messages captured during the initial sync; empty until it completes. Key material is never exposed: security publicKey/privateKey/adminKey and network wifiPsk are replaced with "REDACTED". In-memory only, reset on every bridge reconnect.',
})
@ApiResponse({
status: 200,
description: 'Device info',
example: {
myNodeNum: 123456789,
firmwareVersion: '2.7.0.1',
metadata: {
firmwareVersion: '2.7.0.1',
deviceStateVersion: 1,
canShutdown: true,
hasWifi: false,
hasBluetooth: true,
hasEthernet: false,
role: 3,
positionFlags: 65,
hwModel: 42,
hasRemoteHardware: false,
hasPKC: true,
excludedModules: 0,
},
localConfig: {
device: { role: 3, buttonGpio: 13 },
security: {
publicKey: 'REDACTED',
privateKey: 'REDACTED',
adminKey: 'REDACTED',
isManaged: true,
},
network: { wifiEnabled: false, wifiSsid: '', wifiPsk: 'REDACTED' },
},
moduleConfig: {
telemetry: { environmentUpdateInterval: 900 },
},
},
})
device(): DeviceInfo {
return this.mesh.deviceInfo();
}
@Get('messages')
@ApiOperation({
summary: 'Message history (last 100)',
@@ -141,7 +187,7 @@ export class MeshController {
@ApiOperation({
summary: 'Known mesh nodes (lean summaries)',
description:
'Node database collected during the initial sync plus live POSITION_APP updates; reset on every bridge reconnect. Names, hwModel and batteryLevel appear only when the device reported them.',
'Node database collected during the initial sync plus live POSITION_APP updates; reset on every bridge reconnect. Names, hwModel and batteryLevel appear only when the device reported them; snr/hopsAway/viaMqtt only when carried by the NodeInfo.',
})
@ApiResponse({
status: 200,
@@ -155,6 +201,9 @@ export class MeshController {
batteryLevel: 87,
lastHeard: 1758000000,
position: { lat: 52.1049637, lon: 20.9833152, alt: 123 },
snr: -2.5,
hopsAway: 1,
viaMqtt: true,
},
],
})