android - 无法通过 LLCP 向 Galaxy Nexus 发送数据或从 Galaxy Nexus 发送数据

标签 android nfc nfc-p2p

我有一部搭载 Android 4.0.2 和 NXP 演示板 PN532-C106 的 Galaxy Nexus 手机。

我正在尝试连接它们以使用 LLCP 协议(protocol)发送数据,我正在使用 libnfc-llcp 中的“npp-server”和“llcp-test-server”来执行此操作。但我只能让他们启动连接,然后关闭它。我无法发送任何数据和 logcat 接缝表明连接设置有问题,请参阅帖子末尾。

我试图找到任何用于发送数据的示例代码,并且我试图使用 nfcpy(用于 nfc 通信的 python 库),但它拒绝找到我的演示板。 “npp-server”示例需要一个文件才能运行,而我使用的是一个空文件,因为我不知道要在其中放入什么。

我不知道是我的设置有问题还是遗漏了什么。有没有人知道为什么我的连接死得这么快,或者有一个我可以效仿的工作示例?

这是 logcat 的输出
来自 npp-server 的测试

03-09 14:22:28.035: D/dalvikvm(196): GC_EXPLICIT freed 134K, 10% free 24179K/26759K, paused 6ms+5ms
03-09 14:22:58.723: W/NFC-LLC(429): bad LLC length byte 90
03-09 14:22:58.723: W/NFC-LLC(429): bad LLC length byte ec
03-09 14:22:58.723: W/NFC-LLC(429): bad LLC length byte 50
03-09 14:22:58.723: W/NFC-LLC(429): bad LLC length byte 0
03-09 14:22:58.723: W/NFC-LLC(429): bad LLC length byte 31
03-09 14:22:58.723: W/NFC-LLC(429): bad LLC length byte 56
03-09 14:22:59.129: D/NFC JNI(429): Discovered P2P Target
03-09 14:22:59.137: D/NfcService(429): LLCP Activation message
03-09 14:22:59.137: D/NfcService(429): NativeP2pDevice.MODE_P2P_TARGET
03-09 14:22:59.168: D/NfcService(429): Cannot connect remote Target. Polling loop restarted.
03-09 14:22:59.785: W/ThrottleService(196): unable to find stats for iface rmnet0
03-09 14:23:04.481: D/dalvikvm(7375): GC_CONCURRENT freed 151K, 2% free 14308K/14535K, paused 7ms+3ms
03-09 14:23:08.535: D/NfcService(429): Set Foreground Dispatch
03-09 14:23:08.543: D/NfcService(429): Set Foreground Dispatch
03-09 14:23:08.598: V/PhoneStatusBar(271): setLightsOn(true)
03-09 14:23:08.598: I/WindowManager(196): createSurface Window{41c2a718 android.stickynotes/android.stickynotes.StickyNotesActivity paused=false}: DRAW NOW PENDING
03-09 14:23:20.238: W/NFC-LLC(429): bad LLC length byte d0
03-09 14:23:20.238: W/NFC-LLC(429): bad LLC length byte db
03-09 14:23:20.238: W/NFC-LLC(429): bad LLC length byte 52
03-09 14:23:20.238: W/NFC-LLC(429): bad LLC length byte 1
03-09 14:23:20.340: W/NFC_uart(429): timeout!
03-09 14:23:20.340: W/NFC-LLC(429): LLC length mis-match
03-09 14:23:20.637: D/NfcService(429): SE FIELD ACTIVATED
03-09 14:23:20.637: D/NfcService(429): SE FIELD DEACTIVATED

这部分来自于 llcp-test-server 的测试

enter code here

03-09 14:23:20.653: D/NFC JNI(429): Discovered P2P Target
03-09 14:23:20.653: D/NfcService(429): LLCP Activation message
03-09 14:23:20.653: D/NfcService(429): NativeP2pDevice.MODE_P2P_TARGET
03-09 14:23:20.684: D/NfcService(429): Cannot connect remote Target. Polling loop restarted.
03-09 14:23:53.957: D/NfcService(429): Set Foreground Dispatch
03-09 14:23:53.965: D/NfcService(429): Set Foreground Dispatch
03-09 14:23:53.973: V/PhoneStatusBar(271): setLightsOn(true)
03-09 14:23:53.988: W/InputManagerService(196): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@41a3b620
03-09 14:24:03.082: W/NFC_uart(429): timeout!
03-09 14:24:03.082: W/NFC-LLC(429): LLC length mis-match
03-09 14:24:03.387: D/NfcService(429): SE FIELD ACTIVATED
03-09 14:24:03.387: D/NfcService(429): SE FIELD DEACTIVATED
03-09 14:24:03.387: D/NfcService(429): SE FIELD ACTIVATED
03-09 14:24:03.387: D/NfcService(429): SE FIELD DEACTIVATED
03-09 14:24:03.418: D/NFC JNI(429): Discovered P2P Initiator
03-09 14:24:03.418: D/NFC JNI(429): 46 
03-09 14:24:03.418: D/NFC JNI(429): 66 
03-09 14:24:03.418: D/NFC JNI(429): 6d 
03-09 14:24:03.418: D/NfcService(429): LLCP Activation message
03-09 14:24:03.418: D/NfcService(429): NativeP2pDevice.MODE_P2P_INITIATOR
03-09 14:24:03.418: I/NFC JNI(429): LLCP Link deactivated
03-09 14:24:03.418: D/NfcService(429): Target Activate LLCP OK
03-09 14:24:03.418: I/NfcP2pLinkManager(429): LLCP activated
03-09 14:24:03.418: D/NfcP2pLinkManager(429): onP2pInRange()
03-09 14:24:03.426: D/PermissionCache(116): checking android.permission.READ_FRAME_BUFFER for uid=1025 => granted (457 us)
03-09 14:24:03.567: D/dalvikvm(429): GC_FOR_ALLOC freed 174K, 5% free 14576K/15303K, paused 15ms
03-09 14:24:03.574: I/dalvikvm-heap(429): Grow heap (frag case) to 17.416MB for 3265936-byte allocation
03-09 14:24:03.621: D/dalvikvm(429): GC_CONCURRENT freed 4K, 5% free 17761K/18503K, paused 4ms+5ms
03-09 14:24:03.660: D/NfcP2pLinkManager(429): onP2pSendConfirmationRequested()
03-09 14:24:03.668: D/NfcService(429): LLCP Link Deactivated message. Restart polling loop.
03-09 14:24:03.668: D/NfcService(429): not disconnecting from initiator
03-09 14:24:03.668: I/NfcP2pLinkManager(429): LLCP deactivated.
03-09 14:24:03.668: D/PhoneStatusBar(271): disable: < EXPAND* icons alerts ticker system_info back home recent clock >
03-09 14:24:03.676: I/WindowManager(196): createSurface Window{41bde010  paused=false}: DRAW NOW PENDING
03-09 14:24:03.684: D/libEGL(429): loaded /system/lib/egl/libGLES_android.so
03-09 14:24:03.699: D/libEGL(429): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
03-09 14:24:03.707: D/libEGL(429): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
03-09 14:24:03.715: D/libEGL(429): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
03-09 14:24:03.817: D/OpenGLRenderer(429): Enabling debug mode 0
03-09 14:24:03.824: W/IInputConnectionWrapper(7375): showStatusIcon on inactive InputConnection
03-09 14:24:03.824: W/InputManagerService(196): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@41b90588 (uid=10090 pid=7375)
03-09 14:24:04.426: D/NfcP2pLinkManager(429): Debounce timeout
03-09 14:24:04.426: D/NfcP2pLinkManager(429): onP2pOutOfRange()
03-09 14:24:04.754: D/PhoneStatusBar(271): disable: < expand* icons alerts ticker system_info back home recent clock >
03-09 14:24:04.801: W/SurfaceTexture(429): freeAllBuffersExceptCurrentLocked called but mQueue is not empty
03-09 14:24:07.676: D/NfcService(429): SE FIELD ACTIVATED
03-09 14:24:07.699: D/NfcService(429): SE FIELD DEACTIVATED`

最佳答案

我已经通过 Arduino + PM532 使用了这个项目。我使用了 GitHub 上的 PN532 库。使用它,我可以将文本和图像从 PM532 发送到 Android 手机。您可以使用此库 ( https://github.com/don/NDEF )。

关于android - 无法通过 LLCP 向 Galaxy Nexus 发送数据或从 Galaxy Nexus 发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9636200/

相关文章:

android - NFC 读卡器 ACR 122 与 Android 4.1 Jelly Beans 不兼容?

android - 切换到 'Main'协程并将其挂起以将结果发送回 'IO'协程

android - 找不到 ID 为 'android' 的插件 (Android Studio)

windows-phone-8 - 无法打开此消息

安卓光束 : share a in-app link with fallback to web version

java - NFC 安卓光束

android - Google Play 游戏服务注销回调

android - 如何下载使用 WordPress 下载监控插件重定向的真实文件?

安卓 NFC : How to route APDUs for one certain AID to secure element UICC (Off-Host-Routing)

java - 如何在 Java 中加快 PC/SC 读卡器上的卡缺失检测?