Featured EventsOther

Using WebBluetooth and WebUSB for POS Hardware Integration

3 min read

Next week, I have the privilege of being a presenter at the Commit Conference in Madrid, a summit dedicated to all aspects of IT and software development. The topic I am presenting is very important for us because it is closely related with one of the challenges we face every day to provide our customers with a rich and full-featured POS application: interoperability with the hardware required in a POS solution.

So one of the capabilities of Openbravo WebPOS is to communicate with different types of hardware, such as receipt printers, customer displays, scales, payment devices, etc. But when it comes to a web application, the communication with the hardware is a lot more complicated.

For example, receipt printers and scales are usually connected via USB or serial port, some payment devices are connected via network sockets… And unfortunately, web browsers do not provide direct access to the hardware layer.

For this reason, we created the Openbravo Hardware Manager, a Java application with an embedded web server that provides an API that can be consumed by Openbravo WebPOS. The Openbravo Hardware Manager can work with a wide range of devices, it is extensible, and it allows us to provide a fully featured POS application that fulfills our customer requirements all around the world.

We have taken care to keep the Openbravo Hardware Manager as isolated and small as possible, so that the business logic that goes into the Openbravo WebPOS and the Openbravo Hardware Manager is only responsible for: a) communicating with the hardware, and b) isolating the various models supported. But it is still another piece of software we have to install in every POS system that runs Openbravo WebPOS, which adds complexity to the deployment and maintenance of the solution.

Fortunately, web browsers are improving day by day. Nowadays Google Chrome supports Bluetooth and USB through the new Javascript APIs WebBluetooth and WebUSB. And so now Openbravo WebPOS supports receipt printers by connecting with WebBluetooth and WebUSB, starting with Version 3.0RR19Q3. This new functionality is the perfect solution to eliminate the need for installing the Openbravo Hardware Manager and to offer a pure web application, and it also extends the capabilities of Openbravo WebPOS. 

Now we can offer a complete mobile solution and print receipts using a portable bluetooth receipt printer from Openbravo Web POS running on an Android device, as you can see in the image below.

Going into the technical details, currently WebBluetooth (https://webbluetoothcg.github.io/web-bluetooth/) and WebUSB (https://wicg.github.io/webusb/) specifications are in draft status and it is supported by Google Chrome and Opera, but it is planned other browsers will support them in the future (https://caniuse.com/#feat=web-bluetooth, https://caniuse.com/#feat=webusb). 

For security reasons, both API are HTTPS only, which means it is available only to secure contexts. Also for security reasons, the request of a device connection must be triggered by a user gesture such as a touch or a mouse click. And both API are asynchronous and rely heavily on Javascript Promises. If you want to play with this functionality and inspect the code, we published a small project in GitHub that can print formatted documents to receipt printers .(https://adrianromeroopenbravo.github.io/webhardware/)

In this example we use the protocol ESC/POS (https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=2). This protocol is an Epson Standard Code for receipt printers that is widely used not only by Epson but also by other receipt printer manufacturers. The printers used for this example are the Epson TM-T88V using WebUSB and the POS-5802DD using WebBluetooth. 

Epson TM-T88V

The Commit Conference will be taking place November 22-23 2019 in Madrid. If you would like to know more about this topic, I will be presenting my topic, “Las aplicaciones web y el hardware también pueden llevarse bien” on November 22 at 18:00 at Track 8 . To learn more about Openbravo’s flexible and cost-effective technology platform for retailers and restaurants, please visit our website, www.openbravo.com