|
@@ -339,7 +339,12 @@ export default {
|
|
|
},
|
|
|
//打开蓝牙搜索
|
|
|
onBluetoothDeviceFound() {
|
|
|
- console.log("打开蓝牙搜索");
|
|
|
+ console.log(
|
|
|
+ "打开蓝牙搜索 device_status",
|
|
|
+ $this.device_status,
|
|
|
+ "是否有id _deviceId",
|
|
|
+ $this._deviceId
|
|
|
+ );
|
|
|
try {
|
|
|
// 5秒后判断 这5秒在搜索设备,搜索到就赋值给_deviceId
|
|
|
setTimeout(() => {
|
|
@@ -347,6 +352,10 @@ export default {
|
|
|
wx.stopBluetoothDevicesDiscovery();
|
|
|
$this.change_device_status(0);
|
|
|
Toast.fail("未连接到设备");
|
|
|
+ } else if ($this.device_status == 1) {
|
|
|
+ wx.stopBluetoothDevicesDiscovery();
|
|
|
+ $this.change_device_status(0);
|
|
|
+ Toast.fail("设备未打开");
|
|
|
}
|
|
|
}, 5000);
|
|
|
wx.onBluetoothDeviceFound((res) => {
|
|
@@ -363,6 +372,8 @@ export default {
|
|
|
game_store.setters.setDeviceId(device.deviceId);
|
|
|
$this._deviceId = device.deviceId;
|
|
|
|
|
|
+ console.log("蓝牙搜索状态 device_status", $this.device_status);
|
|
|
+
|
|
|
$this.createBLEConnection();
|
|
|
}
|
|
|
});
|
|
@@ -373,6 +384,12 @@ export default {
|
|
|
},
|
|
|
// 停止蓝牙搜索
|
|
|
stopBluetoothDevicesDiscovery() {
|
|
|
+ console.log(
|
|
|
+ "脑环被占用的情况下我能获取到吗?",
|
|
|
+ $this.device_status,
|
|
|
+ "是否有id _deviceId",
|
|
|
+ $this._deviceId
|
|
|
+ );
|
|
|
wx.stopBluetoothDevicesDiscovery();
|
|
|
},
|
|
|
//连接低功耗蓝牙设备。
|