Bhaskar 1 year ago
commit 73a0a0ddfb

@ -3746,19 +3746,27 @@ exports.changeMotorStatus = async (req, reply) => {
// Perform any necessary logic to handle motor status update from the device // Perform any necessary logic to handle motor status update from the device
// For example, update a database with the new status, current, and temp values // For example, update a database with the new status, current, and temp values
const result = await Tank.findOneAndUpdate(
{ motor_id: motor_id }, await Tank.updateOne(
{ $set: { motor_stop_status: action } { "connections.inputConnections.motor_id": motor_id },
}); {
$set: {
"connections.inputConnections.$.motor_stop_status":action ,
}
}
);
// Send immediat
// Fetch the motor_status for the given motor_id // Fetch the motor_status for the given motor_id
const updatedMotor = await Tank.findOne({ motor_id: motor_id });
// Send the response with motor_stop_status and motor_status // Send the response with motor_stop_status and motor_status
reply.send({ reply.send({
status_code: 200, status_code: 200,
motor_stop_status: action, motor_stop_status: action,
motor_status: updatedMotor.motor_status // Assuming motor_status is a field in your Tank model // motor_status: updatedMotor.motor_status // Assuming motor_status is a field in your Tank model
}); });

Loading…
Cancel
Save