Write BYTES to MIFARE without trancoding to ASCII-HEX

why represent the data as ASCII strings ?

consider

// simulate MRFC interface
struct Mfrc {
    void MIFARE_Ultralight_Write (int i, byte *buf, int nByte )  {
        Serial.print ("MIFARE_Ultralight_Write: "); 
        for (int n = 0; n < nByte; n++)  {
            char s [20];
            sprintf (s, " 0x%02x", buf [n]);
            Serial.print (s);
        }
        Serial.println ();
    }
} mrfc522;

// -----------------------------------------------------------------------------
#define DATA_LEN    4
byte data [][DATA_LEN] = {
    { 0x11, 0xb7, 0x01, 0xe0 },
    { 0xbd, 0xb8, 0xb0, 0xd7 },
    { 0x76, 0xf2, 0xc5, 0x20 },
    { 0xc9, 0x74, 0x8a, 0xde },
    { 0x57, 0xc1, 0xbe, 0x9a },
};
#define N_DATA      (sizeof(data)/DATA_LEN)

// -----------------------------------------------------------------------------
void
setup (void)
{
    Serial.begin (9600);

    for (unsigned n = 0; n < N_DATA; n++)
        mrfc522.MIFARE_Ultralight_Write (n, & data [n][0], DATA_LEN);
        
}

// -----------------------------------------------------------------------------
void
loop (void)
{
}
1 Like