Question

I have downloaded nfcpy and successfully ran the beam examples. I use the beam.py to send data from a RPi with PN532 NFC chip to a Nexus Android phone, the data is sent correctly but on the RPi the python script does not exist as long as I keep the phone next to the reader. The question applies to sending and receiving from nfcpy. What do I have to do for the beam.py to exist safely ?

Example:

Sending:

./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

Receiving:

./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
Was it helpful?

Solution

The most natural way that an NFC P2P link terminates is with some error caused by link disruption. For as long as both devices are in proximity, the communication will just continue with exchange of symmetry packets. This way either device may start other conversations as it wishes - SNEP (or beam) is not just the only thing.

Specifically for nfcpy's beam example, the way to terminate earlier is by Ctrl-C. Or to modify the example to terminate when the task is done.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top