|
@@ -517,11 +517,22 @@ Page({
|
|
}
|
|
}
|
|
|
|
|
|
///去蓝牙连接处理
|
|
///去蓝牙连接处理
|
|
- if (index === deviceListSelect) {
|
|
|
|
- var param = '?param=' + JSON.stringify(device);
|
|
|
|
- route_util.jumpParam('/pages/pageC/deviceDetail/detail', param);
|
|
|
|
|
|
+ // {"connectType":1,"deviceId":"E4:9F:80:09:40:EC","name":"E4:9F:80:09:40:EC","state":"online","ProdModel":"MW-SR1(4G_WIFI)","devName":"猫王音响x阿基米德 SR1 妙播收音机"}
|
|
|
|
+ if (index === deviceListSelect && device.state === "online") {
|
|
|
|
+ route_util.jumpParam('/pages/deviceDetail/detail', JSON.stringify(device))
|
|
} else if (device.state === "offline") {
|
|
} else if (device.state === "offline") {
|
|
- console.log("去连接蓝牙", device)
|
|
|
|
|
|
+
|
|
|
|
+ var deviceList = that.getDeviceList();
|
|
|
|
+ var deviceListSelect = that.getDeviceListSelect();
|
|
|
|
+ if (deviceListSelect != null && deviceList.length > deviceListSelect) {
|
|
|
|
+ that.setData({
|
|
|
|
+ deviceListSelect: null,
|
|
|
|
+ });
|
|
|
|
+ var currentDevice = deviceList[deviceListSelect];
|
|
|
|
+ await BtHelper.getInstance().disconnect(currentDevice);
|
|
|
|
+ // await time_util.delayMills(500);
|
|
|
|
+ }
|
|
|
|
+
|
|
device.name = device.devName;
|
|
device.name = device.devName;
|
|
BtHelper.getInstance().connect(device, function (isConnected, d) {
|
|
BtHelper.getInstance().connect(device, function (isConnected, d) {
|
|
if (isConnected) {
|
|
if (isConnected) {
|
|
@@ -530,7 +541,24 @@ Page({
|
|
}
|
|
}
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|
|
- // {"connectType":1,"deviceId":"E4:9F:80:09:40:EC","name":"E4:9F:80:09:40:EC","state":"online","ProdModel":"MW-SR1(4G_WIFI)","devName":"猫王音响x阿基米德 SR1 妙播收音机"}
|
|
|
|
|
|
+ var deviceList = that.getDeviceList();
|
|
|
|
+ var deviceListSelect = that.getDeviceListSelect();
|
|
|
|
+ if (deviceListSelect != null && deviceList.length > deviceListSelect) {
|
|
|
|
+ that.setData({
|
|
|
|
+ deviceListSelect: null,
|
|
|
|
+ });
|
|
|
|
+ var currentDevice = deviceList[deviceListSelect];
|
|
|
|
+ await BtHelper.getInstance().disconnect(currentDevice);
|
|
|
|
+ // await time_util.delayMills(500);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ device.name = device.devName;
|
|
|
|
+ BtHelper.getInstance().connect(device, function (isConnected, d) {
|
|
|
|
+ if (isConnected) {
|
|
|
|
+ device.state = "online";
|
|
|
|
+ that.addBlueDevice(device);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|