Hi all,
I am developing a hardware combination that is based on an Android as a USB slave device and some specific hardware as a USB host (http://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_Vinco.pdf), connected by a host/slave USB cable. I do not want OTG, because this is not reliably available before Android V4.
(To answer some answers upfront: due to restrictions on certification a cable based connection must be used, Wifi or Bluetooth is a no-go.)
The whole setup works together with a java application on the Android and some firmware in the host board. It seems as if a tunnel is opened over USB.
A serversocket server is opened on the Android device port 1337 and traffic is handled through this server.
Also USB debugging needs to be enabled. i.e. at the very low level the basic adb interface is used. It is claimed that the technique works on every device since Android V1.6, so it is indeed a very basic and attractive method.
As my java skills do not allow me to continue developing in that language I would like to continue exploring a way to use B4A for further developments. However, I would demand to understand how things work in general.
Has anybody got an idea and can hint me to more basic understanding of the mechanics of such an interface and the best way to replicate this by B4A? (I have the java sources of the application, but except for opening of the serversocket they do not tell me about the underlying low level stuff)
Thank you
Andy
Basic connection code from inside a device java application
I am developing a hardware combination that is based on an Android as a USB slave device and some specific hardware as a USB host (http://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_Vinco.pdf), connected by a host/slave USB cable. I do not want OTG, because this is not reliably available before Android V4.
(To answer some answers upfront: due to restrictions on certification a cable based connection must be used, Wifi or Bluetooth is a no-go.)
The whole setup works together with a java application on the Android and some firmware in the host board. It seems as if a tunnel is opened over USB.
A serversocket server is opened on the Android device port 1337 and traffic is handled through this server.
Also USB debugging needs to be enabled. i.e. at the very low level the basic adb interface is used. It is claimed that the technique works on every device since Android V1.6, so it is indeed a very basic and attractive method.
As my java skills do not allow me to continue developing in that language I would like to continue exploring a way to use B4A for further developments. However, I would demand to understand how things work in general.
Has anybody got an idea and can hint me to more basic understanding of the mechanics of such an interface and the best way to replicate this by B4A? (I have the java sources of the application, but except for opening of the serversocket they do not tell me about the underlying low level stuff)
Thank you
Andy
Basic connection code from inside a device java application
B4X:
try
{
//Create new server
ServerSocket socket = new ServerSocket(1337);
//Wait until the andropodInterface is connected
Socket andropodInterface = socket.accept();
//Open streams
PrintReader in = new BufferedReader(new InputStreamReader(andropodInterface.getInputStream()));
PrintWriter out = new PrintWriter(andropodInterface.getOutputStream(), true);
//Write what you want to write
out.println("Hello Androdpod!");
//Read what you want to read ;-)
string message = in.readln();
}
catch (IOException e)
{
//Something went really wrong
}