Merge commit '19fb63c8574a9fb75b198efe65cff2353ec8ce10' into fanpeng
This commit is contained in:
commit
751c6bee87
@ -7,44 +7,44 @@ export default {
|
|||||||
if (!log) return
|
if (!log) return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
const logger = log.tag(arguments[0].name)
|
||||||
log.debug.apply(log, arguments)
|
logger.info(arguments[0].message, arguments[0])
|
||||||
},
|
},
|
||||||
info() {
|
info() {
|
||||||
if (!log) return
|
if (!log) return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
const logger = log.tag(arguments[0].name)
|
||||||
log.info.apply(log, arguments)
|
logger.info(arguments[0].message, arguments[0])
|
||||||
},
|
},
|
||||||
warn() {
|
warn() {
|
||||||
if (!log) return
|
if (!log) return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
const logger = log.tag(arguments[0].name)
|
||||||
log.warn.apply(log, arguments)
|
logger.warn(arguments[0].message, arguments[0])
|
||||||
},
|
},
|
||||||
error() {
|
error() {
|
||||||
if (!log) return
|
if (!log) return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
const logger = log.tag(arguments[0].name)
|
||||||
log.error.apply(log, arguments)
|
logger.error(arguments[0].message, arguments[0])
|
||||||
},
|
},
|
||||||
setFilterMsg(msg) {
|
setFilterMsg(msg) {
|
||||||
// 从基础库2.7.3开始支持
|
|
||||||
if (!log || !log.setFilterMsg) return
|
if (!log || !log.setFilterMsg) return
|
||||||
if (typeof msg !== 'string') return
|
if (typeof msg !== 'string') return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
log.setFilterMsg(msg)
|
const logger = log.tag(arguments[0].name)
|
||||||
|
logger.setFilterMsg(JSON.stringify(arguments[0]))
|
||||||
},
|
},
|
||||||
addFilterMsg(msg) {
|
addFilterMsg(msg) {
|
||||||
// 从基础库2.8.1开始支持
|
|
||||||
if (!log || !log.addFilterMsg) return
|
if (!log || !log.addFilterMsg) return
|
||||||
if (typeof msg !== 'string') return
|
if (typeof msg !== 'string') return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
log.addFilterMsg(msg)
|
const logger = log.tag(arguments[0].name)
|
||||||
|
logger.addFilterMsg(JSON.stringify(arguments[0]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -295,7 +295,7 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
lockList[accountInfo.uid] = [this.lockInfo]
|
lockList[accountInfo.uid] = [this.lockInfo]
|
||||||
setStorage('starLockList', lockList)
|
setStorage('starLockList', lockList)
|
||||||
}
|
}
|
||||||
} else {
|
} else if (code === Result.Fail.code) {
|
||||||
const lockList = getStorage('starLockList')
|
const lockList = getStorage('starLockList')
|
||||||
if (lockList[accountInfo.uid]) {
|
if (lockList[accountInfo.uid]) {
|
||||||
const index = lockList[accountInfo.uid].findIndex(item => item.lockId === lockId)
|
const index = lockList[accountInfo.uid].findIndex(item => item.lockId === lockId)
|
||||||
@ -318,8 +318,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
async openDoor(params) {
|
async openDoor(params) {
|
||||||
const { accountInfo, type } = params
|
const { accountInfo, type } = params
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
Result.Success.code,
|
Result.Success.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -328,8 +328,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`开始开门`
|
`开始开门`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
// 设置执行账号
|
// 设置执行账号
|
||||||
const result = await this.login(accountInfo)
|
const result = await this.login(accountInfo)
|
||||||
@ -337,8 +338,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
result.code,
|
result.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -347,16 +348,17 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`登录星云账号: ${result.message}`
|
`登录星云账号: ${result.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!params.connected) {
|
if (!params.connected) {
|
||||||
const searchResult = await searchAndConnectDevice(
|
const searchResult = await searchAndConnectDevice(
|
||||||
this.lockInfo.bluetooth.bluetoothDeviceName
|
this.lockInfo.bluetooth.bluetoothDeviceName
|
||||||
)
|
)
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
searchResult.code,
|
searchResult.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -365,8 +367,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`连接设备: ${searchResult.message}`
|
`连接设备: ${searchResult.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
if (searchResult.code !== Result.Success.code) {
|
if (searchResult.code !== Result.Success.code) {
|
||||||
return searchResult
|
return searchResult
|
||||||
}
|
}
|
||||||
@ -379,8 +382,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
return checkResult
|
return checkResult
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
checkResult.code,
|
checkResult.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -389,8 +392,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`确认是否为锁用户: ${checkResult.message}`
|
`确认是否为锁用户: ${checkResult.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
// 是否需要联网
|
// 是否需要联网
|
||||||
let onlineToken = ''
|
let onlineToken = ''
|
||||||
@ -403,8 +407,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
checkResult.code,
|
checkResult.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -413,8 +417,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`判断是否需要联网token: ${this.lockInfo.lockSetting.appUnlockOnline}`
|
`判断是否需要联网token: ${this.lockInfo.lockSetting.appUnlockOnline}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
// 开门方式
|
// 开门方式
|
||||||
let openMode
|
let openMode
|
||||||
@ -472,8 +477,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
|
|
||||||
const packageArray = createPackageEnd(headArray, cebArray)
|
const packageArray = createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
Result.Success.code,
|
Result.Success.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -482,8 +487,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`开始写入`
|
`开始写入`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
const writeResult = await writeBLECharacteristicValue(
|
const writeResult = await writeBLECharacteristicValue(
|
||||||
this.lockInfo.deviceId,
|
this.lockInfo.deviceId,
|
||||||
@ -496,8 +502,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
return writeResult
|
return writeResult
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
writeResult.code,
|
writeResult.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -506,8 +512,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`写入完成:${writeResult.message}`
|
`写入完成:${writeResult.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
return this.getWriteResult(this.openDoor, params)
|
return this.getWriteResult(this.openDoor, params)
|
||||||
},
|
},
|
||||||
@ -1570,8 +1577,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
characteristicValueCallback = async data => {
|
characteristicValueCallback = async data => {
|
||||||
// code 6 token过期,重新获取
|
// code 6 token过期,重新获取
|
||||||
if (data.code === Result.NotTokenLock.code) {
|
if (data.code === Result.NotTokenLock.code) {
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
data.code,
|
data.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -1579,8 +1586,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`token过期:${data.message}`
|
`token过期:${data.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
resolve(await request({ ...params, connected: true }))
|
resolve(await request({ ...params, connected: true }))
|
||||||
} else if (data.code === Result.NotRegisteredLock.code) {
|
} else if (data.code === Result.NotRegisteredLock.code) {
|
||||||
const checkResult = await this.checkLockUser(true)
|
const checkResult = await this.checkLockUser(true)
|
||||||
@ -1596,8 +1604,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
await this.disconnectDevice()
|
await this.disconnectDevice()
|
||||||
}
|
}
|
||||||
console.log('写入结果', data, request, params)
|
console.log('写入结果', data, request, params)
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
data.code,
|
data.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -1605,8 +1613,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`开门结果:${data.message}`
|
`开门结果:${data.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
resolve(data)
|
resolve(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1834,9 +1843,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
lockId: this.lockInfo.lockId
|
lockId: this.lockInfo.lockId
|
||||||
})
|
})
|
||||||
return characteristicValueCallback(new Result(result.code))
|
return characteristicValueCallback(new Result(result.code))
|
||||||
|
} else {
|
||||||
|
characteristicValueCallback(new Result(decrypted[2]))
|
||||||
}
|
}
|
||||||
characteristicValueCallback(new Result(decrypted[2]))
|
|
||||||
|
|
||||||
break
|
break
|
||||||
case subCmdIds.resetLockPassword:
|
case subCmdIds.resetLockPassword:
|
||||||
this.updateLockInfo({
|
this.updateLockInfo({
|
||||||
@ -1914,7 +1923,7 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
user: decrypted[8 + 17 * i] * 256 + decrypted[9 + 17 * i],
|
user: decrypted[8 + 17 * i] * 256 + decrypted[9 + 17 * i],
|
||||||
date: arrayToTimestamp(decrypted.slice(10 + 17 * i, 14 + 17 * i)) * 1000,
|
date: arrayToTimestamp(decrypted.slice(10 + 17 * i, 14 + 17 * i)) * 1000,
|
||||||
success: 1,
|
success: 1,
|
||||||
password
|
password: password
|
||||||
}
|
}
|
||||||
records.push(record)
|
records.push(record)
|
||||||
}
|
}
|
||||||
@ -1954,6 +1963,21 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
}
|
}
|
||||||
characteristicValueCallback(new Result(decrypted[6], { lock: this.lockInfo }))
|
characteristicValueCallback(new Result(decrypted[6], { lock: this.lockInfo }))
|
||||||
break
|
break
|
||||||
|
case cmdIds.resetDevice:
|
||||||
|
this.updateLockInfo({
|
||||||
|
token: decrypted.slice(2, 6),
|
||||||
|
electricQuantity: decrypted[7],
|
||||||
|
electricQuantityStandby: decrypted[9]
|
||||||
|
})
|
||||||
|
if (decrypted[6] === Result.Success.code) {
|
||||||
|
updateElectricQuantityRequest({
|
||||||
|
lockId: this.lockInfo.lockId,
|
||||||
|
electricQuantity: decrypted[7],
|
||||||
|
electricQuantityStandby: decrypted[9]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
characteristicValueCallback(new Result(decrypted[6], { lock: this.lockInfo }))
|
||||||
|
break
|
||||||
case cmdIds.resetDevice:
|
case cmdIds.resetDevice:
|
||||||
this.updateLockInfo({
|
this.updateLockInfo({
|
||||||
token: decrypted.slice(2, 6)
|
token: decrypted.slice(2, 6)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user