|
@@ -1,5 +1,6 @@
|
|
|
import game_store from "../store/game";
|
|
|
import ble_store from "../store/bluetooth"
|
|
|
+import bluetooth from "../store/bluetooth";
|
|
|
|
|
|
export default {
|
|
|
test_name: 'hello world',
|
|
@@ -81,7 +82,7 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
// 发送连接玩具指令
|
|
|
- sendConnect($hex, deviceId, serviceId, Cid, Toast) {
|
|
|
+ sendConnect($hex, deviceId, serviceId, Cid, Toast, $this) {
|
|
|
//获取最后两个字节
|
|
|
const that = this
|
|
|
// 玩具对应指令数组
|
|
@@ -114,6 +115,7 @@ export default {
|
|
|
// wx.showLoading({
|
|
|
// title: '正在创建连接',
|
|
|
// })
|
|
|
+ that.watching_toy($this, deviceId, serviceId, Cid, Toast)
|
|
|
|
|
|
let $game_status = game_store.getters.getGameStatus();
|
|
|
if ($game_status == 1) {
|
|
@@ -452,6 +454,8 @@ export default {
|
|
|
game_store.setters.setDeviceId(deviceId)
|
|
|
game_store.setters.setServiceId(serviceId)
|
|
|
game_store.setters.setCid(item.uuid)
|
|
|
+ //打开数据帧
|
|
|
+ $this.sendOpen(deviceId, serviceId, item.uuid)
|
|
|
// $this.sendPause(deviceId, serviceId, item.uuid)
|
|
|
//获取玩具的值
|
|
|
// bluetooth.sendConnect($this.toy_hex, deviceId, serviceId, item.uuid)
|
|
@@ -474,23 +478,22 @@ export default {
|
|
|
},
|
|
|
//监听玩具得状态
|
|
|
watching_toy($this, deviceId, serviceId, Cid, Toast) {
|
|
|
- Toast.clear()
|
|
|
Toast.loading({
|
|
|
duration: 0,
|
|
|
forbidClick: false,
|
|
|
- message: "检测连接中"
|
|
|
+ message: "正在创建连接"
|
|
|
})
|
|
|
let that = this
|
|
|
let $count = 0
|
|
|
setTimeout(() => {
|
|
|
Toast.clear()
|
|
|
- }, 10000)
|
|
|
+ }, 5000)
|
|
|
//关闭核销选项窗口
|
|
|
// $this.pay_window = false
|
|
|
wx.onBLECharacteristicValueChange((characteristic) => {
|
|
|
try {
|
|
|
- console.log("收到" + that.ab2hex(characteristic.value));
|
|
|
let hexStr = that.ab2hex(characteristic.value)
|
|
|
+ console.log("收到" + hexStr);
|
|
|
//连接玩具
|
|
|
let $flag = that.connect_toy(hexStr, deviceId, serviceId, Cid, Toast)
|
|
|
//连接不上设备
|
|
@@ -507,7 +510,7 @@ export default {
|
|
|
that.watchingDevice($this)
|
|
|
} else {
|
|
|
$count++
|
|
|
- if ($count == 15) {
|
|
|
+ if ($count == 10) {
|
|
|
Toast.clear()
|
|
|
$this.change_toy_connect_status(3)
|
|
|
wx.offBLECharacteristicValueChange()
|