eclipse-keyple / keyple-java-example

Eclipse Keyple™ Project: use case examples of the Keyple Java components for end users
https://keyple.org
Eclipse Public License 2.0
7 stars 4 forks source link

[Question][Android] How to get card number from calypso card / mobib card? #26

Closed lorenc-tomasz closed 7 months ago

lorenc-tomasz commented 7 months ago

Hi, I have Calypso/Mobib card and I would like to get the card number printed on the card. Was playing with the example but without luck. Any suggestions?

jeanpierrefortune commented 7 months ago

Hi,

I noticed your query about retrieving the card number from a Calypso/Mobib card.

To assist you with this, I'd like to point you towards the first Calypso example in the Keyple Java example repository, which demonstrates how to display the serial number. You can find this specific example here.

To successfully run this example and get the card number, please ensure you:

The serial number of the card should be displayed in the console in hexadecimal format. The length of this number is 8 bytes. Keep in mind that sometimes only the 4 least significant bytes are taken into account. Also, be aware that the number printed on the card might be in decimal format, requiring a conversion from hexadecimal if you need to match the printed number.

If you encounter any specific issues or errors while following these steps, please feel free to share them for further assistance.

Hope this helps!

lorenc-tomasz commented 7 months ago

Hi @jeanpierrefortune, thank you for your answer. I have managed to read card number and card serial number. Wondering if it's possible to read calypso cards on iOS? I know that this is Android example, but from technical point of view I'm wondering if iPhones can establish connection with those cards.

jeanpierrefortune commented 7 months ago

Hi @lorenc-tomasz, It is indeed possible to read a Calypso card using iOS. However, Keyple currently does not natively support this type of terminal. Nevertheless, in a server-driven operation, controlling the card processing via a remote Keyple application is achievable. This can be done using a dedicated API as detailed in the Server JSON API for non-Keyple clients. In these cases, the mobile application developer simply needs to create a basic application. This application's primary function is to relay APDUs from the server to the card, utilizing the terminal's native OS capabilities (specifically, the Apple NFC API in this case). This approach to handling transactions with a Calypso card is particularly advantageous when implementing the card’s security functions (like certified reading and writing), which require a SAM, because the SAM cannot be physically integrated into an iOS device’s terminal.

lorenc-tomasz commented 7 months ago

Hmm.... I have Calypso card with Available I/O Class: IsoDep, NfcB and any of iPhones I have don't see physically the card.

When I try different cards or tags the delegate method:

func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
...

is fired on iOS. However not when I try to read Calypso card.

Sorry for bothering you with this, but I'm simply wondering why I cannot even "physically" detect the card on iOS. Tried on iPhone 14, 15, SE 3rd gen and SE 1st gen.

jeanpierrefortune commented 7 months ago

I'm not particularly familiar with the iOS NFC API, but I've seen that for ISO7816 tags you need to declare the AIDs of the cards you want to communicate with. Do you have this configuration? https://developer.apple.com/documentation/corenfc/nfctagreadersession

lorenc-tomasz commented 7 months ago

Hi, I have all the settings done. I figure it out :D To read the card I need to place it exactly near the antenna. On Android device the NFC module has more power than the one on iPhones.

Thank you for all the answers.