Modifying data for an rfid reader

Good afternoon, I consult you: I have associated with a nodemcu an RFID card reader and I have in the sketch the id of the cards that must authenticate. Now if I lose a card, can I modify the id of the cards through this IOT environment?

HI @Lucas19906, yes, you can modify any value from your sketch. I have tried a very basic example that seems to work by using arrays.

#define MAX_CARDS 5
#define CARD_ID_LENGTH 20
// create some dummy cards
char auth_cards[MAX_CARDS][CARD_ID_LENGTH] = {"12345678904",
                                                "d1234567892",
                                                "d1234567899"
                                                };

void setup(){
    // your normal setup code

    thing["auth_cards"] << [](pson& in){
        // provide current auth devices
        if(in.is_empty()){
            pson_array& array = in;
            for(int i=0; i<MAX_CARDS; i++){
                array.add((const char*)auth_cards[i]);
            }
        // update current cards
        }else if(in.is_array()){
            pson_array& array = in;
            for(int i=0; i<array.size() && i<MAX_CARDS; i++) {
                const char *card_id = (const char *) *array[i];
                if(strlen(card_id)>CARD_ID_LENGTH) continue;
                strcpy(auth_cards[i], card_id);
            }
        }
    };
}

void loop(){
    // your normal loop
}

With this code, you should be able to see a new resource in your Device API Explorer, where you can see and modify current authorized cards. Something like:

If your devices goes off, this information will be lost, so it may be worth to store the information in the eprom or something similar, so it can be reinitialized after reboot.

Hope it helps!

Muchas gracias por la info. Me sirvió mucho. Saludos

Buenos dias, con respecto al codigo, lo pude utilizar correctamente para actualizar los datos de las tarjetas en la memoria eprom.
Pero ahora estoy intentado realizar la autenticacion y me encuentro con el hecho de que para realizar la misma, debo utilizar números hexadecimales.
¿Tendrías algún código que me facilite ingresar datos hexadecimales en vez de chars(o strings)?

Gracias

Good morning, regarding the code, I could use it correctly to update the data of the cards in eprom memory.
But now I am trying to authenticate and I find the fact that to perform the same, I must use hexadecimal numbers.
Would you have some code that would allow me to enter hexadecimal data instead of characters (or strings)?

Thank you