Skip to content

Commit

Permalink
Merge pull request #1100 from OSGP/feature/SMHE-1809-dev-null-check-p…
Browse files Browse the repository at this point in the history
…ower-quality-ber

SMHE-1809: add null fix for emtpy SignalQuality and BER
  • Loading branch information
abolder authored Oct 19, 2023
2 parents 3c8873e + 7842876 commit ea857bb
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,20 @@ private ProfileEntryValueDto makeGsmDiagnosticProfileEntryValueDto(
try {
if (selectableObject.attributeIndex == GsmDiagnosticAttribute.CELL_INFO.attributeId()) {
if (selectableObject.dataIndex == DATA_INDEX_SIGNAL_QUALITY) {
final int value = this.dlmsHelper.readLong(dataObject, "Read signal quality").intValue();
final Long signalQualityLong =
this.dlmsHelper.readLong(dataObject, "Read signal quality");
if (signalQualityLong == null) {
return notKnownProfileEntryValue();
}
final int value = signalQualityLong.intValue();
final SignalQualityDto signalQuality = SignalQualityDto.fromIndexValue(value);
return new ProfileEntryValueDto(signalQuality.value());
} else if (selectableObject.dataIndex == DATA_INDEX_BER) {
final int value = this.dlmsHelper.readLong(dataObject, "Read ber").intValue();
final Long berLong = this.dlmsHelper.readLong(dataObject, "Read ber");
if (berLong == null) {
return notKnownProfileEntryValue();
}
final int value = berLong.intValue();
return new ProfileEntryValueDto(value);
}
}
Expand All @@ -510,6 +519,10 @@ private ProfileEntryValueDto makeGsmDiagnosticProfileEntryValueDto(
return new ProfileEntryValueDto(debugInfo);
}

private static ProfileEntryValueDto notKnownProfileEntryValue() {
return new ProfileEntryValueDto(99);
}

private ProfileEntryValueDto createNumericProfileEntryValueDto(
final DataObject dataObject, final SelectableObject selectableObject) {
try {
Expand Down

0 comments on commit ea857bb

Please sign in to comment.