0

I have Moto G4 Plus device. I have to do some stuff by enabling USB host mode on my device. I have enabled USB debugging and it is on charging. I am using USB cable. My device is non-rooted

enter image description here

It shows these option on click on "USB charging this device"

enter image description here

Does anyone have any idea how to do this?

1

1 Answer 1

4

As beeshyams pointed out in comments, the software doesn't control which endpoint is the host and which is the peripheral: the hardware itself controls it. On a phone that doesn't have a USB-A port, you use a USB-OTG cable or adapter. This has a "host end" and a "peripheral end". (On the early USB-OTG cables, it was hard to tell which is which, but on an adapter, the end that is a USB-A port is the peripheral end.) A resistor inside the plug tells the USB controller hardware on the phone whether to act as a host or a peripheral. When you plug the "host end" into the phone, it automatically acts as a host: no user input is needed. (That said, whatever app wants to use the connection or talk to a mass storage device will pop up a permission dialog.)

The options you show in your screenshot only take effect when the phone is in peripheral mode, so they're not related to your problem.

You say in your comments that you'd like to transfer data to a Windows PC, for example. That's not possible this way. Without extra hardware, a PC can only act as a USB host, which means the phone needs to act as the peripheral. To send arbitrary data this way (i.e. not acting as a filesystem), you'd need to write software on the phone using the USB Accessory API, and other software on the PC for the host side of the connection. This isn't a programming site, so we can't help you achieve this.

4
  • Thanks Dan! So in a communication one need to be host and rest need to be peripheral right ? Communication between host to host is not possible ?
    – Ajay S
    Jul 7, 2017 at 15:05
  • Yes, that's right.
    – Dan Hulme
    Jul 7, 2017 at 16:30
  • This is machine gi-de.com/en/products_and_solutions/products/… which runs on windows OS, I want to communicate with it from android app as a host. Is it possible ? What do you think that machine is device (peripheral) or host ?
    – Ajay S
    Jul 7, 2017 at 17:43
  • As I said, Windows PC's can only act as a host, not a peripheral.
    – Dan Hulme
    Jul 9, 2017 at 20:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .