Browse DevX
Sign up for e-mail newsletters from DevX


Shout from the Hilltops with the J2ME Wireless Messaging API

Text messaging rapidly surfaced as the killer app of the wireless space. Find out how to integrate text messaging into your J2ME applications using the Wireless Messaging APIs.

he design of J2ME provides a flexible architecture that allows additional APIs to extend the application specifications such as MIDP and Personal Profile. One such extension is the Wireless Messaging API (WMA) that provides text messaging capabilities from within a J2ME application. In this article I discuss how to integrate messaging protocols such as SMS and CBS into J2ME applications. Although the examples here are shown using MIDP, the same capabilities and principles apply to the Personal Profile space, provided the device supports WMA.

The focus of WMA is around two protocols: Short Message Service (SMS) and Cell Broadcast Service (CBS). The differences between the two are as follows.

Short Message Service (SMS)
SMS provides the ability to send messages between devices. Generally this is referred to as a one-to-one or one-to-few messaging paradigm. The WMA provides full support of two-way messaging, allowing an application to act not only as a client to send messages but also as a server to receive incoming messages.

SMS messages are generally less than 160 characters and contain only simple text. No graphics or other media support is provided by SMS.

The SMS protocol works much in the same way as email. First a message is created and sent to a server. The server then issues a request to find the target device for which the message is intended. If the target device is out of coverage or their device is turned off, the server will hold onto the message until communications can be established with the target device. Once the device can be located, the message it transmitted to the target device. When the target device responds with an acknowledgement of successfully receiving the message, the server is relived of its delivery responsibility and can delete its copy of the message. Figure 1 illustrates how SMS messages are sent between devices.

Figure 1. Message in Motion: An SMS message is routed to the server provided by the SMS service provider. The SMS server then forwards the message on to the target device.
Figure 2. One Way: The broadcast of CBS messages are one way. A CBS message is usually distributed to a localized access point or cell. The message is repeatedly transmitted from the access point to devices within range for a specified time period. Each message is sent on a CBS channel.

Cell Broadcast Service (CBS)
CBS provides the ability to send messages to many devices within a geographical area. The geographical area is usually denoted by a region of cell towers, which are provided with a specific message. These messages are generally repeated at periodic intervals to any devices registered in the cell. By repeating the message for a specified duration, devices just coming into range, or being turned on in the cell, have the opportunity to receive the message, even though the first transmission was missed. Figure 2 illustrates CBS messages being sent to devices.

The content of a CBS message can as large as 1,395 bytes in ether an ASCII or binary format; however, this can vary between network providers. Each message contains the following information, in addition to the message payload:

Table 1. Contents of a CBS message.

Channel Number This is the category or topic ID indicating the types of messages that will be received. Examples include current weather or stock quotes.
Message Code This is an ID of the specific message instance.
Update Number This is a version of a specific message.
Language This is indicates what language the message content is written in, such as English or French.

Thanks for your registration, follow us on our social networks to keep up-to-date