Git Product home page Git Product logo

bluetooth-scanner's Introduction

bluetooth-scanner

bluetooth-scanner is a bluetooth scanner java library using bluez-dbus with BlueZ version 5.50 on linux OS. I releases this in the form of the Eclipse plug-in project. You need Java 8 or higher.

It uses the dbus PropertiesChanged mechanism to catch the advertising signal and provide the BluetoothDevice object and RSSI / TxPower data to the handler.

The purpose of this library is to use an advertising signal to trigger the connection to a bluetooth device.

I have confirmed that it works in Raspberry Pi 3B (Raspbian Buster Lite OS (2019-07-10)).

Install Raspbian Buster Lite OS (2019-07-10)

The reason for using this version is that it is the latest as of July 2019 and BlueZ 5.50 is included from the beginning.

Install jdk8 on Raspberry Pi 3B

For example, the installation of OpenJDK 8 is shown below.

# apt-get update
# apt-get install openjdk-8-jdk

Install git

If git is not included, please install it.

# apt-get install git

Use this with the following bundles

I would like to thank the authors of these very useful codes, and all the contributors.

How to use

The following sample code implementing the IScanHandler interface will be helpful.

import com.github.hypfvieh.bluetooth.DiscoveryFilter;
import com.github.hypfvieh.bluetooth.DiscoveryTransport;
import com.github.hypfvieh.bluetooth.wrapper.BluetoothDevice;

import io.github.s5uishida.iot.bluetooth.scanner.IScanHandler;
import io.github.s5uishida.iot.bluetooth.scanner.ScanData;
import io.github.s5uishida.iot.bluetooth.scanner.ScanProcess;

public class MyScan {
    public static void main(String[] args) throws IOException, InterruptedException {
        Map<DiscoveryFilter, Object> filter = new HashMap<DiscoveryFilter, Object>();
        filter.put(DiscoveryFilter.Transport, DiscoveryTransport.LE);
        
        ScanProcess scanProcess = new ScanProcess("hci0", new MyScanHandler(), filter);
        scanProcess.start();
    }
}

class MyScanHandler implements IScanHandler {
    private static final Logger LOG = LoggerFactory.getLogger(MyScanHandler.class);
    
    @Override
    public void handle(BluetoothDevice device, ScanData data) {
        LOG.info(device.toString());
        LOG.info(data.toString());
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.