-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Host and Accessory communication(NOT AN ISSUE) #560
Comments
Does it sound like a USB hub in the Host machine? if I understand correctly, USB serial can only be one-to-one communication. https://forum.arduino.cc/t/connecting-to-multiple-serial-devices/348510/2 something like that I am buying. |
@Jai-GAY thanks for the prompt response. Actually I want to facilitate communication between 2 android phones, via USB-C cable using Android USB framework. Phone A will act as the host, and Phone B will act as the accessory. And I would like to share some kind of data, text/image from A to B and B to A. |
Have you come to the wrong place to find an answer? By the way, is your connecting cable a PD or OTG cable? Why you do not consider Bluetooth, wifi-direct, P2P connection, Google Drive, Onedrive, etc? |
I would expect that it should work if you use an OTG adapter, as this will switch the Android device in host mode. With USB-C to USB-C cable it unlikely will work |
ya, in the market seems like all are PD cable only. |
@Jai-GAY |
@Jai-GAY I'm grateful for your help, but the Stack Overflow link you provided doesn't completely address my concerns, even though I'm dealing with the exact same scenario. |
you should try with combination of:
|
@kai-morich Thank you. I'll share the results here after testing. |
If FTDI USB NMC works on Android, you can communicate directly by treating it like a serial connection. If your smartphone supports Bluetooth, I recommend communicating via Bluetooth. |
If you want to use Android Open Accessory, you need to emulate USB Accessory, but it seems to be close to impossible due to Android security. |
@ckdo8008 thanks for your input, I have develop an App using where I have 2 android phones connected via wire(USB-C to USB-C cable). Connection is established, but when I try to send data from 1 phone to other, the connection gets loss. And I am facing the same issue while using usb-serial-for-android. |
I'm sorry. I tested it. It communicates via OTG. It seems that you need to communicate using controlTransfer or bulkTransfer in file transfer mode. The current library is a serial communication library, so it doesn't seem to be usable. (There is no information on file transfer modes, etc. for compatible devices.) |
If you use developer mode, various approaches are possible by using libraries that implement ADB. |
@kai-morich as I said I'll be sharing the results here, so nothing worked for me. I tried the both ways:
|
@ckdo8008 thanks for sharing your findings/results here. Can you plz tell did you test it between 2 android phones? BTW, I had tried it using OTG, connectivity did happen but the bulktransfer did not happen. get devices, request permission, open device As on one device I'm using the following code to send the data as a UsbHost
and on the other device:
Receiving logic is like
And
|
First of all, I am developing on Android 11 or higher. SDK uses 34. It seems difficult to bypass Android's MTP service in the MTP method. If you do not like the IPC communication method using files, you can set it to Midi and process send and receive through MidiReceiver. |
I'm encountering difficulties establishing communication between two Android devices, where one is designated as the host and the other as the accessory. I attempted to utilize the usb-serial-for-android library on one device and connected the two devices using a wired connection. However, I'm facing issues in establishing a connection and facilitating communication between the devices.
The text was updated successfully, but these errors were encountered: