Java and Bluetooth integration - PowerPoint PPT Presentation

1 / 122
About This Presentation
Title:

Java and Bluetooth integration

Description:

Feb 1998 - five companies (Ericsson, Nokia, IBM, Toshiba and Intel) ... [4] Isochronous Data Transfers. For realtime traffics. ( ex: voice) - USB Data Flow Types ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 123
Provided by: pllabCs
Category:

less

Transcript and Presenter's Notes

Title: Java and Bluetooth integration


1
Java and Bluetooth integration
2
Introduction
3
- Overview -
Java Object or Component
4
Bluetooth ???
  • 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
19
Bluetooth Protocol Stack
20
  • Bluetooth Profiles
  • give guideline on how applications should
  • use the Bluetooth protocol stack
  • TCS
  • Telephony Control Protocol Specification
  • provides telephony services
  • SDP
  • Service Discovery Protocol
  • discover services of other Bluetooth devices

21
  • RFCOMM
  • Provides an RS232 like serial interface
  • L2CAP
  • Logic Link Control and Adaption
  • multiplexes data from higher layers
  • converts between different packet sizes
  • HCI
  • Host Controller Interface
  • handles communications between a
  • separate host and a Bluetooth module

22
Windows CE .NET 4.2
  • TDI

Transport Driver Interface
An adaptation layer to Winsock

23
  • OBEX (Object Exchange)

Allow 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)
25
Deciding How to Implement ?
26
1
Host
BluetoothModule
27
2
Host
BluetoothModule
Dont need HCI Layer
28
3
BluetoothModule
Dont need HCI Layer
29
JavaBT Implementation
30
Java 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
31
JavaBT
Protocol Stack Implementation
Java RMI over Bluetooth
32
The develop environment
JavaBT
JavaBT
33
HCI Layer
34
  • Upper HCI Layer
  • HCI Driver
  • Located on the host (ex computer, PDA, ..)
  • Lower HCI Layer
  • HCI Firmware
  • Located on the bluetooth module

35
  • HCI Transport Layer
  • 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)
37
Transport 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)
40
Layer Factory and Base Layer
41
UART 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.

42
Transport Layer in Java

43
We Need Solaris version for JavaBT Linux Porting
44
(No Transcript)
45
(No Transcript)
46
(No Transcript)
47
(No Transcript)
48
TransportBaseLayer class
  • Need implement
  • init()
  • sendData(byte buf)
  • Call back to
  • TransportLayer.gotData(byte buf)

49
TransportBaseLayer
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)
59
2
Test the driver
60
(No Transcript)
61
3
Revised the code
62
- Dongle HCI Command Test Result -
63
- JNI -
64
- javah -
65
- Driver Native Code -
66
HCI Packet
  • Command packets
  • used by the host to control the bluetooth
  • module
  • Event packets
  • used by the bluetooth module to inform the
  • host

67
  • Data packets
  • 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)

70
HCI Layer in Java
71
Receiving data
f
72
Transmitting data
f
73
HCI Layer in Java, CommandController
74
Method of HCILayer.java
75
myCommandController.Reset()
HCI command packet
HCI event packet
76
EBDK
77
CommandControllerCommands
  • CommandController methods
  • READ_BD_ADDDR()
  • Inquiry(LAP, Inquiry_Length, Num_Response)
  • Create_Connection(BD_ADDR, )

Ex myCommandController.Reset()
78
CommandControllerCommand Result
  • Command Result
  • extends abstract class Return_Parameters
  • RP_Read_BD_ADDR
  • BD_ADDR bd_addr

Return value
79
(No Transcript)
80
(No Transcript)
81
BD_ADDR class
  • The class of Bluetooth Address
  • 6bytes long address, like 0x0001EC4AD8EE

82
(No Transcript)
83
HCI Event
  • HCI Event
  • extends abstract class Event
  • Event_Inquiry_Result
  • Num_Responses
  • BD_ADDR
  • Event_Connection_Complete
  • Connection_Handel
  • BD_ADDR

84
Return_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.

88
Command completes immediately
HOST
Bluetooth Module
HCI Command
HCI_Command_Complete
89
Command cant completes immediately
HOST
Bluetooth Module
HCI Command
HCI_Command_Status
HCI_Command_Complete
90
Device Discovery and Connection Setup
See Next Page
91
(No Transcript)
92
  • Inquiry (for Master)

To discovery other Bluetooth devices in the
neighbourhood.
  • Inquiry Scan (for Slave)

Becoming discoverable.
  • Page (for Master)

Initiating connections.
  • Page Scan (for Slave)

Receiving connections.

93
  • FHS (Frequence Hop Synchronisation)

Provides all the information required by the
recipient to address the sender in terms of
timing.
  • Access Code

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.
  • ID

Consists only of the access code and is used
during preconnection operation.

94
  • NULL

Used to pass acknowledgment or flow control back
to a device following reception of a packet.
  • POLL

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.
95
HCI Command and Inquiry
96
L2CAP Layer
Communication channel to upper layers
Communication channel to HCI layer
97
  • provides
  • 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 )

99
L2CAP Service
100
(No Transcript)
101
Communication channel to HCI layer
102
L2CAP Channels
103
Host
See next slide
104
Module
105
RMI over Bluetooth
106
Socket over Bluetooth (1)
  • Too many layers of protocol stacks
  • TCP/IP Too heavy?

107
Socket over Bluetooth (2)
  • Something limited

108
JavaBT Socket Layer
109
Socket 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

110
BluetoothServerSocket
  • extends ServerSocket
  • 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
112
BluetoothServerSocket
Overloads the constructor
Initialize the L2CAPService
Wait for connection
113
BluetoothServerSocket
114
BluetoothInetAddress
  • extends java.net.InetAddress
  • Pack BD_ADDR class
  • Not compatible with JDK 1.1 InetAddress
  • Java 2 better?
  • Override every method
  • getByName()

115
BluetoothInetAddress extends InetAddress
116
BluetoothSocket
  • 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

117
BluetoothSocket
118
BluetoothInputStream
  • extends java.io.InputStream
  • Override read() method
  • Read data from Bluetooth L2CAP Service/L2CAP
    Channel

119
BluetoothOutputStream
  • extends java.io.OutputStream
  • Override write(int n) method
  • Write data through Bluetooth L2CAP Service/L2CAP
    Channel

120
RMI 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)
122
Related Topics
- Linux Porting -
- USB Porting -
- EBDK -
- Spec Profile -
- Experience on trace code -
Write a Comment
User Comments (0)
About PowerShow.com