Skip to content

Commit

Permalink
[tr064] fix incorrectly reported decibel values for DSL Noise Margin …
Browse files Browse the repository at this point in the history
…and Attenuation (#11337)

* [tr064] fix incorrectly reported decibel values for DSL Noise Margin and Attenuation

Signed-off-by: Stefan Giehl <[email protected]>

* apply review feedback

Signed-off-by: Stefan Giehl <[email protected]>
  • Loading branch information
sgiehl authored Oct 16, 2021
1 parent 18d26aa commit 19cd505
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.Units;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
Expand Down Expand Up @@ -200,6 +201,20 @@ private State processMacSignalStrength(State state, Tr064ChannelConfig channelCo
return mappedSignalStrength;
}

/**
* post processor for decibel values (which are served as deca decibel)
*
* @param state the channel value in deca decibel
* @param channelConfig channel config of the channel
* @return the state converted to decibel
*/
@SuppressWarnings("unused")
private State processDecaDecibel(State state, Tr064ChannelConfig channelConfig) {
Float value = state.as(DecimalType.class).floatValue() / 10;

return new QuantityType(value, Units.DECIBEL);
}

/**
* post processor for answering machine new messages channel
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,25 +284,25 @@
<item type="Number:Dimensionless" unit="dB" statePattern="%.1f dB"/>
<service deviceType="urn:dslforum-org:device:WANDevice:1"
serviceId="urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1"/>
<getAction name="GetInfo" argument="NewDownstreamNoiseMargin"/>
<getAction name="GetInfo" argument="NewDownstreamNoiseMargin" postProcessor="processDecaDecibel"/>
</channel>
<channel name="dslUpstreamNoiseMargin" label="DSL Upstream Noise Margin">
<item type="Number:Dimensionless" unit="dB" statePattern="%.1f dB"/>
<service deviceType="urn:dslforum-org:device:WANDevice:1"
serviceId="urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1"/>
<getAction name="GetInfo" argument="NewUpstreamNoiseMargin"/>
<getAction name="GetInfo" argument="NewUpstreamNoiseMargin" postProcessor="processDecaDecibel"/>
</channel>
<channel name="dslDownstreamAttenuation" label="DSL Downstream Attenuation">
<item type="Number:Dimensionless" unit="dB" statePattern="%.1f dB"/>
<service deviceType="urn:dslforum-org:device:WANDevice:1"
serviceId="urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1"/>
<getAction name="GetInfo" argument="NewDownstreamAttenuation"/>
<getAction name="GetInfo" argument="NewDownstreamAttenuation" postProcessor="processDecaDecibel"/>
</channel>
<channel name="dslUpstreamAttenuation" label="DSL Upstream Attenuation">
<item type="Number:Dimensionless" unit="dB" statePattern="%.1f dB"/>
<service deviceType="urn:dslforum-org:device:WANDevice:1"
serviceId="urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1"/>
<getAction name="GetInfo" argument="NewUpstreamAttenuation"/>
<getAction name="GetInfo" argument="NewUpstreamAttenuation" postProcessor="processDecaDecibel"/>
</channel>
<channel name="dslFECErrors" label="DSL FEC Errors">
<item type="Number:Dimensionless"/>
Expand Down

0 comments on commit 19cd505

Please sign in to comment.