|
@@ -463,17 +463,18 @@ export default {
|
|
|
|
|
|
//todo 接收脑机关机指令
|
|
|
if (hexStr.toUpperCase().indexOf("AADD5A00000000A5") >= 0) {
|
|
|
- Notify({
|
|
|
- type: 'danger',
|
|
|
- duration: 0,
|
|
|
- message: '智脑机已关机,训练结束',
|
|
|
- onOpened() {
|
|
|
- setTimeout(() => {
|
|
|
+ let $game_status = game_store.getters.getGameStatus();
|
|
|
+ if ($game_status === 1 || $game_status === 2) {
|
|
|
+ Notify({
|
|
|
+ type: 'danger',
|
|
|
+ duration: 0,
|
|
|
+ message: '智脑机已关机,训练结束',
|
|
|
+ onOpened() {
|
|
|
$this.endTheGame();
|
|
|
- that.clearStatus($this);
|
|
|
- }, 2000)
|
|
|
- }
|
|
|
- });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ that.clearStatus($this);
|
|
|
$comments = "脑环关机的应答";
|
|
|
}
|
|
|
}
|
|
@@ -494,26 +495,32 @@ export default {
|
|
|
*/
|
|
|
watchBLEstatus($this) {
|
|
|
let that = this;
|
|
|
+ if($this && $this.$options.name){
|
|
|
+ LOG_DEBUG("微信自身监听低功耗蓝牙连接状态:", $this.$options.name);
|
|
|
+ }
|
|
|
// 微信自身监听低功耗蓝牙连接状态的改变事件
|
|
|
wx.onBLEConnectionStateChange((res) => {
|
|
|
// 该方法回调中可以用于处理连接意外断开等异常情况
|
|
|
ble_store.setters.setBluetoothLinkStatus(res.connected);
|
|
|
LOG_DEBUG("监听脑机连接状态:", res.connected);
|
|
|
- if (res.connected === false) {
|
|
|
+ if (!res.connected) {
|
|
|
//判断游戏是否游戏中
|
|
|
let $game_status = game_store.getters.getGameStatus();
|
|
|
+ LOG_DEBUG("智脑机已断开连接,游戏状态:", $game_status);
|
|
|
if ($game_status === 1 || $game_status === 2) {
|
|
|
if($this && $this.$options.name && $this.$options.name === "StartGames"){
|
|
|
$this.endTheGame();
|
|
|
}
|
|
|
- Notify({
|
|
|
- type: 'danger',
|
|
|
- duration: 0,
|
|
|
- message: '智脑机已断开连接,正在尝试重新连接',
|
|
|
- onOpened() {
|
|
|
- that.reconnect(res.deviceId, $this)
|
|
|
- }
|
|
|
- });
|
|
|
+ // if($this && $this.$options.name && $this.$options.name === "StartGames"){
|
|
|
+ // Notify({
|
|
|
+ // type: 'danger',
|
|
|
+ // duration: 0,
|
|
|
+ // message: '智脑机已断开连接,正在尝试重新连接',
|
|
|
+ // onOpened() {
|
|
|
+ // that.reconnect(res.deviceId, $this)
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
} else {
|
|
|
that.clearStatus($this);
|
|
|
}
|
|
@@ -544,6 +551,7 @@ export default {
|
|
|
let $connect_count = 0;
|
|
|
let $rec = setInterval(() => {
|
|
|
let $game_status = game_store.getters.getGameStatus();
|
|
|
+ LOG_DEBUG("正在尝试重新连接,游戏状态:", $game_status);
|
|
|
if ($game_status === 1 || $game_status === 2) {
|
|
|
let $code = ble_store.getters.getDeviceSn();
|
|
|
wx.createBLEConnection({
|
|
@@ -557,18 +565,20 @@ export default {
|
|
|
that.getBLEDeviceServices($deviceInfo.deviceId)
|
|
|
that.notifyDatas($this)
|
|
|
} else {
|
|
|
- //that.openNotify($this)
|
|
|
that.watchBLEstatus($this);
|
|
|
}
|
|
|
- // that.sendToyPower();
|
|
|
},
|
|
|
fail() {
|
|
|
Notify({type: 'danger', message: `第${$connect_count}次重新连接失败`});
|
|
|
+ LOG_WECHAT($code, `第${$connect_count}次重新连接失败`);
|
|
|
game_store.setters.setGameCloseStatus(1);
|
|
|
}
|
|
|
})
|
|
|
if ($connect_count >= 3) {
|
|
|
- $this.endTheGame();
|
|
|
+ let $game_status = game_store.getters.getGameStatus();
|
|
|
+ if ($game_status === 1 || $game_status === 2) {
|
|
|
+ $this.endTheGame();
|
|
|
+ }
|
|
|
that.clearStatus($this);
|
|
|
clearInterval($rec)
|
|
|
}
|