mqtt-devices-parser 1.0.30 → 1.0.31
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.
- package/Changelog.md +3 -0
- package/package.json +1 -1
- package/src/device/device.js +20 -21
package/Changelog.md
CHANGED
package/package.json
CHANGED
package/src/device/device.js
CHANGED
|
@@ -370,6 +370,24 @@ var self = module.exports = {
|
|
|
370
370
|
}
|
|
371
371
|
},
|
|
372
372
|
|
|
373
|
+
handleFotaSuccess: async (deviceId)=>{
|
|
374
|
+
let object = {
|
|
375
|
+
"nAttempts" : 0,
|
|
376
|
+
"fUpdate" : 0,
|
|
377
|
+
}
|
|
378
|
+
$.db_fota.update(deviceId,object);
|
|
379
|
+
object = {
|
|
380
|
+
success : 1,
|
|
381
|
+
}
|
|
382
|
+
$.db_fota.updateLog(deviceId,object);
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
handleFotaError: async (deviceId, error)=>{
|
|
386
|
+
let object = {
|
|
387
|
+
error : error,
|
|
388
|
+
}
|
|
389
|
+
$.db_fota.updateLog(deviceId,object);
|
|
390
|
+
}
|
|
373
391
|
}
|
|
374
392
|
|
|
375
393
|
async function parseLwm2mMessage(client, project_name, device, topic, payload, action){
|
|
@@ -480,14 +498,14 @@ async function parseMqttMessage(client, project_name, device, topic, payload, re
|
|
|
480
498
|
if (payload != null && payload != device?.version) {
|
|
481
499
|
$.db_device.addLog(device.id,"version",payload);
|
|
482
500
|
$.db_device.update(device.id, "version", payload);
|
|
483
|
-
handleFotaSuccess(device.id);
|
|
501
|
+
self.handleFotaSuccess(device.id);
|
|
484
502
|
}
|
|
485
503
|
break;
|
|
486
504
|
case "app_version":
|
|
487
505
|
if (payload != null && payload != device?.app_version) {
|
|
488
506
|
$.db_device.addLog(device.id,"app_version",payload);
|
|
489
507
|
$.db_device.update(device.id, "app_version", payload);
|
|
490
|
-
handleFotaSuccess(device.id);
|
|
508
|
+
self.handleFotaSuccess(device.id);
|
|
491
509
|
}
|
|
492
510
|
break;
|
|
493
511
|
case "fw":
|
|
@@ -706,25 +724,6 @@ async function synchSettings(device,key){
|
|
|
706
724
|
*/
|
|
707
725
|
}
|
|
708
726
|
|
|
709
|
-
function handleFotaSuccess (deviceId){
|
|
710
|
-
let object = {
|
|
711
|
-
"nAttempts" : 0,
|
|
712
|
-
"fUpdate" : 0,
|
|
713
|
-
}
|
|
714
|
-
$.db_fota.update(deviceId,object);
|
|
715
|
-
object = {
|
|
716
|
-
success : 1,
|
|
717
|
-
}
|
|
718
|
-
$.db_fota.updateLog(deviceId,object);
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
function handleFotaError (deviceId, error){
|
|
722
|
-
let object = {
|
|
723
|
-
error : error,
|
|
724
|
-
}
|
|
725
|
-
$.db_fota.updateLog(deviceId,object);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
727
|
function cleanAndParse(payload) {
|
|
729
728
|
if (typeof payload === 'string') {
|
|
730
729
|
let cleaned = payload.trim();
|