-2

i am developing an application where users can transfer files from phone to desktop using NFC technology. As i found in this post there is an option to use ACR122U in reader/writer mode and Nexus 5 phone in HCE mode. Can anyone please suggest some samples of such application as it is difficult for me to understand how it works. Your help will be so appreciated, thanks in advance.

Community
  • 1
  • 1
luna kass
  • 1
  • 1

2 Answers2

0

When you use HCE on your Nexus 5 the Nexus will emulate a NFC tag. The ACR122U can read this tag in reader/writer mode, so that makes the communication possible. Study this example, it will help you farther. For more general information about HCE on Android you can read this.

S.Pols
  • 3,414
  • 2
  • 21
  • 42
  • Thanks for your response. As I understood in this example there is an exchange of simple messages, is it possible then for ACR122U in this mode to read the file such as PDF document from Nexus 5? – luna kass Nov 12 '14 at 17:18
  • Yes that's possible. You can send whatever you want, because it are just bytes you are transmitting between the ACR122U and your Nexus. So if you want to send a PDF file, you just create a byte array and translate the PDF in bytes. After the ACR122U recieved all bytes, you can re-create the PDF file on the desktop's side. – S.Pols Nov 12 '14 at 17:36
  • As you suggested, I executed HceDemo on desktop side and host-card-emulation-sample on Android where I changed it so that I have to send pdf file converted into bytes. However, i am getting error "apdu must be at least 2 bytes long" when i try to send pdf in bytes. When i pass string converted into bytes it works. Could you advise about this issue? – luna kass Nov 14 '14 at 13:01
  • Are you sure your pdf byte array isn't empty? Read this question about how to translate a pdf to bytes: http://stackoverflow.com/questions/1131116/pdf-to-byte-array-and-vice-versa – S.Pols Nov 14 '14 at 14:29
  • I've looking for a while to make this work but cant find anything that comes close in communicating hce between android and windows. Can you post a demo? Thank you! – Niels Jul 11 '16 at 19:18
0

I have worked in this exact use case. I used P2P mode. I didn't have to treat one partner as a tag, infact data transfer worked both ways.

In my experiment- Smart phone side I tried Samsung S4, HTC One, Nexus 3, Nokia LUMIA etc.. worked like a charm. There is some limitation in the APDU/payload size. For Reader to Phone case. For your case P2P mode with attachments works fine.

  1. I downloaded this NFC library and tweaked it to my needs. I used it in WP7 along with ACCR122U.
  2. I wrote a simple Android app to receive/send data to ACCR122U.

if your ok to try P2P mode with SNEP as opposed to NPP, do let me know.I can help you.