Skip to content

Commit

Permalink
core: frontend: deviceIdDecoder: expose devid parameter number
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Jan 31, 2024
1 parent b0dbeb6 commit f2ccdea
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/frontend/src/utils/deviceid_decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ function toHex(value: number): string {
export interface deviceId {
param: string
paramValue: number
deviceIdNumber: number
deviceName?: string
busType: string
bus: number
Expand All @@ -128,6 +129,9 @@ export default function decode(device: string, devid: number): deviceId {
const bus = devid >> 3 & 0x1F
const address = devid >> 8 & 0xFF
const devtype = devid >> 16
// set deviceIdNumber to the last number of the "device" string or 1 if it's not a number
const deviceIdNumber = parseInt(device.slice(-1), 10) || 1

let decodedDevname = 'UNKNOWN'

if (device.startsWith('COMPASS')) {
Expand Down Expand Up @@ -163,6 +167,7 @@ export default function decode(device: string, devid: number): deviceId {
bus,
address: toHex(address),
devtype,
deviceIdNumber,
paramValue: devid,
}
}

0 comments on commit f2ccdea

Please sign in to comment.