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'
|
||||
import {
|
||||
addCustomPasswordRequest, addFingerprintRequest, addIcCardRequest,
|
||||
changeAdminKeyboardPwdRequest, clearAllIcCard, deleteIcCardRequest,
|
||||
changeAdminKeyboardPwdRequest, clearAllFingerprint, clearAllIcCard, deleteFingerprintRequest, deleteIcCardRequest,
|
||||
deleteLockRequest,
|
||||
deletePasswordRequest,
|
||||
getLastRecordTimeRequest,
|
||||
getLockNetTokenRequest,
|
||||
getStarCloudToken,
|
||||
getUserNoListRequest,
|
||||
updateElectricQuantityRequest, updateIcCardRequest,
|
||||
updateElectricQuantityRequest, updateFingerprintRequest, updateIcCardRequest,
|
||||
updateLockUserNoRequest,
|
||||
updatePasswordRequest,
|
||||
uploadRecordRequest
|
||||
@ -699,7 +699,7 @@ export function listenCharacteristicValue(res) {
|
||||
} else {
|
||||
this.parsingCharacteristicValue(binaryData).then(() => {
|
||||
})
|
||||
console.log('listenCharacteristicValue binaryData', binaryData)
|
||||
|
||||
}
|
||||
} else if (this.completeArray) {
|
||||
const combinedArray = new Uint8Array(this.completeArray.length + binaryData.length)
|
||||
@ -717,6 +717,7 @@ export function listenCharacteristicValue(res) {
|
||||
|
||||
// 解析特征值
|
||||
export async function parsingCharacteristicValue(binaryData) {
|
||||
|
||||
// 0x20 明文 0x22 SM4(事先约定密钥) 0x23 SM4(设备指定密钥)
|
||||
if (binaryData[7] === 0x20) {
|
||||
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 decrypted = sm4.decrypt(cebBinaryData, this.lockInfo.bluetooth.privateKey, {
|
||||
mode: 'ecb',
|
||||
output: 'array'
|
||||
output: 'array',
|
||||
padding: 'none'
|
||||
})
|
||||
console.log('ecb解密后的数据', decrypted)
|
||||
|
||||
@ -1001,13 +1003,56 @@ export async function parsingCharacteristicValue(binaryData) {
|
||||
}
|
||||
break;
|
||||
case subCmdIds.registerFingerprint:
|
||||
console.log('注册指纹开始回调')
|
||||
// 返回锁版应答的Status状态
|
||||
this.characteristicValueCallback(new Result(decrypted[2]))
|
||||
console.log('注册指纹开始回调', decrypted)
|
||||
if (decrypted[2] === Result.Success.code) {
|
||||
// 锁版应答成功
|
||||
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;
|
||||
case subCmdIds.registerFingerprintProcess:
|
||||
console.log('注册指纹过程回调', decrypted)
|
||||
emitRegisterFingerprintProcessEvent(decrypted)
|
||||
emitRegisterFingerprintProcessEvent({
|
||||
status: decrypted[5],
|
||||
process: decrypted[6]
|
||||
})
|
||||
break;
|
||||
case subCmdIds.registerFingerprintConfirm:
|
||||
if (this.requestParams.operate === 0) {
|
||||
@ -1020,12 +1065,13 @@ export async function parsingCharacteristicValue(binaryData) {
|
||||
fingerprintUserNo: this.requestParams.fingerprintUserNo
|
||||
})
|
||||
if (addResult.code === Result.Success.code) {
|
||||
console.log('注册指纹确认回调')
|
||||
// 触发指纹确认事件
|
||||
emitRegisterFingerprintConfirmEvent(addResult)
|
||||
// 断开蓝牙连接
|
||||
await this.disconnectDevice()
|
||||
// 增加返回一个指纹序号
|
||||
addResult.data.fingerprintNumber = decrypted[9] * 256 + decrypted[10];
|
||||
}
|
||||
// 触发指纹确认事件
|
||||
emitRegisterFingerprintConfirmEvent(addResult)
|
||||
// 断开蓝牙连接
|
||||
await this.disconnectDevice()
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user