Android NFC:SNEP协议和P2P响应
我正在尝试实现两部Android手机之间的P2P通信(其中一部最终将被独立设备取代)。我已经看到Android 4支持SNEP,该SNEP由NFC论坛发布,并且应该可以在非Android设备上使用。
我遵循了 NFC P2P 的 Google 教程(http://developer.android.com/guide/topics/nfc/nfc.html#p2p),我可以将一些信息从一部手机发送到另一部手机,但我有一些问题:
- Android Beam 只是 NFC 的名称,还是通过 SNEP/NPP 运行的 Android 协议?如果是协议,如何在没有Beam的情况下进行NFC P2P?
- 如何设置SNEP的使用?
- 连接初始化时(收到第一条消息)如何向其他设备发送响应?
感谢您的帮助 !!!
I am trying to implement a P2P communication between two Android phones (one of them will be replaced by an independent device in the end). I have seen that Android 4 supports SNEP which is published by the NFC forum and should be available on non-android devices.
I have following the Google tutorial for NFC P2P (http://developer.android.com/guide/topics/nfc/nfc.html#p2p) and I can send some information from one phone to the other, but I have a few questions:
- Android Beam is just a name for NFC or it is an Android protocol working over SNEP/NPP ? If it's a protocol, how to do NFC P2P without Beam ?
- How to set the use of SNEP ?
- How to send a response to the other device when the connection is initialized (first message received) ?
Thank you for your help !!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Android Beam 只是一个名称,没错。设备默认使用 SNEP,如果失败,则会尝试 NPP。您无法真正从接收设备向发送者发送响应。您只能使用回调来通知推送成功:
http:// /developer.android.com/reference/android/nfc/NfcAdapter.OnNdefPushCompleteCallback.html
Android Beam is just a name, correct. Devices use SNEP by default, if that fails, it tries NPP. You can't send a response really from the receiving device to the sender. You can only use a callback to be notified of a successful push:
http://developer.android.com/reference/android/nfc/NfcAdapter.OnNdefPushCompleteCallback.html
ismb-snep-java 的 Google 代码页介绍了如何使用 SNEP 协议进行通信和数据传输我已经测试过它并且有效。在从 ACR 和 Android 搜索完 PDF 后,我相信您只需要花费一些时间即可使其按照您想要的方式工作。
ismb-snep-java's Google Code page explains communication and data transfer using SNEP protocol and I have tested it and it works. After searching through the PDF's from both ACR and Android, I believe you would just have to make some tweeks to make it work the way you desire.
给出更清晰的解释:
Android Beam 只是 NFC 的名称,还是通过 SNEP/NPP 工作的 Android 协议?如果是协议,如何在没有 Beam 的情况下进行 NFC P2P?
Android Beam 是 Android 操作系统的一项功能。它是 SNEP/NPP 之上的高级 NDEF 消息交换机制。
目前,点对点模式(Android 上)只能通过 Android Beam 访问,不能用于双向通信。
如何设置 SNEP 的使用?
如果您想在 Android 上使用 SNEP,(我认为)唯一的方法是在 ISO-DEP 协议之上编写您自己的 SNEP 实现。
由于 SNEP 位于 LLCP 之上,因此您还需要创建自己的 LLCP 实现。这并不容易。
在连接初始化时(收到第一条消息)如何向其他设备发送响应
使用 SNEP,您做不到。正如 @robertly 所说,只能创建回调消息。
如果您想要真正的双向通信,请使用读/写器和卡模拟操作模式。
To give a more clear explanation:
Android Beam is just a name for NFC or it is an Android protocol working over SNEP/NPP ? If it's a protocol, how to do NFC P2P without Beam ?
Android beam is a feature of the Android OS. It's a high level NDEF message exchange mechanism on top of SNEP/NPP.
For now, peer-to-peer mode (on Android) is only accessible through Android Beam, which can't be used for bi-directional communication.
How to set the use of SNEP ?
If you want to use SNEP on Android, (i think) the only way is to program your own SNEP implementation on top of the ISO-DEP protocol.
Because SNEP is on top of LLCP you also need to create your own LLCP implementation. That's not easy..
How to send a response to the other device when the connection is initialized (first message received)
With SNEP, you can't. As @robertly said it's only possible to create a callback message.
If you want true bi-directional communication, use the reader/writer and card-emulation operation modes.