Skip to content

Commit 07d2711

Browse files
committed
Add parseCommand
1 parent 22ee78b commit 07d2711

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,17 @@ const parse = (raw, options = {}) => {
8989
});
9090
};
9191

92+
const parseCommand = (data) => {
93+
let command = null;
94+
if (data.device === 'tz') {
95+
command = tz.parseCommand(data);
96+
}
97+
return command;
98+
};
99+
92100
module.exports = {
93101
getImei: getImei,
94102
setCache: setCache,
95-
parse: parse
103+
parse: parse,
104+
parseCommand: parseCommand
96105
};

test/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,14 @@ describe('tracking-parzer', () => {
115115
done(err);
116116
});
117117
});
118+
119+
it('should return TZ raw command', () => {
120+
const data = {
121+
instruction: 'reboot',
122+
password: 897463,
123+
device: 'tz'
124+
};
125+
const raw = tracking.parseCommand(data);
126+
expect(raw).to.eql('*897463,991#');
127+
});
118128
});

0 commit comments

Comments
 (0)