android串口设备连接失败怎么办,【已解决】Android中连接蓝牙设备时遇到createRfcommSocketToServiceRecord的UUID问题和BluetoothSocket的co...

在尝试通过Android设备连接蓝牙串口设备时,遇到了createRfcommSocketToServiceRecord方法的UUID问题和BluetoothSocket连接失败的异常。经过一系列尝试,包括使用不同UUID和参考各种资源,最终发现必须使用特定的UUID:00001101-0000-1000-8000-00805F9B34FB(SSP协议栈默认),才能成功连接到外部串口蓝牙设备。
摘要由CSDN通过智能技术生成

【问题】

折腾:

期间,参考:

参考“Connecting as a client”中的:tmp = device.createRfcommSocketToServiceRecord(MY_UUID);

遇到UUID不懂的问题。

然后随便去

弄了个UUID:

e214d9ae-c3ba-4e25-abb5-299041353bc3

结果运行到:try {

// Connect the device through the socket. This will block

// until it succeeds or throws an exception

mmSocket.connect();

} catch (IOException connectException) {

// Unable to connect; close the socket and get out

try {

mmSocket.close();

} catch (IOException closeException) { }

return;

}

中的:mmSocket.connect();

时就抛异常了。

即:

遇到createRfcommSocketToServiceRecord的UUID不懂,以及BluetoothSocket的connect失败。

【解决过程】

1.参考:

去试试:Method m = device.getClass().getMethod(&

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值