One day Crash Course in Java ME Developmentuberthings.com/mobile/workshop.pdf · One day Crash...

114
One day Crash Course in Java ME Development by Michael Sharon, Co-founder/CTO, Socialight

Transcript of One day Crash Course in Java ME Developmentuberthings.com/mobile/workshop.pdf · One day Crash...

One day Crash Course in Java ME Development

by Michael Sharon, Co-founder/CTO, Socialight

Platform Language CostLearning Curve

Emulator Availability

Java ME Java FREE Average Free ~1.5bn

Flash Lite AS Varies Average With IDE 77-115m

Symbian C++ FREE STEEP! Free 120m

.NETC#, C++, VB.NET

$$$$ STEEP! IDE 4.5m

BREW C++ $$$$ STEEP! Simulator ????

Python Python FREE Gentle Add-on Nokia-only

WAP / Mobile Web

XHTML, WML

FREE Gentle Free 2bn+

sources: http://www.biskero.org/?p=430, http://alindh.iki.fi/2006/06/27/mobile-platform-statistics/, http://en.wikipedia.org/wiki/Mobile_development

Java ME (J2ME)

Java ME / J2MEJava ME (formerly known as Java 2 Platform, Micro Edition or J2ME), is a collection of Java APIs for developing software on resource constrained devices such as PDAs, cell phones and other consumer appliances.

Java Sources

• Java Community Process - http://jcp.org• JSR specification requests• reference implementations

• Sun - http://java.sun.com• SDK, tools, community

• Manufacturer• SDKs, community, device emulators

Java VM

Virtual Machine (KVM)

Operating System

Hardware

Native Apps

Other Apps

A typical Java ME stack

1. Configurations- specifies minimum Java technology that we can expect for certain devices- Includes language, virtual machine features, core libraries

2. Profiles- layer defining APIs and specifications for a particular device or market - MIDP, FP- MIDlets

3. Optional Packages- includes additional functionality only supported by certain devices - e.g. Bluetooth API, Location API

1. Configurations: CLDCConnected Limited Device Configuration

- specifies environment for mobile phone, pagers- 160-512k of memory for Java- limited power / batteries- intermittent, low-bandwidth connectivity

CLDC 1.0- May 2000, JSR 30- java.lang

CLDC 1.1- Dec 2002, JSR 139- adds floating point support- bug fixes

2. Profiles: MIDPMobile Information Device Profile

MIDP 1.0- December 2000, JSR 37- java.microedition.midlet- java.microedition.rms- java.microedition.lcdui- java.microedition.io.HttpConnection

MIDP 2.0- Nov 2002, JSR 118- java.microedition.media- java.microedition.lcdui.game

MIDP 3.0- Q3 2006? No! Sometime 2007...

3. Optional Packages

Bluetooth API (JSR 82)- communication with Bluetooth devices

Wireless Messaging API (JSR 120, JSR 205)- SMS, MMS, multi-part messages

Mobile Media API (JSR 135)- audio, video and multimedia

Location API (JSR 179)- interface to location services

MIDP 3.0AKA “The Future”

• Background MIDlets (remember TSRs?)• Drawing to secondary displays• Improved large screen support• Auto-start MIDlets • And much more... to forget about for the moment

? MIDletsMIDlets are like Java applets for mobile devices.

Has a lifecycle with four stages, created, started, paused, destroyed.

The Not-So-Secret Lives of MIDlets

START

PAUSED

RUNNING

DESTROYEDstartApp()pauseApp()

destroyApp()

destroyApp()

Your phone

Status Bar

Viewport

Soft keylabels

Call Button(select, fire)

Soft keys

Menu button

Hang up(suspend app)

Joystick- 4 way- center fire/select

Lightning tour of Java ME* NOT TO BE CONFUSED WITH AN ACTUAL PROGRAMMING COURSE

Java ME, classes, objects

• Object oriented language

• Multi-threaded

• Object is an instance of a class

• Object inherits/extends/implements from single class

• Methods accessed using dot notation

• Reveal the MIDP Reference docs

Is this possible? Wireframes / IA

Development

Platforms

Debugging

Testing

Deployment

Your idea Pick one!! NB!!!

What?How?Why?

Where?Who?

Sample Mobile Development Process

Development

• Use IDE (Eclipse, Netbeans etc), Java Wireless Toolkit, Manufacturer SDK

• Create .java files

• Compile & preverify into .class files

• Create packaged MIDlet suite

• Run in emulator / deploy live

Java Application Descriptor (JAD)- describes MIDlet suite- specifies name, icon, MIDlets, permissions

Java Archives (JARs)- glorified zip file- contains class files, resources- contains MANIFEST.MF

MIDlet Suite = 1 JAD file + 1 JAR file

AMS- application management software

Packaging MIDlets

Tips’n’tricks: JAD Edition

Check The Details

Optional extras

Debugging

Tips

• Use System.out.println to print out to console

• What works in the emulator MAY NOT work identically on phone

• Emulator runs code much faster than device

Testing

Tips

• Do a quick check for known issues in MIDP on device

• Test in the emulator & device

• Multimedia applications which use camera, video etc, MUST be tested on device

Deployment!!!!Deployment

Deployment/ProvisioningAKA “getting it on the phone”

• Over the Air (OTA)

• Web / WAP / Carrier Deck

• JAD file specifies location

• Create .htaccess, MIME-Types

• Bluetooth (OS X, Windows)

• Easy, quick installation

• USB cable

• expensive, sometimes difficult to obtain

• Web based - MPowerplayer, ME4SE

Tips’n’tricks: Deployment

• Bluetooth

• Drag + Drop on OS X

• OTA - upload to a server

• Email the URL

• [phone_number]@carrier_email_host.com

• Get list here: http://www.hiptools.net/sms/

Exercise 1

• Create a HelloWorld-type application

• Run it in the emulator

• Deploy it to your phone

• Ensure it runs successfully

• Extra credit: add an icon

• http://uberthings.com/teaching/wiki/

Part Deux

MIDlet UI

• 2 main options

• Abstraction

• High level classes, Screens (Alert, List, Form, Textbox)

• Discovery

• Low level classes - Canvas, GameCanvas

• javax.microedition.lcdui + .game

Displayable

Screen

Alert List Form Textbox

Canvas GameCanvas

High Level Low Level

Display & Displayable

• Display manages the screen

• Display d = Display.getDisplay(this);

• Displayable is shown on the display

• Like Easel & Canvas OR Frame & Painting

• Flexible event handling with Commands and CommandListener

Screens(Form, Alert,List, Textbox)

• Higher-level

• Standard widgets

• Implementation dependent

• Less control over UI

• Event handling via Commands

Canvases

• Low-level

• Discovery

• Key level event handling

• More control over UI

• Animation

TOP | HCENTER

BOTTOM | HCENTER

TOP | RIGHTTOP | LEFT

VCENTER | LEFT VCENTER | RIGHT

BOTTOM | LEFT BOTTOM | RIGHT

VCENTER HCENTER

Quick recap

The Not-So-Secret Lives of MIDlets

START

PAUSED

RUNNING

DESTROYEDstartApp()pauseApp()

destroyApp()

destroyApp()

OR

A MIDlet’s Life

1. Show a Displayable

2. Wait for input

3. Do something, then show next screen

4. Lather, rinse, repeat.

•Idea = Zombie Detector

•Platform = Nokia N80

•Wireframes / IA

START DETECT

RESULT

Zombie Detector IA v0.1

Forms-A-Go-Go

TastingCanvas

Exercise 2

• Write a multi-screen application that takes some input from the user, uses it and returns some type of response.

• Run it in the emulator

• Deploy it to your phone and run successfully

• Extra credit: make an animation!

Tips’n’tricks: Graphics edition

Images/Icons

• PNG

• Lossless competitor to GIF

• Supports >256 colours and alpha

• Only use indexed images! 8-bit or 4-bit

• Some support for transparency

Resolutions

• Nokia Series 60 3rd Edition = 352x216 - definitely not traditional

• Dual portrait + landscape modes

Resolutions

• 176w x variable height (mostly 208px) = current standard

• Portrait orientation

• Nokia Series 60 2nd Edition, Motorola RAZR, ROKR, PEBL, iDEN, Sony Ericsson

• 128w x variable height

• Old standard

• 96x - even older, painful to resize artwork

Tools

• Photoshop / Gimp / Pixel

• Debabelizer

• PNGCrush, PNGOut, TweakPNG

• Icon Studio

Part Three

Exceptions

• What are exceptions?

• “an event that occurs in a program that disrupts the normal flow of operations”

• Use try, catch, finally to handle

• 1 - Checked exceptions - IllegalArgumentException

• 2 - Errors - serious errors

• 3 - Runtime exception - NullPointerException

Why we love Exceptions

• Separate error handling code

• Grouping and differentiating error types

• Aids in debugging

Threads

• What are threads?

• “Single sequential flow of control”

• AKA sub processes which will do things for you

• Application = System thread + other threads

• J2ME is multithreaded

Threads (2)

• Every thread has a context

• Running thread is executing code• Ready thread is ready to execute code• Suspended thread is waiting on an external event. • Terminated thread has finished executing code.

• Threads are scheduled (usually by OS)

Unthreaded MIDlet

System Thread

Other process

startApp()

doSomething()

showMenu()

showMenu()

Threaded MIDlet

System Thread

Other process

startApp()

doSomethingThread()

showMenu()

showMenu()

Threads (3)

• To use threads you need:

1. an instance of java.lang.Thread

2. an object that implements java.lang.Runnable

public class DoSomething implements Runnable { public void run(){ // here is where you do something }}

Using Threads

DoSomething doIt = new DoSomething();Thread myThread = new Thread( doIt );myThread.start();

Multimedia

MMAPI (JSR-135)

• MIDP 2.0

• Audio playback / record

• Video playback / record

• Vibration

!

"#$%&'(#)*+',#&

!" #$%"&'()*%"&%+),"-./"

!01" -23$)4%3452%"

!"#$%#&

&'(()*#&+$%$

!"#$%&

,$-$.#"

'#(#)*+&,% -*.(&*"("/0*+#&

!/-%"/)&

/

!"#$%#&

&'(()*#&+$%$

!"#$%&

,$-$.#"

'#(#)*+&,% -*.(&*"("/0*+#&

!/-%"/)&

/

!

"*-%$.!/0!11234!+$,5*6.,6%$.!

Manager!*7!+!,8+77!9*65!#:8;!76+6*,!&.65#<7=!+>>8*,+6*#:7!,+::#6!,$.+6.!+:!*:76+:,.!#?!*6'!Manager!>$#@*<.7!76+6*,!&.65#<7!?#$!,$.+6*:-!>8+;.$7!+:<!A%.$;*:-!7%>>#$6.<!>$#6#,#87!+:<!,#:6.:6!6;>.7'!46!

+87#!>$#@*<.7!+!,#:@.:*.:6!&.65#<B!playToneB!?#$!>8+;*:-!+!7*:-8.!6#:.'!

ManagerC7!createPlayer!&.65#<7!,$.+6.!+!Player!9*65!+:!+77#,*+6.<!DataSource!6#!7%>>8;!*6!9*65!<+6+'!D5*7!DataSource!,+:!E.!E%*86!?$#&!+:!InputStream!#$!?$#&!+!FG4H76;8.!8#,+6#$'!D5.!

DataSource!*:76+:,.!*7!:#6!@*7*E8.!6#!65.!+>>8*,+6*#:!>$#-$+&&.$'!(#)*+C7!11234!*&>8.&.:6+6*#:!

7%>>#$67B!?#$!.I+&>8.B!65.!?#88#9*:-!8#,+6#$!?#$&70!

!" http://something.com/somefile.wav

!" capture://video!!J<*7>8+;7!@*<.#!?$#&!65.!<.@*,.C7!E%*86H*:!,+&.$+K!

D5*7!<#,%&.:6!9*88!<*7,%77!&#$.!+E#%6!8#,+6#$7!*:!65.!?#$65,#&*:-!,5+>6.$7'!2%<*#!+:<!@*<.#!

$.,#$<*:-!*7!<*7,%77.<!*:!L.,6*#:!M'NB!OG.,#$<*:-!L#%:<!+:<!P*<.#'Q!4:!+<<*6*#:B!65.!6.,5:*,+8!:#6.!

14R30!1#E*8.!1.<*+!234!L%>>#$6!4:!(#)*+!R.@*,.7!SNT!,#:6+*:7!&#$.!*:?#$&+6*#:!+E#%6!8#,+6#$!7%>>#$6!

#:!<.@*,[email protected]'!

Manager!,$.+6.7!65.!,#$$.,6!)*:<!#?!Player!*&>8.&.:6+6*#:!,8+77!E;!,5.,)*:-!65.!DataSourceC7!,#:6.:6!6;>.!J?#$!.I+&>8.B!?$#&!+:!UDD3!$.7>#:7.C7!V#:6.:6HD;>.!5.+<.$K!#$!?*8.!.I6.:7*#:'!4?!*6!

,+::#6!<.6.$&*:.!65.!DataSourceC7!,#:6.:6!6;>.B!*6!9*88!65$#9!+!MediaException'!

W:,.!65.!>8+;.$!5+7!E..:!,$.+6.<B!;#%!,+:!+7)!*6!?#$!@+$*#%7!)*:<7!#?!ControlB!?#$!*:76+:,.0!

!" VolumeControl!X!6#!,#:6$#8!+!>8+;.$C7!+%<*#!@#8%&.!

!" StopTimeControl!X!6#!&+).!+!>8+;.$!76#>!+?6.$!>8+;*:-!?#$!+!-*@.:!8.:-65!#?!6*&.!

!" VideoControl!X!6#!,#:6$#8!5#9!+!@*<.#!>8+;.$C7!*&+-.!*7!75#9:!

D5.$.!+$.!&+:;!#65.$!6;>.7!#?!ControlB!E%6!:#6!+88!9*88!E.!7%>>#$6.<!E;!+!-*@.:!<.@*,.C7!1#E*8.!

1.<*+!234!*&>8.&.:6+6*#:B!#$!?#$!+!-*@.:!,#:6.:6!6;>.'!Y#%!,+:!?*:<!#%6!95+6!,#:6$#87!+$.!7%>>#$6.<!

*:!+!<.@*,.!E;!,5.,)*:-!65.!7;76.&!>$#>.$6*.7!J?#$!.I+&>8.B!

System.getProperty(“supports.video.capture”)K'!2!?%88!8*76!#?!65.7.!>$#>.$6*.7!*7!>$#@*<.<!*:!65.!!"#$%&'!&($)'*+,'-.&/$0$/)1$"2!SZT'!

!

!

14R30!1#E*8.!1.<*[email protected]#>.$[7!\%*<.! 1

MMAPI Architecture

!

"#$%&'(#)*+',#&

!"!# $%&'()#*+&+(#,-.(%#

!"#$%&'($)

#$%&'($)

*#$+$,-.$)

/,%#,$)

-&0/$)

!"#$%&"'(

)!"*"+,-'(

.+#!+'(

/"#$$0,#+"'(

,$0."'(

/"#$$0,#+"'(

.+0)'(0!1"2/0*13"/%#

,$0."'(

,$0."'(

,$0."'(

!"#$%&'($)

#$%&'($)

*#$+$,-.$)

/,%#,$)

-&0/$)

!"#$%&"'(

)!"*"+,-'(

.+#!+'(

/"#$$0,#+"'(

,$0."'(

/"#$$0,#+"'(

.+0)'(0!1"2/0*13"/%#

,$0."'(

,$0."'(

,$0."'(

!

"*-%$.!/0!12+3.$!45+5.!&#6.2!

"*-%$.!/!47#84!57.!45+5.!&#6.2!9#$!Player4'!Player4!+$.!,$.+5.6!*:!57.!;(<=>?@A=B!45+5.C!+:6!+$.!53D*,+223!$.+2*E.6C!57.:!D$.9.5,7.6C!+:6!57.:!45+$5.6'!F7.:!57.3!$.+,7!57.!.:6!#9!57.*$!&.6*+!9*2.C!#$!

stop()!*4!,+22.6C!57.3!$.5%$:!5#!57.!1<="=GHI=B!45+5.'!

J#%!,+:!,7.,)!+!D2+3.$K4!45+5.!L3!,+22*:-!*54!getState!&.57#6'!M%5!L.!+8+$.!57+5!D2+3.$4!,+:!,7+:-.!

45+5.!63:+&*,+223!#$!#57.$!57$.+64!,+:!,7+:-.!57.*$!45+5.C!4#!57+5!L3!57.!5*&.!57.!getState!&.57#6!

$.5%$:4C!*54!$.4%25!&+3!:#!2#:-.$!$.92.,5!57.!,%$$.:5!45+5.!#9!57.!D2+3.$'!

N*&*2+$23C!3#%!,+:!-.5!:#5*9*,+5*#:4!#9!+!D2+3.$K4!45+5.!,7+:-.4!L3!$.-*45.$*:-!+!PlayerListener!8*57!*5!+:6!L3!%4*:-!57.!2*45.:.$K4!playerUpdate!&.57#6'!M%5!:#5.!57+5!57.!!"#$%&'!&($)'*+,'

-.&/$0$/)1$"2!-*O.4!:#!-%+$+:5..4!+L#%5!7#8!D$#&D523!57.!45+5.!,7+:-.!.O.:54!8*22!L.!6.2*O.$.6C!4#!

87.:!3#%!$.,.*O.!57.!P45+$5.6Q!.O.:5C!57.!&.6*+!&+3!+2$.+63!7+O.!.:6.6!R+:6!57.$.!&+3!L.!+:!P.:6!

#9!&.6*+Q!.O.:5!+2$.+63!:.S5!*:!57.!T%.%.!9#$!6.2*O.$3!5#!3#%U'!

>:#57.$!,#&D2*,+5*#:!*4!57+5!57.!:#5*9*,+5*#:4!+$.!+43:,7$#:#%4C!57+5!*4C!3#%$!.O.:5!,+22L+,)!&+3!L.!

,+22.6!9$#&!+!6*99.$.:5!57$.+6!5#!57.!%4%+2!%4.$!*:5.$9+,.!57$.+6C!+:6!*5!&+3!L.!,+22.6!87*2.!3#%$!,2+44!

*4!+2$.+63!7+:62*:-!+!%4.$!*:5.$9+,.!.O.:5!*:!+!6*99.$.:5!57$.+6'!G#!-.5!L+,)!5#!57.!D%$.23!4.T%.:5*+2!

.O.:5!&#6.2C!57.!D2+3.$!45+5.!,7+:-.!,+22L+,)4!*:!57.!.S+&[email protected]!D$.4.:5.6!*:!57*4!6#,%&.:5!%4.!

57.!callSerially!&.57#6!#9!57.!V@B1!Display!,2+44!+:6!4*&D23!T%.%.!:.8!%4.$!*:5.$9+,.!.O.:54'!

G7.4.!:.8!.O.:54!+$.!57.:!7+:62.6!4.T%.:5*+223!8*57!57.!#57.$!%4.$!*:5.$9+,.!.O.:54C!$+57.$!57+:!

D#44*L23!#O.$2+DD*:-'!

!

V@B10!V#L*2.!V.6*+!>1@!B.O.2#D.$W4!X%*6.! 1

Player State Model

MMAPI Usage

• Check device support(stage 1)

• Check Content-Type

• Audio -

• sampled files large

• MIDI small

MMAPI Camera

• Capture video (mostly stills)

• Draw to Form / Screen

• Create thumbnails

• Interesting applications

• Attack of the Killer Virus• http://www.ojom.com/?id=16

Networking! (the good kind)

GCF

• Generic Connection Framework

• lives in javax.microedition.io

• HTTP required in MIDP 2.0

Connection

InputConnection OutputConnection

StreamConnection

CommConnection ContentConnection

HttpConnection

HttpsConnection

Partial GCF Diagram

HTTP

• Powers the “dubdubdub” AKA the Interweb

• Stateless protocol

• Required in MIDP 2.0

OPERATION: HTTP

• Requests + Responses

• GET, HEAD, POST

• GET - parameters in URL (query string)

• http://mysite.com/?this=that&p=1

• HEAD - only headers get returned

• POST - parameters passed in body

HTTP Gotchas

• POST is more complex

• Costs $$ [except for WiFi on N80 :-) ]

• Affects MIDlet Security

• Set Permissions

• javax.microedition.io.Connector.http (and friends)

Exercise 3

• Create a simple MIDlet which uses user input and (possibly) HTTP GET to return a “useful” response

• Run in the emulator

• Deploy it to your phone and run successfully

• Extra credit: display something crazy!

HTTP Part Deux: XML

XML parsing

• Use existing libraries

• kXML - http://kxml.sourceforge.net/

• NanoXML - http://nanoxml.cyberelf.be/

• Import libraries into code - /lib folder

Download & import kXML

Export for emulation

Exercise 4

• Create a MIDlet which consumes a data feed in an interesting way

• Run it in the emulator

• Deploy it to your phone and run successfully

• Extra credit: use pipes.yahoo.com

Optional topic: Games

Where Am I?

Finding yourself

• Many many ways

• Read Chris Heathcote’s eTech presentation

• 35 Ways to find your location http://conferences.oreillynet.com/cs/et2004/view/e_sess/4657

• A few more than that these days

• Location API (JSR-179)

• javax.microedition.location

Locating mobile devices

• GSM positioning

• OTD - Observer Time Difference

• EOTD - Enhanced - OTD

• TDOA - Time Difference of Arrival

• GPS / AGPS - Global Positioning System

• Galileo (soon)

Location + web

• Geocoding - via Yahoo!, Google, Ask.com, geocoder.us

• Reverse geocoding (via Autodesk, ESRI et al)

• TIGER / Line data

• Other GIS services

US Options

• Nextel / Boost (iDEN network)

• MIDP 2.0 + A-GPS

• J2ME access to the GPS device (for free!!)

• Verizon

• BREW = boo!

• Cingular / T-Mobile = Bluetooth GPS (for now)

iDEN SDK + GPS Demo

Obfuscation in da Nation

Obfuscation

• AKA bytecode obfuscator

• What is it?

• Software build tool

• What does it do?

• Reduces the size of your class files

• Makes it difficult to decompile your code

• Removes unused/unnecessary methods

Shrink, optimize, obfuscate

• Detect and remove unused classes, fields, methods, and attributes.

• Optimize bytecode and remove unused instructions.

• Rename the remaining classes, fields, and methods using short meaningless names.

• Resulting jars are smaller and harder to reverse-engineer. *(thanks Proguard docs!)

Smaller JAR files

= reduced storage requirements= faster downloading of your application= faster loading& smaller memory footprints

3 Obfuscators

• Proguard

• http://proguard.sourceforge.net/

• Retroguard

• http://www.retrologic.com/

• Jode

• http://jode.sourceforge.net/

Exercise 5

• Create a fun little game OR create a MIDlet which you would use every single day

• Run it in the emulator

• Deploy it to your phone and run successfully

• Extra credit: add a splashscreen!

Bluetooth

What is Bluetooth?

• Short range wireless networking

• Operates in the 2.45Ghz ISM band

• Named after a swedish King - Harald Blatand

• Cable replacement / short range serial

• Personal Area Network (PAN)

• “piconet” - 1 master + 7 slaves

Bluetooth Info

• 1 billion BT devices

• More than 5 million ways to use it?? (from the Bluetooth.org site)

• Bluetooth 1.0 + 1.1 = 1Mbit/s - only 720kb for user applications

• Bluetooth 2.0 supports EDR (Enhanced Data Rate) allows for up to 3Mb of raw data (2.1 Mb for your apps)

• Much lower in practice ~ 100kb/s

Bluetooth - JSR 82

• Java API for Bluetooth Wireless Technology

• Consists of two separate APIs

1. Java API for Bluetooth

• Communications via BT radio

2. Java API for OBEX

• The OBEX protocol

• Optional API

Bluetooth Implementation

Radio Hardware

Link Controller

Link Manager Protocol

Host Controller

L2CAP

RFCOMM SDP

Java API for Bluetooth

{ Hardware

{ Firmware

{ SoftwareProtocols + APIs

Pros Cons

Local area networking Slow handshaking

Transfer media + files over standard protocol

Complex implementation

Communicates with numerous devices (GPS, phones, computers, PICs)

Difficult to troubleshoot

Bluetooth Pros & Cons

Useful links

• Official Bluetooth Site (lots of technical info)

• http://bluetooth.com

• Java Bluetooth

• http://javabluetooth.com

• JSR-82 Specification

• http://jcp.org/en/jsr/detail?id=82

Bluetooth Interactions

1. Discovery2. Client activities / services3. Server activities4. Peer activities

Discovery (SDP)

L2CAP (Packet)

RFCOMM (Stream)

Bluetooth Service Model

m

s

Client

ServiceMasterSlave

m

s

s

s

s

Devices + Services

• Services - identified by UUID

• UUID = Universally Unique Identifier

• 128 / 32 /16 bits

• Devices - identified by BluetoothAddress & FriendlyName

• ServiceRecord = entry in Service Discovery Database (SDDB)

• ServiceRecoed = ID + value

Your BT Stack

• Local BT Stack accessed with LocalDevice

• LocalDevice myDevice = LocalDevice.getLocalDevice()

• DiscoveryAgent.getFriendlyName()

• Methods

• int getDiscoverable()

• boolean setDiscoverable(int mode)

• static String getProperty(String property)

Properties

• bluetooth.api.version

• bluetooth.master.switch

• bluetooth.sd.attr.retrievable.max

• bluetooth.connected.devices.max

• bluetooth.l2cap.receiveMTU.max

• bluetooth.sd.trans.max

Steps to connect

1. Access Local Device

2. Discover Devices (perform inquiry)

3. Discover Services (identified by UUID)

4. Connect with specific device / service

Concepts

• DiscoveryAgent

• DiscoveryAgent myDa = LocalDevice.getInstance().getDiscoveryAgent();

• Service level or device level discovery

• boolean startInquiry(int accessCode, DiscoveryListener listener)

• accessCode = General Inquiry Access Code (GIAC) or

• Limited Inquiry Access Code (LIAC)

• See http://bluetooth.org/assigned-numbers/