-
Notifications
You must be signed in to change notification settings - Fork 8
/
commands.js
191 lines (166 loc) · 4.71 KB
/
commands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
var meiligao = require('../index.js');
// Set up server
var server = new meiligao.Server().listen(20180, function(error) {
if (error) {
throw error;
}
console.log('gps server is listening');
});
// All commands will be executed one by one
// Uncomment commands to enable
server.on('connect', function(tracker) {
tracker.on('login', function() {
console.log('tracker logged in!');
});
// Handle errors
tracker.on('error', function(error, buffer) {
console.log('error happened', error);
});
// Commands
tracker.requestReport(function(err, data) {
if (err) {
console.log('REQUEST REPORT ERROR: ', err);
} else {
console.log('REQUEST REPORT: ', data);
}
});
tracker.getSnImei(function(err, data) {
if (err) {
console.log('GET SN IMEI ERROR: ', err);
} else {
console.log('GET SN IMEI: ', data);
}
});
tracker.resetConfiguration(function(err, result) {
if (err) {
console.log('RESET CONFIGURATION ERROR: ', err);
} else {
console.log('RESET CONFIGURATION: ', result);
}
});
tracker.rebootGps(function(err, result) {
if (err) {
console.log('REBOOT GPS ERROR: ', err);
} else {
console.log('REBOOT GPS: ', result);
}
});
tracker.setExtendedSettings({
smsReplyOnCall : true,
useGPRMSFormat : false, // works for sms only
hangUpAfter5Rings : false,
enableCallBuzzer : false,
enableLedLights : true,
alarmPowerOn : true,
alarmPowerCut : false,
alarmGpsBlindArea : false,
}, function(err, result) {
if (err) {
console.log('SET EXTENDED SETTINGS ERROR: ', err);
} else {
console.log('SET EXTENDED SETTINGS: ', result);
}
});
tracker.setHeartbeatInterval(1, function(err, result) {
if (err) {
console.log('SET HEARTBEAT INTERVAL ERROR: ', err);
} else {
console.log('SET HEARTBEAT INTERVAL: ', result);
}
});
tracker.clearMileage(function(err, result) {
if (err) {
console.log('CLEAR MILEAGE ERROR: ', err);
} else {
console.log('CLEAR MILEAGE: ', result);
}
});
tracker.setPowerDownTimeout(15, function(err, result) {
if (err) {
console.log('SET POWER DOWN TIMEOUT ERROR: ', err);
} else {
console.log('SET POWER DOWN TIMEOUT: ', result);
}
});
tracker.getMemoryReports(function(err, reports) {
if (err) {
console.log('GET MEMORY REPORTS ERROR: ', err);
} else {
console.log('GET MEMORY REPORTS: ', reports);
}
});
tracker.setMemoryReportInterval(1, function(err, result) {
if (err) {
console.log('SET MEMORY REPORT INTERVAL ERROR: ', err);
} else {
console.log('SET MEMORY REPORT INTERVAL: ', result);
}
});
tracker.clearMemoryReports(function(err, result) {
if (err) {
console.log('CLEAR MEMORY REPORTS ERROR: ', err);
} else {
console.log('CLEAR MEMORY REPORTS: ', result);
}
});
tracker.setAuthorizedPhones(79991234567, 79991234567, function(err, result) {
if (err) {
console.log('SET AUTHORIZED PHONE ERROR: ', err);
} else {
console.log('SET AUTHORIZED PHONE: ', result);
}
});
tracker.getAuthorizedPhones(function(err, phones) {
if (err) {
console.log('GET AUTHORIZED PHONES ERROR: ', err);
} else {
console.log('GET AUTHORIZED PHONES: ', phones);
}
});
tracker.setReportTimeInterval(2, function(err, result) {
if (err) {
console.log('SET REPORT TIME INTERVAL ERROR: ', err);
} else {
console.log('SET REPORT TIME INTERVAL: ', result);
}
});
tracker.getReportTimeInterval(function(err, interval) {
if (err) {
console.log('GET REPORT TIME INTERVAL ERROR: ', err);
} else {
console.log('GET REPORT TIME INTERVAL: ', interval);
}
});
tracker.setReportDistanceInterval(300, function(err, result) {
if (err) {
console.log('SET REPORT DISTANCE INTERVAL ERROR: ', err);
} else {
console.log('SET REPORT DISTANCE INTERVAL: ', result);
}
});
tracker.setAlarmSpeeding(15, function(err, result) {
if (err) {
console.log('SET ALARM SPEEDING ERROR: ', err);
} else {
console.log('SET ALARM SPEEDING: ', result);
}
});
tracker.setAlarmMovement(0x03, function(err, result) {
if (err) {
console.log('SET ALARM MOVEMENT ERROR: ', err);
} else {
console.log('SET ALARM MOVEMENT: ', result);
}
});
tracker.setAlarmGeofence(55.753905, 37.620872, 200, function(err, result) {
if (err) {
console.log('SET ALARM GEOFENCE ERROR: ', err);
} else {
console.log('SET ALARM GEOFENCE: ', result);
}
});
});
// Handle disconnects
server.on('disconnect', function(tracker) {
console.log('tracker disconnected');
});