Using Taplinx library on iOS with Desfire EV2/EV3 tags

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Using Taplinx library on iOS with Desfire EV2/EV3 tags

跳至解决方案
160 次查看
vimassJSC
Contributor I

Dear Team,

I am developing an application to format and read data from a DESFire EV3 16KB card.

I followed the UG10045 guide and successfully added both TapLinx and J2ObjC libraries as instructed.

I also disabled the "Debug executable" option in my application map. Passed the license verification step.

However, when I send the SelectApplication or GetFreeMemory command, I get the error as below.

I would love to get some help or guidance to resolve this issue.

Thank you very much,
Manh Vu
Vimass

class ViewController: UIViewController, NFCTagReaderSessionDelegate  {
    
    let licenseKey = "..."
    let licenseKeyLocal = "..."
    
    @IBAction func nfcAction(_ sender: Any) {
        print("nfcAction")
        var tagReaderSession: NFCTagReaderSession!
        tagReaderSession = NFCTagReaderSession(pollingOption: [.iso14443, .iso15693], delegate: self)
        tagReaderSession.alertMessage = "begin scan nfc"
        tagReaderSession.begin()
    }
    
    func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
        print("tagReaderSessionDidBecomeActive")
    }
    
    func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: any Error) {
        print("tagReaderSession " + error.localizedDescription)
    }
    
    func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
        guard let firstTag = tags.first else {
            session.invalidate(errorMessage: "ok nfc")
            return
        }
        
        session.connect(to: firstTag){
            (error: Error?) in
            switch firstTag {
            case .iso7816(let tag):
                self.libraryManager.getDESFireEV3Instance().selectApplication(withAppID: 0) { isSS in
                    print("result selectApplication: \(isSS)")
                }
                
                self.libraryManager.getDESFireEV3Instance().getFreeMemoryonCompletion { data, isSS in
                    print("result getFreeMemoryonCompletion: \(isSS) - \(data)")
                }
                break
            case .feliCa(_):
                print("feliCa card 1")
                break
            case .iso15693(_):
                print("iso15693 card 1")
                break
            case .miFare(_):
                print("miFare card 1")
                break
            @Unknown default:
                print("unknow card 1")
                break
            }
        }
        
    }
    
    
    //
    var tapLinxLibrary: TapLinxLibrary = TapLinxLibrary.shared()
    var libraryManager : TLLibraryManager!
    
    
    func initializeTapLinx() {
        tapLinxLibrary.verifyLicense(licenseKey) { isSS, res in
            if (isSS) {
                print("onl TapLinx initialized successfully " + res)
                self.libraryManager = TLLibraryManager.shared()
            } else {
                print("onl TapLinx initialized false " + res )
            }
        }
        
        tapLinxLibrary.doLocalVerification(withSignature: licenseKeyLocal) { isSS, res in
            if (isSS) {
                print("TapLinx initialized successfully " + res)
                self.libraryManager = TLLibraryManager.shared()
            } else {
                print("TapLinx initialized false " + res )
            }
            
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initializeTapLinx()
    }
    
}


error:

onl TapLinx initialized successfully Online license verified successfully, time to explore Taplinx Library
TapLinx initialized successfully License Verified Successfully, Time to explore Taplinx Library
nfcAction
tagReaderSessionDidBecomeActive
Command sent to card : 5A000000
Exception Caught: -[ComNxpNfclibCustomModules apduExchangeWithByteArray:]: unrecognized selector sent to instance 0x3007da160
Caught an exception (
    0   CoreFoundation                      0x00000001a19d1098 47427277-EE15-3C17-AD68-6886B0380B5E + 540824
    1   libobjc.A.dylib                     0x000000019ecd32e4 objc_exception_throw + 88
    2   CoreFoundation                      0x00000001a1ad77c8 47427277-EE15-3C17-AD68-6886B0380B5E + 1615816
    3   CoreFoundation                      0x00000001a196e888 47427277-EE15-3C17-AD68-6886B0380B5E + 137352
    4   CoreFoundation                      0x00000001a196e1b0 _CF_forwarding_prep_0 + 96
    5   VCard.debug.dylib                   0x000000010705fe70 kl0 + 2100
    6   VCard.debug.dylib                   0x0000000106efcbe4 oBo + 820
    7   VCard.debug.dylib                   0x000000010704bee0 nrou + 416
    8   VCard.debug.dylib                   0x0000000106ce2bcc -[TL_DESFireEV3 selectApplicationWithAppID:onCompletion:] + 52
    9   VCard.debug.dylib                   0x00000001068f67ec $s5VCard14ViewControllerC16tagReaderSession_9didDetectySo06NFCTageF0C_Say7CoreNFC0I0OGtFys5Error_pSgcfU_ + 704
    10  CoreNFC                             0x000000023c6be28c D938B7C1-5EC0-3CFC-94A2-00A56583760B + 270988
    11  CoreNFC                             0x000000023c68d198 D938B7C1-5EC0-3CFC-94A2-00A56583760B + 70040
    12  libdispatch.dylib                   0x00000001a9648370 B8C15E69-D076-317D-9296-1279500738FC + 9072
    13  libdispatch.dylib                   0x00000001a964a0d0 B8C15E69-D076-317D-9296-1279500738FC + 16592
    14  libdispatch.dylib                   0x00000001a96516d8 B8C15E69-D076-317D-9296-1279500738FC + 46808
    15  libdispatch.dylib                   0x00000001a9652214 B8C15E69-D076-317D-9296-1279500738FC + 49684
    16  libdispatch.dylib                   0x00000001a965d258 B8C15E69-D076-317D-9296-1279500738FC + 94808
    17  libdispatch.dylib                   0x00000001a965caa4 B8C15E69-D076-317D-9296-1279500738FC + 92836
    18  libsystem_pthread.dylib             0x0000000228d1bc7c _pthread_wqthread + 288
    19  libsystem_pthread.dylib             0x0000000228d18488 start_wqthread + 8
)
result selectApplication: false
Command sent to card : 6E
Exception Caught: -[ComNxpNfclibCustomModules apduExchangeWithByteArray:]: unrecognized selector sent to instance 0x3007da160
Caught an exception (
    0   CoreFoundation                      0x00000001a19d1098 47427277-EE15-3C17-AD68-6886B0380B5E + 540824
    1   libobjc.A.dylib                     0x000000019ecd32e4 objc_exception_throw + 88
    2   CoreFoundation                      0x00000001a1ad77c8 47427277-EE15-3C17-AD68-6886B0380B5E + 1615816
    3   CoreFoundation                      0x00000001a196e888 47427277-EE15-3C17-AD68-6886B0380B5E + 137352
    4   CoreFoundation                      0x00000001a196e1b0 _CF_forwarding_prep_0 + 96
    5   VCard.debug.dylib                   0x000000010705fe70 kl0 + 2100
    6   VCard.debug.dylib                   0x0000000106f18f7c CQPYCiZw + 164
    7   VCard.debug.dylib                   0x000000010707ffb8 DiaUpCq + 216
    8   VCard.debug.dylib                   0x0000000106ce53e0 -[TL_DESFireEV3 getFreeMemoryonCompletion:] + 44
    9   VCard.debug.dylib                   0x00000001068f693c $s5VCard14ViewControllerC16tagReaderSession_9didDetectySo06NFCTageF0C_Say7CoreNFC0I0OGtFys5Error_pSgcfU_ + 1040
    10  CoreNFC                             0x000000023c6be28c D938B7C1-5EC0-3CFC-94A2-00A56583760B + 270988
    11  CoreNFC                             0x000000023c68d198 D938B7C1-5EC0-3CFC-94A2-00A56583760B + 70040
    12  libdispatch.dylib                   0x00000001a9648370 B8C15E69-D076-317D-9296-1279500738FC + 9072
    13  libdispatch.dylib                   0x00000001a964a0d0 B8C15E69-D076-317D-9296-1279500738FC + 16592
    14  libdispatch.dylib                   0x00000001a96516d8 B8C15E69-D076-317D-9296-1279500738FC + 46808
    15  libdispatch.dylib                   0x00000001a9652214 B8C15E69-D076-317D-9296-1279500738FC + 49684
    16  libdispatch.dylib                   0x00000001a965d258 B8C15E69-D076-317D-9296-1279500738FC + 94808
    17  libdispatch.dylib                   0x00000001a965caa4 B8C15E69-D076-317D-9296-1279500738FC + 92836
    18  libsystem_pthread.dylib             0x0000000228d1bc7c _pthread_wqthread + 288
    19  libsystem_pthread.dylib             0x0000000228d18488 start_wqthread + 8
)
result getFreeMemoryonCompletion: false - 0
tagReaderSession Session invalidated by user

 

标签 (2)
0 项奖励
回复
1 解答
131 次查看
Fabian_R
NXP TechSupport
NXP TechSupport

Hello, thank you for your interest in our products.

I was checking your code snippet, nfcAction does look according to the UG snippet from section 3.3.

The issue is in the session.connect()

You are calling selectApplication() while falling in the iso7816 case. This isn't correct, as you can see in section 3.4, there is a code snippet that shows that only APDU commands should be used for ISO7816 case.

My recommendation is to check if when placing the EV3 card, the case enters into .miFare case or there is an issue with the switch statement or session.connect module.

As shown in the code snippet of section 3.5. there is a MIFARE case that uses NFCTag.mifare that determines wither is a DESFire, Plus, ultralight or unknown. We highly recommend taking this approach for selecting your card.

Please keep in mind that if you want to use APDU commands, the card should be personalized as intended.

Best Regards,
Fabian

在原帖中查看解决方案

0 项奖励
回复
2 回复数
132 次查看
Fabian_R
NXP TechSupport
NXP TechSupport

Hello, thank you for your interest in our products.

I was checking your code snippet, nfcAction does look according to the UG snippet from section 3.3.

The issue is in the session.connect()

You are calling selectApplication() while falling in the iso7816 case. This isn't correct, as you can see in section 3.4, there is a code snippet that shows that only APDU commands should be used for ISO7816 case.

My recommendation is to check if when placing the EV3 card, the case enters into .miFare case or there is an issue with the switch statement or session.connect module.

As shown in the code snippet of section 3.5. there is a MIFARE case that uses NFCTag.mifare that determines wither is a DESFire, Plus, ultralight or unknown. We highly recommend taking this approach for selecting your card.

Please keep in mind that if you want to use APDU commands, the card should be personalized as intended.

Best Regards,
Fabian
0 项奖励
回复
87 次查看
vimassJSC
Contributor I

Hi Fabian,

Thank you so much for your support!

I tried to put the card in .miFare case, it only jumps to that case with EV2 card. with EV3 card, it always jumps to .ISO7816 case.

But even if it jumps to that case, it still doesn't work with EV2 card. You can see the attached photo and see the error is still the same.

Yes, our card has been personalized for its own purpose. We have used a lot of chips including EV2, EV3 (8KB vs 16KB) since 2020 until now.
The card reading and writing on IOS was deployed in that year when there was no TapLinx library on IOS with the help of an engineer from NXP. Now we want to work more with cards on IOS so we just started with TapLinx on this platform. And are stuck as you can see.

0 项奖励
回复