我想连接一个安卓设备在蓝牙和 matlab 之间交换数据之间的matlab和我自己的安卓应用程序。但我无法通过“仪表控制”(Toolbox)与我的android设备连接。为什么?

首先,我扫描了所有可用的设备,然后尝试(用" connect "-button)与安卓连接。
我搜索了一下,上面写着:
所以我看了技术规范。从我的设备中,我发现它们无法支持所需的SPP蓝牙配置文件。
但在android的文档中,它说:
所以我认为android本身支持SPP,而不是我用过的设备?
有没有办法通过蓝牙将其中一部手机与matlab连接起来?
哪些android设备在工作?
发布于 2015-06-08 08:47:45
溶液
在这里,‘在android中激活蓝牙spp’说:
您需要侦听传入的连接请求,因此您应该使用以下功能:
listenUsingRfcommWithServiceRecord(String, UUID)在这里你可以找到一些例子:
代码示例
final Thread connect = new Thread(new Runnable() {
@Override
public void run() {
BluetoothServerSocket serverSocket;
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
UUID sppUUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
BluetoothSocket bluetoothSocket = null;
try {
serverSocket = bluetoothAdapter.listenUsingRfcommWithServiceRecord("your app name", sppUUID);
bluetoothSocket = serverSocket.accept(); // blocking call, until a connection is established.
Log.i("TAG", "serverSocket accept");
} catch (IOException e) {
Log.e("TAG", "IOException");
}
// If a connection was accepted
if (bluetoothSocket != null) {
// Do work to manage the connection (in a separate thread)
manageConnectedSocket(bluetoothSocket);
}
}
});
connect.start();我的错是认为我可以连接matlab和android没有自己的应用程序,只是与android‘蓝牙’连接部分的设置。
https://stackoverflow.com/questions/30568271
复制相似问题