From eb5c14d5d4b18ea8e69586e3879bf054ea224262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=9F=E8=BF=9B?= Date: Wed, 16 Jan 2019 04:32:11 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20main.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/main.js b/main.js index 435456f..9db78d3 100644 --- a/main.js +++ b/main.js @@ -4,13 +4,13 @@ 'use strict'; const utils = require(__dirname + '/lib/utils'); -let modbus = null; +let rsonoff = null; let fs; let serialport = null; let adapter = utils.Adapter({ - name: 'modbus', + name: 'rsonoff', unload: stop }); @@ -50,9 +50,9 @@ adapter.on('message', function (obj) { }); function stop(callback) { - if (modbus) { - modbus.close(); - modbus = null; + if (rsonoff) { + rsonoff.close(); + rsonoff = null; } if (adapter && adapter.setState && adapter.config && adapter.config.params) { @@ -72,16 +72,16 @@ let infoRegExp = new RegExp(adapter.namespace.replace('.', '\\.') + '\\.info\\.' adapter.on('stateChange', (id, state) => { if (state && !state.ack && id && !infoRegExp.test(id)) { - if (!modbus) { + if (!rsonoff) { adapter.log.warn('No connection') } else { if (objects[id]) { - modbus.write(id, state); + rsonoff.write(id, state); } else { adapter.getObject(id, (err, data) => { if (!err) { objects[id] = data; - modbus.write(id, state); + rsonoff.write(id, state); } }); } @@ -809,8 +809,8 @@ function main() { parseConfig(options => { let Modbus; Modbus = require(__dirname + '/lib/master'); - modbus = new Modbus(options, adapter); - modbus.start(); + rsonoff = new Modbus(options, adapter); + rsonoff.start(); }); }