fix: mockup topic2
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { DeviceQueryParams } from '../schema'
|
||||
import { queryDeviceStatus } from './query'
|
||||
|
||||
export default abstract class QueryService {
|
||||
static async getDeviceStatus(query: DeviceQueryParams): Promise<{
|
||||
@@ -15,12 +14,16 @@ export default abstract class QueryService {
|
||||
towerNumber: string
|
||||
payload: string
|
||||
}
|
||||
} | null> {
|
||||
}> {
|
||||
// TODO: Check nonce for replay attack when DB is implemented
|
||||
|
||||
const topic = `${query.merchantName}/${query.floorName}_${query.unitNumber}-${query.deviceName}-${query.roomName}-${query.deviceType}-S-${query.towerNumber}`
|
||||
|
||||
if (topic == 'SAVY/L2_01-BL-LV-S-S-T1') {
|
||||
// if (!['SAVY/L2_01-BL-LV-S-S-T1', 'SAVY/L2_01-L-LV-S-S-T1'].includes(topic)) {
|
||||
// throw new Error('Unsupported device topic')
|
||||
// }
|
||||
|
||||
if (topic === 'SAVY/L2_01-BL-LV-S-S-T1') {
|
||||
return {
|
||||
status: 'success',
|
||||
message: 'command accepted',
|
||||
@@ -35,9 +38,7 @@ export default abstract class QueryService {
|
||||
payload: 'Open',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if (topic == 'SAVY/L2_01-L-LV-S-S-T1') {
|
||||
} else {
|
||||
return {
|
||||
status: 'success',
|
||||
message: 'command accepted',
|
||||
@@ -53,16 +54,5 @@ export default abstract class QueryService {
|
||||
},
|
||||
}
|
||||
}
|
||||
const deviceData = await queryDeviceStatus(topic)
|
||||
|
||||
if (deviceData) {
|
||||
return {
|
||||
status: 'success',
|
||||
message: 'command accepted',
|
||||
data: deviceData,
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user