收藏
回答

page中的data赋值出错,怎么处理?

在Page中的data:{client:" ",},

然后在函数中使用var client = crypto.createDiffieHellman(p, "hex", g, "hex");

然后使用:

self.setData({ client: client });

老是出错?这个是什么原因?


回答关注问题邀请回答
收藏

1 个回答

  • cj
    cj
    2020-01-01

    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)

    2020-01-01
    有用
    回复 12
    • cj
      cj
      2020-01-01
      基本上到这里就不执行了。
      2020-01-01
      回复
    • Mr.Zhao
      Mr.Zhao
      2020-01-01回复cj
      写出死循环了
      2020-01-01
      回复
    • cj
      cj
      2020-01-01回复Mr.Zhao
      不是的,我看了,就是执行到self.setData({ client: client });,这里就不行了,查了一下var client返回的是个对象,但是data中的client h好像是变量,怎么设置对象?好像是这个原因。但是不知道怎么改
      2020-01-01
      回复
    • Mr.Zhao
      Mr.Zhao
      2020-01-01回复cj
      你写个示例代码片段吧,要不然不知道你怎么写的代码
      2020-01-01
      回复
    • cj
      cj
      2020-01-01回复Mr.Zhao
      Page({
        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;
      }
      2020-01-01
      回复
    查看更多(7)
登录 后发表内容
问题标签