mm_os 2.4.3 → 2.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -275,11 +275,16 @@ Drive.prototype.pushSync = function(clientid, msg, func, longtime = 0) {
275
275
  if (!longtime) {
276
276
  longtime = this.config.longtime || 60000;
277
277
  }
278
- var timer = setTimeout(() => {
278
+ setTimeout(async () => {
279
279
  // 如果时间到了,回调函数还在队列中,则视为无回复
280
280
  if (this.drives[clientid][key]) {
281
+ try {
282
+ await this.drives[clientid][key].func(null);
283
+ } catch (error) {
284
+ $.log.error("MQTT回调错误", key, error);
285
+ //TODO handle the exception
286
+ }
281
287
  this.del_msg(clientid, key);
282
- func(null);
283
288
  }
284
289
  }, longtime);
285
290
  }
@@ -340,7 +345,7 @@ Drive.prototype.push = function(method, clientid, params, longtime = 0) {
340
345
  msg[cg.msgid] = this.get_msgid(method);
341
346
  msg[cg.method] = method;
342
347
  msg[cg.params] = params;
343
- return this.pushS(clientid, msg);
348
+ return this.pushS(clientid, msg, longtime);
344
349
  }
345
350
 
346
351
  /**
@@ -58,6 +58,9 @@ exports.unlock = async function(clientid, uuid = '0', pass = false, tip = '没
58
58
  // 0不开门,1开门
59
59
  "ctrl_type": pass ? "on" : "off"
60
60
  });
61
+ if (!res) {
62
+ return "请求超时!"
63
+ }
61
64
  if (res.message !== "ACK") {
62
65
  return res.code;
63
66
  }
@@ -75,6 +78,9 @@ exports.delete_member = async function(clientid, uuid) {
75
78
  "per_id": uuid,
76
79
  "type": 0
77
80
  });
81
+ if (!res) {
82
+ return "请求超时!"
83
+ }
78
84
  if (res.message !== "ACK") {
79
85
  return res.code;
80
86
  }
@@ -151,6 +157,9 @@ exports.delete_member_batch = async function(clientid, arr, longtime) {
151
157
  */
152
158
  exports.reboot_device = async function(clientid) {
153
159
  var res = await this.push("reboot_cam", clientid, {});
160
+ if (!res) {
161
+ return "请求超时!"
162
+ }
154
163
  if (res.message !== "ACK") {
155
164
  return res.code;
156
165
  }
@@ -168,6 +177,9 @@ exports.set_device_time = async function(clientid, datetime) {
168
177
  }
169
178
  });
170
179
 
180
+ if (!res) {
181
+ return "请求超时!"
182
+ }
171
183
  if (res.message !== "ACK") {
172
184
  return res.code;
173
185
  }
@@ -180,15 +192,15 @@ exports.set_device_time = async function(clientid, datetime) {
180
192
  * @param {Boolean} member 是否恢复成员,true为恢复
181
193
  * @param {Boolean} log 是否恢复请求日志,true为恢复
182
194
  */
183
- exports.reset_device = function(clientid, record = true, member = false, log = true) {
195
+ exports.reset_device = async function(clientid, record = true, member = false, log = true) {
184
196
  if (record) {
185
197
  // 清空记录
186
- this.push("delete_record", clientid, {});
198
+ await this.push("delete_record", clientid, {});
187
199
  }
188
200
 
189
201
  if (member) {
190
202
  // 删除所有成员
191
- this.push("delete_face", clientid, {
203
+ await this.push("delete_face", clientid, {
192
204
  type: 4
193
205
  });
194
206
  }
@@ -339,6 +351,9 @@ exports.member_model_out = function(m) {
339
351
  exports.update_member = async function(clientid, user) {
340
352
  var member = this.member_model_out(user);
341
353
  var res = await this.push("update_face_ex", clientid, member);
354
+ if (!res) {
355
+ return "请求超时!"
356
+ }
342
357
  if (res.message !== "ACK") {
343
358
  return res.code;
344
359
  }
@@ -434,6 +449,9 @@ exports.play_audio = async function(clientid, type = 3) {
434
449
  body
435
450
  });
436
451
 
452
+ if (!res) {
453
+ return "请求超时!"
454
+ }
437
455
  if (res.message !== "ACK") {
438
456
  return res.code;
439
457
  }
@@ -452,6 +470,10 @@ exports.set_qrcode_mode = async function(clientid, mode = 1) {
452
470
  mode
453
471
  }
454
472
  });
473
+
474
+ if (!res) {
475
+ return "请求超时!"
476
+ }
455
477
  if (res.message !== "ACK") {
456
478
  return res.code;
457
479
  }
@@ -469,6 +491,10 @@ exports.send_led = async function(clientid, color = 1) {
469
491
  color
470
492
  }
471
493
  });
494
+
495
+ if (!res) {
496
+ return "请求超时!"
497
+ }
472
498
  if (res.message !== "ACK") {
473
499
  return res.code;
474
500
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "2.4.3",
3
+ "version": "2.4.4",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {