/* 根据主服务 UUID 获取已连接的蓝牙设备*/
getConnectedBluetoothDevices() {
let _ = this;
wx.getConnectedBluetoothDevices({
services: [uni.getStorageSync('currentServiceId')],
success(res) {
console.log('kkkkk')
console.log(res)
console.log(uni.getStorageSync('currentDeviceId'))
console.log('kkkkk')
if (res.devices.length == 0) { // 没有设备连接
uni.showLoading({
title: '蓝牙连接中...',
mask: true
})
if (uni.getSystemInfoSync().platform === 'android') {
console.log('安卓直接连接2222')
console.log(this.deviceId)
_.toConnectEquip()
} else { // ios开始搜索
_.find() // 开始搜索蓝牙
}
} else {
for (let item of res.devices) {
if (item.deviceId == uni.getStorageSync('currentDeviceId')) {
_.hasConnectBTFlag = true;
uni.setStorageSync('hasConnectBTFlag', true);
_.deviceId = uni.getStorageSync('currentDeviceId')
_.serviceId = uni.getStorageSync('currentServiceId')
uni.hideLoading()
_.notifyBLECharacter()
_.writePileStatusCode()
}
}
}
}
})
},
06-05
2601

01-12
4244

01-20