|
|
@ -1474,11 +1474,11 @@ exports.readMotorStatus = async (req, reply) => {
|
|
|
|
return reply.status(404).send({ status_code: 404, message: 'Tank not found for the specified motor_id' });
|
|
|
|
return reply.status(404).send({ status_code: 404, message: 'Tank not found for the specified motor_id' });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const motor_status = motorInfo.motor_status;
|
|
|
|
const motor_stop_status = motorInfo.motor_stop_status;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reply.send({ status_code: 200, motor_status:motor_status });
|
|
|
|
reply.send({ status_code: 200, motor_stop_status:motor_stop_status });
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
throw boom.boomify(err);
|
|
|
|
throw boom.boomify(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1520,21 +1520,25 @@ exports.writeMotorStatus = async (req, reply) => {
|
|
|
|
exports.changeMotorStatus = async (req, reply) => {
|
|
|
|
exports.changeMotorStatus = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const motor_id = req.body.motor_id;
|
|
|
|
const motor_id = req.body.motor_id;
|
|
|
|
const action =req.body.action
|
|
|
|
const action = req.body.action;
|
|
|
|
|
|
|
|
|
|
|
|
// 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 },
|
|
|
|
|
|
|
|
{ $set: { motor_stop_status: action }
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fetch the motor_status for the given motor_id
|
|
|
|
const result = await Tank.findOneAndUpdate(
|
|
|
|
const updatedMotor = await Tank.findOne({ motor_id: motor_id });
|
|
|
|
{ motor_id: motor_id },
|
|
|
|
|
|
|
|
{ $set: { motor_stop_status: action } });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reply.send({ status_code: 200,motor_stop_status: action });
|
|
|
|
// 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
|
|
|
|
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
throw boom.boomify(err);
|
|
|
|
throw boom.boomify(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|