修复bluetooth中的命名错误

This commit is contained in:
范鹏 2025-02-06 14:59:10 +08:00
parent 150b1a0e75
commit 747a469baf

View File

@ -787,8 +787,7 @@ export const useBluetoothStore = defineStore('ble', {
// 倒序 weekStr
weekStr = weekStr.split('').reverse().join('')
const weekRound = parseInt(weekStr, 2)
return weekRound
return parseInt(weekStr, 2)
},
// 查找设备并连接
async searchAndConnectDevice() {
@ -1078,11 +1077,11 @@ export const useBluetoothStore = defineStore('ble', {
return headArray
},
// 生成包尾 头部数据+内容数据
createPackageEnd(headArray, conentArray) {
createPackageEnd(headArray, contentArray) {
// 拼接头部和内容
let mergerArray = new Uint8Array(headArray.length + conentArray.length)
let mergerArray = new Uint8Array(headArray.length + contentArray.length)
mergerArray.set(headArray)
mergerArray.set(conentArray, headArray.length)
mergerArray.set(contentArray, headArray.length)
// crc加密
const crcResult = crc.crc16kermit(mergerArray)
@ -1107,13 +1106,13 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if (!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if (srerchResult.code !== 0) {
return srerchResult
const searchResult = await this.searchAndConnectDevice()
if (searchResult.code !== 0) {
return searchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult.data.deviceId
deviceId: searchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
const result = await this.connectBluetoothDevice()
@ -1126,16 +1125,16 @@ export const useBluetoothStore = defineStore('ble', {
}
const headArray = this.createPackageHeader(0, 42)
const conentArray = new Uint8Array(42)
const contentArray = new Uint8Array(42)
conentArray[0] = cmdIds.getPublicKey / 256
conentArray[1] = cmdIds.getPublicKey % 256
contentArray[0] = cmdIds.getPublicKey / 256
contentArray[1] = cmdIds.getPublicKey % 256
for (let i = 0; i < name.length; i++) {
conentArray[i + 2] = name.charCodeAt(i)
contentArray[i + 2] = name.charCodeAt(i)
}
const packageArray = this.createPackageEnd(headArray, conentArray)
const packageArray = this.createPackageEnd(headArray, contentArray)
await this.writeBLECharacteristicValue(packageArray)
return this.getWriteResult()
@ -1153,13 +1152,13 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if (!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if (srerchResult.code !== 0) {
return srerchResult
const searchResult = await this.searchAndConnectDevice()
if (searchResult.code !== 0) {
return searchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult.data.deviceId
deviceId: searchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
const result = await this.connectBluetoothDevice()
@ -1173,36 +1172,36 @@ export const useBluetoothStore = defineStore('ble', {
const length = 2 + 40 + 40 + 20 + 4 + 1 + 16
const headArray = this.createPackageHeader(2, length)
const conentArray = new Uint8Array(length)
const contentArray = new Uint8Array(length)
conentArray[0] = cmdIds.getCommKey / 256
conentArray[1] = cmdIds.getCommKey % 256
contentArray[0] = cmdIds.getCommKey / 256
contentArray[1] = cmdIds.getCommKey % 256
for (let i = 0; i < name.length; i++) {
conentArray[i + 2] = name.charCodeAt(i)
contentArray[i + 2] = name.charCodeAt(i)
}
for (let i = 0; i < keyId.length; i++) {
conentArray[i + 42] = keyId.charCodeAt(i)
contentArray[i + 42] = keyId.charCodeAt(i)
}
for (let i = 0; i < authUid.length; i++) {
conentArray[i + 82] = authUid.charCodeAt(i)
contentArray[i + 82] = authUid.charCodeAt(i)
}
conentArray.set(this.timestampToArray(nowTime), 102)
contentArray.set(this.timestampToArray(nowTime), 102)
conentArray[106] = 16
contentArray[106] = 16
const md5Array = this.md5Encrypte(
authUid + keyId,
conentArray.slice(102, 106),
contentArray.slice(102, 106),
this.currentLockInfo.publicKey
)
conentArray.set(md5Array, 107)
contentArray.set(md5Array, 107)
const cebArray = sm4.encrypt(conentArray, conentArray.slice(2, 18), {
const cebArray = sm4.encrypt(contentArray, contentArray.slice(2, 18), {
mode: 'ecb',
output: 'array'
})
@ -1240,13 +1239,13 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if (!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if (srerchResult.code !== 0) {
return srerchResult
const searchResult = await this.searchAndConnectDevice()
if (searchResult.code !== 0) {
return searchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult.data.deviceId
deviceId: searchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
const result = await this.connectBluetoothDevice()
@ -1262,19 +1261,19 @@ export const useBluetoothStore = defineStore('ble', {
const length = 2 + 40 + 20 + 4 + 4
const headArray = this.createPackageHeader(3, length)
const conentArray = new Uint8Array(length)
conentArray[0] = cmdIds.getLockStatus / 256
conentArray[1] = cmdIds.getLockStatus % 256
const contentArray = new Uint8Array(length)
contentArray[0] = cmdIds.getLockStatus / 256
contentArray[1] = cmdIds.getLockStatus % 256
for (let i = 0; i < name.length; i++) {
conentArray[i + 2] = name.charCodeAt(i)
contentArray[i + 2] = name.charCodeAt(i)
}
for (let i = 0; i < uid.length; i++) {
conentArray[i + 42] = uid.charCodeAt(i)
contentArray[i + 42] = uid.charCodeAt(i)
}
conentArray.set(this.timestampToArray(nowTime), 62)
conentArray.set(this.timestampToArray(localTime), 66)
contentArray.set(this.timestampToArray(nowTime), 62)
contentArray.set(this.timestampToArray(localTime), 66)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
@ -1312,13 +1311,13 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if (!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if (srerchResult.code !== 0) {
return srerchResult
const searchResult = await this.searchAndConnectDevice()
if (searchResult.code !== 0) {
return searchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult.data.deviceId
deviceId: searchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
const result = await this.connectBluetoothDevice()
@ -1352,51 +1351,51 @@ export const useBluetoothStore = defineStore('ble', {
const length =
2 + 40 + 20 + 40 + 20 + 1 + 1 + 4 + 4 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 20 + 4 + 1 + 16
const headArray = this.createPackageHeader(3, length)
const conentArray = new Uint8Array(length)
const contentArray = new Uint8Array(length)
conentArray[0] = cmdIds.addUser / 256
conentArray[1] = cmdIds.addUser % 256
contentArray[0] = cmdIds.addUser / 256
contentArray[1] = cmdIds.addUser % 256
for (let i = 0; i < name.length; i++) {
conentArray[i + 2] = name.charCodeAt(i)
contentArray[i + 2] = name.charCodeAt(i)
}
for (let i = 0; i < authUid.length; i++) {
conentArray[i + 42] = authUid.charCodeAt(i)
contentArray[i + 42] = authUid.charCodeAt(i)
}
for (let i = 0; i < keyId.length; i++) {
conentArray[i + 62] = keyId.charCodeAt(i)
contentArray[i + 62] = keyId.charCodeAt(i)
}
for (let i = 0; i < uid.length; i++) {
conentArray[i + 102] = uid.charCodeAt(i)
contentArray[i + 102] = uid.charCodeAt(i)
}
conentArray[122] = openMode
conentArray[123] = keyType
contentArray[122] = openMode
contentArray[123] = keyType
conentArray.set(this.timestampToArray(startDate), 124)
conentArray.set(this.timestampToArray(expireDate), 128)
contentArray.set(this.timestampToArray(startDate), 124)
contentArray.set(this.timestampToArray(expireDate), 128)
conentArray[132] = useCountLimit / 256
conentArray[133] = useCountLimit % 256
contentArray[132] = useCountLimit / 256
contentArray[133] = useCountLimit % 256
conentArray[134] = isRound
conentArray[135] = weekRound
conentArray[136] = startHour
conentArray[137] = startMin
conentArray[138] = endHour
conentArray[139] = endMin
conentArray[140] = role
contentArray[134] = isRound
contentArray[135] = weekRound
contentArray[136] = startHour
contentArray[137] = startMin
contentArray[138] = endHour
contentArray[139] = endMin
contentArray[140] = role
for (let i = 0; i < password.length; i++) {
conentArray[i + 141] = password.charCodeAt(i)
contentArray[i + 141] = password.charCodeAt(i)
}
conentArray.set(this.currentLockInfo.token || this.timestampToArray(startDate), 161)
contentArray.set(this.currentLockInfo.token || this.timestampToArray(startDate), 161)
conentArray[165] = 16
contentArray[165] = 16
const md5Array = this.md5Encrypte(
authUid + keyId,
@ -1404,9 +1403,9 @@ export const useBluetoothStore = defineStore('ble', {
this.currentLockInfo.publicKey
)
conentArray.set(md5Array, 166)
contentArray.set(md5Array, 166)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
@ -1573,10 +1572,10 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if (!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if (srerchResult.code === 0) {
const searchResult = await this.searchAndConnectDevice()
if (searchResult.code === 0) {
log.info({
code: srerchResult.code,
code: searchResult.code,
message: `开门中,已搜索到设备`,
data: {
lockName: this.currentLockInfo.name,
@ -1587,9 +1586,9 @@ export const useBluetoothStore = defineStore('ble', {
email: $user.userInfo.email
}
})
} else if (srerchResult.code === -1) {
} else if (searchResult.code === -1) {
log.info({
code: srerchResult.code,
code: searchResult.code,
message: `开门失败,搜索失败`,
data: {
lockName: this.currentLockInfo.name,
@ -1600,9 +1599,9 @@ export const useBluetoothStore = defineStore('ble', {
email: $user.userInfo.email
}
})
} else if (srerchResult.code === -2) {
} else if (searchResult.code === -2) {
log.info({
code: srerchResult.code,
code: searchResult.code,
message: `开门失败,锁已被重置`,
data: {
lockName: this.currentLockInfo.name,
@ -1613,9 +1612,9 @@ export const useBluetoothStore = defineStore('ble', {
email: $user.userInfo.email
}
})
} else if (srerchResult.code === -3) {
} else if (searchResult.code === -3) {
log.info({
code: srerchResult.code,
code: searchResult.code,
message: `开门失败设备已找到但uuid异常`,
data: {
lockName: this.currentLockInfo.name,
@ -1626,9 +1625,9 @@ export const useBluetoothStore = defineStore('ble', {
email: $user.userInfo.email
}
})
} else if (srerchResult.code === -4) {
} else if (searchResult.code === -4) {
log.info({
code: srerchResult.code,
code: searchResult.code,
message: `开门失败,未搜索到操作设备`,
data: {
lockName: this.currentLockInfo.name,
@ -1639,9 +1638,9 @@ export const useBluetoothStore = defineStore('ble', {
email: $user.userInfo.email
}
})
} else if (srerchResult.code === -22) {
} else if (searchResult.code === -22) {
log.info({
code: srerchResult.code,
code: searchResult.code,
message: `开门失败,微信附近设备权限未开启`,
data: {
lockName: this.currentLockInfo.name,
@ -1652,9 +1651,9 @@ export const useBluetoothStore = defineStore('ble', {
email: $user.userInfo.email
}
})
} else if (srerchResult.code === -23) {
} else if (searchResult.code === -23) {
log.info({
code: srerchResult.code,
code: searchResult.code,
message: `开门失败,微信定位权限未开启`,
data: {
lockName: this.currentLockInfo.name,
@ -1666,12 +1665,12 @@ export const useBluetoothStore = defineStore('ble', {
}
})
}
if (srerchResult.code !== 0) {
if (searchResult.code !== 0) {
return { code: -1 }
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult.data.deviceId
deviceId: searchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
const result = await this.connectBluetoothDevice()
@ -1760,27 +1759,27 @@ export const useBluetoothStore = defineStore('ble', {
const length = 2 + 40 + 20 + 1 + 4 + 4 + 1 + 16 + 16
const headArray = this.createPackageHeader(3, length)
const conentArray = new Uint8Array(length)
conentArray[0] = cmdIds.openDoor / 256
conentArray[1] = cmdIds.openDoor % 256
const contentArray = new Uint8Array(length)
contentArray[0] = cmdIds.openDoor / 256
contentArray[1] = cmdIds.openDoor % 256
for (let i = 0; i < name.length; i++) {
conentArray[i + 2] = name.charCodeAt(i)
contentArray[i + 2] = name.charCodeAt(i)
}
for (let i = 0; i < uid.length; i++) {
conentArray[i + 42] = uid.charCodeAt(i)
contentArray[i + 42] = uid.charCodeAt(i)
}
conentArray[62] = openMode
contentArray[62] = openMode
conentArray.set(this.timestampToArray(openTime), 63)
contentArray.set(this.timestampToArray(openTime), 63)
console.log('开门时token', this.currentLockInfo.token)
conentArray.set(this.currentLockInfo.token || this.timestampToArray(openTime), 67)
contentArray.set(this.currentLockInfo.token || this.timestampToArray(openTime), 67)
conentArray[71] = 16
contentArray[71] = 16
const md5Array = this.md5Encrypte(
name + uid,
@ -1788,13 +1787,13 @@ export const useBluetoothStore = defineStore('ble', {
this.currentLockInfo.signKey
)
conentArray.set(md5Array, 72)
contentArray.set(md5Array, 72)
for (let i = 0; i < onlineToken.length; i++) {
conentArray[i + 88] = onlineToken.charCodeAt(i)
contentArray[i + 88] = onlineToken.charCodeAt(i)
}
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
@ -1839,13 +1838,13 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if (!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if (srerchResult.code !== 0) {
return srerchResult
const searchResult = await this.searchAndConnectDevice()
if (searchResult.code !== 0) {
return searchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult.data.deviceId
deviceId: searchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
const result = await this.connectBluetoothDevice()
@ -1861,40 +1860,40 @@ export const useBluetoothStore = defineStore('ble', {
const length = 2 + 40 + 20 + 40 + 20 + 2 + userNoList.length + 4 + 1 + 16
const headArray = this.createPackageHeader(3, length)
const conentArray = new Uint8Array(length)
const contentArray = new Uint8Array(length)
conentArray[0] = cmdIds.cleanUser / 256
conentArray[1] = cmdIds.cleanUser % 256
contentArray[0] = cmdIds.cleanUser / 256
contentArray[1] = cmdIds.cleanUser % 256
for (let i = 0; i < name.length; i++) {
conentArray[i + 2] = name.charCodeAt(i)
contentArray[i + 2] = name.charCodeAt(i)
}
for (let i = 0; i < authUid.length; i++) {
conentArray[i + 42] = authUid.charCodeAt(i)
contentArray[i + 42] = authUid.charCodeAt(i)
}
for (let i = 0; i < keyId.length; i++) {
conentArray[i + 62] = keyId.charCodeAt(i)
contentArray[i + 62] = keyId.charCodeAt(i)
}
for (let i = 0; i < uid.length; i++) {
conentArray[i + 102] = uid.charCodeAt(i)
contentArray[i + 102] = uid.charCodeAt(i)
}
conentArray[122] = userNoList.length / 256
conentArray[123] = userNoList.length % 256
contentArray[122] = userNoList.length / 256
contentArray[123] = userNoList.length % 256
for (let i = 0; i < userNoList.length; i++) {
conentArray[i + 124] = userNoList[i]
contentArray[i + 124] = userNoList[i]
}
conentArray.set(
contentArray.set(
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
124 + userNoList.length
)
conentArray[128 + userNoList.length] = 16
contentArray[128 + userNoList.length] = 16
const md5Array = this.md5Encrypte(
authUid + keyId,
@ -1902,9 +1901,9 @@ export const useBluetoothStore = defineStore('ble', {
this.currentLockInfo.publicKey
)
conentArray.set(md5Array, 129 + userNoList.length)
contentArray.set(md5Array, 129 + userNoList.length)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
@ -1928,13 +1927,13 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if (!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if (srerchResult.code !== 0) {
return srerchResult
const searchResult = await this.searchAndConnectDevice()
if (searchResult.code !== 0) {
return searchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult.data.deviceId
deviceId: searchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
const result = await this.connectBluetoothDevice()
@ -1957,29 +1956,29 @@ export const useBluetoothStore = defineStore('ble', {
const { name, authUid } = data
const length = 2 + 40 + 20 + 4 + 1 + 16
const headArray = this.createPackageHeader(3, length)
const conentArray = new Uint8Array(length)
const contentArray = new Uint8Array(length)
conentArray[0] = cmdIds.resetDevice / 256
conentArray[1] = cmdIds.resetDevice % 256
contentArray[0] = cmdIds.resetDevice / 256
contentArray[1] = cmdIds.resetDevice % 256
for (let i = 0; i < name.length; i++) {
conentArray[i + 2] = name.charCodeAt(i)
contentArray[i + 2] = name.charCodeAt(i)
}
for (let i = 0; i < authUid.length; i++) {
conentArray[i + 42] = authUid.charCodeAt(i)
contentArray[i + 42] = authUid.charCodeAt(i)
}
conentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 62)
conentArray[66] = 16
contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 62)
contentArray[66] = 16
const md5Array = this.md5Encrypte(
name,
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
this.currentLockInfo.publicKey
)
conentArray.set(md5Array, 67)
contentArray.set(md5Array, 67)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
@ -2003,13 +2002,13 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if (!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if (srerchResult.code !== 0) {
return srerchResult
const searchResult = await this.searchAndConnectDevice()
if (searchResult.code !== 0) {
return searchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult.data.deviceId
deviceId: searchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
const result = await this.connectBluetoothDevice()
@ -2032,27 +2031,27 @@ export const useBluetoothStore = defineStore('ble', {
const { keyId, uid } = data
const length = 2 + 1 + 1 + 40 + 20 + 4 + 1 + 16
const headArray = this.createPackageHeader(3, length)
const conentArray = new Uint8Array(length)
const contentArray = new Uint8Array(length)
conentArray[0] = cmdIds.expandCmd / 256
conentArray[1] = cmdIds.expandCmd % 256
contentArray[0] = cmdIds.expandCmd / 256
contentArray[1] = cmdIds.expandCmd % 256
// 子命令
conentArray[2] = subCmdIds.resetLockPassword
contentArray[2] = subCmdIds.resetLockPassword
conentArray[3] = length - 4
contentArray[3] = length - 4
for (let i = 0; i < keyId.length; i++) {
conentArray[i + 4] = keyId.charCodeAt(i)
contentArray[i + 4] = keyId.charCodeAt(i)
}
for (let i = 0; i < uid.length; i++) {
conentArray[i + 44] = uid.charCodeAt(i)
contentArray[i + 44] = uid.charCodeAt(i)
}
conentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 64)
contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 64)
conentArray[68] = 16
contentArray[68] = 16
const md5Array = this.md5Encrypte(
keyId + uid,
@ -2060,9 +2059,9 @@ export const useBluetoothStore = defineStore('ble', {
this.currentLockInfo.signKey
)
conentArray.set(md5Array, 69)
contentArray.set(md5Array, 69)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
@ -2086,13 +2085,13 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if (!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if (srerchResult.code !== 0) {
return srerchResult
const searchResult = await this.searchAndConnectDevice()
if (searchResult.code !== 0) {
return searchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult.data.deviceId
deviceId: searchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
const result = await this.connectBluetoothDevice()
@ -2115,43 +2114,43 @@ export const useBluetoothStore = defineStore('ble', {
const { keyId, uid, pwdNo, operate, isAdmin, pwd, userCountLimit, startTime, endTime } = data
const length = 2 + 1 + 1 + 40 + 20 + 2 + 1 + 1 + 20 + 2 + 4 + 4 + 4 + 1 + 16
const headArray = this.createPackageHeader(3, length)
const conentArray = new Uint8Array(length)
const contentArray = new Uint8Array(length)
conentArray[0] = cmdIds.expandCmd / 256
conentArray[1] = cmdIds.expandCmd % 256
contentArray[0] = cmdIds.expandCmd / 256
contentArray[1] = cmdIds.expandCmd % 256
// 子命令
conentArray[2] = subCmdIds.setLockPassword
contentArray[2] = subCmdIds.setLockPassword
conentArray[3] = length - 3
contentArray[3] = length - 3
for (let i = 0; i < keyId.length; i++) {
conentArray[i + 4] = keyId.charCodeAt(i)
contentArray[i + 4] = keyId.charCodeAt(i)
}
for (let i = 0; i < uid.length; i++) {
conentArray[i + 44] = uid.charCodeAt(i)
contentArray[i + 44] = uid.charCodeAt(i)
}
conentArray[64] = pwdNo / 256
conentArray[65] = pwdNo % 256
contentArray[64] = pwdNo / 256
contentArray[65] = pwdNo % 256
conentArray[66] = operate
conentArray[67] = isAdmin
contentArray[66] = operate
contentArray[67] = isAdmin
for (let i = 0; i < pwd.length; i++) {
conentArray[i + 68] = pwd.charCodeAt(i)
contentArray[i + 68] = pwd.charCodeAt(i)
}
conentArray[88] = userCountLimit / 256
conentArray[89] = userCountLimit % 256
contentArray[88] = userCountLimit / 256
contentArray[89] = userCountLimit % 256
conentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 90)
contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 90)
conentArray.set(this.timestampToArray(startTime), 94)
conentArray.set(this.timestampToArray(endTime), 98)
contentArray.set(this.timestampToArray(startTime), 94)
contentArray.set(this.timestampToArray(endTime), 98)
conentArray[102] = 16
contentArray[102] = 16
const md5Array = this.md5Encrypte(
keyId + uid,
@ -2159,9 +2158,9 @@ export const useBluetoothStore = defineStore('ble', {
this.currentLockInfo.signKey
)
conentArray.set(md5Array, 103)
contentArray.set(md5Array, 103)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})