Skip to content

Commit ed1a78d

Browse files
committed
Add getRebootCommand
1 parent 7c8ece2 commit ed1a78d

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,20 @@ const parseCommand = (data) => {
8989
return command;
9090
};
9191

92+
const getRebootCommand = (data) => {
93+
let command = null;
94+
if (/TZ-AVL(05|08|201)/.test(data.device)) {
95+
command = tz.getRebootCommand(data.password || '000000');
96+
} else if (/MVT380/.test(data.device)) {
97+
command = meitrack.getRebootCommand(data.imei);
98+
}
99+
return command;
100+
};
101+
92102
module.exports = {
93103
getImei: getImei,
94104
setCache: setCache,
95105
parse: parse,
96-
parseCommand: parseCommand
106+
parseCommand: parseCommand,
107+
getRebootCommand: getRebootCommand
97108
};

test/test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,22 @@ describe('tracking-parser', () => {
131131
const raw = tracking.parseCommand(data);
132132
expect(raw).to.match(/^@@([\x41-\x7A])(\d{1,3}),353358017784062,C01,0,10000\*([0-9A-F]{2})\r\n$/);
133133
});
134+
135+
it('should return TZ raw command reboot', () => {
136+
const data = {
137+
password: 897463,
138+
device: 'TZ-AVL05'
139+
};
140+
const raw = tracking.getRebootCommand(data);
141+
expect(raw).to.eql('*897463,991#');
142+
});
143+
144+
it('should return Meitrack raw command reboot', () => {
145+
const data = {
146+
imei: 353358017784062,
147+
device: 'MVT380'
148+
};
149+
const raw = tracking.getRebootCommand(data);
150+
expect(raw).to.match(/^@@([\x41-\x7A])(\d{1,3}),353358017784062,F02\*([0-9A-F]{2})\r\n$/);
151+
});
134152
});

0 commit comments

Comments
 (0)