getBLEDeviceCharacteristics() {
let deviceId = this.deviceId;
let serviceId = this.serviceId;
let self = this;
return new Promise((resolve, reject) => {
uni.getBLEDeviceCharacteristics({
deviceId,
serviceId,
success: res => {
console.log('获取设备信息',JSON.stringify(res.characteristics))
for (let _obj of res.characteristics) {
// 获取notify
if (_obj.properties.notify) {
self.notifyId = _obj.uuid;
uni.setStorageSync('notifyId', self.notifyId);
}
// 获取writeId
if (_obj.properties.write) {
self.writeId = _obj.uuid;
uni.setStorageSync('writeId', self.writeId);
}
}
let result = {
'notifyId': self.notifyId,
'writeId': self.writeId
};
self.showToast(`获取服务中所有特征值OK,${JSON.stringify(result)}`);
resolve(result)
},
fail: err => {
self.showToast(`getBLEDeviceCharacteristics` + JSON.stringify(err));
reject(err);
}
})
});
}