|
@@ -416,30 +416,7 @@ class Manager {
|
|
|
deviceId: deviceId,
|
|
|
serviceId: that.writeServiceId,
|
|
|
success: function (res) {
|
|
|
- var characteristics = res.characteristics;
|
|
|
- if (characteristics.length <= 0) {
|
|
|
- failed();
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- for (let i = 0; i < characteristics.length; i++) {
|
|
|
- var charc = characteristics[i];
|
|
|
- ///可以开始读取数据
|
|
|
- if (charc.properties.notify) {
|
|
|
- console.log("gadsfasdfadfaf===zzz==");
|
|
|
- getMessageCall(charc.uuid);
|
|
|
- }
|
|
|
-
|
|
|
- ///可以开始写入数据
|
|
|
- if (charc.properties.write || charc.properties.writeWithoutResponse) {
|
|
|
- console.log("gadsfasdfadfaf===yyy==" + charc.properties.write + "===" + charc.properties.writeWithoutResponse);
|
|
|
- that.writeCharaterId = charc.uuid;
|
|
|
- console.log("gadsfasdfadfaf===uuu==" + that.writeServiceId + "===" + that.writeCharaterId);
|
|
|
- setTimeout(() => {
|
|
|
- successed();
|
|
|
- }, 100);
|
|
|
- }
|
|
|
- }
|
|
|
+ that._forProcessDeal(res, failed, getMessageCall, successed);
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
failed();
|
|
@@ -447,6 +424,31 @@ class Manager {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ async _forProcessDeal(res, failed, getMessageCall, successed) {
|
|
|
+ var that = this;
|
|
|
+ const time_util = require('./../../utils/time_util');
|
|
|
+ var characteristics = res.characteristics;
|
|
|
+ if (characteristics.length <= 0) {
|
|
|
+ failed();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (let i = 0; i < characteristics.length; i++) {
|
|
|
+ var charc = characteristics[i];
|
|
|
+ ///可以开始读取数据
|
|
|
+ if (charc.properties.notify) {
|
|
|
+ getMessageCall(charc.uuid);
|
|
|
+ await time_util.delayMills(300);
|
|
|
+ }
|
|
|
+
|
|
|
+ ///可以开始写入数据
|
|
|
+ if (charc.properties.write || charc.properties.writeWithoutResponse) {
|
|
|
+ that.writeCharaterId = charc.uuid;
|
|
|
+ successed();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 监听特征值变化
|
|
|
monitorCharacteristicValueChange(device, serviceId, notifyCharaterId) {
|
|
|
console.log("gadsfasdfadfaf===wwww==" + device.deviceId + "===" + serviceId +
|
|
@@ -459,11 +461,11 @@ class Manager {
|
|
|
serviceId: serviceId,
|
|
|
characteristicId: notifyCharaterId,
|
|
|
success: function (res) {
|
|
|
- console.log("gadsfasdfadfaf===eee==" + JSON.stringify(res));
|
|
|
+ console.log("啊是的发生的发生等份===cccc==" + JSON.stringify(res));
|
|
|
resolve(true);
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
- console.log("gadsfasdfadfaf===rrr==" + JSON.stringify(res));
|
|
|
+ console.log("啊是的发生的发生等份===dddd==" + JSON.stringify(res));
|
|
|
resolve(false);
|
|
|
}
|
|
|
});
|