fix:nb透传模块调试完成

V0.5.x
tangfudong 2023-07-19 10:52:23 +08:00
parent 104c193951
commit e3e4596f13
4 changed files with 31 additions and 19 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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",

View File

@ -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();