|
@@ -17,26 +17,27 @@ function getDeviceWriteInfo() {
|
|
|
let characteristicNotifyId = ble_store.getters.getCharacteristicNotifyId();
|
|
|
return { deviceId, serviceId, characteristicWriteId, characteristicNotifyId};
|
|
|
}
|
|
|
-/**
|
|
|
- * 转移原始数据
|
|
|
- * @param buffer
|
|
|
- * @returns {*[]}
|
|
|
- */
|
|
|
-function doOriginBufferToData(buffer) {
|
|
|
- let buffer_ary = []
|
|
|
- for (let i = 8; i < buffer.length; i += 2) {
|
|
|
- buffer_ary.push(parseInt(buffer.substr(i, 2), 16))
|
|
|
- }
|
|
|
- let _buffer_ary = buffer_ary.slice(0, buffer_ary.length - 2)
|
|
|
- let _buffer_16_ary = []
|
|
|
- for (let i = 0; i < _buffer_ary.length; i += 2) {
|
|
|
- let high = _buffer_ary[i];
|
|
|
- let low = _buffer_ary[i + 1]
|
|
|
- var _firstNumber = (((high & 0xff) << 8) | (low & 0xff));
|
|
|
- _buffer_16_ary.push(this.hex2int(_firstNumber.toString(16)))
|
|
|
- }
|
|
|
- return _buffer_16_ary;
|
|
|
-}
|
|
|
+// /**
|
|
|
+// * 转移原始数据
|
|
|
+// * @param buffer
|
|
|
+// * @returns {*[]}
|
|
|
+// */
|
|
|
+// function doOriginBufferToData(buffer) {
|
|
|
+// let buffer_ary = []
|
|
|
+// for (let i = 8; i < buffer.length; i += 2) {
|
|
|
+// buffer_ary.push(parseInt(buffer.substr(i, 2), 16))
|
|
|
+// }
|
|
|
+// let _buffer_ary = buffer_ary.slice(0, buffer_ary.length - 2)
|
|
|
+// let _buffer_16_ary = []
|
|
|
+// for (let i = 0; i < _buffer_ary.length; i += 2) {
|
|
|
+// let high = _buffer_ary[i];
|
|
|
+// let low = _buffer_ary[i + 1]
|
|
|
+// var _firstNumber = (((high & 0xff) << 8) | (low & 0xff));
|
|
|
+// _buffer_16_ary.push(this.hex2int(_firstNumber.toString(16)))
|
|
|
+// }
|
|
|
+// return _buffer_16_ary;
|
|
|
+// }
|
|
|
+
|
|
|
/**
|
|
|
* ArrayBuffer转16进度字符串示例
|
|
|
* @param buffer
|
|
@@ -44,8 +45,7 @@ function doOriginBufferToData(buffer) {
|
|
|
*/
|
|
|
function ab2hex(buffer) {
|
|
|
const hexArr = Array.prototype.map.call(
|
|
|
- new Uint8Array(buffer),
|
|
|
- function (bit) {
|
|
|
+ new Uint8Array(buffer), function (bit) {
|
|
|
return ("00" + bit.toString(16)).slice(-2);
|
|
|
}
|
|
|
);
|
|
@@ -203,16 +203,16 @@ export default {
|
|
|
let $hexStr = `03 00 00 00 ${id}`;
|
|
|
this.WriteBufferInBle($hexStr)
|
|
|
},
|
|
|
- /**
|
|
|
- * 接收原始数据开关
|
|
|
- */
|
|
|
- Send2BOrder(status = true) {
|
|
|
- let $hexStr = `03 00 00 01 2b`;
|
|
|
- if (!status) {
|
|
|
- $hexStr = `03 00 00 00 2b`;
|
|
|
- }
|
|
|
- this.WriteBufferInBle($hexStr)
|
|
|
- },
|
|
|
+ // /**
|
|
|
+ // * 接收原始数据开关
|
|
|
+ // */
|
|
|
+ // Send2BOrder(status = true) {
|
|
|
+ // let $hexStr = `03 00 00 01 2b`;
|
|
|
+ // if (!status) {
|
|
|
+ // $hexStr = `03 00 00 00 2b`;
|
|
|
+ // }
|
|
|
+ // this.WriteBufferInBle($hexStr)
|
|
|
+ // },
|
|
|
/**
|
|
|
* 打开或关闭LED灯 AA CC 03 00 00 ctrl EC CKS
|
|
|
* 00/01
|
|
@@ -364,13 +364,11 @@ export default {
|
|
|
// 监听脑机电量
|
|
|
if (hexStr.substring(0, 8) === "55550203") {
|
|
|
let $power = parseInt(hexStr.substring(8, 10), 16);
|
|
|
- let $voltage = parseInt(hexStr.substring(10, 12), 16);
|
|
|
- // 监听是否插入USB
|
|
|
- $this.hasUsb = $voltage.toString().substring(0, 1) === "1";
|
|
|
- // 监听脑机电量
|
|
|
+ // let $voltage = parseInt(hexStr.substring(10, 12), 16);
|
|
|
+ // // 监听是否插入USB
|
|
|
+ // $this.hasUsb = $voltage.toString().substring(0, 1) === "1";
|
|
|
if ($power) {
|
|
|
$this.device_power = $power;
|
|
|
- // $this.device_voltage = $voltage;
|
|
|
}
|
|
|
if ($power < 10 && $power > 0) {
|
|
|
wx.showToast({ title: "脑机电量不足", icon: "none", duration: 2000});
|
|
@@ -407,10 +405,10 @@ export default {
|
|
|
setTimeout(() => {
|
|
|
that.SendOrder('87')
|
|
|
}, 3000)
|
|
|
- // 更改为不断获取教具电量
|
|
|
+ // 不断获取教具电量
|
|
|
let toy_interval = setInterval(() => {
|
|
|
let $game_status = game_store.getters.getGameStatus();
|
|
|
- if($game_status === 1){
|
|
|
+ if($game_status !== 1){
|
|
|
clearInterval(toy_interval);
|
|
|
} else{
|
|
|
that.SendOrder('8a');
|
|
@@ -435,7 +433,7 @@ export default {
|
|
|
if (hexStr.toUpperCase().indexOf("AADD8A") >= 0) {//接收教具电量状态
|
|
|
let $_hexStr = hexStr.substring(hexStr.toUpperCase().indexOf("AADD8A") + 6);
|
|
|
let $power = parseInt($_hexStr.substring(0, 2), 16)
|
|
|
- let $voltage = parseInt($_hexStr.substring(2, 4), 16)
|
|
|
+ //let $voltage = parseInt($_hexStr.substring(2, 4), 16)
|
|
|
connect_toy = true;
|
|
|
// $this.toy_power = Math.round(that.CalBLEPower($voltage));
|
|
|
if ($power > 0) {
|
|
@@ -556,20 +554,19 @@ export default {
|
|
|
ble_store.setters.setBluetoothLinkStatus(true)
|
|
|
FlagOpenControl = true;
|
|
|
}
|
|
|
- // 监听原始数据
|
|
|
- if (hexStr.substring(0, 6) === "5555e2") {
|
|
|
- let _buffer = doOriginBufferToData(hexStr)
|
|
|
- if ($game_status === 1) {
|
|
|
- wx.setStorageSync('origin_buffer', wx.getStorageSync('origin_buffer') + _buffer.join(',') + ",")
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //todo 打开原始数据
|
|
|
- if (hexStr.toUpperCase().indexOf("AADD04") >= 0) {
|
|
|
- // raw_data_open = true;
|
|
|
- that.Send2BOrder(true)
|
|
|
- wx.setStorageSync('origin_buffer', "");
|
|
|
- }
|
|
|
+ // // 监听原始数据
|
|
|
+ // if (hexStr.substring(0, 6) === "5555e2") {
|
|
|
+ // let _buffer = doOriginBufferToData(hexStr)
|
|
|
+ // if ($game_status === 1) {
|
|
|
+ // wx.setStorageSync('origin_buffer', wx.getStorageSync('origin_buffer') + _buffer.join(',') + ",")
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // // 打开原始数据
|
|
|
+ // if (hexStr.toUpperCase().indexOf("AADD04") >= 0) {
|
|
|
+ // // raw_data_open = true;
|
|
|
+ // that.Send2BOrder(true)
|
|
|
+ // //wx.setStorageSync('origin_buffer', "");
|
|
|
+ // }
|
|
|
|
|
|
});
|
|
|
},
|