I am aiming to be able to send a small chunk of data from a USB accessory to an Android phone, after the accessory is enumerated (in other words, on connection). The USB accessory is a charger which we will be designing.
As I understand:
The USB host is the one enumerating the devices, so that would have to be the Android device. But could the USB master be the one consuming the power?
If not, then if the Android device is acting as an accessory, could it be the one polling data?
If so, am I actually using USB OTG or not?
Would the accessory need to comply with Android Open Accessory specification to do such a thing?
Since it is sending the data on connection, I wouldn't be going into charging + sending data issue, right?
References I've been reading:
https://developer.android.com/guide/topics/connectivity/usb/index.html
https://developer.android.com/guide/topics/connectivity/usb/accessory.html
https://developer.android.com/guide/topics/connectivity/usb/host.html
Related
Basically I need to build an APP to communicate between two android devices, send and receive data, in the safest way without Internet.
I could use WiFi, but they are prone to hacks and Jamming. My first question is
if Local WiFi Hot Spot connection could be made fully secured to public?
I am looking into wired communication between android devices using OTG USB serial communication. My second question is
Are there ways to communicate between android devices over OTG-USB using serial ports?
As Android supports both USB gadget and USB host interface, it is definitely possible to make communication between two devices over USB OTG. In this case, your one device will become USB Host which will initiate connection. And the other will become USB gadget device. And you will have to write application considering that.
I'm trying to figure out how to connect two Android powered devices,
namely a smartphone (Android 4.1.2) and an android developer
board (Android 4.0.4) with apps running on each, via USB and get them
to communicate with each other.
Right now the developer board is running as the host and the phone as
an accessory. The hosts app is searching for connected devices and is
able to identify the phone as a device, but the app running on the
phone isn't able to find the host.
I've searched the web for quite a while now (!!) but I didn't come
up with anything helpful yet that solved my problem.
For my project it is crucial that I use an USB connection, so please
don't propose that I use bluetooth, WiFi, or anything else...
Regards
USB is host initiated, so it's not surprising that this is not working. Your device that is functioning as the USB device should respond to requests initiated from the USB host. You will probably have to create some sort of vendor specific protocol around this. I don't know what you are trying to do with this connection, but if the device needs to know things on the host you will need to bake this in to your protocol definition and send that information directly to the device.
What you could try doing is using both devices as a host and connecting a USB to UART bridge device between them, then you can transmit data generically in any direction by using the serial connection (through USBManager if the USB protocol is available, or some Android Java Serial class if it is not), plus you don't have to worry about the host-device connection. This would look something like this:
[Android 4.1.2 Device]<--USB Connection-->[USB to UART Bridge]<--Serial Connection-->[USB to UART Bridge]<--USB Connection-->[Android 4.0.4 Device].
Use OTG Cable to interact with your board and phone. Its easily available in the market.
Using Arduino I can get the sensor values logged into the serial monitor over the USB cable...
Is there any way that I can read these values directly on an android tablet by connecting a usb convertor(So that I can tramnsmitt it via GPRS to a server Db)...Please give my some solid directions...
You can do it wired if you use a FT232 or CP2102 converter. Here are a couple apps on the Google Play store that act as a serial monitor.
USB Serial Terminal
Slick USB Serial Terminal
One thing to note is that wired USB communication with Android is not very common, so you may run into some problems depending on the phone you are using. If you want a more guaranteed solution, look into an Arduino Bluetooth module that supports SPP - Serial Port Profile. You can connect the Arduino's RX/TX pins to the Bluetooth module, and have it communicate with the Android device over a wireless Bluetooth serial connection.
Also, here is a similar question on SO, however the answer may have outdated information regarding using the wired solution.
How to make Android and Arduino communicate without a wireless module
I just started looking into OAPavailable in android.I came accros few doubts
Is accessory mandatory my android phone/table for me to talk to an external device over usb?Cant I talk to my external hardware using normal usb mode?Accessory mode means the phone will always be USB device and my external device will be the USB host.My application in phone should be able to talk to the external hardware regardless whether its a host or a USB device
What exactly are the difference between a USB host and device? Is it just that who powers the bus?When two devices connect how the device say "hey i will be the host and u be the device?"
In short my aim is I want to create an application that can talk to a usb device connected regardless its a usb device or a usb host.Can I acheive it using UsbManager apis without depending on OAP of Android
If you want to be able to work in either situation, you will basically have to write two communication subsystems, one using the APIs appropriate for each case.
It will be the external device and cabling which determines which mode is active (though if the phone cannot be a host, the connection of something external which requires that will be ignored, meaning no communication).
I have to do an Android application that reads value via Bluetooth from a Bluetooth device connected to OBD-II port of a car.
I use the UUID SPP UUID 00001101-0000-1000-8000-00805F9B34FB .
If I create 4 threads that want to connect to the OBD-II device, 3 connect()s fail and only one thread is able to connect to the device.
Is there a way to connect more thread to an OBD-II device via Bluetooth?
I don't know if the elm-237 device is able to communicate with more threads.
I am not an expert on OBD/OBD-II, but I know a little on serial ports.
Actually, what you see does not surprise me at all. Serial-port devices usually must operate in exclusive mode, so only one actor can talk to them at a single point of time. There is totally no point in creating multiple threads for that - this will not make your serial port "talk faster", nor it will make the external device (OBD chip) respond faster! This is not a network! To talk to several devices in parallel, you'd need to have actual several cables - and probably also several chips.
ELM327 is the device in your OBD-2 cable. It mediates the communication between the chips in the car and your USB port and exposes a virtual serial port over USB bus. I never heard of any cheap Bluetooth-enabled ELM327 clones, but I know that there are OBD-II Bluetooth adapters - the last I've seen costed about $2000 as it was coming with a large diagnostic software and database of car parts(strike: see comments) and of course worked without any cables. But I think that still it would provide only 1 virtual serial port to talk with 1 device.