ECE/CS 4984 Wireless and Mobile Systems Design Spring 2003

Lecture 3 Middleware Fundamentals
Ing-Ray Chen Copyright Reserved

Lecture Objectives

• • •

Understand role of middleware Understand unique requirements of wireless and mobile applications that middleware should address Understand mobile computational models and functionality supported by various middleware platforms

ECE/CS 4984, Spring 2003

2

Middleware: Fundamentals

1

Sources

• • • • • •

S. Helal, “Pervasive Java,” IEEE Pervasive Computing, Vol. 1, No. 1, 2002, pp. 82-85 and Vol. 1, No. 2, 2002, pp. 85-89. C. Neable, “The .NET Compact Framework,” IEEE Pervasive Computing, Vol. 1, No. 3, 2002, pp. 84-87. A. Tripath, “Challenges in designing next-generation middleware systems,” Communications on the ACM, Vol. 45, No. 6, June 2002, pp. 39-42. http://www.wapforum.org/ - for WAP http://www.wapforum.com/ - for WAP F.P. Coyle, Wireless Web, Addison-Wesley, 2001.
3 Middleware: Fundamentals

ECE/CS 4984, Spring 2003

Agenda

• • • • •

Characteristics of mobile wireless applications Role of middleware Desirable functionality of mobile middleware Overview of mobile middleware for application developments Building your first iPAQ applications with GUI using the following middleware:
wizards

! Sun’s Java Wireless Toolkit and Java 2 Micro Edition (J2ME) ! Microsoft’s Embedded Visual Tool (eVT) with application

ECE/CS 4984, Spring 2003

4

Middleware: Fundamentals

2

Middleware for Mobile Application Developments

Client-server computational model:

! Wireless application protocol (WAP) ! Wireless web access

• • •

" Server: Microsoft’s Mobile Internet Toolkit (MIT) " Client: Microsoft’s eMbedded Visual Tool, Sun’s Java 2 Micro Edition, Microsoft’s .NET Compact Framework

Peer-to-peer and ad hoc computational model:

! Intel/Microsoft Universal Plug and Play (UPnP) ! Jini/J2ME ! Service Location Protocol (SLP)

Pervasive (or ubiquitous) computing

! Context-sensitive middleware: Transparency vs. awareness
5 Middleware: Fundamentals

Data services in wireless mobile environments

ECE/CS 4984, Spring 2003

Characteristics of Wireless and Mobile Applications

Resource-poor on mobile devices

• • • •

! Limited memory/buffer space (no disk typically) ! Small screen ! Low processing capability ! Low battery power

Locations of mobile devices are subject to frequent changes due to mobility Limited and fluctuated wireless bandwidth Unreliable communication Forced or voluntary disconnection
on data caching, pre-fetching and integration.
6

! Disconnected operations (read/write) require system supports
Middleware: Fundamentals

ECE/CS 4984, Spring 2003

3

Role of Middleware • •
Middleware is defined as services provided by a layer in between the operating system and the applications Middleware provides an abstract interface that gives an application developer a uniform view of lowlevel operating systems and networks In wireless mobile environments, middleware must be flexible to enable adaptation to changes in the underlying operating systems and networks, and to changes in application requirements
7

Applications
User Profile and QoS Policy

Middleware Services and Protocols

Network and Operating System Resources

ECE/CS 4984, Spring 2003

Middleware: Fundamentals

Desirable Middleware Functionality • • • • • • • •
Optimization – data compression Transformation – data format transformation to suit various device specifications

! ! !

HTML pages to WML (for WAP 1.0) and vice versa SOAP/XML for web services: from XML to xHTML (for WAP 2.0 and future i-mode) or cHTML (for existing i-mode phone devices)

Security and privacy Mobility support
Location transparency (ad hoc communication) vs. awareness

Service discovery support Disconnected operation support Context-aware adaptability

!

Status of the host device, the user, the surrounding environment, and the interactions between the host device and other devices

Platform independence – same program can be downloaded and run over a wide variety of devices and platforms
8 Middleware: Fundamentals

ECE/CS 4984, Spring 2003

4

WAP and Wireless Web Access
• • • • •
Data transformation

! ! ! !

The WAP gateway performs data transformation between WML (or XHTML) and HTML Technique are used for dealing with images/graphics User profile and device characteristics are stored in the WAP gateway SEP (Secure Enterprise Proxy using 128-bit encryption) in WAP 1.2 WAP’s “walled garden” – WAP gateways are provided by ISP such as AOL
9

Data compression Adaptability

Encoded request

Encoded Response (WML)

WAP Gateway
Request (e.g., HTTP) Response (e.g., HTML)

Security

Service discovery and mobility support

!

Web Server

ECE/CS 4984, Spring 2003

Middleware: Fundamentals

J2ME – Java for Hand-Held Devices

Platform independence

! !

• • •

The same byte-code Java application (e.g., a MIDlet created based on the MIDP API) can be downloaded and executed by all java-enabled devices Pre-verification at compile time to verify if an application can run with J2ME’s KVM A MIDlet application comes with a JAD metafile containing instructions for uncompressing the application in compressed JAR (Java Archive) format Java Card technology using public key A downloaded Java program must have a legal digital signature to execute JINI based on Java service objects
10

Data compression

!

Byte-code Java Applications (e.g., MIDlets) dynamically delivered to mobile devices

Security

! ! !

Service discovery

ECE/CS 4984, Spring 2003

Middleware: Fundamentals

5

J2ME Architecture
• •
Mobile Information Device (MID) profile Connected, Limited Device Configuration Kilobyte Virtual Machine
11 Middleware: Fundamentals

Personal profile

Foundation profile

Connected Device Configuration

Profile layer: minimum set of APIs available for the specified underlying configuration Configuration layer: defining a minimum set of JVM features and core Java class libraries available on a particular category of devices JVM layer (bottom layer)

C virtual machine
ECE/CS 4984, Spring 2003

Setup J2ME/MIDP Runtime Environment on iPAQ/Pocket PC •
Sun Microsystems has released JVM with MIDP for PDAs (with PalmOS), but is not continuing development of JVM for PocketPC (with Windows CE). To setup the J2ME environment on iPAQ/Pocket PC, you need to first install the Jeode JVM that provides Personal Java 1.2 support. Then, a software package called “me4se” that includes a simulator for MIDP devices based on Personal Java needs to be installed.
12

J2ME applications (MIDP) ME4SE (including J2ME emulator) Jeode JVM (Personal Java) iPAQ/Pocket on Windows CE
Middleware: Fundamentals

• •

ECE/CS 4984, Spring 2003

6

HelloJ2ME – Hello World MIDlet
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloJ2ME extends MIDlet implements CommandListener { private Display display; private TextField tfHello; private Command cmExit; private Form fmMain; public HelloJ2ME() { //Get a handle to the display object display = Display.getDisplay(this); //Create the main form fmMain = new Form("HelloJ2ME"); //Create the exit command button cmExit = new Command("Exit", Command.SCREEN,1); //Create a single-line text field 15 characters long with the label “ECE/CS 4984" tfHello = new TextField(“ECE/CS 4984","Hello World!",15,TextField.ANY); //Add the components to the form and set up the command listener fmMain.addCommand(cmExit); fmMain.append(tfHello); fmMain.setCommandListener(this); }
ECE/CS 4984, Spring 2003 13

Middleware: Fundamentals

HelloJ2ME – Hello World MIDlet (cont.)
public void startApp() { //set fmMain as the active object display.setCurrent(fmMain); } public void pauseApp() { /*app is being paused*/ } public void destroyApp(boolean unconditional) { /*app is being ended*/ } public void commandAction(Command c, Displayable s) { //click on the Exit button if (c == cmExit) { //destroyApp must be called manually destroyApp(false); //ask the manager to end the app notifyDestroyed(); } }}
ECE/CS 4984, Spring 2003 14 Middleware: Fundamentals

7

Build your First J2ME MIDlet Application using Sun’s J2ME Wireless Toolkit

• •

• • •

Create a new project “HelloJ2ME” Create a Java source file using Notepad and put the file under C:\WTK104\apps\HelloJ2 ME\src Build HelloJ2ME Run HelloJ2ME on a selected emulator Input: Can use the keyboard on the PC
15 Middleware: Fundamentals

ECE/CS 4984, Spring 2003

Deploy and Run your First J2ME MIDlet Application on an iPAQ

To deploy the MIDlet onto an iPAQ, package the MIDlet first

!

• •

Create a MIDlet package from Project -> Package -> Create Package using Sun’s J2ME Wireless Toolkit

Copy HelloJ2ME.jar created to the iPAQ’s /Windows folder On the iPAQ, execute Jeode with appropriate program arguments:

!

-cp /Windows/me4se.jar;/Windows/png .jar;/Windows/HelloJ2ME.jar org.me4se.MIDletRunner HelloJ2ME

Input: use stylus on the iPAQ or use keyboard on a “Remote Display Control” PC host
16 Middleware: Fundamentals

ECE/CS 4984, Spring 2003

8

Microsoft’s .NET Compact Framework

.NET CF (as part of .NET Framework) is based on Microsoft’s Common Language Infrastructure (CLI) standard

! Source code and complied binaries (in MSIL - Microsoft !

Intermediate Language) can run across CLI-based heterogeneous devices Microsoft’s common language runtime (CLR) is sort of like Sun’s JVM for the reason of platform independence

.NET CF allows smart devices to easily access remote (server) data using the Internet standard protocols such as XML-based SOAP and WSDL (Web Service Description Language)

! XML Web services is central to Microsoft .NET framework
17

ECE/CS 4984, Spring 2003

Middleware: Fundamentals

.NET CF Architecture for dealing with Device Heterogeneity
• • • •
On top of the host operating system is the platform adaptation layer (PAL) tailored for a specific platform Build on top of the PAL is the CLR that runs MSIL and uses Just-in-time (JIT) compiler to convert MSIL to native code On top of CLR is a set of CLIcompliant base class libraries that provide building block functionality for all applications including basic file I/O, networking and XML handling Available to applications in .NET CF are: windows forms library for windows CE, XML web services, and ADO.NET (the remote data-access technology available in Microsoft’s .NET framework)
ECE/CS 4984, Spring 2003 18

Applications
Windows forms, XML/SOAP web services, ADO.NET

.NET CF

CLI-compliant Base Classes CLR execution

Compiled Into MSIL

Platform Adaptation Layer (PAL) Host Operating System

JIT to native code

Middleware: Fundamentals

9

Mobile Data Access in .NET CF

ADO .NET (Active Data Object) lets mobile applications access Microsoft SQL Server 2000 on remote servers or access a SQL Server CE locally on the device Disconnected mode support: SQL Server CE lets applications cache large volumes of data (tens of MBytes), read, and update in disconnected mode SQL Server CE provides synchronization mechanisms for changes made upon reconnection
19

SQL Server CE (CSI) caching synchronization

Internet
Internet Information Server (SSI)

SQL Server

ECE/CS 4984, Spring 2003

Middleware: Fundamentals

Middleware Functionality in .NET CF
• • • •
Platform independence

! !

The same .NET MSIL-code application can be downloaded and executed by CLR enabled devices Proxy protocols can be designed to optimize performance using techniques such as forms differencing
MSIL-code .NET Applications can be dynamically delivered to CLR-enabled mobile devices

Optimization

Data Transformation: XML to HTML, XHTML, cHTML, WML is transformed automatically in .NET technology (at the server end) Disconnected operations

!

Data caching, pre-fetching and synchronization available using Microsoft SQL server 2000 on the remote server and SQL CE on the local device
20 Middleware: Fundamentals

ECE/CS 4984, Spring 2003

10

User Interface Design on Pocket PC

User Interface design constraints

! A small, portrait-oriented, touch-sensitive screen ! User input with an input panel and the stylus (pointer)
" Single-tap: opening an item " A tap and hold: displaying a pop-up menu or a tip

• •

Normally no “Close” button is necessary:
memory is needed

! Pocket PC automatically closes idle applications as more ! The pocket PC relies on application’s “autosave” to retain
user data, so no data loss would occur when switching applications or powering down

Normally no “Save” button is necessary:

ECE/CS 4984, Spring 2003

21

Middleware: Fundamentals

User Interface Design on Pocket PC (cont.)

System-level and Start navigation actions at the top of the screen Navigation

! Start Menu, Navigation bar
Bar (top)

Application-level and editing actions at the bottom of the screen

! Menu bar (also called !

command bar) Input Panel Button: far side of the command bar

Command (menu) bar
22

Keyboard (on/off)

ECE/CS 4984, Spring 2003

Middleware: Fundamentals

Input option

11

Pocket PC User Interface Controls
• • • • • • • • • • • • •
Buttons Check boxes Option buttons Command bars Tool bars ToolTips Menus Pop-up menus Message boxes Property sheets Tabs Text boxes List boxes
23

• • • • • • • • • • • •

Combo boxes Up/Down controls Date/Time pickers MonthCal controls List views Header controls Tree views Group Line Separators Scroll bars Sliders Status bars Progress bars
Middleware: Fundamentals

ECE/CS 4984, Spring 2003

Microsoft’s Embedded Visual Tool

• •

Microsoft’s Embedded Visual Tool is an integrated development environment (IDE) for creating mobile applications and system components A wide range of processors and Windows CE based platforms are supported with emulation:

! Pocket PC ! Palm-size PC ! Handheld PC

Programming languages supported include eMbedded Visual Basic® and eMbedded Visual C++®

ECE/CS 4984, Spring 2003

24

Middleware: Fundamentals

12

Build Your First Pocket PC Application with GUI using Microsoft’s eVC++ (1)

• Building a Pocket PC application with GUI:
! ! ! ! !
Use the eVC++ IDE Application Wizard to create the shell of your application instead of from scratch Use the Resource Editor to create menus and resources, such as dialog boxes Use “drag and drop” to put UI controls in your application and fill in the event code for control actions Select project configuration " Run/debug in the emulation environment " Release/deploy the project to Pocket PC Set the active WCE configuration " Choose platform/device: WIN32 WCE/Pocket PC
25 Middleware: Fundamentals

• Running your GUI application

ECE/CS 4984, Spring 2003

Build Your First Pocket PC Application with GUI using Microsoft’s eVC++ (2)

• Create a •

project from eVC++ Select the MFC AppWizard (exe) to create executable files

From Pocket PC SDK

ECE/CS 4984, Spring 2003

26

Middleware: Fundamentals

13

Build Your First Pocket PC Application with GUI using Microsoft’s eVC++ (3)

• Types of
! ! ! !

Applications:
Single Document with Doc List Single Document Interface (SDI) Dialog based

• All are formsbased

Dialog-based is the simplest

ECE/CS 4984, Spring 2003

27

Middleware: Fundamentals

Build Your First Pocket PC Application with GUI using Microsoft’s eVC++ (4)

• A single document

interface (SDI), formsbased application allows only one instance of a particular form to run at a time. However, it is possible to run different forms at the same time by selecting a new form from the “New” command

!

“New”, “Edit”, “Tools” menus in the menu bar are created automatically
28 Middleware: Fundamentals

ECE/CS 4984, Spring 2003

14

Build Your First Pocket PC Application with GUI using Microsoft’s eVC++ (5) • •
When a single document with Doc List application is created, a Doc List control is also added to the UI All Folders also lets you see files that are saved in the root of the My Documents folder. The folders shown in the menu are subfolders of My Documents “New”, and “Tools” menus are created automatically in the menu bar by the AppWizard

!

The developer then insert code into event handler routines
29 Middleware: Fundamentals

ECE/CS 4984, Spring 2003

Build Your First Pocket PC Application with GUI using Microsoft’s eVC++ (6)

• Use the “drag

and drop” feature to add UI controls to the main dialog of your application Change properties of controls:

text button

! Caption ! ID

ECE/CS 4984, Spring 2003

30

Middleware: Fundamentals

15

Build Your First Pocket PC Application with GUI using Microsoft’s eVC++ (7)

• Add event-

handling code to UI controls in response to input, e.g., to a text control, or to a button control, etc. Double click on a control to bring up the code insertion interface
ECE/CS 4984, Spring 2003 31

button

Middleware: Fundamentals

eVC++ Example – A Standalone Stock Quote Client
void CLab3Dlg::OnGo() { CListBox * resList = (CListBox *)GetDlgItem(IDC_RESULTS); // display in a listbox CEdit * symbol = (CEdit *)GetDlgItem(IDC_SYMBOL ); // user input in an edit box CString strSymbol ; // hold stock entered by the user char buf[40]; // hold randomly generated stock quote

// get the stock symbol entered by user from the edit box symbol->GetWindowText(strSymbol) ; // generate a stock price in the range of 20*(1+[-10%,10%]) sprintf( buf, "%6f", 20 *(1 + (rand() % 20 -10)/100.0)); // insert the result into the list box for display resList->InsertString(0, strSymbol + “\t” + CString(buf) ); }
ECE/CS 4984, Spring 2003 32 Middleware: Fundamentals

16

Debugging and Deployment in eVC++

• Applications can be debugged locally using an •
!
Run the application on an emulator

emulator and then deployed remotely on the device Local debugging

• deployment
!
Deploy and run the application on the iPAQ

ECE/CS 4984, Spring 2003

33

Middleware: Fundamentals

Local Debugging on Emulation vs. Remote Execution on Device
Emulator VS. iPAQ

ECE/CS 4984, Spring 2003

34

Middleware: Fundamentals

17

J2ME Code for the Standalone Stock Quote Application
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import java.util.*; import javax.microedition.io.*; public class lab3_j2me extends MIDlet implements CommandListener { Form mainForm = new Form ("StockQuotes"); TextField symbolField = new TextField ("Symbol","A001",5, TextField.ANY); StringItem resultItem = new StringItem ("", ""); Command getCommand=new Command ("Get", Command.SCREEN, 1); public lab3_j2me () { mainForm.append (symbolField); mainForm.append (resultItem); mainForm.addCommand (getCommand); mainForm.setCommandListener (this); }
ECE/CS 4984, Spring 2003 35 Middleware: Fundamentals

J2ME Code for the Standalone Stock Quote Application (Cont.)
public void startApp () { Display.getDisplay (this).setCurrent (mainForm); } public void pauseApp () { } public void destroyApp (boolean unconditional) { } public void commandAction (Command c, Displayable d) { // build request string String symbol = symbolField.getString (); resultItem.setLabel ("Price of " + symbol); resultItem.setText (" " + Integer.toString((int)symbol.charAt(0)) ); } }

ECE/CS 4984, Spring 2003

36

Middleware: Fundamentals

18