UriRecord creation in NDEF message using python

33 Views Asked by At

I am trying to save a ndef record into a nfc card via arc122u reader.

from acr122u.src import nfc
import ndef.uri
import ndef.message
reader = nfc.Reader()

def write(r, position, number, data):
    dat = 0
    while number >= 4:
        write_4(r, position, 4, data[dat:dat + 4])
        dat += 4
        number -= 4
        position += 1

def write_4(r, position, number, data):
    r.update_binary_blocks(position, number, data)

record = ndef.uri.UriRecord('https://www.facebookc.com')
s = b''.join(ndef.message.message_encoder([record]))

Printed s value is b'\xd1\x01\x0eU\x02facebookc.com'. The problem is s message contains only part of the needed bytes for the NFC device to be able to read it. When I write same URL address via NFC Tools there are additional bytes before my message:

['0x1', '0x3', '0xa0', '0xc']
['0x34', '0x3', '0x12', '0xd1']
['0x1', '0xe', '0x55', '0x2']
['0x66', '0x61', '0x63', '0x65']
['0x62', '0x6f', '0x6f', '0x6b']
['0x63', '0x2e', '0x63', '0x6f']
['0x6d', '0xfe', '0x0', '0x0']

My question is what are the bytes after the message at the start ('0x1', '0x3', '0xa0', '0xc', '0x34', '0x3', '0x12') and the end of the message ('0xfe')? Is there way to generate them from a python script? Because without this bytes mobile phone does not detect saved site.

0

There are 0 best solutions below