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.
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:
javax.microedition.io.Push Registry
javax.microedition.io.Connector.sms
javax.microedition.io.Connector.cbs
javax.wireless.messaging.sms.send
javax.wireless.messaging.sms.receive
javax.wireless.messaging.cbs.receive
See "Adding API Permissions" in Chapter 3, "Operating with KToolbar” for information on setting MIDlet permissions.
You can send a text SMS message to a running emulated device from the WMA console by following these steps:
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.
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:
Each time you run an emulated device, a phone number is assigned to it and added to the Selected Clients list.
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.
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 is similar to sending a text message. To send a binary 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:
The Send a Message dialog box opens.
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.
The WMA panel of the Preferences dialog box contains fields that enable you to set WMA-related features.
The Wireless Toolkit assigns unique phone numbers to emulated devices as they are launched. These phone numbers are the addresses of the devices for sending and receiving SMS messages. Each field accepts a numeric string of eighteen digits or less with no spaces.
The Wireless Messaging API specification provides automatic fragmentation and reassembly of messages that are too long to be sent in a single SMS message. The maximum size of a singe SMS fragment is determined by the content type and encoding of the message body. The Wireless Toolkit’s emulators automatically fragment longer messages into individual pieces. All the individual pieces are delivered to the destination address. The recipient automatically reassembles the fragments into the whole message before returning it to the MIDlet.
Many factors contribute to the actual delivery time of a message You can use the following parameters to simulate the real-world constraints on message delivery:
User's Guide Java™ 2 Platform, Micro Edition, Wireless Toolkit, Version 2.1 |
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.