PN7160 Reader plus Card Emulation

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

PN7160 Reader plus Card Emulation

3,508 Views
erkfry
Contributor I

Hi,

I am currently developing a NFC Solution that can interact with Desfire PICCs aswell as with Smartphones, but in case of the I-Phone the only way (I know of right now) is to emulate a card and let the I-phone read that.

The Problem is that the device should interact with a Desfire PICC aswell, therefore it has to be in Reader Mode aswell.

I checked out the given examples and ran the nfc_example_RWandCE which seems to look like it can do just that. But if I approach the reader with a smartphone, in this case a Google Pixel 3a with NFC activated. I am not able to read the PN7160 like a Tag, with for example NFC Tools. After checking the Serial Console, it gets obvious that it went into POLL_MODE and not LISTEN MODE. Probably because the reader saw the Smartphone as a passive tag.

POLL MODE: Remote T4T activated
SENS_RES = 0x04 0x00
NFCID = 08 77 f7 c3
SEL_RES = 0x20

Is there a way I can somehow prevent this from happening. Somthing like switching modes real fast or recognizing the smartphone and trying to do it in listen mode.

In the end I need something like a payment terminal, which can interact with passive tags aswell as with with active Tags (Smartphones).

By the way reading passive PICCs works flawlessly.

Greetings Erik

0 Kudos
Reply
7 Replies

3,447 Views
Tomas_Parizek
NXP Employee
NXP Employee

Hello Erik, 

Are you using our PN7160 dev. kit or do you have your own design? Normally, it should also work without the TagInfo app. You should see the NDEF message once you approach the phone to the antenna proximity. 

I am concerned about the "ff" you are receiving. Why you receiving that. 

 

BR

Tomas 

 

0 Kudos
Reply

3,429 Views
erkfry
Contributor I

Hello Tomas,

I added a log message to how much characters are being printed an it turned out that there were always 258 characters printed. The Issue was, that I am working with the NXP Pn7160 Devkit and an NRF52840 as a Microcontroller, therefore i had to write an adapter for the example. It is quite sketchy but the key point was that i didnt read the first 3 bytes first to determine the payload length. Instead I read 258 Bytes every time. I fixed that and now the listen Mode works just fine. In the sense that there are still some failed attempts, but after on average 2 tries the ndef can be read by the phone. This looks like the following:

WAITING FOR DEVICE DISCOVERY
NCI << 61 05 15 01 02 04 81 ff 01 01 00 81 00 00 09 08 e7 62 e9 2e 00 08 01 00
- LISTEN MODE: Activated from remote Reader
NCI << 61 06 02 01 01
RF Deactivate ntf
NCI >> 21 06 01 00
NCI << 61 06 02 03 02
NCI << 41 06 01 00
Wait for reception
NCI >> 21 03 0d 06 00 01 02 01 01 01 06 01 80 01 81 01
NCI << 41 03 01 00
READER DISCONNECTED

WAITING FOR DEVICE DISCOVERY
NCI << 61 05 0c 01 02 04 80 ff 01 00 80 00 00 01 80
- LISTEN MODE: Activated from remote Reader
NCI << 00 00 0d 00 a4 04 00 07 d2 76 00 00 85 01 01 00
recv dataNDEF APP SEL
NCI >> 00 00 02 90 00
NCI << 60 06 03 01 00 01
NCI << 00 00 07 00 a4 00 0c 02 e1 03
recv dataNDEF CC SEL
NCI >> 00 00 02 90 00
NCI << 60 06 03 01 00 01
NCI << 00 00 05 00 b0 00 00 0f
recv dataNDEF read
NCI >> 00 00 11 00 0f 20 00 ff 00 ff 04 06 e1 04 00 ff 00 00 90 00
NCI << 60 06 03 01 00 01
NCI << 00 00 07 00 a4 00 0c 02 e1 04
recv dataNDEF NDEF SEL
NCI >> 00 00 02 90 00
NCI << 60 06 03 01 00 01
NCI << 00 00 05 00 b0 00 00 02
recv dataNDEF read
NCI >> 00 00 04 00 2b 90 00
NCI << 60 06 03 01 00 01
NCI << 00 00 05 00 b0 00 02 2b
recv dataNDEF read
--- NDEF message written

NCI >> 00 00 2d c4 0f 00 00 00 16 61 6e 64 72 6f 69 64 2e 63 6f 6d 3a 70 6b 67 63 6f 6d 2e 70 72 ...
NCI << 60 06 03 01 00 01
NCI << 61 06 02 03 02
RF Deactivate ntf
READER DISCONNECTED

But I dont think this is a Problem from a User Experience Point of View. I tested it with the NFC Tools -> worked, NFC Info -> worked and even opening an App by NDEF Record worked. THANKS!

Then I tried adding the other Modes again, MODE_POLL | TECH_PASSIVE_NFCA and so on, but now it doesn't work that flawlessly anymore. In some rare cases the Phone is recognized as a Reader how it should be, but most of the times the PN7160 just goes into Reader/Poll mode and tries to read the Phone.

NCI << 61 05 1a 01 02 04 00 ff 01 0a 04 00 04 08 ae f5 0a 01 20 00 00 00 00 05 04 78 80 40 00 
NCI >> 21 06 01 03
NCI << 41 06 01 00
NCI << 61 06 02 03 00
NCI << 61 05 1a 01 02 04 00 ff 01 0a 04 00 04 08 b7 ee 7a 01 20 00 00 00 00 05 04 78 80 40 00
- POLL MODE: Remote T4T activated
SENS_RES = 0x04 0x00
NFCID = 08 ae f5 0a
SEL_RES = 0x20
NCI >> 00 00 0d 00 a4 04 00 07 d2 76 00 00 85 01 01 00
NCI << 60 06 03 01 00 01
NCI << 00 00 02 6a 82
NCI >> 00 00 0c 00 a4 04 00 07 d2 76 00 00 85 01 00
NCI << 60 06 03 01 00 01
NCI << 00 00 02 6a 82
NCI >> 2f 11 00
NCI << 4f 11 01 00
NCI << 6f 11 01 01
NCI >> 2f 11 00
NCI << 4f 11 01 00
NCI << 6f 11 01 01
NCI >> 2f 11 00
NCI << 4f 11 01 00
NCI << 6f 11 01 00
CARD REMOVED
NCI >> 21 06 01 00
NCI << 41 06 01 00
NCI << 61 06 02 00 00
NCI >> 21 03 0d 06 00 01 02 01 01 01 06 01 80 01 81 01
NCI << 41 03 01 00

 

I tried to distinguish the Phone from a Desfire Tag by the length of the NFCID, which is in the case of Desfire 7 Bytes, and in the case of the Phone only 4. But that didn't work.

If a 4 Byte NFCID was recognized i tried to StopDiscovery and restarting it by StartDiscovery with a different set of DiscoveryTechnologies.

unsigned char DiscoveryTechnologies_passive[] = {
    MODE_LISTEN | TECH_PASSIVE_NFCA,
    MODE_LISTEN | TECH_PASSIVE_NFCB,

};

....

NxpNci_StopDiscovery();
while(NxpNci_StartDiscovery(DiscoveryTechnologies_passive,sizeof(DiscoveryTechnologies_passive)));

 

But that resulted somehow in that the phone could not read the pn7160 at all. On the other hand, Desfire tags were readable.

Is there a smart way to set the reader into passive mode if there is a smartphone approaching?

Thanks a lot so far!

Greetings Erik

0 Kudos
Reply

3,342 Views
Fabian_R
NXP TechSupport
NXP TechSupport

Hello sir,
Unfortunately, we don't have a specific way or sequence to follow in case a smartphone is approaching the PN7160. This will depend entirely on the application and, the environment you built. Since the smartphone typically emulates a T4T the PN7160 will have issues identifying these two devices.
Since the TagInfo app is a testing app, my recommendation would be to use a proper CE app that fulfills your project requirements.

Best Regards,
Fabian
0 Kudos
Reply

3,316 Views
erkfry
Contributor I

Hello Fabian,

Thank you for the reply. I understand the issue, what would have been nice is that the PN7160 emulates an NDEF Record that can start the app, and after that the app can read the rest of the NDEF Record.

But I think I've come up with a solution In my environment there are only Smartphones and Desfire Tags, but they can be differentiatet from each other, by the NFCID length, A Desfire Tag has got 7 bytes and a Smartphone 4 bytes.

So if there is something recognized with a 4 Byte ID the Discovery is stopped and and started again but in listen mode only for around 2 seconds. If it is a Smartphone it will then recognize the NDEF Message and behave accordingly. This solution is fine for my application.

But thank you very much for your support.

Best Regards

Erik

0 Kudos
Reply

3,250 Views
Fabian_R
NXP TechSupport
NXP TechSupport

Hello sir,
I'm glad that you came up with your solution. Please, sir, do not hesitate to contact us again, we are happy to provide support to build your solution.

Best Regards,
Fabian
0 Kudos
Reply

3,484 Views
Tomas_Parizek
NXP Employee
NXP Employee

Hello Erik, 

This might help you -> https://community.nxp.com/t5/NFC/PN7160-card-emulation-Can-not-use-TagInfo-for-read-NDEF-and/m-p/180... 

 

First, you can try to disable Polling and keep only the card mode (Listen). Then please check if you can read PN7160 as the tag. 

 

BR

Tomas 

0 Kudos
Reply

3,472 Views
erkfry
Contributor I

Hello Tomas,

I tried this, and it actually doesnt work, the Log can be seen below. After I approach the reader with my Phone it tries to connect but then somehow there is an rf deactivate notification thrown. If I use the TagInfo App it works after some unsuccessful attempts that look like the Log below.

 

WAITING FOR DEVICE DISCOVERY
NCI << 61 06 02 03 02 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ...
NCI << 61 05 15 01 02 04 81 ff 01 01 00 81 00 00 09 08 c2 87 66 0a 00 08 01 00 ff 61 06 02 01 01 ...
- LISTEN MODE: Activated from remote Reader
NCI << 61 06 02 03 02 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ...
RF Deactivate ntf
NCI >> 21 06 01 00
NCI << 41 06 01 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ...
NCI >> 21 03 05 02 80 01 81 01
NCI << 41 03 01 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ...
READER DISCONNECTED

In a Successful atempt made by the TagInfo App there is no RF Deactivate Notification.

I do not understand why the field should be deactivated in the first place, because the reader should be in passive listen mode.

Thanks for the Response

Greetings Erik

0 Kudos
Reply