//通知设备交互方式(是否加密) notifyDevice: function (deviceId, serviceId, characteristicId) { console.log(`notifyDevice is run cj_1`); var self = this; self.setProcess(35, constant.descSucList[3]); console.log(`notifyDevice is run cj_1_1`); var client = util.blueDH(constant.DH_P, constant.DH_G, crypto); console.log(`notifyDevice is run cj_1_1.1.1 : ${client}`); self.setData({ client: client }); console.log(`notifyDevice is run cj_1_2`); var kBytes = util.uint8ArrayToArray(client.getPublicKey()); var pBytes = util.hexByInt(constant.DH_P); var gBytes = util.hexByInt(constant.DH_G); var pgkLength = pBytes.length + gBytes.length + kBytes.length + 6; console.log(`notifyDevice is run cj_3`); console.log(pgkLength); var pgkLen1 = (pgkLength >> 8) & 0xff; var pgkLen2 = pgkLength & 0xff; var data = []; console.log(`notifyDevice is run cj_4`); data.push(constant.NEG_SET_SEC_TOTAL_LEN); console.log(`notifyDevice is run cj_5`); data.push(pgkLen1); console.log(`notifyDevice is run cj_6`); data.push(pgkLen2); console.log(`notifyDevice is run cj_7`); var frameControl = util.getFrameCTRLValue(false, false, constant.DIRECTION_OUTPUT, false, false); var value = util.writeData(constant.PACKAGE_VALUE, constant.SUBTYPE_NEG, frameControl, sequenceControl, data.length, data); var typedArray = new Uint8Array(value); console.log(`notifyDevice is run cj_8`); wx.writeBLECharacteristicValue({ deviceId: deviceId, serviceId: serviceId, characteristicId: characteristicId, value: typedArray.buffer, success: function (res) { console.log(`notifyDevice is run cj_9`); self.getSecret(deviceId, serviceId, characteristicId, client, kBytes, pBytes, gBytes, null); }, fail: function (res) { self.setFailProcess(true, constant.descFailList[3]); } }) },
notifyDevice is run cj_1_1.1.1 : [object Object]
VM33:1 thirdScriptError
Maximum call stack size exceeded;at api notifyBLECharacteristicValueChanged success callback function
RangeError: Maximum call stack size exceeded
at s (eval at n.call.document (http://127.0.0.1:57830/remote-debug/runtime.js?devtools_ignore=true:1:8753), <anonymous>:1:1313386)
at s (eval at n.call.document (http://127.0.0.1:57830/remote-debug/runtime.js?devtools_ignore=true:1:8753), <anonymous>:1:1313622)
at s (eval at n.call.document (http://127.0.0.1:57830/remote-debug/runtime.js?devtools_ignore=true:1:8753), <anonymous>:1:1313622)
at s (eval at n.call.document (http://127.0.0.1:57830/remote-debug/runtime.js?devtools_ignore=true:1:8753), <anonymous>:1:1313622)
at s (eval at n.call.document (http://127.0.0.1:57830/remote-debug/runtime.js?devtools_ignore=true:1:8753), <anonymous>:1:1313622)
at s (eval at n.call.document (http://127.0.0.1:57830/remote-debug/runtime.js?devtools_ignore=true:1:8753), <anonymous>:1:1313622)
at s (eval at n.call.document (http://127.0.0.1:57830/remote-debug/runtime.js?devtools_ignore=true:1:8753), <anonymous>:1:1313622)
at s (eval at n.call.document (http://127.0.0.1:57830/remote-debug/runtime.js?devtools_ignore=true:1:8753), <anonymous>:1:1313622)
at s (eval at n.call.document (http://127.0.0.1:57830/remote-debug/runtime.js?devtools_ignore=true:1:8753), <anonymous>:1:1313622)
at s (eval at n.call.document (http://127.0.0.1:57830/remote-debug/runtime.js?devtools_ignore=true:1:8753), <anonymous>:1:1313622)
data: {
blueConnectNum: 0,
wifiConnectNum: 0,
isClose: false,
failure: false,
value: 0,
desc: "Device connecting...",
frameControl: 0,
flagEnd: false,
defaultData: 1,
isEncrypt: true,
isChecksum: true,
ssidType: 1,
passwordType: 2,
bssidType: 3,
meshIdType: 4,
meshType: 6,
whiteListType: 64,
whiteListLen: 252,
macs: [],
deviceId: "",
ssid: "",
bssid: "",
uuid: "",
serviceId: "",
password: "",
meshId: "",
mesh: 0,
processList: [],
result: [],
client: '',
},
//通知设备交互方式(是否加密)
notifyDevice: function (deviceId, serviceId, characteristicId) {
console.log(`notifyDevice is run cj_1`);
var self = this;
self.setProcess(35, constant.descSucList[3]);
console.log(`notifyDevice is run cj_1_1`);
var client = util.blueDH(constant.DH_P, constant.DH_G, crypto);
console.log(`notifyDevice is run cj_1_1.1.1 : ${client}`);
self.setData({ client: client });
console.log(`notifyDevice is run cj_1_2`);
var kBytes = util.uint8ArrayToArray(client.getPublicKey());
var pBytes = util.hexByInt(constant.DH_P);
var gBytes = util.hexByInt(constant.DH_G);
var pgkLength = pBytes.length + gBytes.length + kBytes.length + 6;
console.log(`notifyDevice is run cj_3`);
console.log(pgkLength);
var pgkLen1 = (pgkLength >> 8) & 0xff;
var pgkLen2 = pgkLength & 0xff;
var data = [];
console.log(`notifyDevice is run cj_4`);
data.push(constant.NEG_SET_SEC_TOTAL_LEN);
console.log(`notifyDevice is run cj_5`);
data.push(pgkLen1);
console.log(`notifyDevice is run cj_6`);
data.push(pgkLen2);
console.log(`notifyDevice is run cj_7`);
var frameControl = util.getFrameCTRLValue(false, false, constant.DIRECTION_OUTPUT, false, false);
var value = util.writeData(constant.PACKAGE_VALUE, constant.SUBTYPE_NEG, frameControl, sequenceControl, data.length, data);
var typedArray = new Uint8Array(value);
console.log(`notifyDevice is run cj_8`);
wx.writeBLECharacteristicValue({
deviceId: deviceId,
serviceId: serviceId,
characteristicId: characteristicId,
value: typedArray.buffer,
success: function (res) {
console.log(`notifyDevice is run cj_9`);
self.getSecret(deviceId, serviceId, characteristicId, client, kBytes, pBytes, gBytes, null);
},
fail: function (res) {
self.setFailProcess(true, constant.descFailList[3]);
}
})
},
const blueDH = (p, g, crypto) => {
var client = crypto.createDiffieHellman(p, "hex", g, "hex");
var clientKey = client.generateKeys();
//var clientSecret = client.computeSecret(server.getPublicKey());
return client;
}