I have my ACR122U in card emulation mode and an Android application which has to start when the emulated tag is detected and send a message, for example: "Hello".
When emulate the tag and scan it with my phone it successfully opens the application by catching it with the android.nfc.action.TAG_DISCOVERED
intent filter.
I have three questions about this situation.
Question 1
I read that the TAG_DISCOVERED
has the lowest priority and you can't be sure your application will be selected after a tag discovery. Using card emulation, is the only way to catch an intent by using the android.nfc.action.TAG_DISCOVERED
intent filter, or is there an other (better) way?
Question 2
I think this question is related to question 1. When i use the tgSetData
command on the PN532 i gues i just send plain text to the android device. For example: FF 00 00 00 08 D4 8E 61 73 64 61 73 64
sends the string "asdasd". Is it also possible in card emulation to send a NDEF message or something similar? I suppose if that's possible Question 1 is answered to because you can use the NDEF intent filter.
Question 3
This question is about the application select part. From the first tgGetData
i recieve the bytes 00 a4 04 00 07 d2 76 00 00 85 01 00
. I read that this is the application select. I also noticed that won't get this procedure when the Android application is opened. I gues that's probably because the application is opened in the front. But how do i interact with this response when my application isn't in the front? My current interaction is this:
- getData
D4 86
- Response =
D5 87 00 00 A4 04 00 07 D2 76 00 00 85 01 01 00
- setData
D4 8E 61 73 64 61 73 64
(just a random string) - Response =
D5 8F 00 90 00
- Use send- / getData to transmit data.
This doesn't work when the application isn't openend. Is this because this procedure is wrong or maybe my handling in Android is wrong?
Any information is welcome related to the questions.
Many thanks!
Regards.