Closed sreekants closed 2 years ago
Unfortunately, I couldn't address this issue in a timely manner because I haven't been working with the ESP32 ever since. In this meantime, I2C Slave support has been added to the official ESP32 framework as you can see in the updated README of this repo. Therefore this library is no longer needed and its development will be ceased.
I am looking at how the WireSlave.onRequest() method is implemented. The function accepts a callback and I was hoping to pass some context variable to the (say an opaque pointer) callback. As the callback has no argument, the only way to pass a variable to it is through a global variable. It can be done, but this would be bad design practice, particularly in a multi-threaded environment.
There are three ways to fix this:
` int readSlaveBuffer( uint8_t *data, size_t max_size, TickType_t ticks_to_wait=1 ) { return i2c_slave_read_buffer(portNum, data, max_size, ticks_to_wait ); }
int writeSlaveBuffer( const uint8_t *data, size_t size, TickType_t ticks_to_wait=0, bool reset_fifo=true ) { if( reset_fifo ) i2c_reset_tx_fifo(portNum); return i2c_slave_write_buffer(portNum, data, size, ticks_to_wait); } `