|
@@ -57,7 +57,9 @@ class bleManager {
|
|
|
if (that.callBackConnect != null) {
|
|
|
if (that.connectWillDevice != null && res.name == that.connectWillDevice.clientType) {
|
|
|
res.advertisData = res.advertisData ? that.buf2hex(res.advertisData) : '';
|
|
|
- that.callBackConnect(res);
|
|
|
+ if (that.callBackConnect != null) {
|
|
|
+ that.callBackConnect(res);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
if (res.name != "") {
|
|
@@ -83,9 +85,14 @@ class bleManager {
|
|
|
if (that.callBackConnect != null) {
|
|
|
for (var i = 0; i < res.devices.length; i++) {
|
|
|
var temp = res.devices[i];
|
|
|
+ if (devices.devices[i].name == "MW-SR1(4G_WIFI)") {
|
|
|
+ console.log("gadsfqwerqeddsafdafwqr==111==" + JSON.stringify(devices.devices[i]));
|
|
|
+ }
|
|
|
if (that.connectWillDevice != null && temp.name == that.connectWillDevice.clientType) {
|
|
|
temp.advertisData = temp.advertisData ? that.buf2hex(temp.advertisData) : '';
|
|
|
- that.callBackConnect(temp);
|
|
|
+ if (that.callBackConnect != null) {
|
|
|
+ that.callBackConnect(temp);
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -115,7 +122,9 @@ class bleManager {
|
|
|
if (that.callBackConnect != null) {
|
|
|
if (that.connectWillDevice != null && res[0].name == that.connectWillDevice.clientType) {
|
|
|
res[0].advertisData = res[0].advertisData ? that.buf2hex(res[0].advertisData) : '';
|
|
|
- that.callBackConnect(res[0]);
|
|
|
+ if (that.callBackConnect != null) {
|
|
|
+ that.callBackConnect(res[0]);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
if (res[0].name != "") {
|
|
@@ -141,14 +150,20 @@ class bleManager {
|
|
|
|
|
|
///获取已连接的设备
|
|
|
getConnectedDevices() {
|
|
|
+ var that = this;
|
|
|
wx.getBluetoothDevices({
|
|
|
success: (res) => {
|
|
|
if (res.devices && res.devices.length > 0) {
|
|
|
for (var i = 0; i < res.devices.length; i++) {
|
|
|
var temp = res.devices[i];
|
|
|
+ if (res.devices[i].name == "MW-SR1(4G_WIFI)") {
|
|
|
+ console.log("gadsfqwerqeddsafdafwqr==000==" + JSON.stringify(res.devices[i]));
|
|
|
+ }
|
|
|
if (that.connectWillDevice != null && temp.name == that.connectWillDevice.clientType) {
|
|
|
temp.advertisData = temp.advertisData ? that.buf2hex(temp.advertisData) : '';
|
|
|
- that.callBackConnect(temp);
|
|
|
+ if (that.callBackConnect != null) {
|
|
|
+ that.callBackConnect(temp);
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|