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.
Cell Broadcast Service (CBS)
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.
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.
||This is the category or topic ID indicating the types of messages that will be received. Examples include current weather or stock quotes.
||This is an ID of the specific message instance.
||This is a version of a specific message.
||This is indicates what language the message content is written in, such as English or French.