B4R Question [SOLVED] MFRC522 Mifare 1k card need to read multi block error

tzfpg

Active Member
Licensed User
Longtime User
below is my code:
B4X:
Sub rfid_CardPresent (UID() As Byte, CardType As Byte)
   Log("UID: ", bc.HexFromBytes(UID))
   Log("Type: ", CardType, ", Is it Mifare: ", rfid.IsMifare)
   If rfid.IsMifare Then
     Dim authenticate_key() As Byte = Array As Byte(0x8D,0x6E,0x14,0xB5,0xEC,0xA6)
     If rfid.MifareAuthenticate2(1,authenticate_key,True) = False Then 
       Log("Failed to authenticate")
       Return
     End If
     Dim buffer(18) As Byte
     If rfid.MifareRead(1, buffer) > 0 Then 'buffer size must be 18 bytes or more
       Log(bc.HexFromBytes(buffer))
     Else
       Log("Failed to read")
     End If
    
     If rfid.MifareAuthenticate2(2,authenticate_key,True) = False Then
       Log("Failed to authenticate")
       Return
     End If
    
     If rfid.MifareRead(8, buffer) > 0 Then 'buffer size must be 18 bytes or more
       Log(bc.HexFromBytes(buffer))
     Else
       Log("Failed to read")
     End If
    
   End If
End Sub

first block read successful but second fail to read, my error coe:
B4X:
UID: 052DE02B
Type: 4, Is it Mifare: 1
000400000000000000000000000000008E61
Failed to read

what wrong with my code? please help me. thanks.
 

tzfpg

Active Member
Licensed User
Longtime User
i solved my problems. anyway thanks.
B4X:
 If rfid.MifareRead(2, buffer) > 0 Then 'buffer size must be 18 bytes or more
       Log(bc.HexFromBytes(buffer))
     Else
       Log("Failed to read")
     End If
 
Upvote 0
Top