PN7150 NDEF Tag Emulation receiving data written by Android phone

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PN7150 NDEF Tag Emulation receiving data written by Android phone

1,389 Views
joel_fergusson
Contributor I

I have a device that uses a PN7150 on a system running Linux to emulate an NDEF card. It needs to be written to and read from a custom Android app.

Using the SWA4325 with "CARDEMU_SUPPORT" defined, the device successfully sends an NDEF record to the phone. However, when the phone comes to write data back to the PN7150, Android raises an exception saying that the tag is not NDEF. See here for the exception:

java.io.IOException: Tag is not ndef
        at android.nfc.tech.Ndef.writeNdefMessage(Ndef.java:329)
        at uk.co.mitrefinch.dev.nfctest01.MainActivity.write(MainActivity.java:140)
        at uk.co.mitrefinch.dev.nfctest01.MainActivity.onNewIntent(MainActivity.java:81)
        at android.app.Activity.performNewIntent(Activity.java:7161)
        at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1388)
        at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1400)
        at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:3325)
        at android.app.ActivityThread.performNewIntents(ActivityThread.java:3341)
        at android.app.ActivityThread.handleNewIntent(ActivityThread.java:3358)
        at android.app.servertransaction.NewIntentItem.execute(NewIntentItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1977)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6923)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)

 

So it appears the NDEF emulation isn't working correctly, though Android recognises the tag as being "ndef.type4". I have attached my nfc_task.c and CMake files from the modified SWA4325 files. The snipped from the android app looks like this:

NdefRecord[] records = { NdefRecord.createTextRecord("en", text) };
NdefMessage message = new NdefMessage(records);

// Get an instance of Ndef for the tag.
Ndef ndef = Ndef.get(tag);

// Perform the write
ndef.connect();
ndef.writeNdefMessage(message);
ndef.close();

 

Tags (3)
0 Kudos
1 Reply

1,374 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi @joel_fergusson ,

 

The original demo doesn't support T4T card emulation in write mode, and you have to update the attached files for this kind of application.

 

The updated demo example works in such a way that, as before it exposes NDEF “Test” text message to a remote reader (NFC android phone for instance).

Then, when you write an NDEF message in it (limited to 256 bytes), until you reboot the board, this new NDEF message will be exposed in place of the original NDEF “Test” text message.

 

Hope that helps,

 

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos