MifareClassic.transceive读数据返回data为什么为空?
发布于 6 年前 作者 juanyao 4928 次浏览 来自 问答
//和卡建立连接
          mc.connect({
            successfunction(res{
              console.log("连接卡成功: " + JSON.stringify(res))

              //验证密码A指令
              var keyaBs = [0x600x040xAE0x380x400x39,  0xFF0xFF0xFF0xFF0xFF0xFF];
              //把字节数组转成ArrayBuffer
              var keyaArray = new Uint8Array(keyaBs.map(function (bs{
                return bs;
              }));
              var keyaBuffer = keyaArray.buffer;
              //验证密码A
              mc.transceive({
                data:keyaBuffer,
                success:function(res){
                  console.error("验证密码A" + "成功" + res.errMsg);

                  var arr = [0x301]
                  var arrayBuffer = new Int8Array(arr).buffer
                  var u8 = new Uint8Array(arrayBuffer)
                  for(var i = 0; i < u8.length; i ++) {
                    console.log(u8[i])
                  }
                  //发送指令
                  mc.transceive({
                    data: arrayBuffer,
                    successfunction(res{
                      console.log("transceive返回: " + JSON.stringify(res))
                    },
                    failfunction(e{
                      console.log("transceive异常: " + JSON.stringify(e))
                    }
                  });

                },
                fail:function(res){
                  console.error("验证密码A" + "失败" + res.errMsg);
                },
                complete:function(res){
                  console.error("验证密码A" + "状态" + res.errMsg);
                }
              });

            },
            failfunction(e{
              console.log("和卡连接异常: " + JSON.stringify(e))
            }
          })

结果:transceive返回: {“errMsg”:“transceive:ok”,“data”:{}}

回到顶部