1 Mobile Software Development Framework: TinyOS, J2ME 10/2/2012 Y. Richard Yang.

Slides:



Advertisements
Similar presentations
How to use TinyOS Jason Hill Rob Szewczyk Alec Woo David Culler An event based execution environment for Networked Sensors.
Advertisements

A System Architecture for Tiny Networked Devices
MIDP Mobile Information Device Profile Johnny Yau CIS 642 Prof. Insup Lee.
J2ME Melih Sakarya Java Teknolojileri Derneği. JVM JAVA Kullanılan yerler  Windows-Linux-Unix-Solaris  PDA lar  Smart Cardlar  Cep Telefonları  Appletler.
Java 2D Training. Basic Tools Java SDK 1.4x Wireless Toolkit 2.x NetBeans IDE + mobility pack Global Code editor Text Comparer Tools Graphics Editor Sprite.
NesC Prepared for the Multimedia Networks Group University of Virginia.
1 Lab 3 Objectives  Case study: “Hello world” program on motes  Write you first program on mote.
Pengantar Teknologi Mobile 12
Multimedia Network Communications Subject:T0934 / Multimedia Programming Foundation Session:13 Tahun:2009 Versi:1/0.
J2ME 25 July Overview  What is J2ME?  The CLDC and CDC configurations  MIDP and MIDlets  Development Tools  Demonstrations.
UNDERSTANDING JAVA APIS FOR MOBILE DEVICES v0.01.
Introduction to Java 2 Micro Edition Mark Balbes, Ph.D. Senior Software Engineer Jeff Brown Senior Software Engineer.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 10 Java for MIDs Rob Pooley
Developing an Application with J2ME Technology Scott Palmer, Nat Panchee, Judy Sullivan, Karen Thabet, Sten Westgard.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Jason Hill, Robert Szewczyk, Alec Woo Spring 2000 TinyOS Operating System for Networked Sensors Networked SensorsSystem Structure Composing Components.
INTRODUCTION OS/2 was initially designed to extend the capabilities of DOS by IBM and Microsoft Corporations. To create a single industry-standard operating.
Developing Software for Wireless Devices
A System Architecture for Tiny Networked Devices Jason Hill U.C. Berkeley 9/22/2000.
1 TinyOS Mohammad Rahimi CSCI599-Spring Motivation  The new class of distributed tiny devices  The new generation of software.
PDA Programming Using J2ME Presenter :涂俊凱 Date : 2003/4/8.
Making Cell Phone Games An Overview Ray Ratelis Guild Software, Inc.
TinyOS Software Engineering Sensor Networks for the Masses.
Developing J2ME Applications Mobile and Wireless Networks.
Cosc 4730 Phone Programming in Java An Introduction.
Java 2 Platform, Micro Edition (J2ME) By Xiaorong Wang.
1 Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources, Listener 10/9/2012 Y. Richard Yang.
An Introduction to the Java ME Project Jens A Andersson.
1 Mobile Software Development Framework 4/14/2009 Richard Yang.
ECE 526 – Network Processing Systems Design Network Processor Architecture and Scalability Chapter 13,14: D. E. Comer.
A System Architecture for Networked Sensors Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kris Pister
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
Michael Brockway Advanced Applications Development in Java J2ME -- Introduction l Introduction / Overview l Java 2 Micro Edition n CLDC n MIDP l Examples.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 11 J2ME and MIDlets Rob Pooley
1 OFDM, Mobile Software Development Framework 9/27/2012 Y. Richard Yang.
April 15, 2005TinyOS: A Component Based OSPage 1 of 27 TinyOS A Component-Based Operating System for Networked Embedded Systems Tom Bush Graduate College.
Computer Science Wi-Fi App using J2ME and MVC Architecture Advisor : Dr. Chung-E Wang Department of Computer Science Sacramento State University Date:
J2ME Presented by May Sayed & Menna Hawash. Outline Introduction “Java Technology” Introduction “What is J2ME?” J2ME Architecture J2ME Core Concepts 
Java 2 Micro Edition (J2ME) and the world of java
PROG Mobile Java Application Development PROG Mobile Java Application Development BlackBerry App Lifecycle Java ME API.
1Basics of J2ME. 2 Objectives –Understand the different java API’s and how the mobile edition API’s fit in –Understand what a mobile configuration and.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 12 lcdui Rob Pooley
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 13 lcdui and OXO Rob Pooley
Overview of: System Architecture Directions for Networked Sensors John Kerwin CSE 291 Sensor Networks Paper by: Jason Hill, Robert Szewczyk, Alec Woo,
Dhanshree Nimje Smita Khartad
System Architecture Directions for Networked Sensors Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kris Pister Presented by Yang Zhao.
Simulation of Distributed Application and Protocols using TOSSIM Valliappan Annamalai.
System Architecture Directions for Networked Sensors Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kris Pister Presenter: James.
Java 2 Micro Edition The Connected, Limited Device Configuration.
TinyOS Sandeep Gupta. Operating System (OS) What is an OS? Main functions  Process management  Memory management  Resource management Traditional OSs.
System Architecture Directions for Networked Sensors.
1 Introduction to J2ME Outline MIDP Building J2ME Apps- Tool J2ME Wireless Toolkit Demo MIDlet Programming -- MIDlet Transition States -- Midlet Skeleton.
Enhanced mobile services in Java enabled phones Björn Hjelt Sonera zed ltd Supervisor: Professor Jorma Jormakka.
Why does it need? [USN] ( 주 ) 한백전자 Background Wireless Sensor Network (WSN)  Relationship between Sensor and WSN Individual sensors are very limited.
Software Architecture of Sensors. Hardware - Sensor Nodes Sensing: sensor --a transducer that converts a physical, chemical, or biological parameter into.
Advance Computer Programming Market for Java ME The Java ME Platform – Java 2 Micro Edition (J2ME) combines a resource- constrained JVM and a set of Java.
1 Mobile Application Development Framework 4/16/2009 Richard Yang.
The Java Platform Micro Edition Java ME
CS434/534: Topics in Networked (Networking) Systems WSN/Mobile Systems Yang (Richard) Yang Computer Science Department Yale University 208A Watson
Voice Controlled Robot by Cell Phone with Android App
Operating Systems & System Software
Simulation of Distributed Application and Protocols using TOSSIM
IzoT™ Device Stacks March 2014.
MOBILE DEVICE OPERATING SYSTEM
Wireless Instant Messaging Using J2ME
Mobile Software Development Framework: TinyOS, J2ME
Mobile Software Development Framework
By Jeff Heaton An Overview of J2ME By Jeff Heaton
Java for Mobile Devices
Presentation transcript:

1 Mobile Software Development Framework: TinyOS, J2ME 10/2/2012 Y. Richard Yang

2 Admin. r Homework 2 posted r Start to think about project

3 Recap: OFDM r Basic idea: use multiple subcarriers to reduce symbol rate per carrier r Problem: inter-carrier-interference (ICI) m Idea: orthogonal subcarriers to avoid ICI: chose each subcarrier frequency so that an integral number of cycles in a symbol period r Problem: implementation complexity m Idea: iFFT as an efficient algorithm for modulation on multiple subcarriers r Problem: ISI m Idea: cyclic prefix (guard interval)

4 Recap: Summary of Wireless PHY

5 Recap: GNURadio r A software development toolkit that provides signal processing blocks to implement software-defined radio systems. r Some key ideas m Hybrid software system (Python/C++) m Composite pattern to build a hierarchy of blocks m Internal scheduler to orchestrate data flows among blocks m Define gr_block as a reusable base so that defining a new block is typically simple: overwrite general_work and forecast

6 Recap: TinyOS r A free and open source component based operating system and platform targeting wireless sensor networks (WSNs) r Some design features m Problem: small footprint Idea: TinyOS: Generate customized OS + application: support one app at a time but flexible reprogramming

7 TinyOS: Software Concepts r A TinyOS consists of one or more components/modules linked together m software components motivated by hardware component r Each component specifies: m it provides some interfaces allows other components to control it m also uses some interfaces control other components

8 Interface r An interface declares m a set of functions called commands that provider must implement m 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 events I1 I2 C provides I3

9 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); }

10 Example Application r A simple TinyOS application which periodically reads in the light intensity value, computes a moving average, displays it on the LED

11 Module: Definition SenseTaskM.nc module SenseTaskM { provides { interface StdControl; } uses { interface Timer; interface ADC; interface StdControl as ADCControl; interface Leds; } A uses interfaces I1 and I2 B provides I1 C provides I2 commands events commands events I1 I2 C provides I3

12 Module: Implementation r Define m commands and event handlers m frame (storage) statically allocated, fixed size to know memory requirement and avoid overhead of dynamic allocation r See SenseTaskM.nc Component Internal State Internal Tasks CommandsEvents

13 Explicit Linking of Components Two types of components: m modules: individual components m configurations : assemble components together, connecting interfaces (objects) used by components to interfaces (objects) provided by others See SenseTask.nc

14 TinyOS Execution Model SenseTask Timer ADC start/stop fired getData dataReady LED ADCControl init/start/stop Design options? xxxOn/Off()

15 TinyOS Execution Model r Concurrency model: only two threads m long running tasks that can be interrupted by hardware event handlers r Tasks are posted to a FIFO queue m Each task is atomic with respect to other tasks m run to completion, but can be preempted by events m the task scheduler is a simple FIFO scheduler r Tasks perform the primary computation work m commands and event handlers post tasks m call lower level commands m signal higher level events m schedule other tasks within a component

16 Running tinyOS Program r make mica r ncc -o main.exe -target=mica SenseTask.nc r avr-objcopy --output-target=srec main.exe main.srec r Use uisp to install

17 A More Complete Sample Application r Sensor network monitoring m monitor temperature and light conditions m periodically transmit measurements to a base station m sensors can forward data for other sensors that are out of range of the base station m dynamically determine the correct routing topology for the network

18 Internal Component Graph RFM Radio byte Radio Packet UART UART Packet I2C Temp Light Active Messages Clocks bit byte packet Ad hoc Routing Application application HW SW

19 Message Send Transition r Total propagation delay up the 5 layer radio communication stack is about 80 instructions Timing diagram of event propagation

20 Evaluation: Storage Component NameCode Size (bytes) Data Size (bytes) Routing AM_dispatch AM_temperature AM_light AM RADIO_packet RADIO_byte RFM Light Temp UART UART_packet I2C Processor_init TinyOS scheduler C runtime Total  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

21 Evaluation: Timing OperationsCost (cycles) Time (µs) Normalized to byte copy Byte copy821 Post an Event Call a Command Post a task to scheduler Context switch overhead Interrupt (hardware cost) Interrupt (software cost)

Summary: TinyOS r Components m provide commands and require callback hooks for event-driven programming r Configurations m Link components r TinyOS m an app (configuration) at a time, linking only necessary components r Two threads exec m one for event m one for task 22 ADC.nc interface ADC { async command result_t getdata(); async command result_t getContinuousData(); event result_t dataReady(uint 16_t data); } configuration SenseTask { // this module does not provide any interfaces } implementation { components Main, SenseTaskM, LedsC, TimerC, DemoSensorC as Sensor; Main.StdControl -> TimerC; Main.StdControl -> Sensor; Main.StdControl -> SenseTaskM; SenseTaskM.Timer -> TimerC.Timer[unique("Timer")]; SenseTaskM.ADC -> Sensor; SenseTaskM.Leds -> LedsC; }

Discussion: Compare TinyOS/GNURadio r What are some similar software concepts? r What are some differences? 23

Discussion r Can we use GNURadio/TinyOS for writing mobile applications for mobile phones/tablets, or in other words, what are missing? 24

25 Java2 Micro Edition (J2ME)

26 Outline r Admin and recap r Mobile/wireless development framework m GNURadio m TinyOS m J2ME

27 Java Platforms r Java2 is divided into three platforms m J2EE (Java2 Enterprise Edition) business applications m J2SE (Java2 Standard Edition) general applications m J2ME (Java2 Micro Edition) small devices such as mobile phone, PDA, car navigation r Oracle’s claims on Java on mobile devices m

28 J2ME Basic Concepts: Versioning r To accommodate heterogeneous mobile devices, define configurations and profiles -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

29 J2ME K mem bit proc Upto 2M mem 32 bit proc

30 Example J2ME Configurations r Connected Limited Device Configuration (CLDC) m 160 KB to 512 KB of total memory available m 16-bit or 32-bit processor m low power consumption and often operating with battery power m connectivity with limited bandwidth m examples: cell phones, certain PDAs r Connected Device Configuration (CDC) m 2 MB or more memory for Java platform m 32-bit processor m high bandwidth network connection, most often using TCP/IP m examples: set-top boxes, certain PDAs

31 CLDC Available Packages r java.lang r java.util r java.io r javax.microedition.io

32 CLDC Classes r Boolean r Byte r Character r Class r Integer r Long r Math r Object r Runnable r Runtime r Short r String r StringBuffer r System r Thread r Throwable r Calendar r Date r Enumeration r Hashtable r Random r Stack r TimeZone r Vector r ByteArrayOutputStream r ByteArrayInputStream r DataOuput r DataInput r DataInputStream r DataOutputStream r InputStream r InputStreamReader r OutputStream r OutputStreamWriter r PrintStream r Reader r Writer java.lang java.util java.io

33 Example J2ME Profiles r Mobile Information Device Profile (MIDP) m GUI, multimedia and game functionality, end-to-end security, and greater networked connectivity m mobile phones and entry level PDAs r Foundation Profile m set of Java APIs that support resource-constrained devices without a standards-based GUI system r Personal Profile m Full set of AWT APIs, including support for applets and Xlets m CDC + Foundation Profile + Personal Profile for high-end PDA r …

34 Mobile Phone Framework

35 MIDP Hardware r Memory (added to CLDC memory) m 128 KB non-volatile for MIDP components m 8 KB non-volatile for application persistent data m 32 KB volatile for KVM r Display m screen 96x54 m display depth 1-bit m pixel shape (aspect ratio) 1:1

36 MIDP Hardware r Input (one or more) m one-handed keyboard (ITU-T phone keypad) m two-handed keyboard (QWERTY keyboard) m or touch screen r Networking m two-way m wireless m possibly intermittent m limited bandwidth

37 MIDP Packages r java.io r java.lang r java.util r javax.microedition.io r javax.microedition.lcdui r javax.microedition.rms r javax.microedition.midlet r javax.microedition.lcdui.game r javax.microedition.media r javax.microedition.media.control r javax.microedition.pki addition in version 2.0 version 1.0

38 MIDP Technology Stack Mobile Information Device Profile KVM CLDC = KVM + J2ME Core APIs in this example DSP chip (e.g., ARM) J2ME core APIs Your MIDlet Yellow Pages, train schedules and ticketing, games… UI, HTTP networking... Threads, no Floats… 32-bit RISC, 256K ROM, 256K Flash, 64K RAM

MIDlet m GUI based m Each MIDP has one instance of Display Display.getDisplay(this) to get the manager At any instance of time at most one Displayable object can be shown on the display device and interact with user –display.setCurrent( ) 39

40 MIDlet r An MIDP application is called a MIDlet m similar to the J2SE applet r A MIDlet moves from state to state in the lifecycle, as indicated m start – acquire resources and start executing m pause – release resources and become quiescent (wait) m destroy – release all resources, destroy threads, and end all activity PauseActiveDestroyed startApp destroyApp pauseApp destroyApp

MIDP Visual Display r Each MIDP has one instance of Display  Display.getDisplay(this) to get the manager  At any instance of time at most one Displayable object can be shown on the display device and interact with user display.setCurrent( ) 41

MIDP Visual Display r Displayable m Canvas GameCanvas m Screen Alert, List, TextBox, Form r Form can contain multiple form items for organization m Labels, Image Items, String Items, Text Fields, Date Fields, Gauges, Choice Groups 42

MIDP: User Interaction  Displayable objects can declare commands and declare a command listener: m addCommand(Command cmd) m addCommandListener() r Command(,, ) m Type: BACK, CANCEL, EXIT, HELP, ITEM, OK, SCREEN, and STOP 43

44 HelloWorldMIDlet.java import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloWorldMIDlet extends MIDlet implements 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(); }

MIDP: Persistent State r Record store defined in javax.microedition.rms r Record store identified by name: m static String[] listRecordStores(); m recordStore = RecordStore.openRecordStore("scores", true); m recordId = addRecord(byte[] data, int offset, int numBytes); m getRecord(int recordId); 45

46 Summary : J2ME r Scale down a popular programming environment to ease learning r Use virtual machines to mask device heterogeneity r Use configuration/profiling to handle device heterogeneity and avoid using lowest common denominator r MIDLet to manage app life cycle r Displayable to visual display, commands and provides command listener r Introduce persistent record store

Discussion on J2ME r What designs of J2ME do you like and hence expect newer frameworks (e.g., IOS, Android) may have too? r What features do you think are missing in J2ME? 47