Taplinx iOS appcrash on tag response

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Taplinx iOS appcrash on tag response

Jump to solution
1,023 Views
DamianD
Contributor III

Hi, i followed UG10045.pdf and created ios application. I created ApduExchangeWithByteArray method and implemented its contents. However when send back response from tag back to taplinx library, application crashes with following entries from device log:

Time	Device Name	Type	PID	Tag	Message
Nov  6 20:44:31	iPhone	Notice	5223	MobileFacilityApp	Command Set - 1
Nov  6 20:44:31	iPhone	Notice	5223	MobileFacilityApp	Command Set - Native
Nov  6 20:44:31	iPhone	Error	0	kernel(Sandbox)	Sandbox: MobileFacilityApp(5223) deny(1) sysctl-read kern.bootargs
Nov  6 20:44:38	iPhone	Notice	5223	MobileFacilityApp(UIKitCore)	Received memory warning.
Nov  6 20:44:38	iPhone	Notice	5223	MobileFacilityApp(UIKitCore)	Received memory warning.
Nov  6 20:44:40	iPhone	Notice	0	kernel	EXC_RESOURCE -> MobileFacilityApp[5223] exceeded mem limit: InactiveHard 3072 MB (fatal)
Nov  6 20:44:40	iPhone	Notice	0	kernel	memorystatus: killing process 5223 [MobileFacilityApp] in high band FOREGROUND (100) - memorystatus_available_pages: 44859

 

When i sent back empty response back to taplinx library (just TL_TagAPDUResponse without setting ResponseData) - app does not crash and i get error about incomplete response (which is expected). What am i doing wrong?  

0 Kudos
Reply
1 Solution
982 Views
DamianD
Contributor III

apparently included headers in TapLinx-v2.0.0 are all wrong. In TapLinxApduHandler.h we see declaration:

- (nullable TL_TagAPDUResponse *)apduExchangeWithByteArray:(NSData *_Nonnull)apduData;

but in reality we should return IOSByteArray*, otherwise app will crash with aforementioned symptoms

View solution in original post

0 Kudos
Reply
6 Replies
924 Views
ukcas
NXP Employee
NXP Employee

Hello Damian,

Maybe the cause of the error is some exceeding memory limit and not TapLinx library?

MobileFacilityApp[5223] exceeded mem limit: InactiveHard 3072 MB (fatal)

 

The application which integrates TapLinx Library can be used as following (no need for ApduExchange implementation on top)

Set the delegate to the APDUHandler

let reader = TL_IOSNFCReader(uid: tag.identifier, historicalBytes: tag.historicalBytes ?? Data())

handler = TapLinxApduHandler(reader: reader)

handler.delegate = self

                

libraryManager?.setApduHandlerWithApduHandler(handler)

 

Next Step will be to implement the protocol method inside the application

 

func apduExchange(withByteArray apduData: Data) -> TL_TagAPDUResponse? {

        var tagAPDUResponse: TL_TagAPDUResponse?

       

        if connectedTag != nil {

            // Send Tag Type Native of ISO and the apdu as NFCISO7816APDU

            executeAPDUCommandOn7816Tag(tagType: tagtype, apdu: apdu) { data in

                let appendedData = data


                tagAPDUResponse = TL_TagAPDUResponse(responseData: appendedData, tag: self.currentTag)

                semaphore.signal()

            }

            let _ = semaphore.wait(timeout: .now() + 3.0)

        } else if connectedMifareTag != nil {

            let semaphore = DispatchSemaphore(value: 0)

           

            print("MIFARE CAPDU -> \(apduData.hex)")

           

            executeAPDUCommandOnMIFARETag(apdu: apduData) { data in

                print("RAPDU <- Data: \(data.hex)")

                tagAPDUResponse = TL_TagAPDUResponse(responseData: data, tag: self.currentTag)

                semaphore.signal()

            }

            let _ = semaphore.wait(timeout: .now() + 3.0)

        }

        print("Tag Response \(String(describing: tagAPDUResponse))")

        return tagAPDUResponse

    }

 

Hope this simplification would help you.

 

Best regards,

TapLinx team

0 Kudos
Reply
921 Views
DamianD
Contributor III

@ukcas - what version of taplinx ios library is 'current'? Because i have 2.0.0 and it definitely crashes when i return TL_TagAPDUResponse from apduExchange method, it has to be raw IOSByteArray from j2objc library. I'm using c# bindings for taplinx library, but it does not matter in this problem.

0 Kudos
Reply
922 Views
DamianD
Contributor III
hi
the crash definietly comes from taplinx library because when i changed
- (nullable TL_TagAPDUResponse *)apduExchangeWithByteArray:(NSData *_Nonnull)apduData;
to actually:
- (nullable IOSByteArray*)apduExchangeWithByteArray:(IOSByteArray*_Nonnull)apduData;
It started working

0 Kudos
Reply
914 Views
DamianD
Contributor III
followup - when i changed my implementation to use provided TapLinxApduHandler instead of providing my own - then apduExchangeWithByteArray does conform to contract - (nullable TL_TagAPDUResponse *)apduExchangeWithByteArray:(NSData *_Nonnull)apduData;
0 Kudos
Reply
979 Views
DamianD
Contributor III

one more thing - apduData is really also IOSByteArray, not NSData

0 Kudos
Reply
983 Views
DamianD
Contributor III

apparently included headers in TapLinx-v2.0.0 are all wrong. In TapLinxApduHandler.h we see declaration:

- (nullable TL_TagAPDUResponse *)apduExchangeWithByteArray:(NSData *_Nonnull)apduData;

but in reality we should return IOSByteArray*, otherwise app will crash with aforementioned symptoms

0 Kudos
Reply