wx.openBluetoothAdapter 判断蓝牙是否处于开启状态
return new Promise((resolve, reject) => {
wx.openBluetoothAdapter({
success: function (res) {
console.log('蓝牙已开启!');
resolve(true);
},
fail: function (e) {
console.log('蓝牙未开启或不支持蓝牙!')
resolve(false);
}
});
});
wx.openBluetoothAdapter(Object object) 初始化蓝牙模块
wx.openBluetoothAdapter({
success: () => {
this.bluetoothInit(); //成功后调用 蓝牙初始化
},
fail: () => { }
});
wx.getBluetoothAdapterState(Object object) 获取本机蓝牙适配器状态
wx.getBluetoothAdapterState({
success (res) {
console.log(res)
}
});
wx.startBluetoothDevicesDiscovery(Obj