Search code examples
fluttermobilenfcmobile-developmenthce

How to send data to the card reader using NFC technology with Flutter?


How can I send data from a mobile device to a USB Mifare card reader using NFC with Flutter?

I spent some time online but couldn't find what I needed. My goal is to send a UID that I specify to the card reader and have it read. The reader can read 4 bytes of hexadecimal.

I tried nfcmanager and flutter_nfc_kit libraries. Either I couldn't do it or it really can't be done with these libraries.


Solution

  • The Tag reader does say "N-TAG Card Emulation", so it might be possible but there are no details of actually what chip is in it or there does not seem to be any programming documents.

    The main problem with trying to do this is NFC has various modes with the most common being Reader Mode->Tag. So you have 2 pieces of hardware acting in "Reader Mode" and Reader Mode->Reader Mode does not work.

    So you need to program one of the pieces of hardware to be in "Tag mode". As an Android phone can be changed in to "Tag Mode" with HCE But a normal user cannot do this with iOS (only Apple can).

    Thus you need to make the Card Reader be the Tag, which is possible on some card readers.

    The other issue is NFC is not RFID, so the UID a Tag generates is not guaranteed to be unique, and thus a Phone generates a Random number that you have no control of, but with writing an app for the phone and programming the USB Reader Hardware you can transfer your own UID as user data.

    So technically possible but a lot of work.