NFC Tag Type 2 - Providing data as RAW bytes

Hello, 

I need to implement bidirectional read/write communication over NFC interface, in order to provide an interface for exchanging two RAW byte arrays with a size of 900bytes.

As a first step, I'm trying to configure the content of the message to be in RAW format, by adjusting the existing demo from the SDK which uses a "Text" as the record type (part of the code listed below).

// ...

NFC_NDEF_TEXT_RECORD_DESC_DEF(nfc_en_text_rec, 0, en_code, sizeof(en_code), en_payload, strlen(en_payload));

NFC_NDEF_MSG_DEF(nfc_text_msg, 1);

nfc_ndef_msg_record_add(&NFC_NDEF_MSG(nfc_text_msg), &NFC_NDEF_TEXT_RECORD_DESC(nfc_en_text_rec));

nfc_ndef_msg_encode(&NFC_NDEF_MSG(nfc_text_msg), m_ndef_msg_buf, &len);

err_code = nfc_t2t_payload_set(m_ndef_msg_buf, len);

// ...

I'm guessing that, instead of calling NFC_NDEF_TEXT_RECORD_DESC_DEF, it should be called NFC_NDEF_GENERIC_RECORD_DESC_DEF with a TNF argument 'U' (referring to the unknown or RAW type), and without language code arguments, but so far I haven't done the configuration successfully.

Is there some existing example describing how to configure the message of NFC T2T as a RAW bytes array?

Thanks.

  • I tried to "manually" set the RAW content of the tag to [0x11, 0x22, 0x33, 0x44], just to test if I understand correctly format of NDF, with the following code:

    // ..
    
    // 0xC5 					-> MB = 1, ME = 1, TNF = 5 (Unknown)
    // 0x01 					-> Type Lenght = 1
    // 0x00, 0x00, 0x00, 0x04 	-> Payload size LSB = 4
    // 0x55 					-> Record Type = 'U'
    // 0x11 					-> Payload[0] 
    // 0x22 					-> Payload[1]
    // 0x33 					-> Payload[2]
    // 0x44 					-> Payload[3]
    static uint8_t m_ndef_msg_buf[11] = {0xC5, 0x01, 0x00, 0x00, 0x00, 0x04, 0x55, 0x11, 0x22, 0x33, 0x44};
    
    err_code = nfc_t2t_payload_set(m_ndef_msg_buf, 11);
    
    // ..

    But the Android application I used for the test still did not recognize the content.
    Is there some noticeable problem with such NDEF?

    Just considering, maybe it's actually a problem with applications that don't recognize this type of record.
    Although I have tried several Android NFC scan apps.

  • The problem was solved by removing the field "Record Type", and changing the field "Type Length" to 0.

Related