【问题标题】:Android NFC: How to setup password and auth on NFC TAG?Android NFC:如何在 NFC TAG 上设置密码和身份验证?
【发布时间】:2020-05-27 18:20:44
【问题描述】:

我有 ntag213,使用 react-native-nfc-manager 并将其与 andriod 一起使用,在我的标签 https://www.nxp.com/docs/en/data-sheet/NTAG213_215_216.pdf 的文档中我首先了解我需要先使用命令 0x1B 到 0x2B 和我的密码进行身份验证:0xFF1FFFFF

let cmd = Platform.OS === 'ios' ? NfcManager.sendMifareCommandIOS : NfcManager.transceive; resp = await cmd(0x1B,0x2B,0xFF1FFFFF);

但我的屏幕上出现错误,并且不了解身份验证后的后续步骤。请解释它是如何工作的

【问题讨论】:

    标签: react-native react-native-android nfc core-nfc


    【解决方案1】:

    我认为您尝试发送的命令存在 2 个问题。

    1) 收发器只需要一个字节数组,0xFF1FFFFF 不是一个字节数组,而是一个需要双精度来存储的大数字。

    因此,您尝试发送 (byte,byte,double) 并且错误消息无法将 double 类型转换为数组。

    2)pwd_auth 命令只需要一个 5 字节的字节数组,1 字节命令 + 4 字节密码,所以不知道为什么你有0x2B

    所以试试

    let cmd = Platform.OS === 'ios' ? NfcManager.sendMifareCommandIOS : NfcManager.transceive; resp = await cmd([0x1B,0xFF,0x1F,0xFF,0xFF]);

    然后检查您的 PACK 是否正确,并且您没有收到 NACK

    我没有在我的应用程序中使用密码,但我相信你会通过身份验证发送正常命令,直到你关闭连接或卡超出范围。

    【讨论】:

    • 我试过并得到了这个错误。 Java.lang.double cannot be caset to com.faceboook.react.bridge.ReadableNativeArray 所以 0xFF,0x1F,0xFF,0xFF 表示密码的每个字节?
    • 抱歉忘了用括号把它变成一个数组,现在修复
    • 我也忘记了我的主题,但不幸的是我得到了新的错误:Possible Unhandled Promise Rejection (id: 0): "transceive fail"也许你可以建议我一些论坛的信息?因为我在 google 中没有找到任何信息
    • 你在 try catch 块中执行此操作?
    • 是的,testAuth = async()=>{ try{ let tech = Platform.OS === 'ios' ? NfcTech.MifareIOS : NfcTech.NfcA; let resp = await NfcManager.requestTechnology(tech, { alertMessage: 'Ready to do some custom Mifare cmd!' }); let cmd = Platform.OS === 'ios' ? NfcManager.sendMifareCommandIOS : NfcManager.transceive; resp = await cmd([0x1B,0xFF]); console.warn(resp); }catch(err){ if(err) throw err; } }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多