master^2
Bhaskar 6 months ago
parent b576a853df
commit a0c6014a79

@ -1007,10 +1007,16 @@ exports.getMasterSlaveSummary = async (req, reply) => {
// Update connection status and timestamps
const updateStatusPromises = allDevices.map(async device => {
const hwId = device.connected_to;
if (!hwId) return;
let checkHardwareId = device.hardwareId?.trim();
if (!checkHardwareId) return;
const latestData = await IotData.findOne({ hardwareId: hwId })
// For slave, check connection via master's hardwareId (i.e., connected_to)
if (device.type === 'slave') {
checkHardwareId = device.connected_to?.trim();
if (!checkHardwareId) return;
}
const latestData = await IotData.findOne({ hardwareId: checkHardwareId })
.sort({ date: -1 })
.lean();
@ -1043,7 +1049,6 @@ exports.getMasterSlaveSummary = async (req, reply) => {
device.connected_lora_time = time;
}
}
}
updateFields.connected_status = status;

Loading…
Cancel
Save