changed ranging to bool

This commit is contained in:
2022-11-19 00:41:23 +01:00
parent 6a63fa4b1b
commit cbe5b13e40

42
main.go
View File

@@ -148,13 +148,13 @@ type SaltResponse struct {
}
type DOCSISChannelInfo struct {
Type ChannelType
Power float64
RangingStatus *string
SNR *float64
Direction ChannelDirection
Frequency uint64
ID string
Type ChannelType
Power float64
RangingOK *bool
SNR *float64
Direction ChannelDirection
Frequency uint64
ID string
}
func main() {
@@ -227,7 +227,7 @@ func main() {
enc.AddField("power", lineprotocol.MustNewValue(channel.Power))
if channel.Direction == UP {
enc.AddField("ranging_status", lineprotocol.MustNewValue(*channel.RangingStatus))
enc.AddField("ranging_ok", lineprotocol.BoolValue(*channel.RangingOK))
} else {
enc.AddField("snr", lineprotocol.MustNewValue(*channel.SNR))
}
@@ -416,24 +416,26 @@ func transformDOCSIS(rawDOCSIS *DOCSISResponse) (nChannels []*DOCSISChannelInfo)
}
for _, channel := range rawDOCSIS.OfdmaUpstream {
rangingOk := channel.RangingStatus != "Completed"
nChannels = append(nChannels, &DOCSISChannelInfo{
Type: ChannelType(channel.ChannelType),
Power: powerStr2Power(channel.Power),
RangingStatus: &channel.RangingStatus,
Direction: UP,
Frequency: freqStr2Hz(channel.CentralFrequency),
ID: channel.ChannelIDUp,
Type: ChannelType(channel.ChannelType),
Power: powerStr2Power(channel.Power),
RangingOK: &rangingOk,
Direction: UP,
Frequency: freqStr2Hz(channel.CentralFrequency),
ID: channel.ChannelIDUp,
})
}
for _, channel := range rawDOCSIS.Upstream {
rangingOk := channel.RangingStatus != "Completed"
nChannels = append(nChannels, &DOCSISChannelInfo{
Type: ChannelType(channel.ChannelType),
Power: powerStr2Power(channel.Power),
RangingStatus: &channel.RangingStatus,
Direction: UP,
Frequency: freqStr2Hz(channel.CentralFrequency),
ID: channel.ChannelIDUp,
Type: ChannelType(channel.ChannelType),
Power: powerStr2Power(channel.Power),
RangingOK: &rangingOk,
Direction: UP,
Frequency: freqStr2Hz(channel.CentralFrequency),
ID: channel.ChannelIDUp,
})
}