SmartCardMBS - NFC Reader

I tested several cards with my ACS ACR122 reader.
I noticed that the CardID provided by the status method of the SmartCardMBS class actually returned the ATR value.
After some digging around I found a “Transmit” way of getting the UID of the RFID card.

Public Function getID(card as SmartCardMBS, IncludeColon as Boolean = True) As String
  If card = Nil Then Return ""
  
  Var blockSize As UInteger = 8
  
  Var header As New MemoryBlock( 8)
  header.Int32Value(0) = 2 // T1
  header.Int32Value(4) = 8 // size of this block
  
  Var command As New MemoryBlock(5)
  command.Int8Value(0) = &hFF // Request data
  command.Int8Value(1) = &hCA // Request the UID
  command.Int8Value(2) = 0
  command.Int8Value(3) = 0
  command.Int8Value(4) = 0
  
  Var buffer As New MemoryBlock(1024)
  Var ReceiveHeader As New MemoryBlock(8)
  
  Var RecvLength As UInt32 = buffer.Size
  card.Transmit(header, command, command.Size, ReceiveHeader, buffer, RecvLength)
  
  If RecvLength = 0 Then Return ""
  // no length returned. So, no CardID passed back.

  Var id As String
  id = buffer.StringValue(0, RecvLength, Encodings.UTF8)
  
  Var info As String
  info = toHexString(id, IncludeColon, 2) // last parameter trims the 2 result / status bytes.
    
  Var code As Integer = card.Lasterror
  Var hCode As String = Hex(code)
   //  The hCode is for convenience only, it makes it easier to lookup the errorcode in the documentation I found online. 
  
  Return info
End Function

Private Function toHexString(mb as MemoryBlock, IncludeColon as Boolean = False, trimTail as Integer = 0) As String
  If mb = Nil Then Return "" 
  
   Var ss() As String
  Var h As String
  Var i As Integer
  
  For i = 0 To mb.Size-1 - trimTail
    h = "00" + mb.UInt8Value(i).ToHex.Uppercase
    ss.Add h.Right(2)
  Next
  
  Var sep As String = If(IncludeColon, ":", "")
  
  h = String.FromArray(ss, sep)
  Return h
End Function

So, when I need to get the actual cardID I use this:

Var CardID As String
CardID = GetID(myCard, True) // Returns: 04:23:91:DA:99:3D:80, in my case. Your ID will be different.
CardID = GetID(myCard, False) // Returns: 042391DA993D80

Some links I used to get the info I needed:

I used this tool to verify my UID