Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Android poll for NFC devices

I am working with a contactless reader to communicate with my Android device.

I have observed that any point in time I cannot connect to my Android device using P2P. If I want to connect to initiate an Android Beam transfer I must continuously try to connect to the device multiple times over a one second period.

An NFC Android device can detect contactless cards, NFC P2P targets and NFC P2P initiators i.e. 3 different modes. I am beginning to think that there is some kind of polling going on behind the scenes that switches between the three modes very quickly.

This means that at any given point in time when I try to connect to the phone, it may or may not be in the correct mode and will fail. This is why I need to attempt multiple connections.

I have been looking at the Android source to try and figure this out with no real luck. here is the most promising file I have seen yet but it still makes no sense.

My question is: How does Android detect multiple NFC modes, does it use a switching algorithm and if so what are the specifics of the algorithm?

Thanks.

like image 726
jim Avatar asked Jul 23 '13 14:07

jim


People also ask

What is NFC polling?

Description. nfc-poll is a utility for polling any available target (tags but also NFCIP targets) using ISO14443-A, FeliCa, Jewel and ISO14443-B modulations. This tool uses hardware polling feature if available (ie. PN532) or switch back to software polling, it will display available information retrieved from the tag.

How does NFC work on Android?

Near Field Communication (NFC) is a set of short-range wireless technologies, typically requiring a distance of 4cm or less to initiate a connection. NFC allows you to share small payloads of data between an NFC tag and an Android-powered device, or between two Android-powered devices. Tags can range in complexity.

Can I use Android as NFC tag?

Its possible to make Android device behave as an NFC Tag. Such a behaviour is called Card Emulation. Card emulation can be host-based(HCE) or secure-element based(CE). In HCE, an application running on the Android main processor responds to the reader.

Where is NFC located on Android?

You can check for NFC settings on your Samsung Android device by looking in the settings app > connections > tap NFC and contactless payments. If you see an option for NFC there, your device is enabled to make NFC payments.


1 Answers

I am beginning to think that there is some kind of polling going on behind the scenes that switches between the three modes very quickly.

Exactly this is going on. The different technologies gets time-multiplexed. It's much more than three modes though. Typically a NFC device will poll for:

  • Reader ISO14443 A
  • Reader ISO14443 B
  • Reader FeliCa (aka tag type 3)
  • Reader ISO15693
  • Card Emulation ISO14443 A
  • Card Emulation ISO14443 B
  • Card Emulation Felica

Peer-to-Peer mode uses Reader A, Reader FeliCa as initiator. Card emulation A and card emulation Felica are also used as Peer-to-Peer Target mode technology.

The exact timing of the polling is not public and you will not find much about that in the source-code. This is handled by the NFC chip internally.

like image 100
Nils Pipenbrinck Avatar answered Oct 01 '22 18:10

Nils Pipenbrinck