简体   繁体   English

如何在Java中读取蓝牙低功耗RSSI而不是android

[英]How to read Bluetooth Low Energy RSSI in Java not android

I have a Bluetooth low energy USB that is based on TI CC2540, all i need to do is to scan the RSSI values from other beacons using my computer and save it in the database (Mysql,etc), is there a Java library that does this? 我有一个基于TI CC2540的蓝牙低功耗USB,我需要做的就是使用我的计算机扫描其他信标的RSSI值并保存在数据库中(Mysql等),是否有一个Java库可以做这个? I know how to do it in Android but i need to do it on my PC that is operating on Windows 我知道如何在Android中执行此操作,但我需要在运行Windows的PC上执行此操作

I've been working on Linux platform with similar application. 我一直在使用类似应用程序的Linux平台。

First C-program who looks for BLE enabled devices via terminal. 第一个通过终端寻找支持BLE的设备的C程序。 Make sure that you've installed bluez and btmon 确保你已经安装了bluez和btmon

    strcpy( command, "sudo ./btmon & hcitool lescan" );
    system(command);

compile and run the file from within Java and read the InputStream of console. 从Java中编译并运行该文件,并读取控制台的InputStream。

        ProcessBuilder builder = new ProcessBuilder("/beacon");
        builder.redirectErrorStream(true);
        Process process = builder.start();
        InputStream is = process.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));

Ones you get the Stream of data you can look for RSSI values and export them to your database. 您可以获得数据流,您可以查找RSSI值并将其导出到您的数据库。

Bluetooth Low Energy API for Windows 7.0 asks a similar question. 适用于Windows 7.0的蓝牙低功耗API提出了类似的问题。 Unfortunately, the answer there seems to be that only Windows 8 (not older versions) supports BLE. 不幸的是,答案似乎只有Windows 8(不是旧版本)支持BLE。

Try this library: 试试这个库:

https://github.com/movisens/SmartGattLib https://github.com/movisens/SmartGattLib

From the ReadMe: 来自自述文件:

"SmartGattLib is a Java library that simplifies the work with Bluetooth SMART devices (aka Bluetooth Low Energy in Bluetooth 4.0). It provides all UUIDs of the adopted GATT specification and an convenient way to interpret the characteristics (eg Heart Rate, BatteryLevel)." “SmartGattLib是一个Java库,它简化了蓝牙SMART设备(蓝牙4.0中的蓝牙低功耗)的工作。它提供了所采用的GATT规范的所有UUID以及解释特征的便捷方式(例如心率,电池级别)。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM