Very simple Android Open Accessory 1.0 library. Finds a device, toggles accessory mode and provides read
and write
functions.
This was written in a few minutes as a proof-of-concept so the code is terrible, sorry about that. Pull requests are welcome :)
First you need to get an Android device handle. Find them by providing a list of (vendor ID, product ID) tuples (you can find them using lsusb
):
dev = find_device([0x04e8, 0x6860)])
Next attempt to switch this device to accessory mode. You need to provide various info like manufacturer and model:
toggle_accessory_mode(dev, "Manufacturer", "Model", "Description", "1.0", "http://example.com", "SN-123-456-789")
This will cause the device to reconnect under a new USB id, you can find it again using find_accessory()
:
dev = find_accessory()
And that's it. Now you can read/write from the device:
data = read(dev, 1024)
write(dev, data)
Requires pyUSB package.