NFCPY:安全地退出beam.py示例

时间:2014-05-12 12:15:36

标签: 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

1 个答案:

答案 0 :(得分:1)

NFC P2P链路终止的最自然方式是链路中断导致的一些错误。只要两个设备都在附近,通信就会继续交换对称分组。这样,任何一个设备都可以按照自己的意愿开始其他对话--SNEP(或波束)不仅仅是唯一的事情。

特别是对于nfcpy的波束示例,之前终止的方法是按Ctrl-C。或者修改示例以在任务完成时终止。