完成开锁功能
This commit is contained in:
parent
2f1c89ebf1
commit
ac5c800bac
@ -143,7 +143,7 @@ export default {
|
|||||||
paramsArray[127] = (nowTime & 0xff)
|
paramsArray[127] = (nowTime & 0xff)
|
||||||
|
|
||||||
// 结束日期
|
// 结束日期
|
||||||
const endTime = 0x11223344
|
const endTime = 0xffffffff
|
||||||
|
|
||||||
paramsArray[128] = (endTime & 0xff000000) >> 24
|
paramsArray[128] = (endTime & 0xff000000) >> 24
|
||||||
paramsArray[129] = (endTime & 0xff0000) >> 16
|
paramsArray[129] = (endTime & 0xff0000) >> 16
|
||||||
@ -317,18 +317,18 @@ export default {
|
|||||||
// authCode长度
|
// authCode长度
|
||||||
paramsArray[71] = 16
|
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)
|
let authCodeBinaryData = new Uint8Array(originAuthCodeLen)
|
||||||
|
|
||||||
for (let i = 0; i < this.keyId.length; i++) {
|
for (let i = 0; i < this.lockId.length; i++) {
|
||||||
authCodeBinaryData[i] = this.keyId.charCodeAt(i)
|
authCodeBinaryData[i] = this.lockId.charCodeAt(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < this.uid.length; 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 + 0] = this.token[0]
|
||||||
authCodeBinaryData[number + 1] = this.token[1]
|
authCodeBinaryData[number + 1] = this.token[1]
|
||||||
@ -339,6 +339,8 @@ export default {
|
|||||||
authCodeBinaryData[number + 4 + i] = this.signKey[i]
|
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))
|
console.log('md5前的数据', Array.from(authCodeBinaryData))
|
||||||
const md5Hex = md5(authCodeBinaryData)
|
const md5Hex = md5(authCodeBinaryData)
|
||||||
const md5Array = new Uint8Array(md5Hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16)))
|
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++) {
|
for (let i = 0; i < 112; i++) {
|
||||||
mergeArray[i + 12] = encryptArray[i]
|
mergeArray[i + 12] = encryptArray[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('crc前的数据', Array.from(mergeArray))
|
console.log('crc前的数据', Array.from(mergeArray))
|
||||||
|
|
||||||
let resultBuffer = new ArrayBuffer(126)
|
let resultBuffer = new ArrayBuffer(126)
|
||||||
let resultArray = new Uint8Array(resultBuffer)
|
let resultArray = new Uint8Array(resultBuffer)
|
||||||
for (let i = 0; i < 124; i++) {
|
for (let i = 0; i < 124; i++) {
|
||||||
@ -724,15 +726,17 @@ export default {
|
|||||||
if(decrypted[0] === 48 && decrypted[1] === 64) {
|
if(decrypted[0] === 48 && decrypted[1] === 64) {
|
||||||
that.lockStatus = decrypted
|
that.lockStatus = decrypted
|
||||||
console.log('锁状态', that.lockStatus)
|
console.log('锁状态', that.lockStatus)
|
||||||
} else {
|
} else if(decrypted[0] === 48 && decrypted[1] === 1) {
|
||||||
that.token = decrypted.slice(42,46)
|
that.token = decrypted.slice(42,46)
|
||||||
console.log('token', Array.from(that.token))
|
console.log('token', Array.from(that.token))
|
||||||
if(decrypted[0] === 48 && decrypted[1] === 1) {
|
if(decrypted[46] === 6) {
|
||||||
if(decrypted[46] === 6) {
|
that.addUser()
|
||||||
that.addUser()
|
}
|
||||||
}
|
} else {
|
||||||
} else if(decrypted[0] === 48 && decrypted[1] === 5) {
|
if(decrypted[0] === 48 && decrypted[1] === 5) {
|
||||||
if(decrypted[46] === 6) {
|
that.token = decrypted.slice(2,6)
|
||||||
|
console.log('token', Array.from(that.token))
|
||||||
|
if(decrypted[6] === 6) {
|
||||||
that.openDoor()
|
that.openDoor()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -781,7 +785,6 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// 连接蓝牙设备
|
// 连接蓝牙设备
|
||||||
connect(item) {
|
connect(item) {
|
||||||
this.config = item
|
this.config = item
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user