Skip to content

Commit

Permalink
fix: return predefined fallbacks on bad modem values for powerLevel a…
Browse files Browse the repository at this point in the history
…nd snr (#143)
  • Loading branch information
totev authored Apr 3, 2024
1 parent e0eb72b commit ad41de6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/modem/arris-modem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@ export function normalizeChannelStatus(channelStatus: ArrisDocsisChannelStatus):
frequency.frequencyStart = Number(ofdmaFrequency[0])
frequency.frequencyEnd = Number(ofdmaFrequency[1])
}


const powerLevel = parseFloat(channelStatus.PowerLevel.split("/")[0]);
const snr = parseInt(`${channelStatus.SNRLevel ?? 0}`, 10);
return {
channelId: channelStatus.ChannelID,
channelType: channelStatus.ChannelType,
modulation: channelStatus.Modulation,
powerLevel: parseFloat(channelStatus.PowerLevel.split('/')[0]),
powerLevel: isNaN(powerLevel) ? -100 : powerLevel,
lockStatus: channelStatus.LockStatus,
snr: parseInt(`${channelStatus.SNRLevel ?? 0}`, 10),
...frequency
} as HumanizedDocsisChannelStatus | HumanizedDocsis31ChannelStatus
snr: isNaN(snr) ? 0 : snr,
...frequency,
} as HumanizedDocsisChannelStatus | HumanizedDocsis31ChannelStatus;
}

export function normalizeDocsisStatus(arrisDocsisStatus: ArrisDocsisStatus): DocsisStatus {
Expand Down

0 comments on commit ad41de6

Please sign in to comment.