Search code examples
androidusbstm32usbserialcdc

How to set Android USB in CDC mode as a device programatically?


I've implemented a USB Host CDC protocol structure on STM32L4 controller which I want to connect to an Android Phone. I want Android to run in Device Mode (Not in Host mode which UsbSerial library uses!) CDC class so that it's USB protocol Class Code can match to the STM32's USB Class Code but when I connect it phone my phone do not provide me any option as CDC/ACM. It only shows:

  1. Charging only. (Class Code: 0xFF)
  2. MTP. (Class Code: 0x8)
  3. PTP. (Class Code: 0x6)

So, is there any way I can switch Android to CDC as Device mode by writing an app?

Also, can implementing AOA protocol on my Host side solve this problem?


Solution

  • Yes In order to communicate with the host when android is acting as device mode you should implement AOA protocol on your host microcontroller to communicate with android phone. alternatively you can check for this option http://www.ftdichip.com/Products/ICs/FT311D.html