收藏
回答

NFC通信 如何验证扇区密码?

 getNFCStatus() {
        var that = this;
        const nfc = wx.getNFCAdapter();
        this.nfc = nfc;
        function discoverHandler(res{
            if (res.techs.includes(that.nfc.tech.mifareClassic)) {
                //获取NFCA实例
                const nfcM1 = that.nfc.getMifareClassic()
                that.nfcM1 = nfcM1
            }
            that.nfcM1.connect({
                success(res) {
                        var array = new Uint8Array([0X30,0X00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF])
                        that.nfcM1.transceive({
                            data: array.buffer,
                            success(res) => {
                                console.log("NFC数据写入成功");
                            },
                            fail(res) => {
                                console.log("NFC数据写入失败");console.log(res)
                            },
                            complete(res) {
                                console.log('res:', res)
                            }
                        })
                },
                fail(err) {
                    console.log("err" + err)
                }
            })
            that.nfcM1.isConnected({
                success:(res)=>{
                    var array = new Uint8Array([0X30,0X00])                    
                                        that.nfcM1.transceive({
                        data: array.buffer,
                        // data:sendData,
                        success(res) => {
                            console.log("NFC数据写入成功");
                            console.log(res.data)
                            var result = that.ab2hex(res.data);
                            console.log(result)
                        },
                        fail(res) => {
                            console.log("NFC数据写入失败");
                            console.log(res)
                        },
                        complete(res) {
                            console.log('res:', res)
                        }
                    })
                }
            })
            return
        }
        nfc.onDiscovered(discoverHandler)
        nfc.startDiscovery({
            fail(err) {
                console.log('failed to discover:', err)
            },
            success(res) {
                console.log("sucess to discover:", res)
            }
        })
    },


我的扇区密码是[0XFF,0XFF,0XFF,0XFF,0XFF,0XFF] 但我验证完成后,返回回来的扇区数据不对,不知道应该如何去验证这个扇区密码?

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

1 个回答

登录 后发表内容