change motor status

master
Varun 1 year ago
parent 2a241a6c62
commit fd4ff96b83

@ -3774,19 +3774,27 @@ exports.changeMotorStatus = async (req, reply) => {
// 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
const result = await Tank.findOneAndUpdate(
{ motor_id: motor_id },
{ $set: { motor_stop_status: action }
});
await Tank.updateOne(
{ "connections.inputConnections.motor_id": motor_id },
{
$set: {
"connections.inputConnections.$.motor_stop_status":action ,
}
}
);
// Send immediat
// 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
reply.send({
status_code: 200,
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