Chrome, HTML5, webdev

New USB API & Bluetooth API In Chrome/ChromeOS

It seems that we are going to have some powerful new APIs on ChromeOS and Chrome in the future. From looking at chromium site last month I’ve saw two new interesting proposal to new APIs that will make Chrome (even) better. The ability to ‘talk’ with hardware and external devices is very important and until today the way to do it (from a web app) was by using network. So there was no (real good) option to communicate with hardware and external accessories that do not support network (e.g Wi-Fi). These two new APIs are going to allow web developers with more power to build amazing apps that communicate with external devices. Think, smart watches, GPSs, robots, Lego cars (my kids will love it!) etc’.


The USB API aims to provide access to fundamental low-level USB operations from within the context of an extension. Some use cases that might come to mind: GPS, Watch, mobile phone or any other devices which require third-party drivers to work. One of the use cases for this API would be to provide the ability for a Chrome extension to function as a device driver and allow previously new devices to be used – is it cool or what? just think on the ‘old’ days where if you needed to talk with your specific hardware you were locked to write you native application for windows, mac and linux (and more if your users are there). In the new world, you will be able to write it once and run it everywhere… (where have we heard this sentence before? back in the 90s? Some technology that start with J?) One big question is if/when we could see this API being part of the web platform. I don’t really know. However, I do hope it will.

The APIs functions:

  • Locates an instance of the device specified by its vendor and product identifier - chrome.experimental.usb.findDevice(
    integer context,
    integer vendorId,
    integer productId,
    function callback)
  • Performs a USB bulk transfer to the specified device - chrome.experimental.usb.bulkTransfer(integer device,
    string direction,
    integer endpoint,
    string data,
    function callback) 
  • Close a USB device handle - chrome.experimental.usb.closeDevice(integer device,
    undefined callback)
  • Performs a USB control transfer to the specified device - chrome.experimental.usb.controlTransfer(integer device,
    string direction,
    string recipient,
    string type,
    integer request,
    integer value,
    integer index,
    string data,
    function callback)
  • Creates a USB context by which devices may be found - chrome.experimental.usb.createContext(function callback)
  • Disposes of a context that is no longer needed. It is not necessary that this call be made at all, unless you want to explicitly free the resources associated with a context - chrome.experimental.usb.destroyContext(integer context)
  • Performs a USB interrupt transfer to the specified device - chrome.experimental.usb.interruptTransfer(integer device,
    string direction,
    integer endpoint,
    string data,
    function callback)

* This API proposal was on March 7th, 2012. For more details check this proposal. After all we are dealing here with an open source project.

Bluetooth API

A bluetooth API that is on par with the Android and iOS APIs. Version 1 will support basic RFCOMM communication. Profile support will be left for a future version. As for the most common use cases we can think on anything that you are doing today on your mobile device (e.g. headset, stream video/audio etc’). One important aspects to pay attention (just like on mobile devices) will be to see how intensive the bluetooth API is in terms of making your battery drain.

The APIs functions:

  • Accept incoming bluetooth connections by advertising as a service - chrome.experimental.bluetooth.acceptConnections(string uuid,
    string service_name,
    string service_description,
    function callback)
  • Connect to a service on a bluetooth device - chrome.experimental.bluetooth.connect(BluetoothDevice device,
    string uuid,
    function callback)
  • Close the bluetooth connection specified by socket - chrome.experimental.bluetooth.disconnect(BluetoothSocket socket, function callback)
  • Get the bluetooth address of the system - chrome.experimental.bluetooth.getBluetoothAddress(function callback)
  • Request a list of bluetooth devices that support service - chrome.experimental.bluetooth.getDevicesWithService(string service_uuid,
    function callback)
  • Get the local Out of Band Pairing data - chrome.experimental.bluetooth.getOutOfBandPairingData(function callback)
  • Check if this extension has access to bluetooth - chrome.experimental.bluetooth.isBluetoothCapable(function callback)
  • Check if the bluetooth adapter has power - chrome.experimental.bluetooth.isBluetoothPowered(function callback)
  • Read data from a bluetooth connection - socket,
    function callback)
  • Set the Out of Band Pairing data for the bluetooth device at bluetooth_address - chrome.experimental.bluetooth.setOutOfBandPairingData(string bluetooth_address, array of ArrayBuffer data,function callback)
  • Write data to a bluetooth connection - chrome.experimental.bluetooth.write(BluetoothSocket socket, ArrayBuffer data, function callback)
  • Fired when the availability of bluetooth on the system changes - chrome.experimental.bluetooth.onBluetoothAvailabilityChange.addListener(function(boolean available) {...your code...});
  • Fired when the powered state of bluetooth on the system changes - chrome.experimental.bluetooth.onBluetoothPoweredChange.addListener(function(boolean powered) {...your code...});

* This API proposal was on March 7th, 2012. More details can be found in the original proposal.

I know few startups that are waiting for these APIs that they would love to built interesting apps to use them. It’s going to be very interesting to see what new smart-watches, GPSs, Mobile devices etc’ will do with these APIs. Be strong & happy.


4 thoughts on “New USB API & Bluetooth API In Chrome/ChromeOS

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s