Ajout gestion Look & Sync firmwares, et routes BST

This commit is contained in:
Arnaud Nelissen
2025-09-17 17:45:46 +02:00
parent e715c265ad
commit 73add80cab
27 changed files with 2209 additions and 386 deletions

View File

@@ -1,67 +1,240 @@
const services = require('../services')
const util = require('../util')
const { device } = services
const getModuleMsn = (req) => {
return req.query.msn || req.query.id || req.body.module
}
const getRelayMsn = (req) => {
return req.body.relayMsn
}
const postGetRequestToDo = async (req, res, next) => {
///// Emit event to server
try {
await device.postRequestToDo(req.body.relayMsn, req.body);
await device.getRequestToDo(req.body.relayMsn);
var response = { todo: [{ serialNumber: req.body.relayMsn, configuration: 1 }] };
await device.postRequestToDo(getRelayMsn(req), req.body);
const todo = await device.getRequestToDo(getRelayMsn(req));
var response = { todo };
console.log(req.body);
res.send(response);
} catch (error) {
res.send(500);
res.sendStatus(500);
}
}
const getModuleConfiguration = async (req, res, next) => {
///// Emit event to server
var response = {
"name": "LRBST-R-TARACE",
"inventory": [
"7400040670330001"
],
"wakeUpTimes": [
60,
480,
540,
600,
660,
720,
780,
840,
900,
960,
1020,
1080
]
};
try {
///// Emit event to server
var response = await device.getConfiguration(getModuleMsn(req))
res.send(response);
res.send(response.configuration);
} catch (error) {
res.sendStatus(500);
}
}
const setModuleConfiguration = async (req, res, next) => {
try {
///// Emit event to server
await device.postConfiguration(getModuleMsn(req), req.body, util.dateToTimestamp(req.body.flashTimeStamp))
}
const getModulePrograms = async (req, res, next) => {
}
const setModulePrograms = async (req, res, next) => {
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
const reportModuleDataSent = async (req, res, next) => {
res.send(200);
try {
///// Emit event to server
await device.postConfiguration(getModuleMsn(req), null, util.dateToTimestamp(req.body.sentAt))
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
const getModulePrograms = async (req, res, next) => {
try {
///// Emit event to server
var response = await device.getPrograms(getModuleMsn(req))
res.send(response.programs);
} catch (error) {
res.sendStatus(500);
}
}
const setModulePrograms = async (req, res, next) => {
try {
///// Emit event to server
await device.postPrograms(getModuleMsn(req), req.body, util.dateToTimestamp(req.body.flashTimeStamp))
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
const reportProgramsDataSent = async (req, res, next) => {
try {
///// Emit event to server
await device.postPrograms(getModuleMsn(req), null, util.dateToTimestamp(req.body.programmingTimestamp))
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
const reportAllModuleProgramsDataSent = async (req, res, next) => {
try {
///// Emit event to server
await device.postPrograms(getModuleMsn(req), null, util.dateToTimestamp(req.body.sentAt))
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
const getModuleSlots = async (req, res, next) => {
try {
///// Emit event to server
var response = await device.getSlots(getModuleMsn(req))
res.send(response.slots);
} catch (error) {
res.sendStatus(500);
}
}
const setModuleSlots = async (req, res, next) => {
try {
///// Emit event to server
await device.postSlots(getModuleMsn(req), req.body, util.dateToTimestamp(req.body.flashTimeStamp))
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
const reportSlotsDataSent = async (req, res, next) => {
try {
///// Emit event to server
await device.postSlots(getModuleMsn(req), null, util.dateToTimestamp(req.body.programmingTimestamp))
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
const reportAllModuleSlotsDataSent = async (req, res, next) => {
try {
///// Emit event to server
await device.postSlots(getModuleMsn(req), null, util.dateToTimestamp(req.body.sentAt))
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
const getManualCommand = async (req, res, next) => {
try {
///// Emit event to server
var response = await device.getManualCommand(getModuleMsn(req))
res.send(response.manualCommand);
} catch (error) {
res.sendStatus(500);
}
}
const reportManualCommandSent = async (req, res, next) => {
try {
///// Emit event to server
await device.postManualCommand(getModuleMsn(req), null)
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
const getStatusCommand = async (req, res, next) => {
try {
///// Emit event to server
var response = await device.getStatusCommand(getModuleMsn(req))
res.send(response.statusCommand);
} catch (error) {
res.sendStatus(500);
}
}
const reportStatusCommandSent = async (req, res, next) => {
try {
///// Emit event to server
await device.postStatusCommand(getModuleMsn(req), null)
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
const getAcknowledgeAlerts = async (req, res, next) => {
try {
///// Emit event to server
var response = await device.getAcknowledgedAlerts(getModuleMsn(req))
res.send(response.acknowledgedAlerts);
} catch (error) {
res.sendStatus(500);
}
}
const reportAcknowledgeAlerts = async (req, res, next) => {
try {
///// Emit event to server
await device.postAcknowledgedAlerts(getModuleMsn(req), null)
res.sendStatus(200);
} catch (error) {
res.sendStatus(500);
}
}
module.exports = {
postGetRequestToDo,
getModuleConfiguration,
setModuleConfiguration,
reportModuleDataSent,
getModulePrograms,
setModulePrograms,
reportModuleDataSent,
reportProgramsDataSent,
reportAllModuleProgramsDataSent,
getModuleSlots,
setModuleSlots,
reportSlotsDataSent,
reportAllModuleSlotsDataSent,
getManualCommand,
reportManualCommandSent,
getStatusCommand,
reportStatusCommandSent,
getAcknowledgeAlerts,
reportAcknowledgeAlerts,
}