router-modems.js 880 Bytes
'use strict';

const express = require('express');
const modems = require('../modems2');

const router = express.Router();
module.exports = router;

function pageIndex(req, res) {
    res.json(modems.dump());
}

function pageSet(req, res) {
    res.end('OK');

    modems.set({
        name: req.query.modem,
        device: req.query.modem_device,
        imsi: req.query.modem_imsi,
        msisdn: req.query.modem_msisdn,
        networkId: req.query.modem.network_id,
        networkName: req.query.modem_network_name,
        signalStrength: req.query.modem_signal_strength,
        uptime: req.query.uptime,
        reportIp: req.query.report_ip || req.ip,
        reportPort: req.query.report_port,
        reportApikey: req.query.report_apikey,
        reportPathSms: req.query.report_path_sms || '/sms',
    });
}

router.get('/', pageIndex);
router.get('/set', pageSet);