const services = require('../services')

const { device } = services

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 }] };
    console.log(req.body);
    res.send(response);
  } catch (error) {
    res.send(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
    ]
  };

  res.send(response);
}

const setModuleConfiguration = async (req, res, next) => {

}

const getModulePrograms = async (req, res, next) => {

}

const setModulePrograms = async (req, res, next) => {

}

const reportModuleDataSent = async (req, res, next) => {
  res.send(200);
}

module.exports = {
  postGetRequestToDo,
  getModuleConfiguration,
  setModuleConfiguration,
  getModulePrograms,
  setModulePrograms,
  reportModuleDataSent,
}