Search code examples
tagsformaturinfcndef

TT3 Attribute Block for sending an email using NFC


I want to send NDEF data through RC-S801 dynamic NFC tag with an Arduino which prompts the user to send an e-mail to a specified person with some subject and body. Can somebody tell which TT3 attribute block to use? For URL I am sending

100101000300000000000000001b0030d102165370d1011255017374757474676172742e736f6e792e64650000000000

for "http://www.stuttgart.sony.de" which works fine but I am unable to construct TT3 attribute block for sending e-mail.


Solution

  • The RC-S801, when used an NFC tag, operates according to the NFC Forum's Type 3 Tag Operation Specification. So I strongly suggest that you start by reading that specification (you can get it for free from the NFC Forum's website).

    A type 3 tag's data area is divided in blocks of 16 bytes. The first block is the Attribute Information Block (i.e. the header of the data area). In your case that's

    100101000300000000000000001b0030
    

    The remaining blocks contain the NDEF data. In your case, that's

    d102165370d101125501737475747467
    6172742e736f6e792e64650000000000
    

    Attribute Information Block (AIB)

    • Byte 0 (10): Version information (1.0)
    • Byte 1 (01): Number of blocks that can be read using one CHECK command. Note that if you want to support Android 4.1.1 devices, you should change this to at least 2 (see AOSP issue #36016).
    • Byte 2 (01): Number of blocks that can be written using one UPDATE command.
    • Bytes 3-4 (0003): Maximum available NDEF blocks (3 blocks).
    • Bytes 5-8 (00000000): Must be set to zero.
    • Byte 9 (00): Write flag, non-zero indicates an ongoing write.
    • Byte 10 (00): Read/write flag, 00 indicates that the tag is read-only, 01 indicates that read/write is allowed.
    • Bytes 11-13 (00001b): The actual size of the NDEF message in bytes (27 bytes). You need to adapt this to the size of whatever NDEF message you want to have on your tag.
    • Bytes 14-15 (0030): Checksum over the AIB. You need to adapt this if you change any value in the AIB. The checksum is calculated as the sum of bytes 0 to 13 of the AIB. (The bytes are treated as unsigned integers.)

    NDEF Message

    Check the NFC Forum's NFC Data Exchange Format (NDEF) specification and the various record type definitions (RTDs) to learn how to format an NDEF message. In your case, the tag contains the following NDEF message:

    +------------------------------------+
    | SmartPoster Record                 |
    +------------------------------------+
    |                                    |
    |  +------------------------------+  |
    |  | URI Record                   |  |
    |  +------------------------------+  |
    |  | http://www.stuttgart.sony.de |  |
    |  +------------------------------|  |
    |                                    |
    +------------------------------------+
    

    If you want an e-mail link instead, you could use something like this:

    D1 01 xx  55  06 <your e-mail address in UTF-8 encoding>
    

    With xx being the length of <your e-mail address in UTF-8 encoding> plus 1. This will produce a link of the form mailto:[email protected].


    Example

    10 02 01 00 04 00 00 00 00 00 00 00 00 39 00 50
    D1 01 35 55 06 79 6F 75 72 40 65 6D 61 69 6C 2E
    61 64 64 72 65 73 73 3F 73 75 62 6A 65 63 74 3D
    54 65 73 74 26 62 6F 64 79 3D 54 68 69 73 20 69
    73 20 61 20 74 65 73 74 2E 00 00 00 00 00 00 00
    

    This example contains a URI to send a predefined e-mail message with subject "Test" and body "This is a test." to the e-mail address [email protected]. The NDEF message consists of one URI NDEF record:

    +-------------------------------------------------------------+
    | URI Record                                                  |
    +-------------------------------------------------------------+
    | mailto:[email protected]?subject=Test&body=This is a test. |
    +-------------------------------------------------------------+
    

    NDEF record:

    • Payload length of the NDEF record: 35 = length(06 79 6F ... 73 74 2E)
    • Type length of NDEF record: 01 = length(55)

    AIB:

    • Maximum number of available NDEF blocks: 0004 = length(D1 01 34 ... 74 2E 00 00 00 00 00 00 00) / 16
    • Size of NDEF message in bytes: 000039 = length(D1 01 34 ... 73 74 2E)
    • Checksum: 0050 = 10 + 02 + 01 + 00 + 04 + 00 + 00 + 00 + 00 + 00 + 00 + 00 + 00 + 39