ST意法半导体
直播中

建立建利12

8年用户 1317经验值
擅长:可编程逻辑 嵌入式技术
私信 关注
[问答]

使用ST25 android sdk向nfc芯片发送数据失败咋办?

我正在使用 ST25 android sdk。向NFC芯片发送数据时,有时会写入数据失败。
我可以发送 4 个字节的任何内容。
当发送 10 个字节时,它会根据数据失败并返回 TAG_NOT_IN_FIELD。
这个成功了:
  •                                     byte[] data = new byte[10];
  •                                     data[ 0 ] = 0;
  •                                     data[ 1 ] = 'A';
  •                                     mTag.writeMailboxMessage( 10, data );
  • 2021-01-31 13:03:39.123 32184-32259/eu.fufla.nfccomm D/Iso15693CustomCommand: ==> Send writeMsg command: 22 aa 02 85 66 df f3 00 24 02 e0 09 00 41 00 00 00 00 00 00 00 00
  • 2021-01-31 13:03:39.125 380-15695/? D/NfcHalCore: Tx 00 00 16 22 aa 02 85 66 df f3 00 24 02 e0 09 00 41 00 00 00 00 00 00 00 00
  • 2021-01-31 13:03:39.127 380-15696/? D/NfcHalCore: Rx 60 06 03 01 00 01
  • 2021-01-31 13:03:39.136 380-15696/? D/NfcHalCore: Rx 00 00 02 00 00
而这个失败了。区别只是价值
  •                                     byte[] data = new byte[10];
  •                                     data[ 0 ] = 0;
  •                                     data[ 1 ] = 'A';
  •                                     data[ 4 ] = 'B';
  •                                     mTag.writeMailboxMessage( 10, data );
  • 2021-01-31 13:02:47.114 31992-32070/eu.fufla.nfccomm D/Iso15693CustomCommand: ==> Send writeMsg command: 22 aa 02 85 66 df f3 00 24 02 e0 09 00 41 00 00 42 00 00 00 00 00
  • 2021-01-31 13:02:47.116 380-15695/? D/NfcHalCore: Tx 00 00 16 22 aa 02 85 66 df f3 00 24 02 e0 09 00 41 00 00 42 00 00 00 00 00
  • 2021-01-31 13:02:47.118 380-15696/? D/NfcHalCore: Rx 60 06 03 01 00 01
  • 2021-01-31 13:02:47.744 390-414/? I/BufferQueueProducer: [eu.fufla.nfccomm/eu.fufla.nfccomm.MainActivity#0](this:0x7bf1102800,id:6999,api:1,p:31992,c:390) queueBuffer: fps=55.46 dur=1009.68 max=34.73 min=13.88
  • 2021-01-31 13:02:47.855 31992-31997/eu.fufla.nfccomm I/zygote64: Compiler allocated 10MB to compile void android.view.ViewRootImpl.performTraversals()
  • 2021-01-31 13:02:48.116 1765-3957/? E/StNfcJni: nativeNfcTag_doTransceive: wait response timeout
  • 2021-01-31 13:02:48.124 31992-32070/eu.fufla.nfccomm W/System.err: com.st.st25sdk.STException: Error TAG_NOT_IN_THE_FIELD
  • 2021-01-31 13:02:48.125 31992-32070/eu.fufla.nfccomm W/System.err:     at com.st.st25android.AndroidType5ReaderInterface.transceive(AndroidType5ReaderInterface.java:132)
  • 2021-01-31 13:02:48.126 31992-32070/eu.fufla.nfccomm W/System.err:     at com.st.st25sdk.command.Iso15693Protocol.transceive(Iso15693Protocol.java:322)
  • 2021-01-31 13:02:48.127 31992-32070/eu.fufla.nfccomm W/System.err:     at com.st.st25sdk.command.Iso15693CustomCommand.writeMsg(Iso15693CustomCommand.java:1816)
  • 2021-01-31 13:02:48.127 31992-32070/eu.fufla.nfccomm W/System.err:     at com.st.st25sdk.command.FastTransferModeCommand.writeMailboxMessage(FastTransferModeCommand.java:90)
  • 2021-01-31 13:02:48.128 31992-32070/eu.fufla.nfccomm W/System.err:     at com.st.st25sdk.command.FastTransferModeCommand.writeMailboxMessage(FastTransferModeCommand.java:74)
  • 2021-01-31 13:02:48.129 31992-32070/eu.fufla.nfccomm W/System.err:     at com.st.st25sdk.type5.st25dv.ST25DVTag.writeMailboxMessage(ST25DVTag.java:1050)
  • 2021-01-31 13:02:48.129 31992-32070/eu.fufla.nfccomm W/System.err:     at eu.fufla.nfccomm.MainActivity$5.run(MainActivity.java:246)
  • 2021-01-31 13:02:48.130 31992-32070/eu.fufla.nfccomm W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
  • 2021-01-31 13:02:48.131 31992-32070/eu.fufla.nfccomm W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
  • 2021-01-31 13:02:48.131 31992-32070/eu.fufla.nfccomm W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
  • 2021-01-31 13:02:48.132 31992-32070/eu.fufla.nfccomm W/System.err:     at java.lang.Thread.run(Thread.java:764)


回帖(1)

康瑜玲

2023-1-6 14:22:17
看来这可能是特定的电话问题。相同的代码适用于不同制造商的手机。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分