microsoft / Windows-universal-samples

API samples for the Universal Windows Platform.
MIT License
9.52k stars 7.98k forks source link

Can not detect type of NFC card #413

Closed SailorMax closed 8 years ago

SailorMax commented 8 years ago

Our city transport has 2 type of tickets. One of them I can't detect by your library. Can you check it and, may be, update the library? ATR: 3B-88-80-01-00-00-00-00-B3-71-71-00-BA

Looks like this is Calypso/Iso14443P4 but I do not sure.

thank you.

oldnewthing commented 8 years ago

This doesn't seem to be a question about the sample. It's a question about the operating system support for certain NFC cards. You can open a support case with our Developer Support team who can further help with the specific problem you are experiencing. Please use these steps below for further help:  

  1. Visit http://aka.ms/storesupport and sign-in with your Microsoft account
  2. Under the “App Development” section choose "Windows 10 universal app development", then choose the appropriate problem type and category to get engaged through a formal support channel.
SailorMax commented 8 years ago

@oldnewthing : I'll re-test it later (can't do it now), but based on source of PcscSdk in your samples problem in PcscSdk/IccDetection.cs, which support only DeviceClass.StorageClass and DeviceClass.MifareDesfire.

PcscSdk/CommonDefs.cs has record for Iso14443P4, but PcscSdk no where use it. If this is not your library, where I can find its developer?

thank you.

oldnewthing commented 8 years ago

I'll have to check with the feature team where PcscSdk came from.

SnowCoderAlex commented 8 years ago

Am assuming that when you say "can’t detect" you mean the SmartCardReader.CardAdded event not firing in response to tapping the card. If that's the case, then it wouldn’t be at all related to the PcscSdk or the sample app (assuming that other types of cards trigger that event fine).

Instead, it would likely be an issue of their NFC reader hardware/driver not supporting that type of card. You should contact the vendor/OEM/IHV that supplied their NFC reader device. If the NFC reader you're trying to use is the built-in NFC on a Windows Phone, then assuming they’re running Windows 10 on a Lumia 640/650/730/830/950 device (and assuming that other types of cards work fine) let me know as my team owns that component and if you can mail us an example card we could take a look at whether it's possible to add support for that type of card in future (assuming it's possible with the hardware).

SailorMax commented 8 years ago

I use Lumia 650. SmartCardReader.CardAdded works fine (on Windows 10 Fast Ring was fixed).

My code insideCardAdded():

var connection = await SmartCard.ConnectAsync();
var cardIdentification = new IccDetection(SmartCard, connection);
await cardIdentification.DetectCardTypeAync();

Result: cardIdentification.PcscDeviceClass.ToString() return "Unknown" cardIdentification.PcscCardName.ToString() return "Unknown" BitConverter.ToString(cardIdentification.Atr) return "3B-88-80-01-00-00-00-00-B3-71-71-00-BA" (await connection.TransceiveAsync(new Pcsc.GetUid())).ToString(); return "ApduResponse SW=6D00 (Unknown)"

online ATR decoder ( https://smartcard-atr.appspot.com/parse?ATR=3B88800100000000B3717100BA ) return:

Public transportation card in Riga, Latvia, called "e-Talons" http://etalons.rigassatiksme.lv/en/payments/activating_the_e-ticket/ Belgian MOBIB (transport)

This result has Latvian (Riga) transport tickets: Personalised (blue) and Riga Resident's cards (https://www.rigassatiksme.lv/en/tickets-and-e-ticket/types-of-e-tickets/paper-ticket/ - Pupil's, ISIC and Citadele did not test, but looks like also).

Based on some information in internet, The MOBIB card operates with Calypso technology => I think problem in PcscSdk, which currently did not support Iso14443P4 (on which based Calypso, as I right understand).

thank you.

SnowCoderAlex commented 8 years ago

For cards based on Calypso the PcscSdk isn't necessarily needed at all, those cards are ISO-DEP/ISO 14443-4/ISO 7816-4 APDU-based and you can directly send your APDUs using the SmartCardConnection.TransmitAsync method. The PcscSdk has a helper class Iso7816.ApduCommand and Iso7816.ApduResponse which can optionally help you in constructing APDU commands and parsing the APDU responses.

Of course, you would need to know what sort of APDUs to send to this type of card and how to process the responses (beyond the basic ISO 7816-4 APDU structure). That's not something we can help you with here though, you'd need to contact the issuer or manufacturer of the cards and request that they provide you with documentation and specifications that will explain that (but often all or important parts of that are not available publicly)

SailorMax commented 8 years ago

I understood. Thank you.

One question left: if PcscSDK DeviceClass enum has Iso14443P4 record, why it is not being used? At least for in IccDetection. Did not plans to fix it? It can help to detect the card type only by this class.

SnowCoderAlex commented 8 years ago

The DeviceClass etc is determined by the IccDetection class based on the ATR, and that only contains firm standardized details of what type of card it is for "storage cards" (eg non ISO-DEP cards) as defined by the PC/SC working group: http://www.pcscworkgroup.com/specifications/files/pcsc3_v2.01.09_sup.pdf

The enum value Iso14443P4 looks like it's present for completeness, however I'm not sure that IccDetection has any way to reliably confirm whether it is or isn't Iso14443P4 based on ATR so it defaults to "Unknown".

SailorMax commented 8 years ago

I see now. Thank you!

P.S. CategoryIndicator.StatusInfoPresentAtEnd also does not use anywhere :)