背景
我正在进行一个项目,通过蓝牙将Android应用程序与Arduino板连接(Arduino Uno有一个HC-05模块)。因此,我开始从Arduino方面开发,临时使用Play Store上的蓝牙终端应用程序来模拟我必须传输的任何数据。现在我要搬到它的Android那一边。
当然,我直接使用BluetoothChat示例(https://developer.android.com/samples/BluetoothChat/index.html)来获得先机。谷歌在线,似乎有一条线的改变应该到BluetoothChat连接到我的HC-05模块。
问题
所以我不能把我的BluetoothChat和HC-05连接到Arduino。Arduino项目应该能工作,它可以很好地连接到Play Store上的各种蓝牙终端应用程序。
我对BluetoothChat示例所做的唯一更改是更改BluetoothChatService.java中的代码:
从…
// Unique UUID for this application
private static final UUID MY_UUID_SECURE =
UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
private static final UUID MY_UUID_INSECURE =
UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66");至
// HC-05 UUID "00001101-0000-1000-8000-00805F9B34FB"
private static final UUID MY_UUID_SECURE =
UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
private static final UUID MY_UUID_INSECURE =
UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");我的印象是,这是我需要做的唯一改变,以允许我的BluetoothChat样本开始移动。类似这样的东西(http://blog.onaclovtech.com/2012/04/modifying-bluetooth-chat.html),尽管它看起来是BluetoothChat的旧版本。
任何帮助都将不胜感激。谢谢!
发布于 2015-08-21 00:30:56
我找到了自己的解决方案,有必要更改设备的名称,以匹配HC-05。如果我是在开箱即用的情况下运行一个普通模块(在本例中不是这样),则需要设置:
// Name for the SDP record when creating server socket
private static final String NAME_SECURE = "BluetoothChatSecure";
private static final String NAME_INSECURE = "BluetoothChatInsecure";至:
private static final String NAME_SECURE = "HC-05";
private static final String NAME_INSECURE = "HC-05";https://stackoverflow.com/questions/32130529
复制相似问题