fix nodeinfo and telemetry
All checks were successful
Build Docker containers / Build (push) Successful in 42s
All checks were successful
Build Docker containers / Build (push) Successful in 42s
This commit is contained in:
@ -792,7 +792,7 @@ client.on('message', async (topic, message) => {
|
|||||||
break;
|
break;
|
||||||
case Portnums.PortNum.NODEINFO_APP:
|
case Portnums.PortNum.NODEINFO_APP:
|
||||||
callback = onNodeInfo;
|
callback = onNodeInfo;
|
||||||
schema = Mesh.NodeInfoSchema;
|
schema = Mesh.UserSchema;
|
||||||
break;
|
break;
|
||||||
case Portnums.PortNum.WAYPOINT_APP:
|
case Portnums.PortNum.WAYPOINT_APP:
|
||||||
callback = onWaypoint;
|
callback = onWaypoint;
|
||||||
@ -1223,25 +1223,28 @@ async function onRouteDiscovery(envelope, payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onTelemetry(envelope, payload) {
|
async function onTelemetry(envelope, payload) {
|
||||||
|
// we need to do some work on the packet to log it properly
|
||||||
|
const telemetryType = payload.variant.case
|
||||||
if(logKnownPacketTypes) {
|
if(logKnownPacketTypes) {
|
||||||
console.log('TELEMETRY_APP', {
|
console.log('TELEMETRY_APP', {
|
||||||
from: envelope.packet.from.toString(16),
|
from: envelope.packet.from.toString(16),
|
||||||
telemetry: payload,
|
type: telemetryType,
|
||||||
|
telemetry: payload.variant.value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
payload = payload.variant.value
|
||||||
|
|
||||||
// data to update
|
// data to update
|
||||||
const data = {};
|
const data = {};
|
||||||
|
|
||||||
// handle device metrics
|
// handle device metrics
|
||||||
if(payload.deviceMetrics){
|
if (telemetryType === 'deviceMetrics'){
|
||||||
|
|
||||||
data.battery_level = payload.deviceMetrics.batteryLevel !== 0 ? payload.deviceMetrics.batteryLevel : null;
|
data.battery_level = payload.batteryLevel !== 0 ? payload.batteryLevel : null;
|
||||||
data.voltage = payload.deviceMetrics.voltage !== 0 ? payload.deviceMetrics.voltage : null;
|
data.voltage = payload.voltage !== 0 ? payload.voltage : null;
|
||||||
data.channel_utilization = payload.deviceMetrics.channelUtilization !== 0 ? payload.deviceMetrics.channelUtilization : null;
|
data.channel_utilization = payload.channelUtilization !== 0 ? payload.channelUtilization : null;
|
||||||
data.air_util_tx = payload.deviceMetrics.airUtilTx !== 0 ? payload.deviceMetrics.airUtilTx : null;
|
data.air_util_tx = payload.airUtilTx !== 0 ? payload.airUtilTx : null;
|
||||||
data.uptime_seconds = payload.deviceMetrics.uptimeSeconds !== 0 ? payload.deviceMetrics.uptimeSeconds : null;
|
data.uptime_seconds = payload.uptimeSeconds !== 0 ? payload.uptimeSeconds : null;
|
||||||
|
|
||||||
// create device metric
|
// create device metric
|
||||||
try {
|
try {
|
||||||
@ -1280,20 +1283,20 @@ async function onTelemetry(envelope, payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle environment metrics
|
// handle environment metrics
|
||||||
if(payload.environmentMetrics){
|
if(telemetryType === 'environmentMetrics'){
|
||||||
|
|
||||||
// get metric values
|
// get metric values
|
||||||
const temperature = payload.environmentMetrics.temperature !== 0 ? payload.environmentMetrics.temperature : null;
|
const temperature = payload.temperature !== 0 ? payload.temperature : null;
|
||||||
const relativeHumidity = payload.environmentMetrics.relativeHumidity !== 0 ? payload.environmentMetrics.relativeHumidity : null;
|
const relativeHumidity = payload.relativeHumidity !== 0 ? payload.relativeHumidity : null;
|
||||||
const barometricPressure = payload.environmentMetrics.barometricPressure !== 0 ? payload.environmentMetrics.barometricPressure : null;
|
const barometricPressure = payload.barometricPressure !== 0 ? payload.barometricPressure : null;
|
||||||
const gasResistance = payload.environmentMetrics.gasResistance !== 0 ? payload.environmentMetrics.gasResistance : null;
|
const gasResistance = payload.gasResistance !== 0 ? payload.gasResistance : null;
|
||||||
const voltage = payload.environmentMetrics.voltage !== 0 ? payload.environmentMetrics.voltage : null;
|
const voltage = payload.voltage !== 0 ? payload.voltage : null;
|
||||||
const current = payload.environmentMetrics.current !== 0 ? payload.environmentMetrics.current : null;
|
const current = payload.current !== 0 ? payload.current : null;
|
||||||
const iaq = payload.environmentMetrics.iaq !== 0 ? payload.environmentMetrics.iaq : null;
|
const iaq = payload.iaq !== 0 ? payload.iaq : null;
|
||||||
const windDirection = payload.environmentMetrics.windDirection;
|
const windDirection = payload.windDirection;
|
||||||
const windSpeed = payload.environmentMetrics.windSpeed;
|
const windSpeed = payload.windSpeed;
|
||||||
const windGust = payload.environmentMetrics.windGust;
|
const windGust = payload.windGust;
|
||||||
const windLull = payload.environmentMetrics.windLull;
|
const windLull = payload.windLull;
|
||||||
|
|
||||||
// set metrics to update on node table
|
// set metrics to update on node table
|
||||||
data.temperature = temperature;
|
data.temperature = temperature;
|
||||||
@ -1342,15 +1345,15 @@ async function onTelemetry(envelope, payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle power metrics
|
// handle power metrics
|
||||||
if(payload.powerMetrics){
|
if(telemetryType === 'powerMetrics'){
|
||||||
|
|
||||||
// get metric values
|
// get metric values
|
||||||
const ch1Voltage = payload.powerMetrics.ch1Voltage !== 0 ? payload.powerMetrics.ch1Voltage : null;
|
const ch1Voltage = payload.ch1Voltage !== 0 ? payload.ch1Voltage : null;
|
||||||
const ch1Current = payload.powerMetrics.ch1Current !== 0 ? payload.powerMetrics.ch1Current : null;
|
const ch1Current = payload.ch1Current !== 0 ? payload.ch1Current : null;
|
||||||
const ch2Voltage = payload.powerMetrics.ch2Voltage !== 0 ? payload.powerMetrics.ch2Voltage : null;
|
const ch2Voltage = payload.ch2Voltage !== 0 ? payload.ch2Voltage : null;
|
||||||
const ch2Current = payload.powerMetrics.ch2Current !== 0 ? payload.powerMetrics.ch2Current : null;
|
const ch2Current = payload.ch2Current !== 0 ? payload.ch2Current : null;
|
||||||
const ch3Voltage = payload.powerMetrics.ch3Voltage !== 0 ? payload.powerMetrics.ch3Voltage : null;
|
const ch3Voltage = payload.ch3Voltage !== 0 ? payload.ch3Voltage : null;
|
||||||
const ch3Current = payload.powerMetrics.ch3Current !== 0 ? payload.powerMetrics.ch3Current : null;
|
const ch3Current = payload.ch3Current !== 0 ? payload.ch3Current : null;
|
||||||
|
|
||||||
// create power metric
|
// create power metric
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user