thanks! appreciate the help and i found this library that makes the change super simple
// A test byte buffer as provided by the user manual of the WL-134A reader
byte buffer[30] = {0x02, 0x31, 0x37, 0x31, 0x41, 0x39, 0x32, 0x35, 0x33, 0x41, 0x33, 0x34, 0x38, 0x33, 0x30, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x07, 0xf8, 0x03};
byte b;
uint8_t idx;
boolean started = false;
#include <Int64String.h>
byte XOR;
byte inverted;
uint64_t value;
void setup() {
// Initialize serial communication at 9600 baud
Serial.begin(9600);
delay(5000);
Serial.println("start:");
}
void loop() {
// Print the contents of the buffer to Serial Monitor for verification
for (int i = 0; i < sizeof(buffer); i++) {
Serial.print(buffer[i], HEX);
Serial.print(" ");
}
Serial.println();
// Check we received the message ok. XOR checksum on bytes 01-26 should match byte 27.
XOR = buffer[1];
for (int x = 2; x <= 26; x++)
{
XOR ^= buffer[x];
}
Serial.print("Calculated checksum: ");
Serial.print(XOR, HEX);
if (XOR == buffer[27])
Serial.println(" (Correct)");
else
Serial.println(" (Error)");
// Check the inverted XOR checksum
inverted = ~XOR;
Serial.print("Inverted checksum: ");
Serial.print(inverted, HEX);
if (inverted == buffer[28])
Serial.println(" (Correct)");
else
Serial.println(" (Error)");
// Extract the card number from bytes 01 (LSB) - 10 (MSB).
value = 0;
for (int x = 10; x >= 1; x--)
{
if(buffer[x] <= '9')
value = (value<<4) + buffer[x] - '0';
else
value = (value<<4) + buffer[x] - '7';
}
Serial.print("Card number: ");
//Serial.println(value);
Serial.println(int64String(value));
// Extract the country number from bytes 11 (LSB) - 14 (MSB).
value = 0;
for (int x = 14; x >= 11; x--)
{
if(buffer[x] <= '9')
value = (value<<4) + buffer[x] - '0';
else
value = (value<<4) + buffer[x] - '7';
}
Serial.print("Country number: ");
//Serial.println(value);
Serial.println(int64String(value));
// Extract the Data Block from byte 15.
Serial.print("Data block: ");
Serial.println(buffer[15] - '0');
// Extract the Animal Flag from byte 16.
Serial.print("Animal flag: ");
Serial.println(buffer[16] - '0');
Serial.println("\r");
delay(5000);
}