Title: Java and Bluetooth integration
1Java and Bluetooth integration
2Introduction
3- Overview -
Java Object or Component
4Bluetooth ???
- Feb 1998 - five companies (Ericsson, Nokia, IBM,
Toshiba and Intel) formed the SIG - May 20, 1998 - Bluetooth publicly announced
- July 26, 1999 - Bluetooth 1.0 Specification
Release - Today - Bluetooth 2.0 work is ongoing
in honor of King of Denmark - Harald Blåtand
(940-981 A.D.)
5(No Transcript)
6(No Transcript)
7(No Transcript)
8(No Transcript)
9(No Transcript)
10(No Transcript)
11(No Transcript)
12(No Transcript)
13(No Transcript)
14(No Transcript)
15(No Transcript)
16- Bluetooth PAN-
17- GPRS, WLAN -
18- Bluetooth Scatternet -
Ad Hoc Network
M
Master
s
Slave
s
s
M
s
s
s
s
M
M
s
M
s
s
routing
19Bluetooth Protocol Stack
20- give guideline on how applications should
- use the Bluetooth protocol stack
- Telephony Control Protocol Specification
- provides telephony services
- Service Discovery Protocol
- discover services of other Bluetooth devices
21- Provides an RS232 like serial interface
- Logic Link Control and Adaption
- multiplexes data from higher layers
- converts between different packet sizes
- Host Controller Interface
- handles communications between a
- separate host and a Bluetooth module
22Windows CE .NET 4.2
Transport Driver Interface
An adaptation layer to Winsock
23Allow a variety of devices to exchange data
simply and spontaneously.
Spontaneously is important for short duration
ad-hoc connections.
Obex has a client/server architecture, and allows
a client to push data to a server or pull data
from a server.
24(No Transcript)
25Deciding How to Implement ?
261
Host
BluetoothModule
272
Host
BluetoothModule
Dont need HCI Layer
283
BluetoothModule
Dont need HCI Layer
29JavaBT Implementation
30Java Programs
RMI
Step 3
Bluetooth Socket Interface
Step 2
Directly
Not according to formal protocol stack suggest
L2CAP Java Implementation
Step 1
HCI Java Implementation
31JavaBT
Protocol Stack Implementation
Java RMI over Bluetooth
32The develop environment
JavaBT
JavaBT
33HCI Layer
34- HCI Driver
- Located on the host (ex computer, PDA, ..)
- HCI Firmware
- Located on the bluetooth module
35- HCI Driver and Firmware communicate via
- this layer
- Bluetooth defines three transport layers
- - USB
- - RS232 (with error correction)
- - UART (no error correction)
36(No Transcript)
37Transport Layer in Java
- Need support several different transport layer
possibly. - Need easy to change to another transport
hardware. - Need platform independent possibly.
38(No Transcript)
39(No Transcript)
40Layer Factory and Base Layer
41UART Transport Layer Factory and Base Layer
- The custom transport base layer, need extend the
TransposrtBaseLayer class - Use Java Communications API to read/write data
to RS-232C cable.
42Transport Layer in Java
43We Need Solaris version for JavaBT Linux Porting
44(No Transcript)
45(No Transcript)
46(No Transcript)
47(No Transcript)
48TransportBaseLayer class
- Need implement
- init()
- sendData(byte buf)
- Call back to
- TransportLayer.gotData(byte buf)
49TransportBaseLayer
50(No Transcript)
51(No Transcript)
52- USB Data Flow Types -
1 Control Transfers
Used to configure usb device at attach time.
2 Bulk Data Transfers
Used to generate or consume large amounts of data.
3 Interrupt Data Transfers
Typically for event notification.
4 Isochronous Data Transfers
For realtime traffics. (ex voice)
53- HCI USB Transport Layer -
54(No Transcript)
55(No Transcript)
56- WinDriver -
57- Transfer HCI packets -
1
Monitor the traffic
58(No Transcript)
592
Test the driver
60(No Transcript)
613
Revised the code
62- Dongle HCI Command Test Result -
63- JNI -
64- javah -
65- Driver Native Code -
66HCI Packet
- used by the host to control the bluetooth
- module
- used by the bluetooth module to inform the
- host
67- to pass voice and data between host and
- bluetooth module
- SCO (Synchronous Connection Oriented)
- links for voice communication
- ACL (Asynchronous Connectionless) links
- for data communication
68- Three types of HCI packets -
HOST
Command Packets
Data Packets
Event Packets
Bluetooth Module
69- All HCI transactions are framed in packets
- Commands
- Event
- Data(ACL)
- Data(SCO)
70HCI Layer in Java
71Receiving data
f
72Transmitting data
f
73HCI Layer in Java, CommandController
74Method of HCILayer.java
75myCommandController.Reset()
HCI command packet
HCI event packet
76EBDK
77CommandControllerCommands
- CommandController methods
- READ_BD_ADDDR()
- Inquiry(LAP, Inquiry_Length, Num_Response)
- Create_Connection(BD_ADDR, )
Ex myCommandController.Reset()
78CommandControllerCommand Result
- Command Result
- extends abstract class Return_Parameters
- RP_Read_BD_ADDR
- BD_ADDR bd_addr
Return value
79(No Transcript)
80(No Transcript)
81BD_ADDR class
- The class of Bluetooth Address
- 6bytes long address, like 0x0001EC4AD8EE
82(No Transcript)
83HCI Event
- HCI Event
- extends abstract class Event
- Event_Inquiry_Result
- Num_Responses
- BD_ADDR
-
- Event_Connection_Complete
- Connection_Handel
- BD_ADDR
84Return_Parameters and Event
Extend
Extend
85(No Transcript)
86- Command Flow Control -
- Each time a command is sent to the
- Bluetooth module, the module responds
- with HCI_Command_Complete or
- HCI_Command_Status.
87- HCI_Command_Complete is used if the
- command can be executed immediately,
- otherwise HCI_Command_Status is used
- and HCI_Command_Complete is sent
- when the command has completed.
88Command completes immediately
HOST
Bluetooth Module
HCI Command
HCI_Command_Complete
89Command cant completes immediately
HOST
Bluetooth Module
HCI Command
HCI_Command_Status
HCI_Command_Complete
90Device Discovery and Connection Setup
See Next Page
91(No Transcript)
92To discovery other Bluetooth devices in the
neighbourhood.
Becoming discoverable.
Initiating connections.
Receiving connections.
93- FHS (Frequence Hop Synchronisation)
Provides all the information required by the
recipient to address the sender in terms of
timing.
During a connection when a link is active, the
access code identifies the packet as being from
or to a specific Master, as it is from the
Masters Bluetooth device address.
Consists only of the access code and is used
during preconnection operation.
94Used to pass acknowledgment or flow control back
to a device following reception of a packet.
Has the same structure as NULL, but must be
acknowledged.
The typical use of a POLL is by a Master to check
the presence of Slaves in a piconet, which must
then response if they are present.
95HCI Command and Inquiry
96L2CAP Layer
Communication channel to upper layers
Communication channel to HCI layer
97- multiplexing capability
- segmentation operation
- reassembly operation
- only for data (no voice support)
- can transmit and receive L2CAP data
- packets up to 64 kilobytes
- based on channels concept
98- Each channel is referred to by a 16bits
- channel identifier (CID )
99L2CAP Service
100(No Transcript)
101Communication channel to HCI layer
102L2CAP Channels
103Host
See next slide
104Module
105RMI over Bluetooth
106Socket over Bluetooth (1)
- Too many layers of protocol stacks
- TCP/IP Too heavy?
107Socket over Bluetooth (2)
108JavaBT Socket Layer
109Socket over Bluetooth
- BluetoothInputStream extends java.io.InputSteam
- BluetoothOutputStream extends java.io.OutputStream
- BluetoothSocket extends java.net.socket
- BluetoothServerSocket extends java.net.ServerSocke
t - BluetoothInetAddress extends java.netInetAddress
110BluetoothServerSocket
- overload the constructor for initializing the
- L2CAPService
- overrides the accept method to accept the
- connection from the BluetoothSocket
- overrides the getInetAddress return a
- BluetoothInetAddress
111- implements L2CAPEventIndicationInterface
- to receive the L2CAP ConnectInd event
- after receiving the ConnectInd event,
- BluetoothServerSocket will create a
- BluetoothSocket with the specific L2CAP
- CID from that event and return it.
Channel ID
112BluetoothServerSocket
Overloads the constructor
Initialize the L2CAPService
Wait for connection
113BluetoothServerSocket
114BluetoothInetAddress
- extends java.net.InetAddress
- Pack BD_ADDR class
- Not compatible with JDK 1.1 InetAddress
- Java 2 better?
- Override every method
- getByName()
115BluetoothInetAddress extends InetAddress
116BluetoothSocket
- extends java.net.Socket
- Connect through the Bluetooth L2CAP Service/L2CAP
Channel - Override every method
- getInetAddress()
- Return a BluetoothInetAddress
- getInputStream()
- Return a BluetoothInputStream
- getOutputStream
- Return a BluetoothOutputStream
117BluetoothSocket
118BluetoothInputStream
- extends java.io.InputStream
- Override read() method
- Read data from Bluetooth L2CAP Service/L2CAP
Channel
119BluetoothOutputStream
- extends java.io.OutputStream
- Override write(int n) method
- Write data through Bluetooth L2CAP Service/L2CAP
Channel
120RMI over Bluetooth Socket
- Need BluetoothRMISocketFactory
- extends java.rmi.server.RMISocketFactory
- Implement createSocket
- Return BluetoothSocket
- Implement createServerSocket
- Return BluetoothServerSocket
- RMISocketFactory.setSocketFactory (new
BluetoothRMISocketFactory())
121(No Transcript)
122Related Topics
- Linux Porting -
- USB Porting -
- EBDK -
- Spec Profile -
- Experience on trace code -