蓝牙连接10003问题
发布于 5 年前 作者 guiyinggu 13190 次浏览 来自 问答

搜索附近可连接蓝牙,搜索到后通过deviceId连接,返回10003,求解啊。为什么搜索到设备连接会失败 10003。

6 回复

那我应该什么时候停止搜索去连接,不是应该在连接成功后,停止搜索吗?

你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码示例。

请问楼主解决没有

这里出现10003是偶现的吧?

理论上说没有合理的关闭close易出现10003.

来源于官网:

ps:这里wx.createBleConnection接口是直接调用的BluetoothDevice.connectGatt,也可以查查这里会有什么坑。

搜索成功后停止是正解,合理的。

这里确认是有正确关闭,还会经常性出现10003是吧?

方便复现一下问题,并在微信任意聊天输入框输入//uplog,提供相应的微信号,

我抓一下日志看一下,感谢。

手机是:坚果pro;微信版本:6.5.19;连接设备:Lenovo A7-60HC;

//搜索蓝牙设备

wx.startBluetoothDevicesDiscovery({

services: [],

allowDuplicatesKey: false,

success: function (res) {

console.log(“蓝牙搜索” + res.isDiscovering)

if (!res.isDiscovering) {

that.getBluetoothAdapterState();

} else {

that.onBluetoothDeviceFound();

}

},

fail: function (err) {

console.log(err);

}

});

//搜索设备,搜索到设备ID后连接,提示连接失败10003

onBluetoothDeviceFound: function () {

var that = this;

console.log(‘onBluetoothDeviceFound’);

wx.onBluetoothDeviceFound(function (res) {

console.log(‘new device list has founded’)

console.log(res.devices[0][‘deviceId’] + “设备名称–” + res.devices[0][‘name’]);

if(res.devices[0][‘deviceId’] == “70:72:0D:6E:90:C9”){

wx.createBLEConnection({

deviceId: ‘70:72:0D:6E:90:C9’,

success: function(res) {

console.log(“连接状态----”+res.errMsg)

},fail:function(res){

console.log(res)

}

})

}

回到顶部