Weekend project: Bluetooth multisender

In my last post I have shown you how to communicate with Bluetooth devices using java + Bluecove.jar. Using this knowledge I have created this small java weekend project – Bluetooth multisender. This program will scan for Bluetooth devices in the area. For each Bluetooth device found, it will check whether it can receives text messages. Each supported device will be added to the list on the left. All you need to do is selected device/s, write a message and press the send button. The message will be sent to all selected devices at once. Yeh, I know it’s not the nicest looking gui there is, but it’s working 🙂 download project View on github

Connecting to Bluetooth devices with Java

In this post I will show you how to use java to connect to Bluetooth devices. To do that, I will use bluecove. Bluecove is a JSR-82 implementation. JSR-82 is a java specification for defining APIs for communicating with Bluetooth devices. To use bluecove you will have to download bluecove jar. You can download it from here. Of course, you will also need a bluetooth device connected to your computer and enabled. Discovering Bluetooth devices To discover devices we need to follow these steps: 1. Get the our local BT device using blucove code. 2. Get the discovery agent from our device. 3. Start a query to search remote Bluetooth devices. Notice that the inquiry is an asynchronous function. This is why we use the lock.wait(). Notice also that we give an object named MyDiscoveryListener as a parameter to the inquiry. This listener will be executed when a device is found and when the inquiry is finished. The functions deviceDiscovered() and inquiryCompleted() are the ones exeuted when a device is found and when the inquiry is finished. The other 2 functions servicesDiscovered and serviceSearchCompleted will be used in the next section. Inquiring a device for a service Now that we Continue reading Connecting to Bluetooth devices with Java