Android USB to work

https://github.com/appsinthesky/Kotlin-Serial-Usb/blob/master/app/src/main/java/com/appsinthesky/kotlinusb/MainActivity.kt
https://www.youtube.com/watch?v=ICjjG1VsZmw&list=TLPQMTMwMzIwMjTr9nsg2XojwA&index=1
https://github.com/felHR85/UsbSerial
https://github.com/felHR85/UsbSerial/wiki/6.-InputStream-and-OutputStream-I-O
https://github.com/appsinthesky/Kotlin-Serial-Usb/blob/master/app/src/main/java/com/appsinthesky/kotlinusb/MainActivity.kt

https://code.google.com/archive/p/android-serialport-api/

https://github.com/cepr/android-serialport-api
https://github.com/xmaihh/Android-Serialport/blob/master/README_EN.md

https://github.com/mik3y/usb-serial-for-android

https://github.com/xmaihh/Android-Serialport/tree/master

https://stackoverflow.com/questions/11011515/how-to-read-and-write-data-to-com-serial-ports-in-android

https://stackoverflow.com/questions/4621580/using-serial-port-rs-232-in-android

https://developer.android.com/guide/topics/connectivity/usb/host.html

https://stackoverflow.com/questions/11011515/how-to-read-and-write-data-to-com-serial-ports-in-android

https://github.com/licheedev/Android-SerialPort-Tool

OTG controller detects the state the USB’s fifth pin(ID pin). If the ID-pin is grounded or floating, the connected device is a Host or device.

USB 2.0 spec introduced 3 new protocols, ADP, SRP, HNP. Pls reference HNP for “a way to programmatically switch from host to slave mode and vice versa”.

Android USB Host Mode and USB Accessory Mode are two important features of the Android operating system that allow Android devices to interact with external USB devices.

  1. USB Host Mode:
    • Definition: USB Host Mode enables an Android device to act as a host or controller for other USB devices. In this mode, the Android device takes on the role of the primary controller, powering and managing the connected USB peripherals.
    • Usage: This mode is commonly used when you want to connect USB peripherals such as keyboards, mice, USB flash drives, or external hard drives to your Android device. The Android device can communicate with and control these peripherals.
    • Implementation: Developers can access USB Host Mode through the Android USB Host API. They can use this API to enumerate and communicate with connected USB devices.
  2. USB Accessory Mode:
    • Definition: USB Accessory Mode allows an Android device to act as a peripheral device or accessory when connected to a host device. In this mode, the Android device provides specific functions or services to the host, rather than controlling other devices.
    • Usage: USB Accessory Mode is often used in scenarios where you want your Android device to offer specific functionalities to a host device, like a computer. For example, when you connect your Android smartphone to a computer via USB, it might enter accessory mode to enable file transfer, tethering, or other functions.
    • Implementation: Developers can implement USB Accessory Mode using the Android USB Accessory API. They can specify how the Android device should behave when connected to a host and define the communication protocols for the accessory mode.

In summary, USB Host Mode allows your Android device to control and communicate with external USB devices, while USB Accessory Mode allows your Android device to act as a peripheral and offer specific functions to a host device. These modes extend the versatility and utility of Android devices by enabling them to interact with a wide range of USB peripherals and host devices.

By navalkishorjha