USB Host Mode Android

According to the USB (Universal Serial Bus) standard a device is classified as either a host or a peripheral device. In the most common scenarios the host, such as your PC, acts as a controller and the peripheral, such as a USB drive, responds to its commands. On-the-Go (OTG) is an extension to USB standard and is often referred to as USB OTG. The original host/peripheral model is maintained — however, what is new is the addition of a new class of devices that can function as either a host or peripheral and which are referred to as dual-role devices.

To enable an OTG connection an OTG cable is connected between two devices. An OTG cable typically has an OTG micro A-Type connector on one end, which connects to the host (e.g. Android device), and a standard USB connector on the other, which connects to the peripheral (e.g. RF Explorer device). When connected with an OTG cable, the initial host device is designated the A-Device (i.e. the Android device), with the initial peripheral designated the B-Device (i.e. the RF Explorer device).

To avoid potential conflicts regarding which device is host and which is peripheral, the assignment of which device is A or B is determined by the orientation of the OTG cable. This cable determines whether the signaling pin of the port it is plugged into is left floating or is pulled to ground. The device with the signaling pin pulled to ground is designated the A-Device, or default host, and the device with the floating signaling pin is designated the B-Device, or default peripheral.

USB ports on most Android smart phones and tablets sold today support OTG. What this means is that instead of your PC being the host and your phone being the peripheral, you can make your phone the host and connect other USB peripherals to it — e.g. RF Explorer. However, even though the Android OS and a particular device is capable of supporting USB Host Mode, some manufacturers and service providers have not enabled that feature by default. When that is the case the solution is fairly simple — to add a configuration file to the Android system files to enable USB Host Mode.

We have identified 3 requirements for an Android device to support USB Host Mode and be able to communicate with an RF Explorer handheld spectrum analyzer:

[1] The Android device must be running version 4.1 (Jelly Bean) of the OS, or higher.
[2] The output power on the Android device’s USB port should be 5V.
[3] The configuration file android.hardware.usb.host.xml must exist on the Android device in the folder /system/etc/permissions. The presence of this configuration file is what enables USB Host Mode on your Android device.

The output power requirement of 5V is rarely an issue except for certain very inexpensive Android devices. If USB Host Mode is not currently supported on your Android device it most likely is due to a missing android.hardware.usb.host.xml configuration file. We have developed a simple tool to help determine whether your Android device meets these requirements. The tool is free and is available from the Google Play Store: OTG Test For RF Explorer.

The Android OS is a customized flavor of linux that Google has modified to run as an embedded OS on phone and tablet hardware. Linux is a mature and secure operating system that requires certain permissions to make changes to system folders and files. There are two methods for adding a missing system file — (1) unlock the Android operating system — referred to as “rooting”, or (2) run Google’s adb.exe (Android Debug Bridge) tool on your Windows PC and copy the android.hardware.usb.host.xml configuration file to the /system/etc/permissions folder on the Android device. We prefer the latter method and provide instructions below for using adb.exe.

[1] Enable “Developer Options” on your Android device. This option is cleverly hidden, but if you know where to look then it is easy to enable. Look for the device’s “Build number” — often found under Settings / About device. After tapping the “Build number” 7 times, you will be notified you are a developer and Developer Options will be available under the Settings menu. And then, under Developer Options, make sure that “USB debugging” is checked.
[2] Using a standard USB cable, attach the Android device to a USB port on your Windows PC — do NOT use a USB hub. If Windows can find the device driver software for your Android device then it will load it. Below are examples from Device Manager that show the “ADB Interface” has been recognized by Windows. The latest versions of Windows can find and load adb drivers for most Android devices — but if it can not find one for yours then you will need to search Google for “android adb driver” and install the appropriate driver software for your Android device.

[3] Download the file install-adb.zip from our web site to your Windows PC, and unzip it into a new folder — e.g. C:\adb.

[4] From the command prompt, run the following adb commands:

* adb kill-server
* adb start-server
* adb usb
* adb devices
* adb remount
* adb push android.hardware.usb.host.xml /system/etc/permissions
* adb reboot

After rebooting then USB Host mode should be enabled and the Android device will be able to
communicate with an RF Explorer device — i.e. send commands and receive data. Please note it is most important to reboot after copying the XML file to the Android device. This is because Android checks for the
presence of this configuration file only during bootup. If the file exists during bootup then USB Host mode will be enabled — otherwise, it will not (even though the configuration file exists).

When you subsequently run an app like OTG Test For RF Explorer and attach an RF Explorer device via USB OTG cable then a permission request pops-up. You should press the ‘OK’ button. This request indicates the RF Explorer device was detected and USB Host Mode is working.

OTG Test For RF Explorer
Though a majority of the latest Android devices are distributed with USB Host Mode enabled by default — there are still many that are not. As long as your device is running version 4.1 (Jelly Bean) or later of the Android operating system, then USB Host Mode can be enabled by copying a configuration file to a system folder. If USB Host Mode is not currently enabled on your Android device, then please follow these instructions: Instructions to enable USB Host Mode
We have developed a simple tool to aid in determining whether a particular Android device is suitable for use with RF Explorer. The app is free and available from the Google Play Store.

We strongly encourage all customers to check-out this tool before purchasing the Touchstone Mobile software.

OTG Test For RF Explorer