USB, Bluetooth unite for wireless printing

Many consumers replace their personal computers every few years but do not replace their printers. The USB printer dongle reference design described here combines Bluetooth technology with embedded USB host technology, bringing ad hoc wireless-printing capabilities to wired printers at a total bill of materials under $15. It allows any printer that has a standard USB port to talk to computers that are equipped with Bluetooth and the Microsoft Windows XP operating system.

The advantages to such a scheme are manifold. In an office environment, visitors can print to a Bluetooth printer without having to acquire a network password to log on to the office LAN. That prevents access to the company's confidential data. For the consumer, it brings the ability to print from anywhere in the house without having to switch on a PC.

A USB host is required on the printer side of this adapter design because the targeted legacy printers in the market implement a USB peripheral interface. A new technology called USB On-the-Go (OTG) provides host capability for standalone devices such as printers without the need for a host PC.

What is it?

The standard implementation of USB has proved to be an easy-to-use peripheral interface. The protocol was designed to use a single bus controller, typically a PC. Peripherals cannot use the bus unless the controller (the PC) grants them access. Even interrupts cannot happen on the bus unless the controller properly queries the peripherals on the bus.

In a PC environment, this approach works very well, but it precludes the opportunity for two peripherals to communicate with each other (peer to peer) using USB. Thus, in order to use your USB printer to print digital images from your (USB) camera, you would have to boot a PC, copy the pictures from the camera to the PC and then print the pictures from that computer. With USB OTG, a peripheral (such as a camera) can communicate directly with another peripheral (such as a printer) without the need for a PC.

The OTG specification ratified by the USB Implementers Forum Inc. provides a means for an OTG-enabled device to become a USB host-the role previously performed by a PC. Using OTG technology, it is possible to print directly from an OTG-enabled digital camera to a USB printer. You may also connect an OTG PDA with an OTG cell phone. An OTG dual-role device (DRD) can be either a host or a peripheral. Host and peripheral DRDs can even swap roles using the Host Negotiation Protocol (HNP).

Embedded hosts

Nearly all desktop operating systems contain a USB host stack-the USB framework and drivers required for the OS to communicate with connected USB peripherals. Many embedded implementations lack that functionality, however, so a USB host stack must be created to provide embedded devices with the ability to act as a USB host.

A PC with a modern operating system may have hundreds or even thousands of USB drivers from which it can choose to provide support for a USB device. It is rarely feasible to support so wide a range of devices in embedded products because of the limited resources available. As a result, OTG specifies that a DRD must contain drivers for each device or class of devices that it is designed to support. This is called the Targeted Peripheral List (TPL) and will typically consist of a small number of device or class drivers.

When a USB peripheral is connected to an OTG device acting as the host, the OTG device will try to match a driver from its TPL. If a match is found, the device is enumerated and a session is started. If a match is not found, the device is not enumerated. (If the peripheral could not be enumerated and if the peripheral is also an OTG DRD, the devices will attempt to use HNP to switch roles dynamically.)

The Bluetooth/USB printer adapter discussed here provides the capability to print over the air to any USB printer that is printer-class compliant. The embedded system within the adapter must function as a USB host to the USB printer and convey data received by the Bluetooth radio to the printer. That implies that a USB framework with TPL functionality and USB printer-class drivers are running in the embedded system.

When the adapter is powered, the USB framework is initialized and waits for a USB peripheral to be connected. If the USB peripheral is a printer-class-compliant device, it will be enumerated and attached to a driver (using TPL) that implements the requirements of the printer-class specification. When the driver is initialized, it will establish communications with the Bluetooth radio. After that, any data that is received from the radio is sent to the attached printer using the USB printer-class protocol.

This USB printer dongle supports the Hardcopy Cable Replacement Profile (HCRP), a feature that includes, but is not limited to, printing and scanning any type of document near the 1-Mbit/second limits of Bluetooth. The HCRP is specialized for hard-copy applications and thus has some advantages over other, more generic profiles, such as the Serial Port Profile.

For example, HCRP supports an IEEE 1284 ID string, which is a transport-agnostic method for identifying a host driver; this allows the host to leverage existing solutions and extend them cleanly to include Bluetooth. The client queries the server's IEEE 1284 ID string to determine which driver needs to be loaded to talk to the server.

The data is rendered through the use of a driver on the client device such as HCRP, which resides within Microsoft's XP stack. There are other existing Bluetooth profiles that could be used for printing and scanning, but HCRP is specialized for hard-copy applications. It requires only a very thin layer of support code. It provides the appropriate mechanisms for the high data volume of printing and scanning, and it is implemented at L2CAP, which avoids the need for the higher layers of the Bluetooth stack (through RFCOMM).

Together with an external flash ROM containing the software stack compatible with Bluetooth, a Bluetooth single-chip radio, baseband and integrated microprocessor solution provides a fully compliant system for wireless data and voice communications. The HCRP, along with the necessary interface to the printer and all Bluetooth firmware functionality, resides in the flash memory on the Bluetooth chip.

There is no need to add the expense and complexity of another microcontroller, and all of the Bluetooth and print processing can be done on the chip. The design can be customized for various printers by leveraging features of the Bluetooth chip that allow the application code to interface with the Bluetooth stack without the need for requalification from the Bluetooth Special Interest Group.

To reduce the design cost for the USB printer dongle even further, the firmware can be ROM-coded into the chip, and additional features may be used to reduce the need for any RF components other than the antennas.

Legacy printers can now become Bluetooth-enabled simply by implementing the above techniques. Although Bluetooth printers are becoming more popular, this design will allow older printers to have a new lease on life. Additionally, this solution may be integrated into new printer designs to bring low-cost Bluetooth technology to these printers as well.