Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PN532 Emulate not working randomly #125

Open
mdjavedakhtar opened this issue Mar 31, 2022 · 10 comments
Open

PN532 Emulate not working randomly #125

mdjavedakhtar opened this issue Mar 31, 2022 · 10 comments
Assignees
Labels
PN532 Label for PN532 UAY Unassigned yet

Comments

@mdjavedakhtar
Copy link

Hi
i have tried emulating a card with PN532 module. it works like 1 out of 20 times

i debug i get tgInitAsTarget Failed or timeout

if i keep the phone on the pn532 with 1 sec timeout in sketch after about 20 retry i get data on phone. then again it stops.

i am using SPI connection.

@mywalkb
Copy link

mywalkb commented Jun 12, 2022

Try to see if my changes mywalkb/PN532 improve your experience.
nfc.emulate use timeout 0, it don't give time to read response from chip, is not infinite timeout.

@jlkalberer
Copy link

jlkalberer commented Sep 4, 2023

@mywalkb - Can you explain what changes you're making in your branch?
There is a lot going on there and I'd like to understand the changes before I try to use your solution as I'm sure I'd only need parts of it.

These are the changes I added. I'm using a Particle Photon (not Arduino) so there are some slight differences. I haven't tested this yet but it compiles.
The other commits on your branch looked like it was for supporting callbacks which I don't want or need.

Cheers!

jlkalberer added a commit to Brewskey/Brewskey.Device that referenced this issue Sep 4, 2023
@mywalkb
Copy link

mywalkb commented Sep 4, 2023

@mywalkb - Can you explain what changes you're making in your branch?

it's been over a year it's hard to remember all the changes and why I made them.
With my changes I tried to implement libnfc's functions which works very well with PN532.
I report the comment in my first commit:

- change include path
- fix some functions with readresponse when it's return 0 length (is not an error). Some other todo
- add setTimeoutComm for change timeout for command inCommunicateThru
- improvement function inCommunicateThru manage buffer len 0 so we can ignore response from TAG
- improvement function startPassiveTargetIDDetection manage better paramenters for all cardbaudrate

The other commits on your branch looked like it was for supporting callbacks which I don't want or need.

you can fork and remove that commit if you don't want it. When you emulate a tag without callback, how can you know when you receive data? Polling is not a good method in my opinion.

@jlkalberer
Copy link

Thanks @mywalkb

I took a lot of what you did and put it in this branch
I'll test this out and let you know if it works for me. If it does, I'll make a smaller patch and put a PR up on this repo.


Polling is not a good method in my opinion.

Yeah, I'd generally agree with this but my code runs in a loop/state machine so a callback doesn't help me too much :)

@MatthewJeffson MatthewJeffson added UAY Unassigned yet PN532 Label for PN532 and removed UAY Unassigned yet labels Oct 9, 2024
@Cincinnatu
Copy link

Hello!Has this issue been resolved yet? If not, I will take a look at it soon.

@mdjavedakhtar
Copy link
Author

Still the issue is there

@Lesords Lesords assigned Lesords and unassigned Cincinnatu Dec 24, 2024
@ackPeng
Copy link

ackPeng commented Jan 7, 2025

@mdjavedakhtar Hello, I tested it using FeliCa_card_detection. After turning on the phone, I put the card on my phone and it can be recognized.

@jlkalberer
Copy link

jlkalberer commented Jan 7, 2025

I haven't been able to verify this yet but it I used another iOS app that could scan the emulated tag. I reached out to the author for details.

Basically, they had two reader implementations:

I'm not sure if he manually wrote the protocol for reading the tag with NFCNDEFReaderSession or not but I know for a fact that it is working.


As for Android... I'm still investigating.

  1. I've seen it successfully scan NfcF (Felica) when I was using reader mode but it would crash the NFC stack on Android. So after the first scan which was successful, I had to manually reset the NFC service for it to scan anything.
  2. Emulating with a MiFare application identifier would not work (or doesn't seem to be working).

@ackPeng
Copy link

ackPeng commented Jan 8, 2025

@jlkalberer My phone is an Android system, and every scan is successful. I haven’t tried it on IOS yet. I’ll give it a try on IOS.

@ackPeng
Copy link

ackPeng commented Jan 8, 2025

@jlkalberer I also tested it on an Apple mobile phone and it can also be detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PN532 Label for PN532 UAY Unassigned yet
Projects
Status: Todo
Development

No branches or pull requests

7 participants