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?
Solved! Go to Solution.
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
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
@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.
one more thing - apduData is really also IOSByteArray, not NSData
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