I use the nfc reader and Im able to get the unique id of the tags. When I read the tag the id is called like this:
id: [ -52, 22, -61, -67, 80, 1, 4, -32, [length]: 8 ]
How can I get the hexadecimal one? It should be called CC:16:C3:BD:50:01:04:E0. That's also the way I will have database entries. So the way I get the id back is somehow useless for me.
I will appreciate any helpful answer. Thank you in advance.
The range of byte is -128 to 127
e.g. For Java https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
"byte: The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive)."
You just need to convert that to display as a String as Hex.
Usually According to ISO/IEC 14443-3 the UID is a 7 byte Number with byte 4 being part of the check bytes
I don't know how to convert bytes to string in Nativescript but in Java you can do
StringBuilder Uid = new StringBuilder();
for (int i = 0; i < result.length; i++) {
// byte 4 is a check byte
if (i == 3) continue;
Uid.append(String.format("%02X ", result[i]));
}
While skipping the check byte is not totally needed to give you an unique ID this code does it.
For JavaScript How to convert hex string into a bytes array, and a bytes array in the hex string? should provide the answer with a similar iterate over the array converting each byte to hex string