|
|
|
@ -687,6 +687,72 @@ module.exports = function (fastify, opts, next) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastify.post('/api/motor/write', {
|
|
|
|
|
schema: {
|
|
|
|
|
tags: ["Tank"],
|
|
|
|
|
description: "This is to Write the motor status",
|
|
|
|
|
summary: "This is to Write the motor status",
|
|
|
|
|
body: {
|
|
|
|
|
type: 'object',
|
|
|
|
|
required: ['motor_id', 'status'],
|
|
|
|
|
properties: {
|
|
|
|
|
motor_id: { type: 'string' },
|
|
|
|
|
status: { type: 'string', enum: ['on', 'off'] },
|
|
|
|
|
current: { type: 'string' },
|
|
|
|
|
temp: { type: 'string' },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// response: {
|
|
|
|
|
// 200: {
|
|
|
|
|
// type: 'object',
|
|
|
|
|
// properties: {
|
|
|
|
|
// // Define your response properties here
|
|
|
|
|
// motor_id: { type: 'string' },
|
|
|
|
|
// status: { type: 'string' },
|
|
|
|
|
// current: { type: 'string' },
|
|
|
|
|
// temp: { type: 'string' },
|
|
|
|
|
// // Add other properties as needed
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
},
|
|
|
|
|
handler: tanksController.writeMotorStatus
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastify.get('/api/motor/read', {
|
|
|
|
|
schema: {
|
|
|
|
|
tags: ["Tank"],
|
|
|
|
|
description: "This is to Read the motor status",
|
|
|
|
|
summary: "This is to Read the motor status",
|
|
|
|
|
querystring: {
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: {
|
|
|
|
|
motor_id: { type: 'string' },
|
|
|
|
|
action: { type: 'string', enum: ['1', '2'] },
|
|
|
|
|
},
|
|
|
|
|
required: ['motor_id', 'action'],
|
|
|
|
|
},
|
|
|
|
|
// response: {
|
|
|
|
|
// 200: {
|
|
|
|
|
// type: 'object',
|
|
|
|
|
// properties: {
|
|
|
|
|
// // Define your response properties here
|
|
|
|
|
// motor_id: { type: 'string' },
|
|
|
|
|
// motor_status: { type: 'string' },
|
|
|
|
|
// motor_speed: { type: 'string' },
|
|
|
|
|
// motor_temperature: { type: 'string' },
|
|
|
|
|
// // Add other properties as needed
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
},
|
|
|
|
|
handler: tanksController.readMotorStatus
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|