|
@@ -233,7 +233,7 @@ export default {
|
|
|
const that = this;
|
|
|
wx.onBLECharacteristicValueChange((characteristic) => {
|
|
|
let hexStr = that.ab2hex(characteristic.value);
|
|
|
- if (hexStr.toUpperCase().indexOf("AADD")!=-1){
|
|
|
+ if (hexStr.toUpperCase().indexOf("AADD") != -1) {
|
|
|
console.log(hexStr);
|
|
|
}
|
|
|
let $data = that.get_big_data(hexStr);
|
|
@@ -261,13 +261,17 @@ export default {
|
|
|
wx.showToast({
|
|
|
title: "已连接到" + $this.toy_item.name
|
|
|
});
|
|
|
+ $this.toy_connected = true;
|
|
|
$this.change_toy_connect_status(2);
|
|
|
+ //连接成功后 获取一次教具电量信息
|
|
|
+ that.SendOrder('8a')
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- //2021年10月21日16:30:07 获取教具电量
|
|
|
+ //2021年10月21日16:30:07
|
|
|
+ // 获取教具电量
|
|
|
if (hexStr.toUpperCase().indexOf("AADD8A") != -1) {//接收教具电量状态
|
|
|
let $_hexStr = hexStr.substr(6);
|
|
|
let $power = parseInt($_hexStr.substr(0, 2), 16)
|
|
@@ -289,35 +293,32 @@ export default {
|
|
|
//2021年10月21日17:22:37
|
|
|
//收到一次UUID就发送一次获取教具的电量
|
|
|
//读取教具UUID
|
|
|
- if (hexStr.toUpperCase().indexOf("AADD84") != -1) {//接收UUID 5个字节
|
|
|
- let $_hexStr = hexStr.substr(6);
|
|
|
- let $datas = $_hexStr.substr(0, 10);
|
|
|
- if ($datas != "0000000000") {
|
|
|
- $this.toy_UUID = $datas;
|
|
|
- //读取教具电量
|
|
|
- that.SendOrder('8a')
|
|
|
- } else {
|
|
|
- //如果游戏中则重新连接
|
|
|
- if ($game_status == 1) {
|
|
|
- //先发UUID 再发id 02
|
|
|
- console.log($this.toy_UUID)
|
|
|
- console.log(`aa cc 03 00 ${$this.toy_hex} 02 0a`)
|
|
|
- } else {
|
|
|
- $this.toy_UUID = ""
|
|
|
- $this.toy_power = 0;
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ // if (hexStr.toUpperCase().indexOf("AADD84") != -1) {//接收UUID 5个字节
|
|
|
+ // let $_hexStr = hexStr.substr(6);
|
|
|
+ // let $datas = $_hexStr.substr(0, 10);
|
|
|
+ // if ($datas != "0000000000") {
|
|
|
+ // $this.toy_UUID = $datas;
|
|
|
+ // //读取教具电量
|
|
|
+ // that.SendOrder('8a')
|
|
|
+ // } else {
|
|
|
+ // //如果游戏中则重新连接
|
|
|
+ // if ($game_status == 1) {
|
|
|
+ // //先发UUID 再发id 02
|
|
|
+ // console.log($this.toy_UUID)
|
|
|
+ // console.log(`aa cc 03 00 ${$this.toy_hex} 02 0a`)
|
|
|
+ // } else {
|
|
|
+ // $this.toy_UUID = ""
|
|
|
+ // $this.toy_power = 0;
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
// 监听脑环电量
|
|
|
let $power = that.get_device_elc(hexStr);
|
|
|
if ($power) {
|
|
|
- //发送一次获取教具的UUID
|
|
|
- that.SendOrder("84");
|
|
|
-
|
|
|
// console.log("当前脑环电量:", $power)
|
|
|
$this.device_power = $power;
|
|
|
}
|
|
@@ -341,9 +342,10 @@ export default {
|
|
|
game_store.setters.setPlayedTime($this.played_time)
|
|
|
$this.played_time_text = that.formatPlaySeconds($this.played_time);
|
|
|
$this.do_datas($data);
|
|
|
- // if ($this.played_time_text.indexOf(":00") != -1 || $this.played_time_text.indexOf(":30") != -1) {
|
|
|
- // $this.post_data();
|
|
|
- // }
|
|
|
+ if ($this.played_time % 10 == 0) {
|
|
|
+ //读取教具电量
|
|
|
+ that.SendOrder('8a')
|
|
|
+ }
|
|
|
}
|
|
|
if ($this.played_time == 0) {
|
|
|
$this.post_data();
|
|
@@ -416,7 +418,7 @@ export default {
|
|
|
return $errmsg;
|
|
|
},
|
|
|
//写入buffer
|
|
|
- WriteBufferInBle($hex,$buffer_len = 8) {
|
|
|
+ WriteBufferInBle($hex, $buffer_len = 8) {
|
|
|
let $device_id = game_store.getters.getDeviceId();
|
|
|
let $service_id = game_store.getters.getServiceId()
|
|
|
let $charateristic = game_store.getters.getCharacterId();
|