Raspberry Pi NFC Tag Emulation

3k views Asked by At

I'm trying to use a NFC shield with a PN532 NFC chip attached to my Raspberry Pi to have the same effect as a NFC tag. Thus, when it is read by a phone, it will display plain text, URL, etc.

I have installed LibNFC successfully and can poll the device, and also get what I want from the example NFC-Emulate-Forum-Tag2. How do I cahnge the data that is sent to the phone?

1

There are 1 answers

0
Michael Roland On

The tag memory is emulated inside the NFC-Emulate-Forum-Tag2 example program that you use. The array __nfcforum_tag2_memory_area contains the tag memory contents:

static uint8_t __nfcforum_tag2_memory_area[] = {
  0x00, 0x00, 0x00, 0x00,  // Block 0
  0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xFF, 0xFF,  // Block 2 (Static lock bytes: CC area and data area are read-only locked)
  0xE1, 0x10, 0x06, 0x0F,  // Block 3 (CC - NFC-Forum Tag Type 2 version 1.0, Data area (from block 4 to the end) is 48 bytes, Read-only mode)

  0x03, 33,   0xd1, 0x02,  // Block 4 (NDEF)
  0x1c, 0x53, 0x70, 0x91,
  0x01, 0x09, 0x54, 0x02,
  0x65, 0x6e, 0x4c, 0x69,

  0x62, 0x6e, 0x66, 0x63,
  0x51, 0x01, 0x0b, 0x55,
  0x03, 0x6c, 0x69, 0x62,
  0x6e, 0x66, 0x63, 0x2e,

  0x6f, 0x72, 0x67, 0x00,
  0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00,
};

See the Type 2 Tag Operation Specification and the NFC Data Exchange Format (NDEF) specification on how to encode the data inside the emulated tag memory area.