android - NFCPY : Safely exiting beam. py 示例

标签 android python nfc

我已经下载了 nfcpy 并成功运行了 beam 示例。 我使用 beam.py 将数据从带有 PN532 NFC 芯片的 RPi 发送到 Nexus Android 手机,数据发送正确但是只要我将手机放在阅读器旁边,RPi python 脚本就不存在。 该问题适用于从 nfcpy 发送和接收。 我需要做什么才能使 beam.py 存在 安全吗?

示例:

发送:

./beam.py --device tty:AMA0:pn53x send ndef start.ndef
[nfc.clf] searching for reader with path 'tty:AMA0:pn53x'
[nfc.clf] using NXP PN532 at /dev/ttyAMA0
[nfc.snep.server] snep server bound to port 4 (MIU=1984, RW=15), will accept up to 1048576 byte NDEF messages
[nfc.dev.pn53x] activated as target in 424 kbps active mode
[nfc.dev.pn53x] [Errno 110] Connection timed out
[nfc.dev.pn53x] activated a p2p target in 424 kbps active mode
[nfc.llcp.llc] LLCP Link established as NFC-DEP Initiator
Local LLCP Settings
  LLCP Version: 1.1
  Link Timeout: 500 ms
  Max Inf Unit: 2175 octet
  Service List: 0000000000010011
Remote LLCP Settings
  LLCP Version: 1.1
  Link Timeout: 1500 ms
  Max Inf Unit: 128 octet
  Service List: 0000000000010011
[nfc.dev.pn53x] [PN53x Error 0x13] Format error during RF communication

接收:

./beam.py --device tty:AMA0:pn53x recv print
[nfc.clf] searching for reader with path 'tty:AMA0:pn53x'
[nfc.clf] using NXP PN532 at /dev/ttyAMA0
[nfc.snep.server] snep server bound to port 4 (MIU=1984, RW=15), will accept up to 1048576 byte NDEF messages
[nfc.dev.pn53x] activated as target in 424 kbps active mode
[nfc.dev.pn53x] [Errno 110] Connection timed out
[nfc.dev.pn53x] activated a p2p target in 424 kbps active mode
[nfc.llcp.llc] LLCP Link established as NFC-DEP Initiator
Local LLCP Settings
  LLCP Version: 1.1
  Link Timeout: 500 ms
  Max Inf Unit: 2175 octet
  Service List: 0000000000010011
Remote LLCP Settings
  LLCP Version: 1.1
  Link Timeout: 1500 ms
  Max Inf Unit: 128 octet
  Service List: 0000000000010011
[nfc.llcp.tco] accepting CONNECT from SAP 32
[nfc.snep.server] serving snep client on remote sap 32
[main] default snep server got put request
[main] print ndef message 'application/com.example.android.beam'
record 1
  type   = 'application/com.example.android.beam'
  name   = ''
  data   = 'Beam me up!\n\nBeam Time: 15:11:22\n'
record 2
  type   = 'urn:nfc:ext:android.com:pkg'
  name   = ''
  data   = 'com.example.android.beam'
[nfc.dev.pn53x] [PN53x Error 0x13] Format error during RF communication

最佳答案

NFC P2P 链接最自然的终止方式是链接中断导致的一些错误。只要两个设备都在附近,通信就会继续交换对称数据包。这样,任一设备都可以根据需要开始其他对话 - SNEP(或波束)不仅仅是唯一的东西。

特别是nfcpy的beam例子,提前终止的方式是Ctrl-C。或者修改示例以在任务完成时终止。

关于android - NFCPY : Safely exiting beam. py 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23608787/

相关文章:

java - Android以编程方式更改抽屉导航面板的宽度

arduino - RFID RC522 是否能够读取 NFC 标签?

android - 如何永久锁定 MIFARE Ultralight C 标签中的特定数据页?

android - 谷歌播放 : REQUEST_INSTALL_PACKAGES: Permission use is not directly related to your app's core purpose

android - 为什么Android Studio需要下载Gradle?

android - App gradle 和 xml 文件在打开时缺少内容

python - 将随机森林模型保存到文件?

python - 包含第一个元素的反向数组切片

python - numba中的随机样本

android - 在 Android manifest 中,如何要求两个硬件中的至少一个?