Retrieving simple text payload

Asked by on 2017-01-03

Hello Stephen, I am struggling with what is a straight forward four text record message on a Felica card. see dump of contents below:

[nfc.tag.tt3] got 118 byte ndef data 9901120c545374616666204d656d62657249616e205768697465204a6f686e73...
NDEF Capabilities:
  readable = yes
  writeable = yes
  capacity = 208 byte
  message = 118 byte
NDEF Message:
record 1
  type = 'urn:nfc:wkt:T'
  name = 'Staff Member'
  data = 'Ian White Johnston'
record 2
  type = 'urn:nfc:wkt:T'
  name = 'Phone Number'
  data = '85291561946'
record 3
  type = 'urn:nfc:wkt:T'
  name = 'Access Status'
  data = 'OUT'
record 4
  type = 'urn:nfc:wkt:T'
  name = 'Time Stamp'
  data = '2016-12-31 16:23:36'
pi@raspberrypi:~/nfcpy/trunk/examples $

What I am trying to do is to is retrieve and break out the each record's base payload. The intent is to write back to the tag with record1 and record2 unchanged, but with record3 and record4 holding new payload data. I have trouble with the iterations of the read tag value as per code snippit below. I get errors due to my lack of understanding of the "nfs.ndef.Message" object and the 'nfs.ndef.Record" object. Can you advise the best way to iterate over the message (tag) so that I can replace the text payloads of record3 and record4? Many thanks and have a great 2017.

Code Snippet:

ndef.Messaelif choice==5:
        print 'Now in Attendance Mode'
        with nfc.ContactlessFrontend('usb:054c:06c3') as clf:
            def connected(tag): return False
            tag = clf.connect(rdwr={'on-connect':connected})

            record1 = nfc.ndef.Message

            name =

            tagstatus = 'XXX'
            record3 = nfc.ndef.Record("urn:nfc:wkt:T", "Access Status", tagstatus)
            tagtime = str(
            tagtime1 = (tagtime[0:19])
            record4 = nfc.ndef.Record("urn:nfc:wkt:T", "Time Stamp", tagtime1)

            #with nfc.ContactlessFrontend('usb:054c:06c3') as clf:
             # def connected(tag): return False
            tag = clf.connect(rdwr={'on-connect':connected})
            tag.ndef.message =, record2, record3, record4)

Question information

English Edit question
nfcpy Edit question
No assignee Edit question
Solved by:
Last query:
Last reply: (ian-5) said : #1


Pls scratch this question. I have finally figured out the syntax to recover payload data "nfs.ndef.message"