Mobile Computing Lab Manual For IT
Mobile Computing Lab Manual For IT
Index
S.N o 1 2 3 4 5 6 7 8 9 10 Title Study about WML and J2ME Emulators Page No
Ex.No : 1 Objective :
To study about WML and J2ME Simulators Contents WML Simulator The entire way of processing a WML page is shown diagrammatically below .
Fig 1.1 General Architecture of WML getting deployed as a Web page for the user The steps are as follows:
1. 2. 3. 4. 5. 6.
Mobile phone sends a Web request Wireless Network provider forwards the request to gateway server. Gateway server sends request to Web server in HTTP format. Web server accesses data, runs ASP/JSP/CGI Script/ pages and generates WML. Web server sends WML back to gateway server as HTTP Response. Gateway server binary compresses WML and sends that to cellular phone as WAP response. 7. Cell phone displays the content. *. The WAP Emulator directly talks to the Web server. Note : The mobile phone output can be emulated using a WAPBrowser
WML Emulator Instead of installing an entire WAP SDK, you can install a WML emulator. An emulator simply lets you view the contents of your WML files as they would be seen on the screen of a WAP-enabled device.
While the emulators do a great job, they are not perfect. Try a few different ones, and you will quickly decide which you like the most. When the time comes to develop a real (commercial) WAP site, you will need to do a lot more testing, first with other SDKs/emulators and then with all the WAP-enabled devices you plan to support. The following lists some of the WAP emulators that are freely available:
Klondike WAP Browser: This is produced by Apache Software. Klondike looks a lot like a Web browser and is therefore very easy to use for beginners. You can access local WML files easily. It also supports drag-anddrop, making local file use very easy. Yospace: This is produced by Yospace. WAP developers can use the desktop edition of the emulator to preview WAP applications from their desktop, safe with the knowledge that the emulator provides a reasonably faithful reproduction of the actual handset products. Ericsson R380 Emulator: This is produced by Ericsson. The R380 WAP emulator is intended to be used to test WML applications developed for the WAP browser in the Ericsson R380. The emulator contains the WAP browser and WAP settings functionality that can be found in the R380. WinWAP : This is produced by Slob-Trot Software. WinWAP is a WML browser that works on any computer with 32-bit Windows installed. You can browse WML files locally from your hard drive or the Internet with HTTP (as with your normal Web browser). Nokia WAP simulator - This is produced by Nokia and fully loaded with almost all functionalities. Try this one.
WML syntax
The topmost layer in the WAP architecture is made up of WAE (Wireless Application Environment), which consists of WML and WML scripting language. WML scripting language is used to design applications that are sent over wireless devices such as mobile phones. This language takes care of the small screen and the low bandwidth of transmission. WML is an application of XML, which is defined in a document-type definition. WML pages are called decks. They are constructed as a set of cards, related to each other with links. When a WML page is accessed from a mobile phone, all the cards in the page are downloaded from the WAP server to mobile phone showing the content. WML commands and syntaxes are used to show content and to navigate between the cards. Developers can use these commands to declare variables, format text, and show images on the mobile phone.
WAPProgramStructure:
A WML program is typically divided into two parts: the document prolog and the body. Consider the following code:
<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd"> <wml> <card> ... </card> ...more cards...
</wml>
The first line of this text says that this is an XML document and the version is 1.0. The second line selects the document type and gives the URL of the document type definition (DTD). This DTD gives the full XML definition of WML. The DTD referenced is defined in WAP 1.1, but this header changes with the versions of the WML. The header must be copied exactly so that the tool kits automatically generate this prolog. The body is enclosed within a <wml>...</wml> tag pair as shown above. The body of a WML document can consist of one or more of the following:
WMLCommands:
The commands used in WML are summarized as follows:
Formatting:
Command <p> <b> <big> <em> <I> <small> <strong> <u> <br> Paragraph Bold Large Emphasized Italicized Small Strongly Emphasized Underlined Line Break Description
Inserting images:
<img src="image-path/image - name" alt="Picture not available" />
Using Tables:
Command <table> <tr> <td> <Thead> Definition of a table Defining a row Defining a column Table header Description
Variables:
Declared as: <setvar name="x" value="xyz"/> Used as: $ identifier or $ (identifier) or $ (Identifier; conversion)
Forms:
Command <select> <input> <option> <fieldset> <optgroup> Define single or multiple list Input from user Defines an option in a selectable list Defines a set of input fields Defines an option group in a selectable list Description
Task Elements
Command <go> <noop> <prev> <refresh> Description Represents the action of switching to a new card Says that nothing should be done Represents the action of going back to the previous card Refreshes some specified card variables.
Events:
The various events are as follows: Command <do> <onevent> <postfield> <ontimer> <onenterforward> <onenterbackward> <onpick> Defines a do event handler Defines an onevent event handler Defines a postfield event handler Defines an ontimer event handler Defines an onenterforward handler Defines an onenterbackward handler Defines an onpick event handler Description
Keep the following WML code into info.wml on your server. If your server is WAP enabled then you can access this page using any WAP device.
<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd"> <!-- WML prolog.declaration of file type and version> <wml> <!-- Declaration of the WML deck> <card id="info" newcontext="true"> <!-- declaration of a card in deck> <p align="center"><b>Information Center</b></p> <!--paragraph declaration to display heading> <p> <!--paragraph declaration to display links> <a href="Movie.wml">1. Movies info.</a> <a href="Weather.wml">2. Weather Info.</a> <!--declaration of links for weather and movies> </p> </card> <!-- card end> </wml> <!-- program end>
J2ME Emulator
Emulation is hard to get right. The ideal is to mimic the behavior of a device exactly, but the accuracy of the emulation correlates to the difficulty involved in developing it. The emulator's developers have to decide how accurate to make the emulation based on the time and skill they have. At one end of the spectrum, a vendor may choose to take the J2ME Wireless Toolkit emulator and simply create a new skin for it. I'll talk more about this option later. At the other end of the spectrum, a vendor may write code to emulate the actual processor and other chips on the device, in which case the emulator can run the same OS-level software and MIDP implementation binaries as the real device. This is quite a bit more difficult and expensive, but the end result is an emulator that behaves much more like the real device. There are other possibilities between these two extremes. It's impossible to be certain what approach a vendor has used without talking to the developers who wrote the emulators, but you can sometimes get a feel for what's been done, especially for emulators that look and behave a lot like the one in the J2ME Wireless Toolkit.
The Sun Java Wireless Toolkit for CLDC (formerly known as Java 2 Platform, Micro Edition (J2ME) Wireless Toolkit) is a state-of-the-art toolbox for developing wireless applications that are based on Java ME's Connected Limited Device Configuration (CLDC) and Mobile Information Device Profile (MIDP), and designed to run on cell phones, mainstream personal digital assistants, and other small mobile devices.
Bluetooth:
Bluetooth provides a way to connect and exchange information between devices such as mobile phones, laptops, personal computers, printers, GPS receivers, digital cameras, and video game consoles over a secure, globally unlicensed shortrange radio frequency.
Bluetooth profile:
A Bluetooth profile is a wireless interface specification for Bluetooth-based communication between devices. At a minimum, each profile specification contains information on the following topics: Dependencies on other profiles Suggested user interface formats Specific parts of the Bluetooth protocol stack used by the profile. To perform its task, each profile uses particular options and parameters at each layer of the stack. This may include an outline of the required service record, if appropriate.
Setting up connections:
Any Bluetooth device will transmit the following information on demand: Device name. Device class. List of services. Technical information, for example, device features, manufacturer, Bluetooth specification used, clock offset. Any device may perform an inquiry to find other devices to connect to, and any device can be configured to respond to such inquiries.
Pairing:
Pairs of devices may establish a trusted relationship by learning (by user input) a shared secret known as a passkey. A device that wants to communicate only with a trusted device can cryptographically authenticate the identity of the other device.
Code Sample
import javax.microedition.lcdui.Display; import javax.microedition.midlet.MIDlet; import java.util.Date; public class HelloWorld extends MIDlet { Alert timeAlert; public HelloWorld() { timeAlert = new Alert("Hello!"); timeAlert.setString("Hello World! The time is now " + new Date().toString()); } public void startApp() { Display.getDisplay(this).setCurrent(timeAlert); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }
Ex: 2 Objective :