有些手机通过蓝牙搜索能够搜索的指定设备,但是有些手机却收不到,我这里有两台设备是搜索不到的。能不能把所有的异步方法改成Promise的##微信小程序教程。
/**
* 搜索蓝牙设备
*/
searchBluetooth: function() {
var that = this;
wx.startBluetoothDevicesDiscovery({
services: [util.MAIN_SERVICE_LIST_UUID],
interval: 3000,
success: function(res) {
console.log('开启搜索蓝牙成功');
},
})
wx.onBluetoothDeviceFound(function(res) {
console.log(res);
console.log('发现新的设备');
// 获取搜索到的蓝牙设备
wx.getBluetoothDevices({
success: function(resList) {
console.log(resList);
that.setData({
bluetoothDevices: resList.devices
});
console.log(that.data.bluetoothDevices);
}
})
})
},
本文来自微信小程序开发者论坛 -微信小程序工厂 http://www.xcxgc.com,转载请保留,开发微信小程序、定制微信小程序来微信小程序工厂网。
网友回复
Br**回复:
手机信息:Redmi4 MIUI9.5|稳定版
android版本:6.0.1 微信版本:6.7.1321
本文网址:http://www.91bianli.com/kaifazhinan/62102.html