Having a hard time with the EEPROM NFC API

09 Jul 2019

I'm trying to edit the EEPROM NFC example here: https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-nfc-EEPROM/ in order to execute some custom logic. I want to be able, in the scope of other code happening in the main, to manually trigger reads and writes to the EEPROM in order to see if someone has written on it at certain points of the program, and to reset the value to a default one at other points.

As the docs explain very little of the whole workflow with queues and everything (I thought I understood after reading this: https://os.mbed.com/docs/mbed-os/v5.13/tutorials/the-eventqueue-api.html but the whole interaction with the NFCEEPROM class and its Delegate got me even more confused), I really don't get how to do something this simple.

If anyone could help I'd really appreciate it!

17 Jul 2019

Hi Giorno,

Not sure if I understand your question correctly. Basically, if you want to test read/write to EEPROM, you can add a test function under EEPROMExample and dispatch the event in main loop

class EEPROMExample : mbed::nfc::NFCEEPROM::Delegate
{
    ...
    void test_rw()
    {
        printf("test write/read\n");
        _queue.call(&_eeprom, &NFCEEPROM::write_ndef_message);
    }
}
...
int main()
{
    ...

    example.run();
    while (1) {
        queue.dispatch(1000);
        example.test_rw();
    }

    return 0;
}

Let me know if you have any questions.

Regards,

Desmond

You need to log in to post a reply