|
@@ -6,22 +6,38 @@ var $ff = "ff";
|
|
|
var $8f = "ffffffff"
|
|
|
export default {
|
|
|
|
|
|
-
|
|
|
- sendOpen() {
|
|
|
+
|
|
|
+ sendOpenBigData() {
|
|
|
this.WriteBufferInBle("03 00 00 00 ff");
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
+ sendCloseBigData() {
|
|
|
+ this.WriteBufferInBle("03 00 00 00 00");
|
|
|
+ },
|
|
|
+
|
|
|
+ sendGetToyType() {
|
|
|
+ this.WriteBufferInBle("03 00 00 00 06");
|
|
|
+ },
|
|
|
+
|
|
|
sendControl() {
|
|
|
this.WriteBufferInBle("03 00 00 00 07");
|
|
|
},
|
|
|
-
|
|
|
- sendEnd() {
|
|
|
+
|
|
|
+ sendControlPause() {
|
|
|
|
|
|
+ this.WriteBufferInBle("03 00 00 00 08");
|
|
|
+ },
|
|
|
+
|
|
|
+ sendControlClose() {
|
|
|
this.WriteBufferInBle("03 00 00 00 09");
|
|
|
},
|
|
|
-
|
|
|
- sendPause() {
|
|
|
- this.WriteBufferInBle("03 00 00 00 08");
|
|
|
+
|
|
|
+ sendConnectOneToMore(id) {
|
|
|
+ this.WriteBufferInBle(`03 00 ${id} 00 0A`);
|
|
|
+ },
|
|
|
+
|
|
|
+ sendConnectOneToOne(id) {
|
|
|
+ this.WriteBufferInBle(`03 00 ${id} 01 0A`)
|
|
|
},
|
|
|
|
|
|
|
|
@@ -192,10 +208,7 @@ export default {
|
|
|
game_store.setters.setServiceId(serviceId);
|
|
|
game_store.setters.setCid(item.uuid);
|
|
|
|
|
|
- $this.sendOpen();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ $this.sendOpenBigData();
|
|
|
}
|
|
|
|
|
|
if (item.properties.notify || item.properties.indicate) {
|
|
@@ -215,15 +228,6 @@ export default {
|
|
|
},
|
|
|
|
|
|
|
|
|
-
|
|
|
- sendConnect($hex) {
|
|
|
-
|
|
|
- this.WriteBufferInBle("03 00 " + $hex + " 00 0a");
|
|
|
- },
|
|
|
-
|
|
|
- getConnectedToy() {
|
|
|
- this.WriteBufferInBle("03 00 00 00 06");
|
|
|
- },
|
|
|
|
|
|
ab2hex(buffer) {
|
|
|
var hexArr = Array.prototype.map.call(
|
|
@@ -234,11 +238,6 @@ export default {
|
|
|
);
|
|
|
return hexArr.join("");
|
|
|
},
|
|
|
-
|
|
|
- shutdownSendControl() {
|
|
|
- this.WriteBufferInBle("03 00 00 00 0a");
|
|
|
- },
|
|
|
-
|
|
|
|
|
|
watchingDevice($this) {
|
|
|
const that = this;
|
|
@@ -246,33 +245,52 @@ export default {
|
|
|
let hexStr = that.ab2hex(characteristic.value);
|
|
|
console.log(hexStr);
|
|
|
let $data = that.get_big_data(hexStr);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
-
|
|
|
- if (hexStr.substr(0, 8).toLowerCase() == "aadd0a00") {
|
|
|
- if ($this.toy_item["hex"]) {
|
|
|
- let $hex = $this.toy_item["hex"].substr($this.toy_item["hex"].length - 2, 2);
|
|
|
- if (hexStr.substr(8, 2) == $hex) {
|
|
|
+
|
|
|
+ if (hexStr.toUpperCase().indexOf("AADD0A") != -1) {
|
|
|
+
|
|
|
+ if (hexStr.toUpperCase().indexOf("AADD0A0000") != -1) {
|
|
|
+ $this.change_toy_connect_status(3);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let $hexAry = $this.current_hex.split(" ")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (new RegExp("00").test($hexAry[2]) == false) {
|
|
|
+ if (new RegExp("00").test($hexAry[3]) == true) {
|
|
|
+ that.sendConnectOneToOne($hexAry[2])
|
|
|
+ $this.current_hex = `03 00 $hexAry[2] 01 0A`
|
|
|
+ console.log("一对多")
|
|
|
+ } else {
|
|
|
+ console.log("一对一")
|
|
|
+ $this.current_hex = "";
|
|
|
wx.showToast({
|
|
|
title: "已连接到" + $this.toy_item.name
|
|
|
});
|
|
|
$this.change_toy_connect_status(2);
|
|
|
- } else if (hexStr.substr(8, 2) == "00") {
|
|
|
- $this.change_toy_connect_status(3);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
- if (hexStr.substr(0, 8).toLowerCase() == "aadd0900") {
|
|
|
- this.shutdownSendControl();
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
if (hexStr.substr(0, 6) == "555520") {
|
|
@@ -317,7 +335,7 @@ export default {
|
|
|
if ($this.played_time == 0) {
|
|
|
$this.post_data();
|
|
|
|
|
|
- that.shutdownSendControl();
|
|
|
+ that.sendControlClose();
|
|
|
let $hide_status = game_store.getters.getHideStatus();
|
|
|
if (!$hide_status) {
|
|
|
$this.game_finished();
|