简体   繁体   English

如何在Android中连接两个蓝牙BLE设备?

[英]How to connect two Bluetooth BLE devices in android?

I want to use Bluetooth BLE to receive data from heart rate and send a command to second device. 我想使用蓝牙BLE从心率接收数据并向第二个设备发送命令。 I write two program acccording to android sample( http://developer.android.com/samples/BluetoothLeGatt/index.html ). 我根据android示例编写了两个程序( http://developer.android.com/samples/BluetoothLeGatt/index.html )。 first program is to use the android to receive heart from A device by bluetooth. 第一个程序是使用android通过蓝牙从A设备接收心脏。 second program is to use the android to send command to B device by bluetooth. 第二个程序是使用android通过蓝牙将命令发送到B设备。 I merge two Bluetooth service into one program. 我将两个蓝牙服务合并到一个程序中。 but it seems not work. 但似乎不起作用。 i created, one BluetoohManager, one BluetoothAdapter, two service classes,two BroadcastReceiver, two BluetoohDevices. 我创建了一个BluetoohManager,一个BluetoothAdapter,两个服务类,两个BroadcastReceiver,两个BluetoohDevice。 I don't if it is the right way. 我不是,如果这是正确的方法。 it seems not work. 看来行不通。 Does anyone have some code example? 有人有代码示例吗? or does someone can tell me how to modify the android code example (BluetoothLeGatt) to deal two bluetooth devices? 还是有人可以告诉我如何修改android代码示例(BluetoothLeGatt)以处理两个蓝牙设备?

We have some of the best libraries available for bluetooth communication, this might help you 我们拥有一些可用于蓝牙通信的最佳库,这可能对您有帮助

Bluetooth LE Library for Android 适用于Android的Bluetooth LE库

SmartGattLib SmartGattLib

android-btxfr android-btxfr

Android-BluetoothSPPLibrary Android-BluetoothSPPLibrary

Android-Bluetooth-Library Android-蓝牙库

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

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