|
NppFromPhoneToACR122
IntroductionTest Environment and Log obtained in testing NPP (NDEF PUSH PROTOCOL) communication from a PHONE Samsung Nexus S and an ACR122 reader DetailsTest Environment:
In the first test on the Android phone, it has been used the SimpleNDEFPusher App (source code - http://ismb-npp-java.googlecode.com/files/AndroidSimpleNDEFPusherSource.zip and installer http://ismb-npp-java.googlecode.com/files/AndroidSimpleNDEFPusherAPK.zip available in Downloads section) to send data to an ACR122 reader. So if you want to test the Java code, you need to install such application on your NFC capable phone and execute it. If you don't want to build your own application also the installer is available in Downloads section. 1 - The first step is to execute the Java code ( PhoneToReceiver contained in the archive: http://ismb-npp-java.googlecode.com/files/NPPFromPhoneToReader.zip) and then wait until in the console appears the following messages: Get factory
Get terminals
Terminal name: ACS ACR122U 00 00
T=0
Called rightProcedureReceiver..
[DEBUG] {sending [50 bytes]} 0xFF 0x00 0x00 0x00 0x2D 0xD4 0x8C 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0xFE 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0xFE 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x46 0x66 0x6D 0x01 0x01 0x10 0x00
"Device not supported, only ACS ACR122 is supported now" it's highly probable that it's not a blocking error. I've received a couple of notifications about such problem. Investigating and trying with different readers, I understand that it depends on the ACR122U firmware version. In the version I have, the behaviour is "blocking".. so you can run the code and then put the phone on the reader. In other versions, instead, the behaviour is "not blocking" so if the phone is not on the reader you'll have such behaviour. So if you see the above mentioned error, please try putting the phone on the reader before executing the java code. 2 - The second step is to put the phone on the reader 3 - At this point the J2SE application will go on and on the Android phone will appear the following window Get factory
Get terminals
Terminal name: ACS ACR122U 00 00
T=0
Called rightProcedureReceiver..
[DEBUG] {sending [50 bytes]} 0xFF 0x00 0x00 0x00 0x2D 0xD4 0x8C 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0xFE 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0xFE 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x46 0x66 0x6D 0x01 0x01 0x10 0x00
[DEBUG] {receiving [35 bytes]} 0xD5 0x8D 0x26 0x1E 0xD4 0x00 0x01 0xFE 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x32 0x46 0x66 0x6D 0x01 0x01 0x10 0x03 0x02 0x00 0x01 0x04 0x01 0x96 0x90 0x00
[DEBUG] {sending [7 bytes]} 0xFF 0x00 0x00 0x00 0x02 0xD4 0x86
[DEBUG] {receiving [24 bytes]} 0xD5 0x87 0x00 0x05 0x21 0x06 0x0F 0x63 0x6F 0x6D 0x2E 0x61 0x6E 0x64 0x72 0x6F 0x69 0x64 0x2E 0x6E 0x70 0x70 0x90 0x00
[DEBUG] {sending [9 bytes]} 0xFF 0x00 0x00 0x00 0x04 0xD4 0x8E 0x85 0x81
[DEBUG] {receiving [5 bytes]} 0xD5 0x8F 0x00 0x90 0x00
[DEBUG] {sending [7 bytes]} 0xFF 0x00 0x00 0x00 0x02 0xD4 0x8A
[DEBUG] {receiving [6 bytes]} 0xD5 0x8B 0x01 0x22 0x90 0x00
[DEBUG] {sending [7 bytes]} 0xFF 0x00 0x00 0x00 0x02 0xD4 0x86
[DEBUG] {receiving [57 bytes]} 0xD5 0x87 0x00 0x07 0x21 0x00 0x01 0x00 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x27 0xD1 0x01 0x23 0x54 0x02 0x65 0x6E 0x4E 0x44 0x45 0x46 0x20 0x50 0x75 0x73 0x68 0x20 0x64 0x61 0x74 0x61 0x20 0x73 0x65 0x6E 0x74 0x20 0x66 0x72 0x6F 0x6D 0x20 0x4E 0x65 0x78 0x75 0x73 0x2D 0x53 0x90 0x00
Finished
4 - This is the log on the Android LogCat Console: [2011-09-07 10:49:07 - SimpleNDEFPusher] Android Launch!
[2011-09-07 10:49:07 - SimpleNDEFPusher] adb is running normally.
[2011-09-07 10:49:07 - SimpleNDEFPusher] Performing it.ismb.android.npp.SimpleNDEFPusher activity launch
[2011-09-07 10:49:07 - SimpleNDEFPusher] Automatic Target Mode: using device '3232AA96F58300EC'
[2011-09-07 10:49:07 - SimpleNDEFPusher] Application already deployed. No need to reinstall.
[2011-09-07 10:49:07 - SimpleNDEFPusher] Starting activity it.ismb.android.npp.SimpleNDEFPusher on device 3232AA96F58300EC
[2011-09-07 10:49:07 - SimpleNDEFPusher] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=it.ismb.android.npp/.SimpleNDEFPusher }Please consider this first release of the application as a Proof of Concept and not as a fully defined and bug free application. Obviously, it's not yet STABLE. |
Please note that if you are using an ACR122U device and you get the error:
THAT'S ALL Here you have received on your Java Application the NDEF message containing NDEF Push data sent from Nexus-S
I have not yet the hardware but am very curious about this project. Which firmware version are you using for the ACR122U ? Good to know in case it is changable so that I do not work with a "blocking" one.
I think I've got the wrong firmware, because it "blocks". Does anyone know how to change it and to which one?
And one more important question: How can I get the message which was pushed as readable string?
I am working on a solution for re-running the application so you can "listen" to the phone(also have the problem with "not supported").
To get the text go to IsmbNppConnection?.java
find the line: //TG_GET_DATA below the byte array = tranceive(TG_GET_DATA,null);
add this: byte b = new byte50?; int textLength = array16?-3; // 1 for UTF-8 (0x02,2) and 2 for locale (101 x64 = e , 110 x6E = n which spells out en which means english locale)
byte charSet = array18?; // UTF-8 or UTF-16? System.arraycopy(array, 21, b, 0, textLength); try { // Read all the data String characterSet = (charSet==2) ? "UTF-8" : "UTF-16"; String s = new String(b, characterSet); System.out.println("Text: " + s);
You dont really need the test for the characterSet, the application provided above is set to UTF-8 but still :D. This will convert any length textstring(as long as it is all in the same "package".
Hope it helps.
@todilo87
¿Any clue on how to make the code run as a listener? So you can re-running the application every time a String is read.
@devedave
If you want to see the pushed HEX String as a Text String you can use this other method, but be carefull because the HexString? may contain more information that just the pushed String.
String outStr = convertHexToString(temp);
Here is the convertHexToString method:
To "fix" the blockable situation there is a way which works.
terminal.isCardPresent() // This is where it crashes, it can be replaced with terminal.waitForCardPresent(0); // This solution is however not very dependable but a "fix" is to add a sleep Thread.sleep(300); // Also a try and catch for the sleep. Just tried that value and seem to work.
@franm No, unfortunately not. A package can only be about 40 characters(which is like 64 bytes includes extra-data).
If I add a string longer than that OR in the android application try to create another NdefRecord?:
Has anyone tried to transfer Data with the new android version ICS? I've got ICS and the data transfer doesn't work anymore.
@deved:
With regards to the ICS version --- i think it's because the protocol has changed from NDEF to SNEP. I'm working on providing code to update this for the project but if anyone can get there faster, feel free.
I've tried pushing a SNEP formatted message but still nothing happens. Anyone had progress here?
I'm tried downgrading back to gingerbread, but I always get the error. I know this is not the place to post this but can anyone help me downgrading back to gingerbread?
Hi guys, I have tried to run the program many times. First it seems that I have the same firmware problem as some of you. So I have to put the phone on the reader. Then when i run the program the received payload of read operations is empty. Following is the output. Any ideas? Thanks
Called rightProcedureReceiver.. DEBUG {sending bytes } 0xFF 0x00 0x00 0x00 0x2D 0xD4 0x8C 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0xFE 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0xFE 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x46 0x66 0x6D 0x01 0x01 0x10 0x00 DEBUG {receiving bytes } 0xD5 0x8D 0x25 0x1E 0xD4 0x00 0x0E 0x0F 0x01 0xD1 0x82 0x40 0x86 0x97 0xD9 0x23 0x00 0x00 0x00 0x32 0x46 0x66 0x6D 0x01 0x01 0x10 0x03 0x02 0x00 0x01 0x04 0x01 0x96 0x90 0x00 DEBUG {sending bytes } 0xFF 0x00 0x00 0x00 0x02 0xD4 0x86 DEBUG {receiving bytes } 0xD5 0x87 0x00 0x00 0x00 0x90 0x00 DEBUG {sending bytes } 0xFF 0x00 0x00 0x00 0x04 0xD4 0x8E 0x85 0x81 DEBUG {receiving bytes } 0xD5 0x8F 0x00 0x90 0x00 DEBUG {sending bytes } 0xFF 0x00 0x00 0x00 0x02 0xD4 0x8A DEBUG {receiving bytes } 0xD5 0x8B 0x01 0x22 0x90 0x00 DEBUG {sending bytes } 0xFF 0x00 0x00 0x00 0x02 0xD4 0x86 DEBUG {receiving bytes } 0xD5 0x87 _*0x00 0x00 0x00*_ 0x90 0x00 Finished@kalhour Same here, i couldnt send tag nor receive one. the payload is alwys empty. but i run ics, i will downgrade to ginger. Maybe it will work again.
With 2.3.3 iam able to receive messages on my phone now! but can´t send back to my ACR122 nfc reader. if i tab the phone, my tag-app on the phone says: unknown tagtype.
@Kalkhore, @berre I'm also getting the same output in the console. payload is always empty. i'm using Galaxy S3 -ICS 4.0.4.. Anyone had progress here? Any suggestions?
hi everyone. recently I have read this article. I have downloaded these code and two codes are run in my phone and eclipse very well. but I met also a problem. "Device not supported, only ACS ACR122 is supported now" always comes out. I have tried several times, but no one successful. Who can help me now.
Anther question. I installed this software in windows 7. There are several software can be used. eg. smart post. But when i wanna receive the message, in this software i can see " the data buffer for returend date is too small.". I confused what is wrong.???
hi everyone, I have met some obstacles in my NFC project. When I attach the ACS ACR122U to the PC and run the code http://ismb-snep-java.googlecode.com/files/ISMB-SNEP-LIBRARY%20FromReaderToPhone_source.zip in eclipes, but it always comes out "Device not supported, only ACS ACR122 is supported now". How can I fix the problem????
@Kalkhore and berre did you fix the empty payload, i have to same problem.