feat:增加指纹蓝牙回调后执行对应的接口操作、增加padding: 'none'解决添加蓝牙步骤时出现的错误
This commit is contained in:
parent
e8cc65de58
commit
c844cfbd3c
72
common.js
72
common.js
@ -17,14 +17,14 @@ import {
|
|||||||
} from './uni/basic'
|
} from './uni/basic'
|
||||||
import {
|
import {
|
||||||
addCustomPasswordRequest, addFingerprintRequest, addIcCardRequest,
|
addCustomPasswordRequest, addFingerprintRequest, addIcCardRequest,
|
||||||
changeAdminKeyboardPwdRequest, clearAllIcCard, deleteIcCardRequest,
|
changeAdminKeyboardPwdRequest, clearAllFingerprint, clearAllIcCard, deleteFingerprintRequest, deleteIcCardRequest,
|
||||||
deleteLockRequest,
|
deleteLockRequest,
|
||||||
deletePasswordRequest,
|
deletePasswordRequest,
|
||||||
getLastRecordTimeRequest,
|
getLastRecordTimeRequest,
|
||||||
getLockNetTokenRequest,
|
getLockNetTokenRequest,
|
||||||
getStarCloudToken,
|
getStarCloudToken,
|
||||||
getUserNoListRequest,
|
getUserNoListRequest,
|
||||||
updateElectricQuantityRequest, updateIcCardRequest,
|
updateElectricQuantityRequest, updateFingerprintRequest, updateIcCardRequest,
|
||||||
updateLockUserNoRequest,
|
updateLockUserNoRequest,
|
||||||
updatePasswordRequest,
|
updatePasswordRequest,
|
||||||
uploadRecordRequest
|
uploadRecordRequest
|
||||||
@ -699,7 +699,7 @@ export function listenCharacteristicValue(res) {
|
|||||||
} else {
|
} else {
|
||||||
this.parsingCharacteristicValue(binaryData).then(() => {
|
this.parsingCharacteristicValue(binaryData).then(() => {
|
||||||
})
|
})
|
||||||
console.log('listenCharacteristicValue binaryData', binaryData)
|
|
||||||
}
|
}
|
||||||
} else if (this.completeArray) {
|
} else if (this.completeArray) {
|
||||||
const combinedArray = new Uint8Array(this.completeArray.length + binaryData.length)
|
const combinedArray = new Uint8Array(this.completeArray.length + binaryData.length)
|
||||||
@ -717,6 +717,7 @@ export function listenCharacteristicValue(res) {
|
|||||||
|
|
||||||
// 解析特征值
|
// 解析特征值
|
||||||
export async function parsingCharacteristicValue(binaryData) {
|
export async function parsingCharacteristicValue(binaryData) {
|
||||||
|
|
||||||
// 0x20 明文 0x22 SM4(事先约定密钥) 0x23 SM4(设备指定密钥)
|
// 0x20 明文 0x22 SM4(事先约定密钥) 0x23 SM4(设备指定密钥)
|
||||||
if (binaryData[7] === 0x20) {
|
if (binaryData[7] === 0x20) {
|
||||||
if (binaryData[12] * 256 + binaryData[13] === cmdIds.getPublicKey) {
|
if (binaryData[12] * 256 + binaryData[13] === cmdIds.getPublicKey) {
|
||||||
@ -763,7 +764,8 @@ export async function parsingCharacteristicValue(binaryData) {
|
|||||||
const cebBinaryData = binaryData.slice(12, binaryData.length - 2)
|
const cebBinaryData = binaryData.slice(12, binaryData.length - 2)
|
||||||
const decrypted = sm4.decrypt(cebBinaryData, this.lockInfo.bluetooth.privateKey, {
|
const decrypted = sm4.decrypt(cebBinaryData, this.lockInfo.bluetooth.privateKey, {
|
||||||
mode: 'ecb',
|
mode: 'ecb',
|
||||||
output: 'array'
|
output: 'array',
|
||||||
|
padding: 'none'
|
||||||
})
|
})
|
||||||
console.log('ecb解密后的数据', decrypted)
|
console.log('ecb解密后的数据', decrypted)
|
||||||
|
|
||||||
@ -1001,13 +1003,56 @@ export async function parsingCharacteristicValue(binaryData) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case subCmdIds.registerFingerprint:
|
case subCmdIds.registerFingerprint:
|
||||||
console.log('注册指纹开始回调')
|
console.log('注册指纹开始回调', decrypted)
|
||||||
// 返回锁版应答的Status状态
|
if (decrypted[2] === Result.Success.code) {
|
||||||
this.characteristicValueCallback(new Result(decrypted[2]))
|
// 锁版应答成功
|
||||||
|
switch (this.requestParams.operate) {
|
||||||
|
case 0:
|
||||||
|
// 注册开始返回最大注册次数
|
||||||
|
this.characteristicValueCallback(new Result(Result.Success.code, {
|
||||||
|
maxRegCount: decrypted[11],
|
||||||
|
}, Result.Success.message))
|
||||||
|
await this.disconnectDevice()
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
// 修改
|
||||||
|
const updateResult = await updateFingerprintRequest({
|
||||||
|
...this.requestParams,
|
||||||
|
fingerprintId: this.requestParams.fingerprintId,
|
||||||
|
fingerRight: this.requestParams.isAdmin
|
||||||
|
})
|
||||||
|
this.characteristicValueCallback(updateResult)
|
||||||
|
await this.disconnectDevice()
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
// 删除
|
||||||
|
const deleteResult = await deleteFingerprintRequest({
|
||||||
|
fingerprintId: this.requestParams.fingerprintId,
|
||||||
|
lockId: this.lockInfo.lockId,
|
||||||
|
})
|
||||||
|
this.characteristicValueCallback(deleteResult)
|
||||||
|
await this.disconnectDevice()
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
// 删除全部
|
||||||
|
const deleteAllResult = await clearAllFingerprint({
|
||||||
|
lockId: this.lockInfo.lockId,
|
||||||
|
})
|
||||||
|
this.characteristicValueCallback(deleteAllResult)
|
||||||
|
await this.disconnectDevice()
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.characteristicValueCallback(new Result(decrypted[2]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case subCmdIds.registerFingerprintProcess:
|
case subCmdIds.registerFingerprintProcess:
|
||||||
console.log('注册指纹过程回调', decrypted)
|
console.log('注册指纹过程回调', decrypted)
|
||||||
emitRegisterFingerprintProcessEvent(decrypted)
|
emitRegisterFingerprintProcessEvent({
|
||||||
|
status: decrypted[5],
|
||||||
|
process: decrypted[6]
|
||||||
|
})
|
||||||
break;
|
break;
|
||||||
case subCmdIds.registerFingerprintConfirm:
|
case subCmdIds.registerFingerprintConfirm:
|
||||||
if (this.requestParams.operate === 0) {
|
if (this.requestParams.operate === 0) {
|
||||||
@ -1020,12 +1065,13 @@ export async function parsingCharacteristicValue(binaryData) {
|
|||||||
fingerprintUserNo: this.requestParams.fingerprintUserNo
|
fingerprintUserNo: this.requestParams.fingerprintUserNo
|
||||||
})
|
})
|
||||||
if (addResult.code === Result.Success.code) {
|
if (addResult.code === Result.Success.code) {
|
||||||
console.log('注册指纹确认回调')
|
// 增加返回一个指纹序号
|
||||||
// 触发指纹确认事件
|
addResult.data.fingerprintNumber = decrypted[9] * 256 + decrypted[10];
|
||||||
emitRegisterFingerprintConfirmEvent(addResult)
|
|
||||||
// 断开蓝牙连接
|
|
||||||
await this.disconnectDevice()
|
|
||||||
}
|
}
|
||||||
|
// 触发指纹确认事件
|
||||||
|
emitRegisterFingerprintConfirmEvent(addResult)
|
||||||
|
// 断开蓝牙连接
|
||||||
|
await this.disconnectDevice()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user