Files
gps-backend/test_device.js
2025-05-29 08:59:40 +00:00

121 lines
4.3 KiB
JavaScript
Executable File

const LibDevice = require('./library/LibDevice');
// gt06: login data
(async () => {
console.log('LOGIN DATA');
const ori_hex_str = '78780d010865784051404195000b565b0d0a';
const me = LibDevice.identifyProtocolFromBuffer(ori_hex_str, {
skip_buffer: true,
});
console.log('ME: ', me);
const act = LibDevice.gt06Action(me, null);
console.log('ACT: ', act);
}); //();
// gt06: location data
(async () => {
console.log('LOCATION DATA');
const ori_hex_str = '78781f1216020410152bc600af54f00b76b39000501101fe0a05df000ea900071ae70d0a';
const me = LibDevice.identifyProtocolFromBuffer(ori_hex_str, {
skip_buffer: true,
});
console.log('ME: ', me);
const act = LibDevice.gt06Action(me, '0865784051404195');
console.log('ACT: ', act);
}); //();
// gt06: heartbeat data
(async () => {
console.log('HEARTBEAT DATA');
const ori_hex_str = '7878251616021115071fc40220585810bc5780004d3f0901fe0a00ad0050370806040302000f5f0d0d0a';
const me = LibDevice.identifyProtocolFromBuffer(ori_hex_str, {
skip_buffer: true,
});
console.log('ME: ', me);
const act = LibDevice.gt06Action(me, '0865784051445891');
console.log('ACT: ', act);
}); //();
// gt06: alarm data
(async () => {
console.log('ALARM DATA');
const ori_hex_str = '7878251600020e142710cb00a83c4b0b7852e00040a70901fe0a00870071070800040302001306a40d0a';
const me = LibDevice.identifyProtocolFromBuffer(ori_hex_str, {
skip_buffer: true,
});
console.log('ME: ', me);
const act = LibDevice.gt06Action(me, '0865784051404195');
console.log('ACT: ', act);
}); //();
// gt06: other data
(async () => {
console.log('OTHER DATA');
const ori_hex_str = '78781f1216030f0f273bcf00abebc80b7ab25014d14501fe0a00c0000b08028a3eb90d0a';
const me = LibDevice.identifyProtocolFromBuffer(ori_hex_str, {
skip_buffer: true,
});
console.log('ME: ', me);
const act = LibDevice.gt06Action(me, 'gatau');
console.log('ACT: ', act);
}); //();
// eelinkCustomAction: uknown flag
(async () => {
const ori_hex_str = '0003541880470205290510101217203406c8090825fff697f200a2714000de00d60329403219ac00050006005e';
const me = LibDevice.identifyProtocolFromBuffer(ori_hex_str, {
skip_buffer: true,
isEelinkCustom: 1,
});
console.log('ME: ', me);
const act = LibDevice.eelinkCustomAction(me, null);
console.log('ACT: ', act);
})();
// testing apa buffer & conversion
// (async () => {
// console.log('');
// const ori_hex_str = '$$'; // equal to 2424
// const ori_hex_str = '##'; // equal to 2323
// const ori_hex_str = ','; // equal to 2c
// const ori_hex_str = '{'; // equal to 7b
// const ori_hex_str = '('; // equal to 28
// const ori_hex_str = ')'; // equal to 29
// const ori_hex_str = '"'; // equal to 22
// const ori_hex_str = '\''; // equal to 27
// const ori_hex_str = '\\'; // equal to 5c
// const ori_hex_str = '*'; // equal to 2a
// const ori_hex_str = '~'; // equal to 7e
// const ori_hex_str = '['; // equal to 5b
// const ori_hex_str = '-'; // equal to 2d
// const ori_hex_str = '<'; // equal to 3c
// const ori_hex_str = '+'; // equal to 2b
// const ori_hex_str = '.'; // equal to 2e
// const ori_hex_str = 'UPC'; // 55 40 43
// const ori_hex_str = 'M2M'; // 4d 32 4d
// const ori_hex_str = 'G2'; // 47 32
// const ori_hex_str = 'GSM'; // 47 53 4d
// const ori_hex_str = 'RPC'; // 52 50 43
// const ori_hex_str = 'ARP'; // 41 52 50
// const ori_hex_str = 'AT'; // 41 54
// const ori_hex_str = 'MGV'; // 4d 47 56
// const ori_hex_str = 'STX'; // 53 54 58
// const ori_hex_str = 'LOG'; // 4C 4f 47
// const ori_hex_str = 'GPRMC'; // 47 50 52 4d 43
// const ori_hex_str = 'G2'; //
// const ori_hex_str = '0510101217203406';
// const ori_hex_str = '81910';
// const buffer = Buffer.from(ori_hex_str, 'hex');
// console.log('buffer from hex => ', buffer);
// console.log('buffer from ascii => ', Buffer.from(ori_hex_str, 'ascii'));
// console.log('buffer from utf8 => ', Buffer.from(ori_hex_str, 'utf8'));
// console.log('buffer from utf-8 => ', Buffer.from(ori_hex_str, 'utf-8'));
// console.log('buffer from binary => ', Buffer.from(ori_hex_str, 'binary'));
// console.log('buffer to ascii => ', buffer.toString('ascii'));
// console.log('buffer to utf8 => ', buffer.toString('utf8'));
// console.log('buffer to utf-8 => ', buffer.toString('utf-8'));
// console.log('buffer to binary => ', buffer.toString('binary'));
// })();