-
Notifications
You must be signed in to change notification settings - Fork 12
Using Driver skeleton on ADK side
Once adk-aoa-skeleton module is loaded and connected device got probed you can use appropriate ioctl/sysfs operations(example code in ioctl-for-init/adk-ioctl.c) from userspace for initialization of device in accessory mode. For the sake of ease sysfs operations are added to this module to initialize using simple shell commands, without the need of c program to use ioctl or any cross compilation.So scripts based on these sysfs operations can work independent of platform. Also you can pass the module parameter init_on_probe=1 to initialize device in AOA mode using default identity strings without the need for ioctl or sysfs operations for initial testing. Here is an example to query protocol,send identification and starting in accessory mode.
cat /sys/kernel/adk_linux/aoa_init/version
echo "manufacturer=Google, Inc." > /sys/kernel/adk_linux/aoa_init/identity
echo "mode=DemoKit" > /sys/kernel/adk_linux/aoa_init/identity
echo "version=2.0" > /sys/kernel/adk_linux/aoa_init/identity
you can send other strings in same way
echo "audio" > /sys/kernel/adk_linux/aoa_init/start
echo "accessory" > /sys/kernel/adk_linux/aoa_init/start
Upon ioctl/sysfs/init_on_probe operations your android device reenumerates to an unified configuration as per android open accessory protocol specifications.Few details are listed here. vendor id=0x18d1, product id in the range of 0x2d00 to 0x2d05 interface 0 with two bulk end points if started in custom accessory mode
Please consider this code as skeleton/reference only at moment as it requires lot of improvements in terms of synchronization,efficiency,ease of use etc especially in terms of read,write operations in accessory mode after initialization
Using adk-aoa-skeleton module and appropriate userspace code (aoa-read-dump or any other examples) you can establish communication between android device and linux machine using simple file operations like open,read,write,close thru system calls in C or any file handling API from other languages.
fd=open("/dev/aoa-skel0",O_RDWR);
To send data from ADK to App
k=write(fd,buf,len);
To read data from App to ADK,suitably in an additional thread
k=read(fd,buf,len);
Towards the end
close(fd);