Get vendor and product name from VID and PID in Android

Usb devices are identified by two 16-bit numbers known as VID and PID (Vendor id and Product Id). These keys are, among a lot of other things, an advantage of Usb over other vintage ports as serial ports. Unfortunately if you are developing an application which needs to show a readable information about devices attached to usb root hubs these keys are pretty cryptic and need to be decoded into human readable information.
During the development of DroidTerm I reach this problem because I am working on a Usb viewer of what is attached to Usb port. First I was looking for a beautiful REST API with its fancy methods and its json responses but I only could find The Usb Id repository which is a text file and nothing more. But It seems very complete and reasonably updated so there is no reason to moan.
I defined this features:
– Data should be stored locally using SQLite to avoid dependency on network.
– Local database should be updated when new devices were added to Usb Id Repository.
– All database operations should be encapsulated.
So I released this piece of code to fill my own requirements.
An example of how it works:

* Example of use
* @author: felhr (

// Clone all the files needed: git clone
// Permissions needed: <uses-permission android:name="android.permission.INTERNET" /> 

// There are some callbacks related with created, opened and updated database events. It is not necessary to use them.
private UsbDataProvider.UsbDbCallback mCallback = new UsbDataProvider.UsbDbCallback()
	public void onDbOpenedFirstTime(boolean status)
	// status == false means database could not be created due to an error fetching data from source
	// status == true means database was successfully created

	// Code here

	public void onDbOpened()
	// Database opened
	// Code here

	public void onDbUpdated(String newVersion)
	// Database updated with newVersion
	// Code here

UsbDataProvider dataProvider;
dataProvider = new UsbDataProvider(context, mCallback); // Create and open, open or update and open database if necessary. Notifications on callback
//dataProvider = new UsbDataProvider(context)

String vid = "03f0"; // Must be an hex representation of 16 bit number (0000-FFFF). Don't worry about uppercase or lowercase
String pid= "010C"; // Must be an hex representation of 16 bit number (0000-FFFF). Don't worry about uppercase or lowercase

UsbData data = dataProvider.lookup(vid, pid); // Returns null if vid or pid are not valid inputs or database could not be created
if(data != null)
	String vendorName = data.getVendorName(); // Vendor name
	String productName = data.getProductName(); // Product name

I hope you find this piece of code useful. Happy craft!


A little library to use Serial Port in Android


During my struggles with Bluetooth Low Energy (I have to write a burst of serious posts about this technology still in its infancy of opportunities but pretty promising) I had to deal with Bluetooth low energy modules and dongles made by Bluegiga. Bluegiga has made them pretty easy to use and it is possible to program them as a standalone bluetooth unit totally independent of where it is connected.

The problem arrives when you want to use this technology with Android devices. Android Bluetooth low energy support is relatively new (4.3) but there are a few capable devices of handling this connections. Most of them at this moment qualify as High-End Android phones or tablets.

There is another problem, Bluetooh low energy is a modern cool saving battery piece of engineering but It is not a best bluetooth. A simple example, if you want to stream data Do not use it, or use it at your own. In Android is worse, I compared data rate of Bluegiga modules and Android nexus 7 tablet and data rate was better in Bluegiga dongles. (I guess that is the prize of being far to the metal).

So I needed to connect my BLED112 Bluegiga dongles to Android as a Serial port devices, in order to do that I coded a little library to do it. I added support to CP210x USB to UART device. More devices must be added and some improves too, but I think it is not a bad piece of code and can get the job done.

It is not so asynchronous as I wanted (Read operations are asynchronous but write operations, if performed in a asynchronous way cause an awful bug involving Segmentation faults. This hideous bug was reported but It still there…

If you want to use it, just download the jar file from and added it to libs folder in your android project. Follow instructions to use it.

If you want to add something just let me know. Final device classes still shared code that could be moved to base class so I would rather refactor the code before adding new features.

Enjoy it!