-1

How can I send ndef message to nfc-explorer? I try to use source code from nfc explorer but all the time get empty ndef message.

user3302358
  • 76
  • 2
  • 10
  • According to https://www.nxp.com/docs/en/application-note/AN11480.pdf, the basic example (section 5.1) should work for peer-to-peer mode with SNEP. Hence that example should work with Android Beam. – Michael Roland Jan 24 '19 at 10:16

1 Answers1

0

You have a full demo implementation here, and read the official documentation.

To answer your question, to send a message:

public NdefMessage CreateNdefMessage (NfcEvent evt)
{
    DateTime time = DateTime.Now;
    var text = ("Beam me up!\n\n" + "Beam Time: " +
        time.ToString ("HH:mm:ss"));
    NdefMessage msg = new NdefMessage (
        new NdefRecord[]{ CreateMimeRecord (
            "application/com.example.android.beam",
            Encoding.UTF8.GetBytes (text)) });
        } };
    return msg;
}

public NdefRecord CreateMimeRecord (String mimeType, byte [] payload)
{
    byte [] mimeBytes = Encoding.UTF8.GetBytes (mimeType);
    NdefRecord mimeRecord = new NdefRecord (
        NdefRecord.TnfMimeMedia, mimeBytes, new byte [0], payload);
    return mimeRecord;
}
Bruno Caceiro
  • 7,035
  • 1
  • 26
  • 45