data/edge5cdab/modbus & logging

This commit is contained in:
2026-07-02 18:39:43 +05:00
parent f5dd5a7f7f
commit d7bfaa678e
12 changed files with 117 additions and 39 deletions

View File

@@ -1,4 +1,5 @@
import { postCloudIngest } from '../cloud-ingest.js'
import { log } from '../helpers/log.js'
import type { TopicHandler } from '../types.js'
const EDGE = 'edge5i'
@@ -42,11 +43,11 @@ async function postMetrics(metrics: DemoModbusMetric[]): Promise<void> {
}
}
console.log(`${EDGE}.modbus.posted ${metrics.length} metrics`)
log(`${EDGE}.modbus.posted ${metrics.length} metrics`)
}
export const handle: TopicHandler = async (topic, payload) => {
console.log(`${EDGE}.modbus.received ${topic} ${payload.length} bytes`)
log(`${EDGE}.modbus.received ${topic} ${payload.length} bytes`)
const values = parseValues(payload)
const metrics = toMetrics(values, new Date().toISOString())