|
@@ -1,18 +1,15 @@
|
|
|
const Manager = require('./manager');
|
|
|
|
|
|
-module.exports = {
|
|
|
- BleUtil
|
|
|
-}
|
|
|
-
|
|
|
class BleUtil {
|
|
|
static _instance = new BleUtil();
|
|
|
+
|
|
|
static getInstance() {
|
|
|
return BleUtil._instance;
|
|
|
}
|
|
|
|
|
|
constructor() {
|
|
|
var that = this;
|
|
|
- that.Manager = new Manager();
|
|
|
+ that.manager = new Manager();
|
|
|
}
|
|
|
|
|
|
///获取比较的数据
|
|
@@ -67,6 +64,7 @@ class BleUtil {
|
|
|
|
|
|
var res = await that.manager.startConnect(device);
|
|
|
if (!res) {
|
|
|
+ console.log("gadsfasdfadfaf===aaaa==");
|
|
|
onChanged(false, device);
|
|
|
return;
|
|
|
}
|
|
@@ -74,6 +72,7 @@ class BleUtil {
|
|
|
const strings = require('./../../utils/strings');
|
|
|
var services = await that.manager.getNotifyServices(device);
|
|
|
if (strings.isEmpty(services)) {
|
|
|
+ console.log("gadsfasdfadfaf===bbb==");
|
|
|
onChanged(false);
|
|
|
return;
|
|
|
}
|
|
@@ -82,6 +81,7 @@ class BleUtil {
|
|
|
async function (notifyServiceId, notifyCharaterId) {
|
|
|
var isTrue = that.manager.monitorCharacteristicValueChange(device, notifyServiceId, notifyCharaterId);
|
|
|
if (!isTrue) {
|
|
|
+ console.log("gadsfasdfadfaf===ccc==");
|
|
|
onChanged(false);
|
|
|
return;
|
|
|
}
|
|
@@ -116,6 +116,7 @@ class BleUtil {
|
|
|
});
|
|
|
},
|
|
|
function () {
|
|
|
+ console.log("gadsfasdfadfaf===ddd==");
|
|
|
onChanged(false);
|
|
|
return;
|
|
|
});
|
|
@@ -123,7 +124,10 @@ class BleUtil {
|
|
|
|
|
|
///发送数据
|
|
|
async sendData(device, text) {
|
|
|
+ var that = this;
|
|
|
+ console.log("gadsfasdfadfaf===222==" + text);
|
|
|
var isTrue = await that.manager.sendData(device, text);
|
|
|
+ console.log("gadsfasdfadfaf===333==" + isTrue);
|
|
|
///发送数据成功
|
|
|
if (isTrue) {
|
|
|
|
|
@@ -135,4 +139,7 @@ class BleUtil {
|
|
|
var that = this;
|
|
|
await that.manager.disconnect(device);
|
|
|
}
|
|
|
+}
|
|
|
+module.exports = {
|
|
|
+ BleUtil
|
|
|
}
|