Contents Previous Next Index

Chapter   7

Wireless Messaging with the Wireless Toolkit


The Wireless Messaging API (WMA) is supported by the J2ME Wireless Toolkit. With WMA, you can send brief text or binary messages by means of a wireless connection to one or to multiple mobile devices. The WMA supports Short Message Service (SMS) and Cell Broadcast Service (CBS) messaging. With SMS, you can have peer to peer messaging or client to server messaging. CBS enables messages to be broadcast to multiple devices connected to a cell or a network of cells simultaneously.

You can develop and test applications that use SMS and CBS messaging. To help you develop and test SMS and CBS messaging applications, the Wireless Toolkit provides you with:

See the WMA specification at http://java.sun.com/products/wma for information about wireless messaging.

Getting Started With WMA Emulation

Use the WMA console to develop and test your messaging applications. You can send text or binary messages in either SMS or CBS mode to one or more emulated devices. You can use the console as a server with the emulated device acting as the client. The next section walks you through using the WMA console to test your messaging application. One way to familiarize yourself with the WMA console is to run the SMSDemo application included with the Wireless Toolkit (select it from the Open Project list), which uses WMA messaging. You can find a walk through of the SMSDemo application in the {j2mewtk.dir}\docs directory.

Before using the console, go through the following checklist for preparatory procedures that apply:

See "Adding API Permissions" in Chapter 3, "Operating with KToolbar” for information on setting MIDlet permissions.

Sending a Text SMS Message From the
WMA Console

You can send a text SMS message to a running emulated device from the WMA console by following these steps:

  1. Click Open Console under WMA in the Utilities window.
  2. The WMA console window opens. The phone number assigned to the console is displayed in the output screen. This number increases incrementally each time you run the console.

    WMA console window displaying current default phone number, 5550000 being used.

    FIGURE 26  –  WMA Console Window

  3. Click Send SMS in the console to send an SMS message to the emulated device.
  4. The Send a Message dialog box opens. The assigned phone numbers of the console and any running emulated devices are shown in the Selected Clients list:

    Send SMS dialog box displaying list of clients.

    FIGURE 27  –  Send a Message - SMS Dialog Box

    Each time you run an emulated device, a phone number is assigned to it and added to the Selected Clients list.

  5. Select the client number from the list and type the client’s port number in the Port text field.
  6. By specifying a port number for an SMS message, you are designating a specific application or communication channel to receive or send your message through. Omitting the port number means that the message is sent directly to the client device. Since MIDlets can only receive SMS messages with a port number specified, you need to enter a port number.

    For information on restrictions on port numbers for SMS messages, see the WMA specification at http://java.sun.com/products/wma.

  7. Type a brief message in the Message field and click Send.
  8. For maximum message length, consult the Wireless Messaging API. Maximum message (payload) length is dependent on the type of encoding used among other factors. If your message exceeds the allowable limit, an error message is displayed in the console’s output screen.

For a description of the SMS Demo application, see the “SMSDemo Application” document in the {j2mewtk.dir}\docs directory.

Sending a Binary SMS Message

Sending a binary SMS message is similar to sending a text message. To send a binary message:

  1. Click Binary SMS in the Send a Message dialog box.
  2. Type the pathname for the binary file you want to send or select one from the file chooser by clicking Browse, then click Send.
  3. The Console screen in the WMA console window displays output with the URL address of the receiving device.

Sending a CBS Message

You can use the WMA console to send a CBS broadcast message to all running emulators. The procedure is similar to sending an SMS message. After you have opened the WMA console from the Utilities window:

  1. Click Send CBS.
  2. The Send a Message dialog box opens.

  3. Click Text CBS or Binary CBS as desired.
  4. Enter a message or specify a binary file and click Send.
  5. If you are sending a text message, you must provide a message identifier and a brief text message in the corresponding fields in the dialog box.

    If you are sending a binary message, you must provide a message identifier and a pathname for the binary file.

    The output screen in the WMA console window displays information whether the information was sent and received or if an error occurred.

Setting WMA Preferences

The WMA panel of the Preferences dialog box contains fields that enable you to set WMA-related features.

 


Contents Previous Next Index User's Guide
Java™ 2 Platform, Micro Edition, Wireless Toolkit, Version 2.1