安卓蓝牙连接一直失败
发布于 6 年前 作者 songyan 1791 次浏览 来自 问答

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

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 回复

遇到同样问题。。。蛋疼

请问楼主问题解决了吗?

回到顶部