Mobile printing on HP printers with Bluetoothİ from Palm OS 5.0
Introduction
This document aims to provide some basics of using the Bluetooth technoloy for mobile printing, from a Palm handheld. Mobile printing techniques are introduced first, followed by a brief coverage of Bluetooth technology. Subsequently, features of the Bluetooth stack as it applies to PalmOs 5 are taken up. The discussion ends with sample code snippets that demonstrate communication with a Bluetooth enabled printer, such as certain HP Deskjets.
Mobile Printing Today
Mobile Printing is the term used for printing from mobile devices such as a Palm handheld, a laptop, a PocketPC or similar device, without cables and without complex printer drivers, and directed towards a printer in the vicinity. Mobile printing is essentially wireless printing.
Depending on the capabilities of the mobile device, and that of the printer, the following scenarios are possible:
- Printing via printer drivers
- Driver-less printing
Printer drivers
Printer drivers are printer-specific code, and not very suitable for smaller devices. They are useful in mobile devices like notebooks that run operating systems such as Windows and Linux. However, it is possible to address a whole family of printers (such as the DeskJet series from HP) using a monolithic driver built from toolkits such as the HP APDK.
While it is possible to have specific printer drivers loaded on devices such as a Palm handheld, this generally curtails mobility, restricting printing to those printers alone.
Driver-less printing
With mobile devices having smaller footprints of memory, display and other resources, driver-less printing is the method of choice. To support this, the following techniques are used:
- Dynamic Printer discovery
- Identification of document to print
- Sending a print stream to the printer
Dynamic printer discovery is possible using protocols such as Bluetooth, IrDA, UPnP, and through next generation print services on the LAN (WiFi) or WAN (cellular - GSM/GPRS/CDMA2000). In the latter case, a print service way be discovered on the local wireless LAN, or an ISP hosted service may be consulted, with the requests routed via a VPN to a corporate setting. This would result in a user selection from a choice of printers offered. As of this writing such protocols have been established and are being implemented (for details, see Printer Working Group at www.pwg.org).
Identifying the document to print could be accomplished in a number of ways. For devices such as a mobile phone, a URL is one option. For less heavy content, the document may be present on the device itself.
Sending a print stream to the printer after discovery can be done in the following ways:
- Send a URL to the printer. Printer can fetch the URL content, transform to a print stream (perhaps using another print service) and print
- Send the URL to a print service with printer description. Proper print stream formatting may be done by the print service. The resulting stream may be sent from the print service to the printer directly, or siphoned through the mobile device to the printer.
- Use a standard document format such as XHTML and send the stream to the printer
- Use a standard protocol such as IPP (Internet Printing Protocol), which is supported by many new printers.
- Use Generic Object Exchange formats used in printing address books, business cards etc. Many printers support this
Bluetoothİ Technology
Bluetoothİ Technology
The Bluetooth technology is an open specification for short-range wireless communication between electronic devices. It has become a standard for interconnecting small mobile devices in wireless world. Bluetooth specification is developed, published and promoted by Bluetooth Special Interest Group (SIG).
Bluetooth technology is used for Wireless Personal Area Networks (WPANs) with range around 10 m. It is a low-power short-range radio communication technology.
The characteristic of the technology offers lot of advantages as listed below:
- Low power requirement makes it ideal for small mobile devices, which run on battery.
- Low Cost makes it ideal for mobile device manufactures to built in Bluetooth support.
- Short Range of 10 m makes ideal for mobile users to connect to other mobile device in a room or adjacent room eliminating wired connection.
- Transmission speed of 800 kbps makes it good enough for transferring small to medium size files.
- 2.4 GHz ISM band enabling developing devices and solutions, which can work worldwide.
- Bluetooth Security, specification provides support for security at its core protocol level, includes authentication, encryption and secure link.
Bluetooth specification overview
Bluetooth Protocol Stack
The below diagram show the core building layers of the Bluetooth architecture.

Source www.palmos.com
Baseband
The baseband layer and the link control layer enable the physical Radio Frequency (RF) link between Bluetooth devices. Two kinds of physical links can be formed with their corresponding baseband packets: Synchronous Connection-Oriented (SCO) and Asynchronous Connectionless (ACL).
Link Manager Protocol (LMP)
The Link Manager Protocol is responsible for setting up the link between Bluetooth devices. This includes security aspects like authentication and encryption by generating, exchanging, and checking of link and encryption keys.
Logical Link Control and Adaptation Protocol (L2CAP)
L2CAP provides both connection-oriented and connectionless data services to the upper layer protocols with protocol multiplexing capability, segmentation and reassembly operation, and group abstractions. L2CAP is defined only for ACL links and not supported for SCO links, as specified by the Bluetooth Specification.
Service Discovery Protocol (SDP)
SDP is used to get specific information about a remote device, such as available services. Using SDP characteristics of these services can be queried.
RFCOMM
The RFCOMM protocol provides emulation of serial ports over the L2CAP protocol. The protocol is based on the ETSI standard TS 07.10. Only a subset of the TS 07.10 standard is used, and some adaptations of the protocol are specified in the Bluetooth RFCOMM specification.
What is a Bluetooth Profile?
The Bluetooth Specification defines a set of usage models or scenarios for using Bluetooth enabled radio devices. These usage modules, referred to as profiles, define standard ways of communicating with Bluetooth-enabled devices. It is intended to reduced the risk of interoperability issues between different manufacturers and provide a basis for the development of a common set of functions that Bluetooth enable devices will support. A profile does not need to include all the protocols defined in the Bluetooth protocol stack. It can be a subset of various protocols in the stack.
Communication between Bluetooth devices
Piconets (a, b) and Scatternet (C) (Source www.palmos.com
Point-to-Point connection
In this type of connection, only two Bluetooth devices are involved. One device acts as a master and other as a slave. The two devices form a network called Piconet.
Point-to-Multipoint
In this type of connection, two or more (Max 8) Bluetooth devices are involved. One device acts as a master and others act as a slave. These devices form a network called Piconet.
Scatternet
Two or more Piconet when connected form a Scatternet.
Bluetooth Profile Overview
Bluetooth specification v1.1 includes following general profiles:
- General Access Profile
- Service Discovery Application Profile
- Cordless Telephony Profile
- Intercom Profile
- Serial Port profile
- Headset Profile
- Dial-up Networking Profile
- Fax Profile
- Generic Object Exchange Profile
- Object Push Profile
- File Transfer Profile
- Synchronization Profile
Additional profiles for a Printing usage model:
- Basic Printing Profile
- Hardcopy cable replacement Profile
Bluetooth Security
Bluetooth security includes both authentication and encryption, and is based around the SAFER+ encryption algorithm.
Palm OS support for Bluetooth
Palm OS 5.0 has a built in support for Bluetooth.
Palm OS Bluetooth architecture

(Reference: Palm documentation www.palmos.com)
Recent releases of Palm OS includes a Bluetooth stack and SDK for developers. The Palm Bluetooth SDK includes the Palm bluetooth library and bluetooth specific drivers.
As of this writing, PalmOS does not support all Bluetooth profiles. In the diagram, the profiles marked in red are not supported on Palm.

Bluetooth specifications specify three security modes for a device.
- Security mode 1 (non-secure): A device will not initiate any security procedure.
- Security mode 2 (service-level enforced security): A device does not initiate security procedures before channel establishment at L2CAP level. This mode allows different and flexible access policies for applications, especially running applications with different security requirements in parallel.
- Security mode 3 (link level enforced security): A device initiates security procedures before the link set-up at the LMP level is completed.
Palm currently supports security modes 1 and 2.
Bluetooth support for HP Printers
HP has included built-in support for Bluetooth in its mobile printer DeskJet 995c. Other printers may be expected to follow suit. In any case, HP also makes available Bluetooth printer adapters so that existing printers may be Bluetooth enabled.
HP's Mobile printing initiative and associated software also has Bluetooth as a key ingredient.
Bluetooth Printing Support
Bluetooth specification has define following profile related to printing
- Basic Printing profile (BPP)
- Supports driverless printing for mobile devices such as mobile phones, pagers, and PDAs. BPP is explained below.
- Hard Copy Replacement profile
- The data is rendered through the use of a driver on the client device like mobile laptops and desktop computer.
Basic Printing profile
This application profile defines the application requirements for Bluetooth devices necessary for the support of the Basic Printing usage model.
This Profile makes use of the Generic Object Exchange Profile (GOEP) to define the interoperability requirements for the protocols needed by applications. The most common devices using these usage models are mobile devices such as mobile phones, pagers, and PDAs, although more complex devices are not excluded. Usage models include printing of text emails, short messages, and formatted documents. Optional support for the printing of structured data objects such as vCard and vCalendar is also defined, as well as methods for negotiating the use of other formats supported by the printer.
The Basic Printing Profile is dependent on the Generic Object Exchange, Serial Port, and Generic Access Profiles.

Source www.bluetooth.org
Sample Integration and Implementation
Sample programming on PalmOs
A sample mobile printing application was developed to print to an HP995c printer from Palm Tungsten OS 5.0 using Bluetooth wireless technology.
Platform and Devices considered for sample implementation:
- Palm OS 5.0
- Palm OS 5.0 has a built-in support for Bluetooth in its architecture. Palm OS supports Service Discovery Profile, Serial Port profile and Object Push profile.
- HP DeskJet 995c
- HP 995c has built-in support for Bluetooth. It supports Service Discovery Profile, Serial Port Profile and Object push Bluetooth profiles.
Overview of Implementation
Pre-requisite for Palm Bluetooth development:
- Palm OS SDK:
- Palm OS SDK can be downloaded from website. They have a developer program to which we can register and get the SDK, which has a support for Bluetooth.
- Palm Tungsten:
- Palm Tungsten is the current lastest model of Palm which comes with Palm OS 5.0.
- Development Environment:
- Metrowerks CodeWarrior or Falch.Net developer studio.
Implementation:
- Simple Palm OS application was created.
- Palm Bluetooth library support was included in the application.
- The Palm Bluetooth Library is a shared library that provides an API for developing Bluetooth enabled application. The API provides functions in the following areas:
- Managing remote devices, piconets
- Communicating with Bluetooth devices at L2CAP and RFCOMM protocol level.
- Advertising services and querying for remote services using SDP
- Maintaining a list of trusted devices
An applications should check if the Bluetooth system is running on the handheld before using any Bluetooth APIs.
To do so, the following code was include in the Application open routine:
- Serial Port Profile was implemented using the Palm Virtual Serial Manager:
- The Bluetooth system implements the serial port profile with a Virtual Serial Driver. Virtual Serial driver work with RFCOMM protocol to emulate cable-less serial connection.
- This driver has the following characteristics:
- Opens a background thread for the Bluetooth stack.
- Supports only one current active serial channel (point-to-point connection ) at a time.
- opens the device as a client or server.
- An RFCOMM-based virtual serial port is less symmetrical than a physical serial port. In a traditional serial port there is no need to establish the underlying transport. When establishing a Bluetooth serial port, there are roles for a client and a server device on three different stack levels-ACL, L2CAP, and RFCOMM-as well as responsibilities for registering with and querying SDP.
- Scenario used
-
The Palm hand-held acts as a Bluetooth client to the HP printer. The palm device first uses Bluetooth SDP to search for a printer in the vicinity. The printer and any other bluetooth enabled device in the vicinity responds with its address (48 bit number), which is unique for each Bluetooth device. This process of searching for Bluetooth device is called Device Discovery Process. Once the device is identified, an RFCOMM-virtual serial channel is created between the client (Palm) and server (Printer). This process creates a data channel between the client and server through which a print stream is sent.
- Following data streams were used:
- ASCII Test data
- PCL data stream generated from HP APDK
- Reference on using the HP APDK is available at www.calsoftlabs.com/hpapdk
Source-code Basics
Opening serial Port code:
SrmExtOpen API is used for opening an RFCOMM-virtual serial port.
Parameters for this API
- Type of port i.e. Bluetooth RFCOMM
- Port configuration structure
- Size of port configuration structure
- Port id, output param
Sending data over serial Port code:
Conclusion
Bluetooth is a key ingredient to enabling mobile printing from low-cost low-power devices. Not only printing, the technology is relevant to a very wide range of industry segments like - computing, telecom, networking, automotive, consumer electronics, medical and military. With industry leaders like Erricson, Nokia and Intel adopting and driving the technology, and the explosive growth of mobile market and the need to be "Always connected", Bluetooth is becoming a very significant and crucial technology. Industry experts project that, by the year 2006, there will be a shipment of 150 million Bluetooth enabled devices from Western Europe itself. Also it is projected that by the year 2004, there will be more than 1 billion mobile subscribers using the internet in some form.
Techniques described in this document can be easily adapted to printing from other mobile platforms as well, such as a PocketPC or mobile-phone. Mobile printing opens an opportunity in the software market to create sophisticated mobile printing network solutions, and this field is still in its early stages.
References
- Plam Bluetooth support document www.plamos.com
- Bluetooth specifications and profiles www.Bluetoothsig.org
- Bluetooth official site www.bluetooth.org
- Printer Working Group www.pwg.org
- Hewlett Packard www.hp.com
- HP Appliance Printing Development Kit www.hpapdk.com

