From ac5c800bac4a44a0dc45cc19f48d9dd21a4d180e Mon Sep 17 00:00:00 2001 From: peng fan Date: Sat, 10 Aug 2024 11:43:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=BC=80=E9=94=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/demo/demo.vue | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/pages/demo/demo.vue b/pages/demo/demo.vue index 3fce7b7..ebebeb9 100644 --- a/pages/demo/demo.vue +++ b/pages/demo/demo.vue @@ -143,7 +143,7 @@ export default { paramsArray[127] = (nowTime & 0xff) // 结束日期 - const endTime = 0x11223344 + const endTime = 0xffffffff paramsArray[128] = (endTime & 0xff000000) >> 24 paramsArray[129] = (endTime & 0xff0000) >> 16 @@ -317,18 +317,18 @@ export default { // authCode长度 paramsArray[71] = 16 - const originAuthCodeLen = this.keyId.length + this.uid.length + 4 + 16 + const originAuthCodeLen = this.lockId.length + this.uid.length + 4 + 16 let authCodeBinaryData = new Uint8Array(originAuthCodeLen) - for (let i = 0; i < this.keyId.length; i++) { - authCodeBinaryData[i] = this.keyId.charCodeAt(i) + for (let i = 0; i < this.lockId.length; i++) { + authCodeBinaryData[i] = this.lockId.charCodeAt(i) } for (let i = 0; i < this.uid.length; i++) { - authCodeBinaryData[this.keyId.length + i] = this.uid.charCodeAt(i) + authCodeBinaryData[this.lockId.length + i] = this.uid.charCodeAt(i) } - const number = this.keyId.length + this.uid.length + const number = this.lockId.length + this.uid.length authCodeBinaryData[number + 0] = this.token[0] authCodeBinaryData[number + 1] = this.token[1] @@ -339,6 +339,8 @@ export default { authCodeBinaryData[number + 4 + i] = this.signKey[i] } + console.log('lockId', this.lockId, 'uid', this.uid, 'token', Array.from(this.token),'signKey', + Array.from(this.signKey)) console.log('md5前的数据', Array.from(authCodeBinaryData)) const md5Hex = md5(authCodeBinaryData) const md5Array = new Uint8Array(md5Hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16))) @@ -366,8 +368,8 @@ export default { for (let i = 0; i < 112; i++) { mergeArray[i + 12] = encryptArray[i] } - console.log('crc前的数据', Array.from(mergeArray)) + let resultBuffer = new ArrayBuffer(126) let resultArray = new Uint8Array(resultBuffer) for (let i = 0; i < 124; i++) { @@ -724,15 +726,17 @@ export default { if(decrypted[0] === 48 && decrypted[1] === 64) { that.lockStatus = decrypted console.log('锁状态', that.lockStatus) - } else { + } else if(decrypted[0] === 48 && decrypted[1] === 1) { that.token = decrypted.slice(42,46) console.log('token', Array.from(that.token)) - if(decrypted[0] === 48 && decrypted[1] === 1) { - if(decrypted[46] === 6) { - that.addUser() - } - } else if(decrypted[0] === 48 && decrypted[1] === 5) { - if(decrypted[46] === 6) { + if(decrypted[46] === 6) { + that.addUser() + } + } else { + if(decrypted[0] === 48 && decrypted[1] === 5) { + that.token = decrypted.slice(2,6) + console.log('token', Array.from(that.token)) + if(decrypted[6] === 6) { that.openDoor() } } @@ -781,7 +785,6 @@ export default { } }) }, - // 连接蓝牙设备 connect(item) { this.config = item