|
|
@ -1,19 +1,33 @@ |
|
|
|
import express from "express"; |
|
|
|
import { delay } from "../utils/helper"; |
|
|
|
import { WsProxy } from "../utils/wss"; |
|
|
|
const router = express.Router(); |
|
|
|
|
|
|
|
router.post("/", async (req, res) => { |
|
|
|
await delay(200); |
|
|
|
// setTimeout(() => {
|
|
|
|
// wsSend(req.app.locals["wss"], {
|
|
|
|
// type: "cmd",
|
|
|
|
// data: {
|
|
|
|
// commandId: req.body.commandId,
|
|
|
|
// status: "D0000",
|
|
|
|
// },
|
|
|
|
// });
|
|
|
|
// }, 2000);
|
|
|
|
res.json({ code: "00000", msg: "执行成功" }); |
|
|
|
router.post("/disconnect-ble", async (req, res) => { |
|
|
|
WsProxy.sendMobile({ |
|
|
|
type: "peripheral-status", |
|
|
|
data: { |
|
|
|
connected: false, //是否已连接蓝牙
|
|
|
|
power: 60, //电量
|
|
|
|
inclinatorX: 0.276, //x轴倾斜
|
|
|
|
inclinatorY: 3.019, //y轴倾斜
|
|
|
|
temperature: 32.026, //温度
|
|
|
|
}, |
|
|
|
}); |
|
|
|
res.json({ success: true }); |
|
|
|
}); |
|
|
|
router.post("/connect-ble", async (req, res) => { |
|
|
|
WsProxy.sendMobile({ |
|
|
|
type: "peripheral-status", |
|
|
|
data: { |
|
|
|
connected: true, //是否已连接蓝牙
|
|
|
|
power: 60, //电量
|
|
|
|
inclinatorX: 0.276, //x轴倾斜
|
|
|
|
inclinatorY: 3.019, //y轴倾斜
|
|
|
|
temperature: 32.026, //温度
|
|
|
|
}, |
|
|
|
}); |
|
|
|
res.json({ success: true }); |
|
|
|
}); |
|
|
|
|
|
|
|
export default router; |