Hi, I'm trying to read the tamper status from a NTAG 213 TT nfc (mifaretag - ultralight). Every time I do a sendMiFareCommand I get an error "Tag is not connected". I can read the tag using an app called NFC tools and it shows the tamper status just fine. This is my code:
guard tags.count > 0,
let tag = tags.first
else {
session.invalidate()
return
}
print("asd tags count \(tags.count) isAvailable \(tag.isAvailable)")
switch tag {
case .miFare(let miFareTag):
print("asd family \(miFareTag.mifareFamily)")
let readBlock4: [UInt8] = [0xA4, 0x00]
print("asd 1")
if #available(iOS 14, *) {
print("asd 2")
miFareTag.sendMiFareCommand(commandPacket: Data(readBlock4)) { (result: Result<Data, Error>) in
print("asd \(result)")
switch result {
case .success(let response):
print("asd bem aqui 1 \(response)")
case .failure(let error):
print("asd 1 Read tag error: \(error.localizedDescription). Please try again.")
}
}
} else {
print("asd 3")
miFareTag.sendMiFareCommand(commandPacket: Data(readBlock4)) { (response: Data, optionalError: Error?) in
guard let error = optionalError else {
print("asd deu bem aqui 2")
return
}
print("asd 2 Read tag error: \(error.localizedDescription). Please try again.")
}
}
print("---")
It is important o point out that I also tried to session.connect before doing the send command and the results are the same.
Any tips?
Thanks