Преглед на файлове

完成了蓝牙连接设备得模块

yerong преди 4 години
родител
ревизия
ba0996485d
променени са 2 файла, в които са добавени 3 реда и са изтрити 5 реда
  1. 1 1
      dist/wx
  2. 2 4
      src/utils/bluetooth.js

+ 1 - 1
dist/wx

@@ -1 +1 @@
-Subproject commit e4b0aba5263b9c7cfc5d505bbf89fc95d9b438b7
+Subproject commit 07b7ca0931124e92a30fdfb8387a5573ea2c1685

+ 2 - 4
src/utils/bluetooth.js

@@ -66,13 +66,11 @@ export default {
   // 发送连接玩具指令
   sendConnect($toy, deviceId, serviceId, Cid) {
     //获取最后两个字节
-    let $toy_hex = $toy['bluetooth'].substr($toy['bluetooth'].length - 2, -2)
+    let $toy_hex = $toy['bluetooth'].substr($toy['bluetooth'].length - 2, 2)
 
     const that = this
     // 玩具对应指令数组
     let arr = ['0x01', '0x02', '0x03', '0x04', '0x05', '0x06', '0x07', '0x08', '0x09', '0x0a', '0x0b']
-    let arr1 = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b]
-    let CheckSum = ((0x03 + 0x00 + ('0x' + $toy_hex) + 0x00 + 0x0a) ^ 0xFFFFFFFF) & 0xFF
     // 向蓝牙设备发送指令
     let buffer = new ArrayBuffer(8)
     let dataView = new DataView(buffer)
@@ -80,7 +78,7 @@ export default {
     dataView.setUint8(1, '0xcc')
     dataView.setUint8(2, '0x03')
     dataView.setUint8(3, '0x00')
-    dataView.setUint8(4, arr[index])
+    dataView.setUint8(4, '0x'+$toy_hex)
     dataView.setUint8(5, '0x00')
     dataView.setUint8(6, '0x0a')
     dataView.setUint8(7, '0xf1')