I would like to connect Raspberry Pi running Android things with Arduino Nano by I2C. The official Android documentation says:
Managing the slave device connection
Is there a way to act Arduino as a master and Raspberry with Android things to act as a slave?
On Arduino side there is onRequest or onReceive callbacks available with Wire library but I don't se any callbacks with Peripherial I/O API on Android side.
Is there any solution or just use on Android side a simple loop to read from Arduino register regardless if there is a change or not. Thanks
Is there any solution or just use on Android side a simple loop to read from Arduino register regardless if there is a change or not.
You could setup a GPIO connection between the two
https://developer.android.com/things/sdk/pio/gpio.html#input-state
Have the arduino "ping" the AndroidThings board when it has data to read.
Then the AndroidThings board can use I2C to read at that point https://developer.android.com/things/reference/com/google/android/things/pio/I2cDevice.html#read(byte[],%20int)
(better than having a polling loop)