安卓蓝牙连接一直失败

发布于 8 年前作者 songyan1923 次浏览最后编辑 8 年前来自 ask

安卓手机蓝牙连接一直失败,设置了五分钟的超时时间还是不行,监听蓝牙状态改变的回调

wx.onBLEConnectionStateChange,蓝牙的状态有时是连接有时是未连接,

wx.createBLEConnection这个方法的success一直不走,走fail的方法,错误信息是10006/10012;iOS测试没有问题;求教

连接代码如下:

//连接蓝牙 – 暴露给外界

function connectBluetoothDevices(device, isFunction) {

connectCallBack = isFunction;

stopBluetoothDevicesDiscovery();

currentDevice = deviceInfo;

deviceId = device[‘devices’][0][‘deviceId’];

console.log(‘要去连接蓝牙啦!’);

wx.createBLEConnection({

deviceId: deviceId,

timeout:300000,

success: function (res) {

console.log(‘连接成功’);

getBluetoothDeviceServices(device)

},

fail: function (error) {

console.log(error);

console.log(‘连接失败’);

closeBluetoothConnect();

connectBluetoothDevices(device, isFunction);

}

})

}

2 回复
gangzhong
gangzhong1 楼6 年前

遇到同样问题。。。蛋疼

qiangyao
qiangyao2 楼6 年前

请问楼主问题解决了吗?