I am trying to develop an Android application for a hospital. In this system there is a need to get the patient information stored in the database in the android phone into the desktop computer using NFC technology. Is there anyway where I could use a NFC USB Reading device (ACR122U NFC Smart Card Reader RFID Writer 5 Mifare USB) to transfer the data from the mobile phone to my desktop computer?
The real scenario for this would be, in a hospital when a person wants to take some test results he will reach to the counter and place the mobile device on the NFC reader device installed at the counter when this is done all the details about the patient should be transferred to the desktop machine at the counter.
I don't want to transfer a lot of information if there is any way in which I could transfer the patient id stored in the mobile database into the desktop using NFC that would be enough.
Depending on what NFC devices you want to use in combination with the ACR122U NFC reader you multiple options:
If you only need to exchange a single message (data packet) in a single direction, you could use peer-to-peer mode. However, the peer-to-peer protocol stack is relatively complex (in comparison to the other alternatives). Moreover, Android's built in Beam functionality will request user confirmation (Beam UI) for every message transfer.
If you only need to support Android devices with Android 4.4 or later (and even then not all Android NFC devices are supported, see this), you could use the ACR122U in reader/writer mode. In reader/writer mode, the ACR122U can communicate with contactless smartcards. See the reader's manual on how to access such ISO/IEC 14443-4 contactless smartcards. On the Android side, you would use the host-based card emulation (HCE) mode. See the Android documentation on how that works on Android 4.4 and later.
In my opinion the best option would be to use the ACR122U in card emulation mode. In card emulation mode the ACR122U can be used to emulate a tag/contactless smartcard that can be detected by an Android device just like any other NFC tag/contactless smartcard. You can find examples, for instance, with libnfc. Also see this answer on how to bring the ACR122U into card emulation mode. This option can be used across all Android versions (and on BlackBerry and with some additional effort to some extent even on Windows Phone). With this scenario, the phone would take the reader (interrogator) part in the communication and the ACR122U (and the connected PC) would be the card (controlled component). Using techniques like inverse reader mode you could reverse that relationship.
You could use the host based card emulation for exchanging the data: http://developer.android.com/guide/topics/connectivity/nfc/hce.html
Or alternatively the p2p communication:
http://developer.android.com/guide/topics/connectivity/nfc/nfc.html#p2p
Related
Currently using React Native and attempting to use react-native-nfc-ios and react-native-nfc so I can have cross-device communication between ios and Android. I'm finding that they cannot communicate, however I think it's due to a broader issue (as other existing apps also don't work).
If I download a NFC reader app on iPhone 7, and an NFC writer app on Android they cannot communicate. Why is this?
Instructions to Duplicate
Turn on NFC Reader on iPhone 7
Put some arbitrary data in NFC write mode on Android
Bringing devices together has no effect.
Not understanding the intricacies of NFC, it's hard for me as a casual programmer to understand what the actual problem is.
I understand that IOS11 on iPhone 7 (plus) supports NFC read, and generally speaking there are card emulation, peer to peer, and read write modes.
Should they not communicate? The iPhone is not able to pick up the
Android writer. Why is this?
How does card emulation (I assume to be Apple Pay), differ from a write mode?
The reason is because Apple's iOS 11 update only allows reading from NFC tags (writing is only permitted for Apple Pay). At the moment, their software does not share the same enjoyment afforded by Android phones which enable card emulation, peer-to-peer, and reader/writer NFC usage. So our only hope is to wait for a software update that will finally enable this existing feature for developers to use.
I am working on an app that will be deployed on a NFC enabled device. I am trying to enable authentication using NFC, so that a user can scan another NFC device such as phone to authenticate.
I went through the NFC documentation that Android has at http://developer.android.com/guide/topics/connectivity/nfc/nfc.html
I am not able to get my use case working.
Here is what I am trying to do:
Deploy app in Device A.
app on Device A will only try to scan for NFC when app is in foreground and is in Login Activity.
User can bring in Device B/NFC tag near Device A, Login Activity will authenticate the user.
I hope this is possible using NFC in Android. My search leads me to example that launches app when NFC is detected but that is not what i am after.
If you want to communicate beween two Android devices by using one as an emulated tag and the other as reader/writer (as opposed to transfering NDEF messages between two devices using Android Beam, which is based on NFC peer-to-peer mode), you could Android HCE (one one device) in combination with reader/writer mode (on the other device).
However, building a solution like this has some limitations. Regarding the emulating side, you have the following limitations and requirements:
Android HCE requires the emulating device to run Android 4.4 or later.
The emulating device needs to support host-based card emulation. Not all Android 4.4+ devices that have NFC also support HCE. For instance, all (most?) devices that contain NXP's PN544 NFC controller do not curently support HCE.
You can only emulate ISO/IEC 7816-4 appliction structures on top of ISO/IEC 14443-4. In case you want to emulate an NFC tag with NDEF data, this would be equivalent to an NFC Forum Type 4 tag. But you are, of course, not limited to emulating NDEF-style NFC tags.
However, an NFC tag (or rather a smartcard application) that is emulated like this imposes some requirements/limitations on the reader side as well:
Android's HCE capabilities run in parallel with its peer-to-peer mode capablities (regardless of whether the device has support for Android Beam enabled or not). As a consequence, other Android devices will detect Android HCE devices as peer-to-peer devices and, by default, communicate with them in peer-to-peer mode. Therefore, other Android devices will normally be unable to access an Android HCE emulated smartcard application.
Only starting with Android 4.4, you can disable peer-to-peer mode discovery by using the reader mode API. So you need Android 4.4+ on the reader side in order to access the emulated NFC tag.
This also prevents automatically starting an app on the second device upon discovery of the first device, so you can only use an Android HCE emulated smartcard application in combination with an activity that already runs in the foreground on the reading device.
I have installed a NXP NFC-ExploreNFC in Raspberry, when I run the sample card_polling program, it can detect my JIS X 6319-4 compatible card, however, it cannot detect my Samsung Note II (NFC is enabled).
Is there any extra setup required in Raspberry?
regards
Unless your phone is in card emulation mode, the card-polling example would normally not detect the phone as a card. That is, before Android 4.4 (and on NXP PN544-based devices) card emulation is normally not enabled. Though the polling example looks as if it could potentially detect a phone's passive peer-to-peer mode (when display is on and device is unlocked) as either "Mifare" ISO 14443-3 or "FeliCa" due to the fact that those modulation and protocol activation schemes are used in peer-to-peer mode too.
For reliable communication with an Android device, I would suggest that you use either the peer-to-peer mode (P2P) example or the card emulation example.
this is my very first post on stackoverflow, I need to read a RFID tag using an external RFID reader, because I have to use android on MK802 via USB port. My concern is in using two packages android.nfc and android.nfc.tech, because I dont' know if I can use them. Do I need to read from USB or from RFID sensor?
You typically can't use the android.nfc.* packages for such a scenario. Android's NFC API is intended for NFC interfaces and not for RFID readers. Even if you do have an NFC interface device connected to your Android device through USB, you would need to provide the hardware abstraction layer to connect your NFC interface device to Android's NFC stack and compile that into your Android system.
Depending on how your RFID reader works, the reader's manufacturer might provide an API for Android (unlikely) or will be able to provide you with specifications on how to interface their device (this could be possibe through ANdroid's USB API but it could also be as simple as receiving keyboard inputs).
I buy ACR122U SDK that has a acr122 reader,cd and cards and I try to test it. the reader detect the cards by changing its LED light from red to green but when I take my phone (NFC is turned on) near the reader,there is nothing happen.
How do I make the reader detect my phone? I have to install java card applet into my phone for letting my phone act as a contactless card?
Using the ACR122U NFC reader you have three options:
ACR122U in peer-to-peer mode: In peer-to-peer mode, you can communicate with an Android device using Android's built in Beam functionality. On the reader side you would need to implement the SNEP service (and the underlying LLCP + NFCIP-1 protocol stack). You can find examples, for instance, with ISMB-SNEP, NFC Tools and nfcpy.
ACR122U in card emulation mode: In card emulation mode the ACR122U can be used to emulate a tag/contactless smartcard that can be detected by an Android device just like any other NFC tag/contactless smartcard. You can find examples, for instance, with libnfc.
ACR122U in reader/writer mode: In reader/writer mode, the ACR122U can communicate with contactless smartcards. This goes into the direction of what takumar already posted in his answer. While you were stuck with the requirement of a secure element (which is typically difficult due to lack of access or even lack of an SE), with recent Android versions (specifically CyanogenMod 9.1+ or Android 4.4+), you have the option to use host card emulation (HCE) mode. See the Android documentation for how that works on Android 4.4 and later.
Your phone must be enabled for card emulation, not all are. Furthermore, you need to figure out where card emulation is routed to. This can be the SIM or some embedded secure element. Once that is done, you can think of deploying the application onto a test SIM (it is very unlikely that you'll ever get the keys to the embedded secure element). Working with an AOSP build of Android (for instance on the Nexus 5) helps because you can set the route. Test SIMs with test keys can be bought online I believe. Once you have one, you can use GPShell to install the application. Good luck.