NFCISO7816APDU sendMifare Command not supported problem

I am trying an NFC write with Mifare Ultralight and I get the following error:

Code Block
Optional(Error Domain=NFCError Code=1 "Feature not supported" UserInfo={NSLocalizedDescription=Feature not supported})

My code for the write request is as follows:

Code Block
if case let NFCTag.miFare(tag) = tags.first! {
let dataMifare: [UInt8] = [240, 0, 0, 0] // READ page 4 + CRC
let dataPacketMifare = Data(bytes: dataMifare, count: dataMifare.count)
session.connect(to: tags.first!) { (error: Error?) in
let apdu = NFCISO7816APDU(instructionClass: 0xFF, instructionCode: 0xD6, p1Parameter: 0x00, p2Parameter: 0xFF, data: dataPacketMifare, expectedResponseLength: 0x02)
tag.sendMiFareISO7816Command(apdu) { (apduData, sw1, sw2, error) in
let tagUIDData = tag.identifier
session.invalidate(errorMessage: "Test")
debugPrint(apduData)
debugPrint(error)
debugPrint(tag.identifier)


I'm writing to a custom device where the value "0xFF" means a write request. If I change that value with "0x00" it works but for my device that is a read request

Am I doing something wrong or IOS 13.0 does not really support writing request on the Mifare?

I'm using Xcode 12.2, iOS 13.0 and Iphone 11.

Thanks in advance for the help


In my Info.plist file:

Code Block
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>D2760000850100</string>
<string>D2760000850101</string>
</array>
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
<string>TAG</string>
</array>



I'm using Xcode 12.0 and IOS 13.0 with Iphone 11.
Thanks in advance for the help
Answered by scorona85 in 661342022
The problem is that you send has not the payload datas. The array [0xF0, 0, 0, 0] has only the page request. The error:

Code Block
NFCTagReader[516:101552] [CoreNFC] 00000002 83fd0090 -[NFCTagReaderSession transceive:tagUpdate:error:]:771 Error Domain=NFCError Code=100 "Tag connection lost" UserInfo={NSLocalizedDescription=Tag connection lost}


is a malformed request.
Accepted Answer
The problem is that you send has not the payload datas. The array [0xF0, 0, 0, 0] has only the page request. The error:

Code Block
NFCTagReader[516:101552] [CoreNFC] 00000002 83fd0090 -[NFCTagReaderSession transceive:tagUpdate:error:]:771 Error Domain=NFCError Code=100 "Tag connection lost" UserInfo={NSLocalizedDescription=Tag connection lost}


is a malformed request.
NFCISO7816APDU sendMifare Command not supported problem
 
 
Q