Sfoglia il codice sorgente

fix:nb透传模块调试完成

tangfudong 1 anno fa
parent
commit
e3e4596f13

+ 13 - 8
data/converters/50b0fdd0-9bc8-448d-a7cf-d3b1b4df944c/converter.js

@@ -11,10 +11,9 @@ function getMid() {
 this.decode = function (msg) {
     var content = msg.content;
     var topic = content.topic;
-    var bytes = CRC.strToByte(content.payload);
-
+    var bytes = arrayGroup(content.payload.params,2);
+    var byteData=content.payload.params;
     if (topic.endsWith("/thing/model/up_raw")) {
-        var byteData = ab2hex(bytes)
         var data = arrayGroup(byteData, 2);
         var params = {};
         var uint8Array = new Uint8Array(bytes.length);
@@ -170,7 +169,12 @@ this.encode = function (service, device) {
     var method = "thing.service.";
     var topic = "/sys/" + service.productKey + "/" + service.deviceName + "/thing/model/down_raw";
     var params = {};
-
+    var payloadArray = [];
+    var deviceArray = [];;
+    var totalArray =[];
+    var totalItemArray = [];
+    var itemArray = [];
+    var outFFIndex = ''
     var type = service.type;
     var identifier = service.identifier;
     if (type == "property" && identifier == "get") {
@@ -195,6 +199,7 @@ this.encode = function (service, device) {
         for (var p in service.params) {
             params[p] = service.params[p];
         }
+        var paramsArr = Object.keys(params)
         //站地址
         if (paramsArr.includes('query')) {
             let queryHexData = arrayGroup(params['query'],2)
@@ -465,14 +470,14 @@ CRC.ToModbusCRC16 = function (str) {
 };
 
 CRC.strToByte = function (str) {
-    var tmp = str.split(''),
+    var tmp = str.split(""),
         arr = [];
     for (var i = 0, c = tmp.length; i < c; i++) {
         var j = encodeURI(tmp[i]);
         if (j.length == 1) {
             arr.push(j.charCodeAt());
         } else {
-            var b = j.split('%');
+            var b = j.split("%");
             for (var m = 1; m < b.length; m++) {
                 arr.push(parseInt('0x' + b[m]));
             }
@@ -482,7 +487,7 @@ CRC.strToByte = function (str) {
 };
 
 CRC.convertChinese = function (str) {
-    var tmp = str.split(''),
+    var tmp = str.split(""),
         arr = [];
     for (var i = 0, c = tmp.length; i < c; i++) {
         var s = tmp[i].charCodeAt();
@@ -496,7 +501,7 @@ CRC.convertChinese = function (str) {
 };
 
 CRC.filterChinese = function (str) {
-    var tmp = str.split(''),
+    var tmp = str.split(""),
         arr = [];
     for (var i = 0, c = tmp.length; i < c; i++) {
         var s = tmp[i].charCodeAt();

+ 4 - 2
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java

@@ -17,11 +17,13 @@ import cc.iotkit.common.utils.JsonUtils;
 import cc.iotkit.common.utils.UniqueIdUtil;
 import cc.iotkit.comp.model.DeviceState;
 import cc.iotkit.comp.model.RegisterInfo;
-import cc.iotkit.data.manager.*;
+import cc.iotkit.data.manager.IDeviceInfoData;
+import cc.iotkit.data.manager.IDeviceOtaDetailData;
+import cc.iotkit.data.manager.IProductData;
+import cc.iotkit.data.manager.IProductModelData;
 import cc.iotkit.model.device.DeviceInfo;
 import cc.iotkit.model.device.message.ThingModelMessage;
 import cc.iotkit.model.ota.DeviceOtaDetail;
-import cc.iotkit.model.ota.DeviceOtaInfo;
 import cc.iotkit.model.product.Product;
 import cc.iotkit.model.product.ProductModel;
 import cc.iotkit.mq.MqProducer;

+ 1 - 1
iot-components/iot-nb-component/src/main/resources/component.js

@@ -127,7 +127,7 @@ function register(payload) {
     var pwd = md5(product.getProductSecret() + auth.clientid);
 
     if (pwd.toLocaleLowerCase() != auth.password.toLocaleLowerCase()) {
-        throw new Error("incorrect password" + "pwd->" + pwd + " productSecret->" + product.productSecret);
+        throw new Error("incorrect password" + "pwd->" + pwd + " productSecret->" + product.getProductSecret());
     }
     return {
         type: "register",

+ 13 - 8
iot-components/iot-nb-component/src/main/resources/convert.js

@@ -11,10 +11,9 @@ function getMid() {
 this.decode = function (msg) {
     var content = msg.content;
     var topic = content.topic;
-    var bytes = CRC.strToByte(content.payload);
-
+    var bytes = arrayGroup(content.payload.params,2);
+    var byteData=content.payload.params;
     if (topic.endsWith("/thing/model/up_raw")) {
-        var byteData = ab2hex(bytes)
         var data = arrayGroup(byteData, 2);
         var params = {};
         var uint8Array = new Uint8Array(bytes.length);
@@ -170,7 +169,12 @@ this.encode = function (service, device) {
     var method = "thing.service.";
     var topic = "/sys/" + service.productKey + "/" + service.deviceName + "/thing/model/down_raw";
     var params = {};
-
+    var payloadArray = [];
+    var deviceArray = [];;
+    var totalArray =[];
+    var totalItemArray = [];
+    var itemArray = [];
+    var outFFIndex = ''
     var type = service.type;
     var identifier = service.identifier;
     if (type == "property" && identifier == "get") {
@@ -195,6 +199,7 @@ this.encode = function (service, device) {
         for (var p in service.params) {
             params[p] = service.params[p];
         }
+        var paramsArr = Object.keys(params)
         //站地址
         if (paramsArr.includes('query')) {
             let queryHexData = arrayGroup(params['query'],2)
@@ -465,14 +470,14 @@ CRC.ToModbusCRC16 = function (str) {
 };
 
 CRC.strToByte = function (str) {
-    var tmp = str.split(''),
+    var tmp = str.split(""),
         arr = [];
     for (var i = 0, c = tmp.length; i < c; i++) {
         var j = encodeURI(tmp[i]);
         if (j.length == 1) {
             arr.push(j.charCodeAt());
         } else {
-            var b = j.split('%');
+            var b = j.split("%");
             for (var m = 1; m < b.length; m++) {
                 arr.push(parseInt('0x' + b[m]));
             }
@@ -482,7 +487,7 @@ CRC.strToByte = function (str) {
 };
 
 CRC.convertChinese = function (str) {
-    var tmp = str.split(''),
+    var tmp = str.split(""),
         arr = [];
     for (var i = 0, c = tmp.length; i < c; i++) {
         var s = tmp[i].charCodeAt();
@@ -496,7 +501,7 @@ CRC.convertChinese = function (str) {
 };
 
 CRC.filterChinese = function (str) {
-    var tmp = str.split(''),
+    var tmp = str.split(""),
         arr = [];
     for (var i = 0, c = tmp.length; i < c; i++) {
         var s = tmp[i].charCodeAt();