I'm trying to read a page of a Mifare Ultralight tag (more specifically EnOcean PTM 215B) using NFCMifareTag.sendMifareCommand
method after it has been discovered and connected onto. The problem is that all commands I've tried to send cause a "Tag connection lost" error which is quite odd as I've just successfully connected to it.
The (simplified) code looks like:
// tag has been determined to be of type NFCMifareTag earlier
session.connect(to: tag) { (error: Error?) in
if (error != nil) {
return
}
print("Connected to the tag")
let data: [UInt8] = [0x30, 0x04, 0xEE, 0x26] // READ page 4 + CRC
let dataPacket = Data(bytes: data, count: data.count)
tag.sendMifareCommand(
commandPacket: dataPacket,
completionHandler: { (response: Data?, error: Error?) in
if nil != error {
return // <-- "Tag connection lost" error
}
// Handle the data as the operation was successful
}
)
}
I'd appreciate any pointers and/or ideas on what could be the reason for this behavior. As mentioned, I've tried various different data packets but all work exactly the same. I've also tried multiple different phones to eliminate hardware problems. The support was just added in iOS 13 and as such I couldn't find any examples online that would use the sendMifareUltralight
command.