Docstoc

EDUCATIONAL

Document Sample
EDUCATIONAL Powered By Docstoc
					Java on Mobile Devices March 18

16:00 – 16:50: Guest Lecture LaCoMoCo 17:00 – 17:40: Unit Testing 17:50 – 18:30: Bluetooth Communication

JPMA S2004

Jørgen Staunstrup

A Common Mistake
public void commandAction(Command c, Displayable s) { … if (c == mConnectCommand) connect(); } private void connect() { String url = … try { HttpConnection hc = (HttpConnection)Connector.open(url); InputStream in = hc.openInputStream();

JPMA S2004

Jørgen Staunstrup

A Solution
public void commandAction(Command c, Displayable s) { if (c == mConnectCommand) { Thread t = new Thread() { public void run() { connect(); } }; t.start(); } }

JPMA S2004

Jørgen Staunstrup

Bluetooth

a cable replacement technology

A standard/protocol for a small , cheap short range (10 meter) radio communication to be plugged into computers, printers, mobile phones, etc. IEEE 802.15 www.bluetooth.org (/spec)

JPMA S2004

Jørgen Staunstrup

Bluetooth - characteristics
• Bluetooth is wireless and automatic. • Bluetooth is inexpensive. • The ISM band that Bluetooth uses is regulated, but unlicensed. • Bluetooth handles both data and voice. • Signals are omni-directional and can pass through walls and briefcases. • Bluetooth is spread spectrum.

JPMA S2004

Jørgen Staunstrup

Frequency Hopping

Source: http://www.swedetrack.com/images/bluet11.htm

JPMA S2004

Jørgen Staunstrup

Piconets and Scatternets

JPMA S2004

Jørgen Staunstrup

Bluetooth in J2ME
HTTP: con= (HttpConnection)Connector.open(url);

L2CAP (Bluetooth): con= (L2CAPConnection)Connector.open(url);

JPMA S2004

Jørgen Staunstrup

Bluetooth Overview
Device Discovery

Service Discovery

Communication

JPMA S2004

Jørgen Staunstrup

Device Management
... LocalDevice local = LocalDevice.getLocalDevice(); String address = local.getBluetoothAddress(); String name = local.getFriendlyName(); ...

RemoteDevice remote = RemoteDevice.getRemoteDevice( c);

JPMA S2004

Jørgen Staunstrup

Device Discovery (1)
DiscoveryAgent agent= local.getDiscoveryAgent(); // place the device in inquiry mode boolean complete= agent.startInquiry(); class InquiryListener implements DiscoveryListener { public void deviceDiscovered( RemoteDevice btDevice, DeviceClass cod) { } public void inquiryCompleted( int discType ) { } … }
JPMA S2004 Jørgen Staunstrup

Device Discovery (2)
DiscoveryAgent agent = local.getDiscoveryAgent(); // return an array of pre-known devices RemoteDevice[] devices= agent.retrieveDevices(DiscoveryAgent.CACHED);

JPMA S2004

Jørgen Staunstrup

Service Discovery
DiscoveryAgent agent = local.getDiscoveryAgent();

class ServiceListener implements DiscoveryListener { public void servicesDiscovered( int transID, ServiceRecord[] servRecord) } public void inquiryCompleted( int discType ) { } … } {

JPMA S2004

Jørgen Staunstrup

Service Records

public interface ServiceRecord A ServiceRecord contains a set of service attributes, where each service attribute is an (ID, value) pair. An SDP Server maintains a Service Discovery Database (SDDB) of service records that describe the services on the local device. ServiceRecords are made available to a client application via an argument of the servicesDiscovered method of the DiscoveryListener interface.

JPMA S2004

Jørgen Staunstrup

Communication (L2CAP)
L2CAPConnection con; byte[] b con.send(b); con.receive(b);

JPMA S2004

Jørgen Staunstrup

Bluetooth Protocols

Source

http://www.palowireless.com/infotooth/tutorial.asp

In J2ME API
JPMA S2004 Jørgen Staunstrup

L2CAP versus RFCOMM
L2CAP (packetss) RFCOMM (serial)

00011010101010

more next week
JPMA S2004 Jørgen Staunstrup

Relevant Links
Bluetooth API http://jcp.org/en/jsr/detail?id=82

Toolkit extension (Nokia): Series 60 MIDP Concept SDK Beta 0.3.1 http://www.forum.nokia.com/main.html

JPMA S2004

Jørgen Staunstrup

Guest Lectures
March 18: Lars Birkedal, ITU -> March 25: Susana Tosca, ITU April 1: Peter Knudsen, BlipNet

JPMA S2004

Jørgen Staunstrup

Final Project
April 1. – April 30.: Two options - a game - wireless communication

May: 4-week projects -> exhibition June 4 Mobile Computing, Games, Location Based Applications, …

JPMA S2004

Jørgen Staunstrup

Exercises March 25

High-level design of a Tetris Game (comparison) • Skeleton classes • Pseudo-code

JPMA S2004

Jørgen Staunstrup


				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:9
posted:9/22/2008
language:English
pages:21
Description: MY BOOKS