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 CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.31
4
+ fix: handleFotaSuccess, make it public
5
+
3
6
  ## 1.0.30
4
7
  fix: tests, recover "settings" parsing, deal with new call addMqttMsgLog
5
8
  doc: update Release
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mqtt-devices-parser",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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();