|
@@ -405,14 +405,14 @@ class Manager {
|
|
|
}
|
|
|
|
|
|
///获取设备真正的属性特征值
|
|
|
- getCharacteristics(device, failed, getMessageCall, successed) {
|
|
|
+ getCharacteristics(device, failed, readSucceed) {
|
|
|
var that = this;
|
|
|
var deviceId = device.deviceId;
|
|
|
wx.getBLEDeviceCharacteristics({
|
|
|
deviceId: deviceId,
|
|
|
serviceId: that.writeServiceId,
|
|
|
success: function (res) {
|
|
|
- that._forProcessDeal(res, failed, getMessageCall, successed);
|
|
|
+ that._forProcessDeal(res, failed, readSucceed);
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
failed();
|
|
@@ -420,7 +420,7 @@ class Manager {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- async _forProcessDeal(res, failed, getMessageCall, successed) {
|
|
|
+ async _forProcessDeal(res, failed, readSucceed) {
|
|
|
var that = this;
|
|
|
const time_util = require('./../../utils/time_util');
|
|
|
var characteristics = res.characteristics;
|
|
@@ -430,19 +430,51 @@ class Manager {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ var isWrited = false;
|
|
|
for (let i = 0; i < characteristics.length; i++) {
|
|
|
var charc = characteristics[i];
|
|
|
- ///可以开始读取数据
|
|
|
- if (charc.properties.notify) {
|
|
|
- getMessageCall(charc.uuid);
|
|
|
- }
|
|
|
-
|
|
|
///可以开始写入数据
|
|
|
if (charc.properties.write || charc.properties.writeWithoutResponse) {
|
|
|
+ isWrited = true;
|
|
|
that.writeCharaterId = charc.uuid;
|
|
|
- successed();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isWrited) {
|
|
|
+ failed();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var isReaded = false;
|
|
|
+ for (let i = 0; i < characteristics.length; i++) {
|
|
|
+ var charc = characteristics[i];
|
|
|
+ ///可以开始读取数据
|
|
|
+ if (charc.properties.notify) {
|
|
|
+ isReaded = true;
|
|
|
+ readSucceed(charc.uuid);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (!isReaded) {
|
|
|
+ failed();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // for (let i = 0; i < characteristics.length; i++) {
|
|
|
+ // var charc = characteristics[i];
|
|
|
+ // ///可以开始读取数据
|
|
|
+ // if (charc.properties.notify) {
|
|
|
+ // writeSucceed(charc.uuid);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // ///可以开始写入数据
|
|
|
+ // if (charc.properties.write || charc.properties.writeWithoutResponse) {
|
|
|
+ // that.writeCharaterId = charc.uuid;
|
|
|
+ // readSucceed();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
// 监听特征值变化
|