How to get data from external USB device to android application? - android

i need functionality like..connect android device to external usb device using RS232 interface.
also receiving / fetching data from external USB device to my application. this type functionality possible in android ? which step follows for this type of functionality ?

Not directly: however, this will probably let you do what you want.
http://www.sparkfun.com/products/10585
Its a combination USB host controller and Android API that uses the ADB protocol to pass data. Alternatively, you can also look at this:
http://code.google.com/p/microbridge/
Which needs an Arduino and doesn't appear to be that cleanly integrated but should also do what you want.

Related

Can an Android device pretend and connect as a Bluetooth controller?

Can an Android device pretend and connect as a Bluetooth controller?
Can Android devices connect as a device to, say, a PC and act as a gamepad or similar device?
Is it allowed and doable in code without root access?
I tried this code: Connect Bluetooth devices. But it can not get it to pair.
Short answer, yes.
I recommend looking at Google's example project on Bluetooth communication BlueToothChat initially. Based on what you've written, I think you're missing several important steps.
You need all of the following components / steps:
General Overview
Set up Bluetooth
Set Permissions
Scan for other Bluetooth devices
Query the local Bluetooth adapter for paired Bluetooth devices
Connect to a remote device as client or server
Transfer data over Bluetooth
If you have access to the device your attempting work with as a controller, then you can create your own communication setup. Define a set of parameters to write and read on both sides that emulate the functionality you're looking for.
If you do not have access to creating your own read/write setup, or you want to use standard interaction methods for the industry, then the best bet is the Bluetooth HID Device profile mentioned by #Morrison Chang.
The HID profile basically establish an industry standard of required device features, read/write formats, combinations of features equaling a controller type (ie: "this is a keyboard"), and data mappings for what read/write numbers mean on either side of the client / server connection.
From the linked comment thread, the Kontroller project on Github has source available for your peruse.
There's also a reasonable Intro to Bluetooth HID that covers some of the topics on what Bluetooth HID is actually doing.
Finally, also recommend looking at Google's own BluetoothHidDevice page.

Transfer data between android device over wifi

I want to send data (for an example it contains the information: name,address) from my app to another hotspot enabled android device using the same app and display the information in it. So, how do I transfer? If it is not possible please tell me if there any possible way to transfer data via WiFi. Since I am new, procedure with code help me a lot.
This is what you need. P2P communication can only by performed by devices that run android 4.0 and up.

Android reading data via USB & UART

I am student and currently working on a project for my university. I am trying to write an app which is capable of reading date by using the TUSB3410(http://www.ti.com/product/tusb3410) and its USB to connect it with the C2500(http://www.ti.com/product/cc2500) connected via UART. Something like USB to serial.
I can get information off the TUSB3140 like its vendor id or its endpoint so I can use the normal USB API. But it is rather tricky to receive the information of the cc2500. I don't know which methods I should use or which parameter are correct. So maybe you have an idea how the methods like controlTransfer() etc. should look like.
I hope you can help me with this problem!
I'm afraid the answer isn't quite as simple as all that.
According to the linked datasheet and associated documentation, the TUSB3410 is not a fixed function device. It's basically a USB device on one side, a UART on the other side, and an MCU applications processor in the middle. In order for that chip to do anything useful, it has to have a firmware application loaded into it to govern how the data moves from one side to the other. So you get to define in the firmware how the data moves through the USB (interrupt transfers, bulk transfers, etc.) and that will govern how an Android application interacts with it.
Also, the chip does not seem to support having its firmware burned in, it always loads the firmware externally from I2C EEPROM or from the USB Host. If your device setup does not already have the EEPROM on it, you will likely have a difficult time because the Android USB APIs don't really give your application access to the device during the enumeration process, which is when the firmware would need to be sent if downloaded from the Host. It also would require you to detect your device twice (once with the standard bootcode VID/PID, and once again after the firmware file takes over and the device reconnects to the bus).
If you are just looking for a simple embedded implementation to get UART, SPI, etc. data into an Android application, you are probably better off with something like the FTDI FT311, which implements the Open Accessory protocol and comes with library code to get you started on both sides of the equation: http://www.ftdichip.com/Products/ICs/FT311D.html
EDIT: From your comment
So if your device conforms to the CDC USB Device Class, then there are basically three points of interest:
Every device has an "endpoint 0" for configuration, and this is accessed in the Android APIs using the controlTransfer() method. CDC devices use this endpoint for changing items like baud rate, stop bits, etc.
CDC Devices like a VCP have two interfaces, one for communications and one for data. The data interface (usually enumerated second) has two bulk endpoints (one in and one out) where the serial data is usually transferred. You can transfer the data back and forth on those endpoints with the bulkTransfer() method, or using an asynchronous UsbRequest.
As a starting point, perhaps take a look at the source of this open source project, which implements CDC basics using the host APIs. You should be able to get a good idea of how to roll your own driver from there (specifically the CdcAcmSerialDriver):
http://code.google.com/p/usb-serial-for-android/
I think apart from the FT311D which is using the AOA protocol, you may also consider to use FT231X, via FT231X, you can use the APK of android hyperterminal which you can easily find in google search/ google play. This is using by OTG method. You may also have a look.

Bluetooth + simulating mouse

anyone know if its posible to make an application to simulate a touchscreen mouse or trackpad by bluetooth??
How can I make that the PC (or MAC) knows me as a mouse device?
Regards,
Juan
You should have a look at the Bluetooth HID specification. It may be possible, depending on the stack of the device that you are using to emulate a mouse/trackpad. I'm not familiar with the stack on Android (assuming that's the platform you're using from the tag on your question) so I don't know if it's possible from there.
Essentially, you create a HID service on the L2CAP protocol. The service record specifies the HID descriptors which describe the data being sent from emulating device. The HID driver on the host computer should be able to interpret that data.
It might be useful to try to connect to another Bluetooth mouse/trackpad from the desktop (Bluecove on a stack other than Microsoft is a good way to hack around in Bluetooth). Have a look at the service record for the HID service on the mouse/trackpad. Also, look at the data coming from the mouse/trackpad for an idea of what needs to be sent and when.
Alternatively, you could write a server application on your computer that communicates via another Bluetooth protocol (e.g., RFCOMM/SPP) to the input-device emulator app running on your phone. The server application would simulate the input device (e.g., move the mouse pointer around on the screen, etc).
Instead of creating your own project why dont you contribute to the remotedroid project?
I'm assuming you know your bluetooth api's well. Remote droid uses Wifi and OSC messaging to communicate with the PC.
Yes you may use GlovePie with the wiimote connected to BlueSoeil, It will alow you to do anything with you computer with the wiimote. It also has a Language it uses
I think you want this:
Serverless Bluetooth Keyboard & Mouse for PC/Phone
It's even open-source!
Unfortunately it is not open source, it just has a GitHub readme for some reason.
But still the app is quite good!

Transfer data between android devices

I have created an android app and would like to enable users to transfer data (e.g. over TCP). Both have my app installed. Is there any framework or guide how to use bluetooth and/or w-lan to get a good user experience? How do they initiate the connection?
Thanks!
I learned how to use Bluetooth on Android by this link, analysing the source code of the example.
About sending information through TCP/IP, use normal Java for that (Sockets, for example). The only extra you could put it is to send an Intent to activate Wireless if was not activated yet.

Categories

Resources