bluetooth-client-hc06

Java library: Bluetooth client for HC06 module which is widely used in projects with Arduino boards

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

org.korecky
ArtifactId

ArtifactId

bluetooth-client-hc06
Last Version

Last Version

2.0
Release Date

Release Date

Type

Type

jar
Description

Description

bluetooth-client-hc06
Java library: Bluetooth client for HC06 module which is widely used in projects with Arduino boards
Project URL

Project URL

https://github.com/vkorecky/bluetooth-client-hc06
Source Code Management

Source Code Management

https://github.com/vkorecky/bluetooth-client-hc06

Download bluetooth-client-hc06

How to add to project

<!-- https://jarcasting.com/artifacts/org.korecky/bluetooth-client-hc06/ -->
<dependency>
    <groupId>org.korecky</groupId>
    <artifactId>bluetooth-client-hc06</artifactId>
    <version>2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.korecky/bluetooth-client-hc06/
implementation 'org.korecky:bluetooth-client-hc06:2.0'
// https://jarcasting.com/artifacts/org.korecky/bluetooth-client-hc06/
implementation ("org.korecky:bluetooth-client-hc06:2.0")
'org.korecky:bluetooth-client-hc06:jar:2.0'
<dependency org="org.korecky" name="bluetooth-client-hc06" rev="2.0">
  <artifact name="bluetooth-client-hc06" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.korecky', module='bluetooth-client-hc06', version='2.0')
)
libraryDependencies += "org.korecky" % "bluetooth-client-hc06" % "2.0"
[org.korecky/bluetooth-client-hc06 "2.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.21
org.slf4j : slf4j-log4j12 jar 1.7.21
net.sf.bluecove : bluecove jar 2.1.0
net.sf.bluecove : bluecove-gpl jar 2.1.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

bluetooth-client-hc06

Java library: Bluetooth client for HC06 module which is widely used in projects with Arduino boards

Linux prerequisites

Install libbluetooth-dev package

On Ubuntu

sudo apt-get install libbluetooth-dev

Usage

Maven

Add to you pom.xml file this dependency

<dependency>
    <groupId>org.korecky</groupId>
    <artifactId>bluetooth-client-hc06</artifactId>
    <version>1.0</version>
</dependency>

Demo project

You can find demo project at link: https://github.com/vkorecky/bluetooth-client-hc06-example

Code example

Pairing

Library doesn't support pairing yet. You have to pair your bluetooth device (HC06) in your operating system first.

Find HC06 bluetooth device

	// Prepare search thread
    BluetoothScanThread scanThread = new BluetoothScanThread(new BluetoothScanEventListener() {
        @Override
        public void error(ErrorEvent evt) {
            // TODO: When error happenes
            ....
        }

        @Override
        public void scanFinished(ScanFinishedEvent evt) {
        	// TODO: When bluetooth scan finished
            ....
        }

        @Override
        public void progressUpdated(ProgressUpdatedEvent evt) {
            // TODO: When work progress is updated
            ....
        }
    });

    // Start search of bluetooth device
    scanThread.start();

Communication with HC06 bluetooth device

	RFCommBluetoothDevice selectedDevice; // Fill this object by bluetooth device which was found by BluetoothScanThread
    RFCommClientThread commThread = new RFCommClientThread(selectedDevice.getUrl(), '\n', new RFCommClientEventListener() {
        @Override
        public void error(ErrorEvent evt) {
            // TODO: When error happenes
            ....
        }

        @Override
        public void messageReceived(MessageReceivedEvent evt) {
            // TODO: When message is received from HC06 module
            ....
        }
    });
    // Starts communication
    commThread.start();

    // Send message to HC06 module
    commThread.send("This is message for Arduino.");

Versions

Version
2.0
1.1
1.0