javaTM API for Bluetooth

 
Introduction

J2ME and Bluetooth are two most popular and exciting technologies for the wireless world. Bluetooth enables devices to communicate wirelessly and J2ME enables to write custom applications and deploy them on mobile devices. As a bridge connecting these two technologies, Java APIs for Bluetooth wireless Technology (JSR82) was designed for the developers to use java language in developing Bluetooth applications.

This report will briefly review the JSR 82, which includes its architecture, its functionalities, some associated APIs and etc.

JSR 82 Capabilities:
The capabilities JSR 82 provides are :
l        Register services
l        Discover devices and services
l        Establish RFCOMM, L2CAP, and OBEX connections between devices
l        Using those connections, send and receive data (voice communication not supported)
l        Manage and control the communication connections
l        Provide security for these activities

JSR 82 Architecture
 
JSR82 consists of two packages: javax.bluetooth and java.obex. The first one is the core Bluetooth API and the second one is defined independently of the Bluetooth transport layer and is packaged separately. The JSR 82 API can work with both native Bluetooth stacks and Java Bluetooth stacks. Information about Bluetooth stacks can be found in Bluetooth website [ref .1]. The APIs are able to call the Java Bluetooth stacks directly, but they have to go through virtual machine if they want to call the native stack.
The Bluetooth API and the MIDP APIs can coexist in a “MIDP+Bluetooth” device but do not depend on each other’s APIs, The figure 1 in appendix 1 shows the hierarchical architecture of J2ME CDLC/MIDP and Bluetooth .

Bluetooth Control Center (BCC) and Security Mode

The BCC is the central authority for local Bluetooth device settings. It prevents the conflicts among applications so that multiple applications can execute simultaneously. The BCC might be a native application, an application with a separate API, or simply a group of settings that are specified by the manufacturer and cannot be changed by the user. the BCC is not a class or an interface defined in this specification but an important part of its security architecture
JSR 82 API Functionalities:
The functionality addressed by this specification can be categorized into three aspects: discovery, communication, and device management.
Discovery
Device discovery: Before setting up the connections a device must be able to find other devices. The core Bluetooth API offers DiscoveryAgent class and DiscoveryListener interface for discover services. DiscoveryAgent class can implement startInquiry () method to place the local device in inquiry mode and the retrieveDevices() method to return information about devices that were found via previous inquiries performed by the local device. It also provides a way to cancel an inquiry via the cancelInquiry() method. DiscoveryListener interface enablesanapplication to specify an event listener that will respond to inquiry-related events.Its method deviceDiscovered() is called every time when a device is found. And the inquiryCompleted()is called when the inquiry is completed or canceled,

Service discovery: As long as a device is discovered ,the search for service can start.
class javax.bluetooth.UUID: It encapsulates unsigned integers that are 16 bits, 32 bits or 128 bits long. And it is used to represent a universally unique identifier used widely as the value for a service attribute. Only service attributes represented by UUIDs can be searched in Bluetooth SDP.
class javax.bluetooth.DataElement: It contains the various data types that a Bluetooth service attribute value can take on.
interface javax.bluetooth.ServiceRecord : It defines the Bluetooth Service Record, provides the remote Bluetooth server device from which a ServiceRecord was obtained and retrieves desired service attributes.
Besides ,The DiscoveryAgent class and DiscoveryListener interface provide the similar functionalities like in device discovery.

Service registration: A service must be advertised on a Bluetooth server device, because only the registered service can be discovered.
interface javax.bluetooth.LocalService: getRecord() method obtains the ServiceRecord and updated service record then can be placed in the SDDB by performing notifier.acceptAndOpen() or using the updateRecord() method of LocalDevice.
class javax.bluetooth.ServiceRegistrationException extends java.io.IOException: it throws exceptions when adding or modifying a service record fails.
DEVICE MANAGEMENT LocalDevice and RemoteDevice are two essential classes for device management defined in the Generic Access Profile. LocalDevice depends on the javax.bluetooth.DeviceClass class to retrieve the device's type and the kinds of services it offers. The RemoteDevice class represents a remote device and provides methods to retrieve information about the device, besides it also defines the methods to authenticate, authorize, or encrypt data transferred between local and remote devices.

COMMUNICATION
To use a service on a remote Bluetooth device, the local Bluetooth device must communicate using the same protocol(s) as the remote service. APIs are provided to allow connections to services that have RFCOMM, L2CAP or OBEX as their highest-level protocol.

Serial port profile
Client and server applications may reside on either end of an RFCOMM session. An SPP server registers its service in the SDDB. A server channel identifier is added to the service record by the implementation. A client locates the service using the service discovery API. It then can connect to the service by specifying the server address and server channel identifier. After a connection is established, data can be transmitted in both directions between the client and server. Negotiation of connection parameters and flow control between two Bluetooth devices must be handled automatically by the SPP connection implementation.
 
 
L2CAP API

The API supports only connection-oriented L2CAP channels.
An L2CAPConnectionNotifier notifies an L2CAP server when a client initiates a connection. Once the connection is established, an L2CAPConnection object is returned. The interface L2CAPConnection and L2CAPConnectionNotifier extends the Connection interface. This L2CAPConnection interface can be used to send data to and receive data from a remote device using the L2CAP protocol.

OBject EXchange protocol (OBEX) API.

The OBEX API allows an application to complete OBEX operations between a client and a server. It is designed to perform multiplexing at the transport layer. This multiplexing model relies on the multiplexing capabilities of the transport layer protocol.

Conclusion

This report is a simple introduction of JSR 82 APIs. It presented the JSR 82 architecture and the functionalities of different APIs and gives a brief idea of how to use the APIs to build up Bluetooth applications.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值