diff --git a/src/index.js b/src/index.js index 1d18d5d..1e4397f 100644 --- a/src/index.js +++ b/src/index.js @@ -222,7 +222,7 @@ const getCommand = (raw) => { const password = match[1]; const code = match[2]; const extra = match[3] ? match[3].substr(1).split(',') : null; - let data = {device: 'TZ-COMMAND', type: 'command', password: password}; + let data = {device: 'TZ-COMMAND-OK', type: 'ok', password: password}; if (code === '001') { data.command = 'SetUserPassword'; data.newPassword = extra[0]; diff --git a/test/test.js b/test/test.js index 07b0904..0fdb3b2 100644 --- a/test/test.js +++ b/test/test.js @@ -141,52 +141,52 @@ describe('tz-parzer', () => { expect(data.datetime).to.eql(new Date('2016-02-19T15:00:17.000Z')); }); - it('should return TZ-COMMAND SetUserPassword data parsed', () => { + it('should return TZ-COMMAND-OK SetUserPassword data parsed', () => { const raw = new Buffer('Receive:\'001\'OK\r\n*000000,001,111111#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SetUserPassword'); expect(data.newPassword).to.eql('111111'); }); - it('should return TZ-COMMAND SETINTERVALOFSMS data parsed', () => { + it('should return TZ-COMMAND-OK SETINTERVALOFSMS data parsed', () => { const raw = new Buffer('Receive:\'002\'OK\r\n*000000,002,1,999#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETINTERVALOFSMS'); expect(data.enable).to.be.true; expect(data.interval).to.eql('1'); expect(data.limit).to.eql('999'); }); - it('should return TZ-COMMAND SETPHONESMSFORSOS data parsed', () => { + it('should return TZ-COMMAND-OK SETPHONESMSFORSOS data parsed', () => { const raw = new Buffer('Receive:\'003\'OK\r\n*000000,003,0,1,005695487459,005695487459#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETPHONESMSFORSOS'); expect(data.enable).to.be.true; expect(data.callNumber).to.eql('005695487459'); expect(data.smsNumber).to.eql('005695487459'); }); - it('should return TZ-COMMAND SETLOWPOWERALARM data parsed', () => { + it('should return TZ-COMMAND-OK SETLOWPOWERALARM data parsed', () => { const raw = new Buffer('Receive:\'004\'OK\r\n*000000,004,380,350#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETLOWPOWERALARM'); expect(data.lowPower).to.eql(3.8); expect(data.autoShutdown).to.eql(3.5); }); - it('should return TZ-COMMAND SETOVERSPEEDALARM data parsed', () => { + it('should return TZ-COMMAND-OK SETOVERSPEEDALARM data parsed', () => { const raw = new Buffer('Receive:\'005\'OK\r\n*000000,005,1,100,10,360#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETOVERSPEEDALARM'); expect(data.enable).to.be.true; expect(data.speed).to.eql(100); @@ -194,11 +194,11 @@ describe('tz-parzer', () => { expect(data.interval).to.eql(360); }); - it('should return TZ-COMMAND SETGEOFENCEALARM data parsed', () => { + it('should return TZ-COMMAND-OK SETGEOFENCEALARM data parsed', () => { const raw = new Buffer('Receive:\'006\'OK\r\n*000000,006,-3321.6805,-07030.9513,-3321.6095,-07030.8714,1,1#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETGEOFENCEALARM'); expect(data.enable).to.be.true; expect(data.mode).to.eql('inside'); @@ -212,199 +212,199 @@ describe('tz-parzer', () => { ]]); }); - it('should return TZ-COMMAND SETEXTEND data parsed', () => { + it('should return TZ-COMMAND-OK SETEXTEND data parsed', () => { const raw = new Buffer('Receive:\'008\'OK\r\n*000000,008,1000001#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETEXTEND'); expect(data.extend).to.eql({a: true, b: false, c: false, d: false, e: false, f: false, g: true}); }); - it('should return TZ-COMMAND SETGSMBAUD data parsed', () => { + it('should return TZ-COMMAND-OK SETGSMBAUD data parsed', () => { const raw = new Buffer('Receive:\'009\'OK\r\n*000000,009,2#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETGSMBAUD'); expect(data.band).to.eql('auto'); }); - it('should return TZ-COMMAND SETAPN data parsed', () => { + it('should return TZ-COMMAND-OK SETAPN data parsed', () => { const raw = new Buffer('Receive:\'011\'OK\r\n*000000,011,imovil.entelpcs.cl,entelpcs,entelpcs#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETAPN'); expect(data.apn).to.eql('imovil.entelpcs.cl'); expect(data.username).to.eql('entelpcs'); expect(data.pass).to.eql('entelpcs'); }); - it('should return TZ-COMMAND SETDNS data parsed', () => { + it('should return TZ-COMMAND-OK SETDNS data parsed', () => { const raw = new Buffer('Receive:\'014\'OK\r\n*000000,014,1,8.8.8.8,8.8.4.4#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETDNS'); expect(data.enable).to.be.true; expect(data.dns1).to.eql('8.8.8.8'); expect(data.dns2).to.eql('8.8.4.4'); }); - it('should return TZ-COMMAND SETIPANDPORT data parsed', () => { + it('should return TZ-COMMAND-OK SETIPANDPORT data parsed', () => { const raw = new Buffer('Receive:\'015\'OK\r\n*000000,015,1,server.com,1331#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETIPANDPORT'); expect(data.host).to.eql('server.com'); expect(data.port).to.eql(1331); }); - it('should return TZ-COMMAND SETGPRSINTERVAL data parsed', () => { + it('should return TZ-COMMAND-OK SETGPRSINTERVAL data parsed', () => { const raw = new Buffer('Receive:\'018\'OK\r\n*000000,018,10,999#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETGPRSINTERVAL'); expect(data.enable).to.be.true; expect(data.interval).to.eql(10); expect(data.limit).to.eql(999); }); - it('should return TZ-COMMAND SETSYSSWITCH data parsed', () => { + it('should return TZ-COMMAND-OK SETSYSSWITCH data parsed', () => { const raw = new Buffer('Receive:\'016\'OK\r\n*000000,016,1#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETSYSSWITCH'); expect(data.enable).to.be.true; }); - it('should return TZ-COMMAND SETTCPSWITCH data parsed', () => { + it('should return TZ-COMMAND-OK SETTCPSWITCH data parsed', () => { const raw = new Buffer('Receive:\'019\'OK\r\n*000000,019,1#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETTCPSWITCH'); expect(data.mode).to.eql('tcp'); }); - it('should return TZ-COMMAND SETTREMBLESWITCH data parsed', () => { + it('should return TZ-COMMAND-OK SETTREMBLESWITCH data parsed', () => { const raw = new Buffer('Receive:\'021\'OK\r\n*000000,021,1,1#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETTREMBLESWITCH'); expect(data.sleep).to.be.true; expect(data.tremble).to.be.true; }); - it('should return TZ-COMMAND SETSLEEPSWITCH data parsed', () => { + it('should return TZ-COMMAND-OK SETSLEEPSWITCH data parsed', () => { const raw = new Buffer('Receive:\'022\'OK\r\n*000000,022,0,0#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETSLEEPSWITCH'); expect(data.closeGps).to.be.true; expect(data.closeGsm).to.be.true; }); - it('should return TZ-COMMAND SETIOSWITCH data parsed', () => { + it('should return TZ-COMMAND-OK SETIOSWITCH data parsed', () => { const raw = new Buffer('Receive:\'025\'OK\r\n*000000,025,A,1#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETIOSWITCH'); expect(data.enable).to.be.true; expect(data.port).to.eql(1); }); - it('should return TZ-COMMAND SETHEARTBEATSWITCH data parsed', () => { + it('should return TZ-COMMAND-OK SETHEARTBEATSWITCH data parsed', () => { const raw = new Buffer('Receive:\'040\'OK\r\n*000000,040,0#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETHEARTBEATSWITCH'); expect(data.enable).to.be.false; }); - it('should return TZ-COMMAND SETHEARTBEATINTERVAL data parsed', () => { + it('should return TZ-COMMAND-OK SETHEARTBEATINTERVAL data parsed', () => { const raw = new Buffer('Receive:\'041\'OK\r\n*000000,041,0#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETHEARTBEATINTERVAL'); expect(data.enable).to.be.false; }); - it('should return TZ-COMMAND SETHEARTBEATINIT data parsed', () => { + it('should return TZ-COMMAND-OK SETHEARTBEATINIT data parsed', () => { const raw = new Buffer('Receive:\'042\'OK\r\n*000000,042#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETHEARTBEATINIT'); }); - it('should return TZ-COMMAND SETTREMBLETOSLEEP data parsed', () => { + it('should return TZ-COMMAND-OK SETTREMBLETOSLEEP data parsed', () => { const raw = new Buffer('Receive:\'044\'OK\r\n*000000,044,30#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETTREMBLETOSLEEP'); expect(data.after).to.eql(30); }); - it('should return TZ-COMMAND SETTREMBLETOWAKEUP data parsed', () => { + it('should return TZ-COMMAND-OK SETTREMBLETOWAKEUP data parsed', () => { const raw = new Buffer('Receive:\'043\'OK\r\n*000000,043,10#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETTREMBLETOWAKEUP'); expect(data.after).to.eql(10); }); - it('should return TZ-COMMAND SETPARKINGALARM data parsed', () => { + it('should return TZ-COMMAND-OK SETPARKINGALARM data parsed', () => { const raw = new Buffer('Receive:\'110\'OK\r\n*000000,110,0#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETPARKINGALARM'); expect(data.enable).to.be.false; }); - it('should return TZ-COMMAND FACTORYRESET data parsed', () => { + it('should return TZ-COMMAND-OK FACTORYRESET data parsed', () => { const raw = new Buffer('Receive:\'990\'OK\r\n*000000,990#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('FACTORYRESET'); }); - it('should return TZ-COMMAND RBOOT data parsed', () => { + it('should return TZ-COMMAND-OK RBOOT data parsed', () => { const raw = new Buffer('Receive:\'991\'OK\r\n*000000,991#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('RBOOT'); }); - it('should return TZ-COMMAND SETOILSENSER data parsed', () => { + it('should return TZ-COMMAND-OK SETOILSENSER data parsed', () => { const raw = new Buffer('Receive:\'113\'OK\r\n*000000,113,100,500#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETOILSENSER'); expect(data.empty).to.eql(1); expect(data.full).to.eql(5); }); - it('should return TZ-COMMAND SETSHUTOIL data parsed', () => { + it('should return TZ-COMMAND-OK SETSHUTOIL data parsed', () => { const raw = new Buffer('Receive:\'117\'OK\r\n*000000,117,60,500,3000,5#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETSHUTOIL'); expect(data.speed).to.eql(60); expect(data.off).to.eql(500); @@ -412,215 +412,215 @@ describe('tz-parzer', () => { expect(data.repeat).to.eql(5); }); - it('should return TZ-COMMAND SETSHUTOILSWITCH data parsed', () => { + it('should return TZ-COMMAND-OK SETSHUTOILSWITCH data parsed', () => { const raw = new Buffer('Receive:\'116\'OK\r\n*000000,116,0#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETSHUTOILSWITCH'); expect(data.enable).to.be.false; }); - it('should return TZ-COMMAND SETCALLA data parsed', () => { + it('should return TZ-COMMAND-OK SETCALLA data parsed', () => { const raw = new Buffer('Receive:\'103\'OK\r\n*000000,103,0,005695487459#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETCALLA'); expect(data.mode).to.eql('gprs'); expect(data.number).to.eql('005695487459'); }); - it('should return TZ-COMMAND SETEXTEND2 data parsed', () => { + it('should return TZ-COMMAND-OK SETEXTEND2 data parsed', () => { const raw = new Buffer('Receive:\'118\'OK\r\n*000000,118,10000001#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETEXTEND2'); expect(data.extend).to.eql({a: true, b: false, c: false, d: false, e: false, f: false, g: false, h: true}); }); - it('should return TZ-COMMAND SETPIN data parsed', () => { + it('should return TZ-COMMAND-OK SETPIN data parsed', () => { const raw = new Buffer('Receive:\'122\'OK\r\n*000000,122,0,1234#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETPIN'); expect(data.enable).to.be.false; expect(data.pin).to.eql('1234'); }); - it('should return TZ-COMMAND SETANGLE data parsed', () => { + it('should return TZ-COMMAND-OK SETANGLE data parsed', () => { const raw = new Buffer('Receive:\'300\'OK\r\n*000000,300,0,360#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETANGLE'); expect(data.enable).to.be.false; expect(data.angle).to.eql(360); }); - it('should return TZ-COMMAND SETANGLE data parsed', () => { + it('should return TZ-COMMAND-OK SETANGLE data parsed', () => { const raw = new Buffer('Receive:\'400\'OK\r\n*000000,400,0,360#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETANGLE'); expect(data.enable).to.be.false; expect(data.angle).to.eql(360); }); - it('should return TZ-COMMAND SETREBOOT data parsed', () => { + it('should return TZ-COMMAND-OK SETREBOOT data parsed', () => { const raw = new Buffer('Receive:\'600\'OK\r\n*000000,600,0,30#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETREBOOT'); expect(data.enable).to.be.false; expect(data.interval).to.eql(30); }); - it('should return TZ-COMMAND SETACCALARM data parsed', () => { + it('should return TZ-COMMAND-OK SETACCALARM data parsed', () => { const raw = new Buffer('Receive:\'120\'OK\r\n*000000,120,0,30,30#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETACCALARM'); expect(data.enable).to.be.false; expect(data.acceleration).to.eql(30); expect(data.deceleration).to.eql(30); }); - it('should return TZ-COMMAND SETROAMING data parsed', () => { + it('should return TZ-COMMAND-OK SETROAMING data parsed', () => { const raw = new Buffer('Receive:\'121\'OK\r\n*000000,121,0,30,210#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETROAMING'); expect(data.enable).to.be.false; expect(data.interval).to.eql(30); expect(data.network).to.eql('210'); }); - it('should return TZ-COMMAND SETACKSTATE data parsed', () => { + it('should return TZ-COMMAND-OK SETACKSTATE data parsed', () => { const raw = new Buffer('Receive:\'123\'OK\r\n*000000,123,0#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETACKSTATE'); expect(data.enable).to.be.false; }); - it('should return TZ-COMMAND SETCALLFILTER data parsed', () => { + it('should return TZ-COMMAND-OK SETCALLFILTER data parsed', () => { const raw = new Buffer('Receive:\'130\'OK\r\n*000000,130,0,0#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETCALLFILTER'); expect(data.enable).to.be.false; expect(data.caller).to.eql('0'); }); - it('should return TZ-COMMAND SETSENDTYPE data parsed', () => { + it('should return TZ-COMMAND-OK SETSENDTYPE data parsed', () => { const raw = new Buffer('Receive:\'119\'OK\r\n*000000,119,0#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETSENDTYPE'); expect(data.mode).to.eql('gprs'); }); - it('should return TZ-COMMAND SETPICTUREINTERVAL data parsed', () => { + it('should return TZ-COMMAND-OK SETPICTUREINTERVAL data parsed', () => { const raw = new Buffer('Receive:\'200\'OK\r\n*000000,200,10,999#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETPICTUREINTERVAL'); expect(data.interval).to.eql(10); expect(data.times).to.eql(999); }); - it('should return TZ-COMMAND CLEARBUF data parsed', () => { + it('should return TZ-COMMAND-OK CLEARBUF data parsed', () => { const raw = new Buffer('Receive:\'500\'OK\r\n*000000,500#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('CLEARBUF'); }); - it('should return TZ-COMMAND GETPICTURE data parsed', () => { + it('should return TZ-COMMAND-OK GETPICTURE data parsed', () => { const raw = new Buffer('Receive:\'210\'OK\r\n*000000,210#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('GETPICTURE'); }); - it('should return TZ-COMMAND SETDATAFLASH data parsed', () => { + it('should return TZ-COMMAND-OK SETDATAFLASH data parsed', () => { const raw = new Buffer('Receive:\'601\'OK\r\n*000000,601,1#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETDATAFLASH'); expect(data.enable).to.be.true; }); - it('should return TZ-COMMAND SETTRACKINGINTERVAL data parsed', () => { + it('should return TZ-COMMAND-OK SETTRACKINGINTERVAL data parsed', () => { const raw = new Buffer('Receive:\'156\'OK\r\n*000000,156,0,30,30#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETTRACKINGINTERVAL'); expect(data.enable).to.be.false; expect(data.intervalOn).to.eql(30); expect(data.intervalOff).to.eql(30); }); - it('should return TZ-COMMAND SETSENDODOMETER data parsed', () => { + it('should return TZ-COMMAND-OK SETSENDODOMETER data parsed', () => { const raw = new Buffer('Receive:\'151\'OK\r\n*000000,151,0,100#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETSENDODOMETER'); expect(data.enable).to.be.false; expect(data.range).to.eql(100); }); - it('should return TZ-COMMAND SETIMEI data parsed', () => { + it('should return TZ-COMMAND-OK SETIMEI data parsed', () => { const raw = new Buffer('Receive:\'155\'OK\r\n*000000,155,0,000000000000000#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETIMEI'); expect(data.enable).to.be.false; expect(data.newImei).to.eql('000000000000000'); }); - it('should return TZ-COMMAND SETIDLE data parsed', () => { + it('should return TZ-COMMAND-OK SETIDLE data parsed', () => { const raw = new Buffer('Receive:\'404\'OK\r\n*000000,404,0,30#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETIDLE'); expect(data.enable).to.be.false; expect(data.interval).to.eql(30); }); - it('should return TZ-COMMAND SETINTERVALGPRSSTANDBY data parsed', () => { + it('should return TZ-COMMAND-OK SETINTERVALGPRSSTANDBY data parsed', () => { const raw = new Buffer('Receive:\'023\'OK\r\n*000000,023,0,30#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETINTERVALGPRSSTANDBY'); expect(data.enable).to.be.false; expect(data.interval).to.eql(30); }); - it('should return TZ-COMMAND SETIOPICTURE data parsed', () => { + it('should return TZ-COMMAND-OK SETIOPICTURE data parsed', () => { const raw = new Buffer('Receive:\'201\'OK\r\n*000000,201,3,3,5#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETIOPICTURE'); expect(data.enable).to.be.true; expect(data.port).to.eql(2); @@ -628,11 +628,11 @@ describe('tz-parzer', () => { expect(data.times).to.eql(5); }); - it('should return TZ-COMMAND SETPICTUREPACKET data parsed', () => { + it('should return TZ-COMMAND-OK SETPICTUREPACKET data parsed', () => { const raw = new Buffer('Receive:\'202\'OK\r\n*000000,202,6#'); const data = tz.parse(raw); expect(data.password).to.eql('000000'); - expect(data.device).to.eql('TZ-COMMAND'); + expect(data.device).to.eql('TZ-COMMAND-OK'); expect(data.command).to.eql('SETPICTUREPACKET'); expect(data.number).to.eql(6); });