PC-side Java development problems encountered with Bluetooth

Source: Internet
Author: User
Tags event listener

Due to the project's cause. To develop a client that transmits data via Bluetooth on a computer. I use the java,jsme development.

Client: To search the Bluetooth signal, and then find the corresponding Bluetooth signal to connect.

Server: The client needs to connect the Bluetooth signal.

An open source component Bluecove is also required on the pcserver side. This component implements the JSR-82 Java Bluetooth specification and masks the various functions of the native Bluetooth protocol stack on the underlying operating system level.

The main reason for this component is that J2SE does not implement the JSR-82 specification protocol.

I'm using a bluecove-2.0.3.jar.

Also need to Commons-io jar package, I use 2.2 jar package.

The Java Bluetooth API relies on the Java Universal Connection framework. This has been a limitation of the Java Bluetooth API app. However, it is recommended to increase the GCF to J2SE.

The Java Bluetooth API makes it possible to access many other systems.

The Java Bluetooth API defines two packages: one is the core javax.bluetooth of the Java Bluetooth API. There is also a Javax.obex (OBEX) for the object Exchange protocol.

no matter what Bluetooth apps have these components: stack initialization component, device management component, Device Discovery component. Service discovery components and communication components.

The JSR82 specification describes the two classes for device management: Localdevice and Remotedevice.

Localdevice agrees to ask for static information about your Bluetooth device. It relies on the Javax.bluetooth.DeviceClass class to obtain the device type and the type of service it provides.

Remotedevice can be used to obtain device information for Bluetooth proximity (for example, the address of a remote Bluetooth device).

It can represent a remote device (for example, a device in the reachable range) and provide a corresponding method to obtain information about the device, including its Bluetooth address and name.

Each Bluetooth device has a unique hardware address. Like a computer's MAC address. You can set the level of device discovery by calling the Setdiscoverable () method in the Localdevice object to enable other Bluetooth devices to discover the current device.

Device Discovery

Wireless devices require a mechanism to consent to their discovery of other devices and access to their capabilities. The Discoveryagent class and Discoverylistener interfaces of the core Bluetooth API provide the required discovery services. There are three ways to get a list of accessible devices. The Discoveryagent.startinquiry () method sets the device to query mode. To take advantage of such a pattern, the application must specify an event listener to respond to the query-related events. The discoverylistener.inquirycompleted () method is called when the query is complete or canceled.

Service discovery

Service discovery agrees to your discovery of nearby services. Regardless of which device provides the service. Discoveryagent provides methods that can be used to discover services on a Bluetooth service device. And initializes the service discovery transaction.

Once the service can be discovered, the service must first be registered or broadcast on a Bluetooth service device.

Service equipment is responsible for a very many tasks, including creating a service record describing the service provided, accepting a connection from the client, and adding a new service record to the service Discovery Database (SDDB) of the service device.

The software I use is an ADT integrated development tool that I previously compiled for Android.

32-bit Java development environment.

The PC side uses the Bluetooth adapter, which installs the bluesoleil_.6.v6.4.249.

Here are some of the problems I encountered while developing my PC

1. Because the Bluecove has not been updated, the jar package can be used only in 32 Java environments, and the 64-bit Java development environment will be error-free.

1.Port Mismarch [4]and [5]

Description: Bluetooth virtual port does not match Bluetooth port on your PC


Solve:

in my device properties for the Bluetooth adapter -- Serial Port -- only a serial port and its own active connection to no, the connection direction is connected

Remove the remaining port numbers, or remove them directly from the classic Bluetooth interface. Another search connection

2.connect failed

Solve:

driver not installed, in Device Manager Right-click exclamation Point Choose to install the driver online.

PC-side Java development problems encountered with Bluetooth

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.