简体   繁体   English

尝试使用ACR122连接到com.android.npp,但收到错误消息[NFCSTATUS_INVALID_STATE]

[英]Trying to connect to com.android.npp using ACR122 but get error saying [NFCSTATUS_INVALID_STATE]

I've been using the javax.cardio package to receive an NDEF message from my Nexus S through my ACR122U. 我一直在使用javax.cardio软件包通过ACR122U从Nexus S接收NDEF消息。 I've created an Android Beam app that sends a simple text "Hello!" 我创建了一个Android Beam应用,该应用发送一个简单的文本“ Hello!”。 when the intent filters for a NDEF_DISCOVERED tag. 当意图过滤NDEF_DISCOVERED标签时。 When using the TgGetData (0x86) command I seem to get: 使用TgGetData(0x86)命令时,我似乎得到了:

NfcP2pLinkManager(7588): Sending ndef via SNEP
NFC JNI(7588): Socket not connected
NFC JNI(7588): LLCP Link deactivated
NFC JNI(7588): LLCP Connect request failed
NfcService(7588): LLCP Link Deactivated message. Restart polling loop.
NFC JNI(7588): phLibNfc_Llcp_Close() returned 0x0001[NFCSTATUS_INVALID_PARAMETER]
NfcP2pLinkManager(7588): Failed to connect over SNEP, trying NPP
NdefPushClient(7588): about to create socket
NfcP2pLinkManager(7588): LLCP deactivated.
NdefPushClient(7588): about to connect to service com.android.npp
NFC JNI(7588): phLibNfc_Llcp_ConnectByUri() returned 0x0011[NFCSTATUS_INVALID_STATE]
NdefPushClient(7588): couldn't send tag
NdefPushClient(7588): exception:
NdefPushClient(7588): java.io.IOException
NdefPushClient(7588):   at 
com.android.nfc.nxp.NativeLlcpSocket.connectToService(NativeLlcpSocket.java:47)

The APDU workflow I'm following for the ACR122 is basically: 我遵循的ACR122的APDU工作流程基本上是:

1) TgInitAsTarget = 0xD4, 0x8c
2) TgGetData = 0xD4, 0x86
3) TgSetData = 0xD4, 0x85, 0x81
4) TgGetData = 0xD4, 0x86

Does anyone know why I cannot connect to the "com.android.npp" service on the Nexus S? 有谁知道为什么我无法连接Nexus S上的“ com.android.npp”服务?

I've found out why my issue was occurring. 我发现了为什么发生我的问题。 I don't need to send a CONNECT APDU once I recieve the first set of bytes from teh phone via TgGetData. 一旦通过TgGetData从电话接收到第一组字节,就不需要发送CONNECT APDU。 After this first stream of bytes, just send a CC APDU or a CONNECTION COMPLETE. 在第一个字节流之后,只需发送CC APDU或CONNECTION COMPLETE。 For those who need help, the APDUs should be : 对于需要帮助的人,APDU应为:

1) TgInitAsTarget 0xD4 0x8C
2) TgGetData 0xD4 0x86
3) TgSetData (CC) 0xD4 0x8E - no need to send the service name. Simple the DSAP-CC-SSAP bytes. That's it.
4) TgGetData 0xD4 0x86 - you should get your data in this byte stream.
5) TgRelease 0xD4 0x8E

REMEMBER: You must switch the DSAP and SSAP that you get from the phone around to use in your TgSetData. 记住:您必须切换从电话获得的DSAP和SSAP,以便在TgSetData中使用。 Good luck! 祝好运!

请参阅 NPP实施ACR122的操作方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM