|
@@ -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')
|