Download - Mobile Software Development Framework
![Page 1: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/1.jpg)
1
Mobile Software Development Framework
4/14/2009
Richard Yang
![Page 2: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/2.jpg)
2
Admin.
Homework 4
![Page 3: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/3.jpg)
3
Recap
What are the major considerations in developing a software environment and application framework for mobile wireless applications? Handle heterogeneous devices/configurations Efficient (memory, battery, …) Easy programming for event-driven
programming …
![Page 4: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/4.jpg)
Overview
Software framework for mobile applications is a quite large topic, we will see three representative examples TinyOS J2ME Android
4
![Page 5: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/5.jpg)
5
TinyOS
http://www.tinyos.net/tinyos-1.x/doc/tutorial/
![Page 6: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/6.jpg)
6
Hardware
Assembled from off-the-shelf components
4Mhz, 8bit MCU (ATMEL) 512 bytes RAM, 8KB ROM
Devices serial Port temperature sensor & light
sensor 900Mhz Radio (RF monolithics)
• 10-100 ft. range LED outputs
1.5” x 1.5”
![Page 7: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/7.jpg)
7
Schematic Diagram of a Mote
![Page 8: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/8.jpg)
8
Sample Application: Environment Monitoring
Environment monitoring, e.g., measure temperature, lighting
values/events periodically transmit measurements/events
to a base station forward data for other nodes that are out of
range of the base station
…
![Page 9: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/9.jpg)
9
Requirements on Software Dev. Framework
Small foot print devices have limited
memory and power resources
Support one application at a time but flexible reprogramming
Flexible configuration of attached devices
![Page 10: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/10.jpg)
TinyOS Application Dev. Framework
Basic principle: Generate customized OS + application for each given scenario
We say each generated scenario generates a tinyOS
10
![Page 11: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/11.jpg)
11
Schematic Diagram
![Page 12: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/12.jpg)
12
TinyOS: Software Components
A tinyOS consists of one or more components linked together software components motivated by hardware
component
Each component specifies that it provides some interfaces
• allows other components to control it also uses some interfaces
• control other components
![Page 13: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/13.jpg)
13
Interface
An interface declares a set of
functions called commands that provider must implement and
another set of functions called events that the interface user must implement
A uses interfaces I1 and I2
B provides I1 C provides I2
commands events commands eventsI1 I2
C provides I3
![Page 14: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/14.jpg)
14
Interface: Examples
StdControl.nc
interface StdControl { command result_t init(); command result_t start(); command result_t stop();}
Timer.nc
interface Timer {
command result_t start(
char type,
uint32_t interval);
command result_t stop();
event result_t fired();
}
ADC.nc
interface ADC {
async command result_t getdata();
async command result_t getContinuousData();
event result_t dataReady(uint 16_t data);
}
![Page 15: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/15.jpg)
15
TinyOS Component: Implementation
Component contains: commands and event
handlers• can invoke lower level
commands, but cannot block
• event handler can signal higher level signals while command cannot
frame (storage)• statically allocated, fixed
sized to know memory requirement and avoid overhead of dynamic allocation
Component
Internal StateInternal Tasks
Commands Events
![Page 16: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/16.jpg)
16
Linking Components
Two types of components:
modules: individual components
configurations : assemble components together, connecting interfaces (objects) used by components to interfaces (objects) provided by others
![Page 17: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/17.jpg)
17
Example Application
A simple TinyOS application which periodically reads in the light intensity value, computes a moving average, displays it on the LEDSee SenseTaskM.nc
SenseTask.nc
![Page 18: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/18.jpg)
18
TinyOS Execution Model
Concurrency model: only two threads long running tasks that can be interrupted by hardware
event handlers
Tasks perform the primary computation work commands and event handlers post tasks call lower level commands signal higher level events schedule other tasks within a component
Each task is atomic with respect to other tasks run to completion, but can be preempted by events the task scheduler is a simple FIFO scheduler
![Page 19: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/19.jpg)
19
Running tinyOS Program make mica ncc -o main.exe -target=mica SenseTask.nc avr-objcopy --output-target=srec main.exe
main.srec Use uisp to install
![Page 20: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/20.jpg)
20
A More Complete Sample Application Sensor network
monitoring monitor temperature and
light conditions periodically transmit
measurements to a base station
sensors can forward data for other sensors that are out of range of the base station
dynamically determine the correct routing topology for the network
![Page 21: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/21.jpg)
21
Internal Component Graph
RFM
Radio byte
Radio Packet
UART
UART Packet
I2C
Temp
Light
Active Messages
Clocksbit
byte
packet
Ad hoc Routing Applicationapplication
HW
SW
![Page 22: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/22.jpg)
22
Message Send Transition
Total propagation delay up the 5 layer radio communication stack is about 80 instructions
Timing diagram of event propagation
![Page 23: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/23.jpg)
23
Evaluation: Storage
Component Name Code Size (bytes)
Data Size (bytes)
RoutingAM_dispatchAM_temperatureAM_lightAMRADIO_packetRADIO_byteRFMLightTempUARTUART_packetI2C
884078
1463563348103108464
196314198
00
328
4040
81111
408
Processor_initTinyOS schedulerC runtime
17217882
3016
0
Total 3450 226
Scheduler only occupies 178 bytes
Complete application only requires 3 KB of instruction memory and 226 bytes of data (less than 50% of the 512 bytes available)
Only processor_init, TinyOS scheduler, and C runtime are required
![Page 24: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/24.jpg)
24
Evaluation: Timing
Operations Cost (cycles)
Time (µs)
Normalized to byte copy
Byte copy 8 2 1
Post an Event
Call a Command
Post a task to scheduler
Context switch overhead
10104651
2.52.5
11.512.7
5
1.251.25
66
Interrupt (hardware cost) 9 2.25 1
Interrupt (software cost) 71 17.75
9
![Page 25: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/25.jpg)
Discussion
What would we need to extend to tinyOS if we were to use it for writing mobile applications for mobile phones and PDAs?
25
![Page 26: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/26.jpg)
26
Java2 Micro Edition (J2ME)
![Page 27: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/27.jpg)
27
Java Platforms
Java2 is divided into three platforms J2EE (Java2 Enterprise Edition)
• business applications
J2SE (Java2 Standard Edition)• general applications
J2ME (Java2 Micro Edition)• small devices such as mobile phone, PDA, car
navigation
![Page 28: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/28.jpg)
28
J2ME
Based on Java
Uses “versioning” to avoid using lowest common denominator
Uses java virtual machines to mask device heterogeneity
![Page 29: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/29.jpg)
29
J2ME Versioning To accommodate heterogeneous mobile
devices, define configurations and profiles
http://developers.sun.com/techtopics/mobility/getstart/articles/survey/
-A configuration provides fundamental services for a broad category of devices (e.g., lang, io, util)
- A profile supports higher-level services common to a more specific class of devices or market (e.g., life cycle, GUI)
-An optional package adds specialized services that are useful on devices of many kinds, but not necessary on all of them
![Page 30: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/30.jpg)
30
J2ME
128-512K mem16-32 bit proc
Upto 2M mem32 bit proc
![Page 31: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/31.jpg)
31
Two Available J2ME Configurations Connected Limited Device Configuration (CLDC)
160 KB to 512 KB of total memory available 16-bit or 32-bit processor low power consumption and often operating with
battery power connectivity with limited bandwidth many Java features deleted, e.g., floating point, finalize examples: cell phones, certain PDAs
Connected Device Configuration (CDC) 2 MB or more memory for Java platform 32-bit processor high bandwidth network connection, most often using
TCP/IP examples: set-top boxes, certain PDAs
![Page 32: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/32.jpg)
32
Available J2ME Profiles
Mobile Information Device Profile (MIDP) delivers an enhanced user interface, multimedia and game
functionality, end-to-end security, and greater networked connectivity to mobile phones and entry level PDAs
Foundation Profile set of Java APIs that support resource-constrained devices
without a standards-based GUI system
Personal Profile Together with CDC and Foundation Profile, Personal Profile
provides a complete application environment for the high-end PDA market. Personal Profile contains the full set of AWT APIs, including support for applets and Xlets
Personal Basis Profile provides a J2ME application environment for network-
connected devices supporting a basic level of graphical presentation
![Page 33: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/33.jpg)
33
Mobile Phone Framework
![Page 34: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/34.jpg)
34
Typical J2ME Technology Stack
Mobile Information
Device Profile
KVMCLDC = KVM + J2ME Core
APIs in this
example DSP chip(e.g., ARM)
J2ME core APIs
YourMIDlet
Yellow Pages, train schedules and ticketing, games…
UI, HTTP networking...
Threads, no Floats…
32-bit RISC, 256K ROM, 256K Flash, 64K RAM
![Page 35: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/35.jpg)
35
CLDC Available Packages
java.lang java.util java.io javax.microedition.io
![Page 36: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/36.jpg)
36
CLDC Classes Boolean Byte Character Class Integer Long Math Object Runnable Runtime Short String StringBuffer System Thread Throwable
Calendar Date Enumeration Hashtable Random Stack TimeZone Vector
ByteArrayOutputStream ByteArrayInputStream DataOuput DataInput DataInputStream DataOutputStream InputStream InputStreamReader OutputStream OutputStreamWriter PrintStream Reader Writer
java.lang java.util java.io
![Page 37: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/37.jpg)
37
Networking Connection
Based on a framework called the Generic Connection Framework (GCF)
GCF consists of an interface hierarchy that is extensible a connection factory, and uses Standard Uniform Resource Locators
(URLs) to indicate the connection types to create• scheme://user:password@host:port/url-path;parameters • e.g.socket://www.j2medeveloper.com:80file:///myResourceFile.resdatagram://www.j2medeveloper.com:7001sms://+12034326400
http://developers.sun.com/techtopics/mobility/midp/articles/genericframework/
![Page 38: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/38.jpg)
38
MIDP Hardware
Memory (added to CLDC memory) 128 KB non-volatile for MIDP components 8 KB non-volatile for application persistent
data 32 KB volatile for KVM
Display screen 96x54 display depth 1-bit pixel shape (aspect ratio) 1:1
![Page 39: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/39.jpg)
39
MIDP Hardware
Input (one or more)one-handed keyboard (ITU-T phone
keypad) two-handed keyboard (QWERTY keyboard)or touch screen
Networking two-way wireless possibly intermittent limited bandwidth
![Page 40: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/40.jpg)
40
MIDP Packages
java.io java.lang java.util javax.microedition.io javax.microedition.lcdui javax.microedition.rms javax.microedition.midlet
javax.microedition.lcdui.game javax.microedition.media javax.microedition.media.contr
ol javax.microedition.pki
addition in version 2.0version 1.0
![Page 41: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/41.jpg)
41
MIDP Application Model
An MIDP application is called a MIDlet similar to the J2SE applet GUI based
MIDlet suites – for applications that share resources or data
![Page 42: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/42.jpg)
42
MIDP: Application Lifecycle
MIDlets move from state to state in the lifecycle, as indicated
start – acquire resources and start executing
pause – release resources and become quiescent (wait)
destroy – release all resources, destroy threads, and end all activity
Pause
Active
Destroyed
startApp
destroyApp
pauseApp
destroyApp
![Page 43: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/43.jpg)
43
HelloWorldMIDlet.javaimport javax.microedition.midlet.*;import javax.microedition.lcdui.*;
public class HelloWorldMIDlet extends MIDletimplements CommandListener {
private Command exitCommand;private Display display;private TextBox t;
public HelloWorldMIDlet() { display = Display.getDisplay(this);exitCommand = new Command("Exit", Command.EXIT, 2);t = new TextBox(“CS434", "Hello World!", 256, 0);t.addCommand(exitCommand);t.setCommandListener(this);
}public void startApp() { display.setCurrent(t); }public void pauseApp() { }public void destroyApp(boolean unconditional) { }public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {destroyApp(false);notifyDestroyed();
}}
}
![Page 44: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/44.jpg)
44
Developing J2ME Applications
Identify the devices Identify the profiles supported by devices
using the MID profile, the application will target cell phones and pagers
Develop application install jdk, a package supporting the wireless
target (e.g., Sun Wireless Toolkit for CLDC) debug using a simulator for deployment, preverify by pre-generating
“stack map”
![Page 45: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/45.jpg)
45
Stack map attribute increases the size of a classfile by appro. 5% but substantially reduces device mem and CPU usage
Deploying: Two-Phase Class File Verification Process
![Page 46: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/46.jpg)
46
Deploying
Generate deployment files: two files• Java Application Description file (.jad)• Java archive file (.jar)
Upload .jad and .jar to the device or a server where the device can download the application
![Page 47: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/47.jpg)
47
Over-The-Air Application Loading Process
Web Page
JAMDownloadsApp
UserSelectsApp
AdvertiseApp on Web Page
Network Transfer Java ApplicationManager
(Name,Version,
Size,…)
Jar File
DescriptorFile
![Page 48: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/48.jpg)
48
Summary: J2ME
Scale down a popular programming environment to ease learning
Use virtual machines to mask (some) device heterogeneity
Use versioning to avoid using lowest common denominator
![Page 49: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/49.jpg)
49
Windows .NET Compact Framework Similar to J2ME Scales down a popular programming environment to ease
learning the .NET CF is a subset of the full .NET framework with some additions designed for resource constrained devices 1,400 classes for .NET CF vs. 8,000 for full 27 UI controls for .NET CF vs. 52 for full 1.5 MB for .NET CF vs. 30 MB for full
Uses versioning to avoid using lowest common denominator pocket PC pocket PC phone version smart phone version
Uses virtual machines to mask device heterogeneity programming languages compile to MSIL
• MSIL is JIT compiled on the device• MSIL code is smaller than native executables• MSIL allows your code to be processor independent
![Page 50: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/50.jpg)
Andriod
50
![Page 51: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/51.jpg)
Andriod
51
![Page 52: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/52.jpg)
Andriod Features
Linux kernel as foundation
Java based framework (J2SE not J2ME)
Dalvik Virtual machine
52
![Page 53: Mobile Software Development Framework](https://reader035.vdocuments.mx/reader035/viewer/2022081501/568152a2550346895dc0c9c4/html5/thumbnails/53.jpg)
Application Framework: Key Concepts
Activity Visible screen
Service Background services
Content provider Shared data
Broadcast receivers Receive and react to broadcast events
Intent Activating component
53