简体   繁体   中英

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. I've created an Android Beam app that sends a simple text "Hello!" when the intent filters for a NDEF_DISCOVERED tag. When using the TgGetData (0x86) command I seem to get:

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:

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?

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. After this first stream of bytes, just send a CC APDU or a CONNECTION COMPLETE. For those who need help, the APDUs should be :

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. Good luck!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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