-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util: Remove hardware specific values from BS router_config #2131
Conversation
pkg/pfconfig/shared/shared.go
Outdated
@@ -33,7 +33,7 @@ import ( | |||
// SX1301Config contains the configuration for the SX1301 concentrator. | |||
type SX1301Config struct { | |||
LoRaWANPublic bool | |||
ClockSource uint8 | |||
ClockSource uint8 `json:"omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Your
json
tag now renames this field toomitempty
- This has no effect, because
SX1301Config
has aMarshalJSON
implementation. That's where you need to change this. - You need to make this a
*uint8
so that we can make a distinction between 0 and "omit"
2775bf8
to
db9c4a3
Compare
import "time" | ||
|
||
// Bool returns a boolean pointer for the given value. | ||
func Bool(v bool) *bool { return &v } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's please not do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a one-time thing you could just oneline this. E.g.
ClassBTimeout: func(v time.Duration) *time.Duration { return &v }(time.Minute), |
Otherwise just have a non-exported boolPtr
next to the usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not? Then I need to define the same boolPtr
and functions for each type in 4 different files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is inherent to Go
@@ -116,10 +116,13 @@ func GetRouterConfig(bandID string, fps map[string]*frequencyplans.FrequencyPlan | |||
// These fields are not defined in the v1.5 ref design https://doc.sm.tc/station/gw_v1.5.html#rfconf-object and would cause a parsing error. | |||
sx1301Conf.Radios[0].TxFreqMin = 0 | |||
sx1301Conf.Radios[0].TxFreqMax = 0 | |||
// Remove hardware specific values that are not necessary. | |||
// Remove hardware specific values that are handled by the gateway itself. | |||
sx1301Conf.ClockSource = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the underlying problem that we have radio specific fields in the frequency plan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well these fields are valid SX1301_conf
fields. Issue is that basic station specifically already has a config file on each hardware and hardware specific fields are already present there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But isn't that true for other gateways too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most gateways use what's provided in the global_conf.json
right? Some have overrides in local_conf.json
but not all of them afaik.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I understand from #2130 is that we send information too specific about a gateway to a gateway. That makes me think that we have fields in our frequency plans that don't belong there. So removing those from BSLNS as you do here is a fix, but it's a fix for the symptoms. We may need to remove these fields from the frequency plans, pfconfig
and GCS.
@@ -285,7 +286,7 @@ func BuildSX1301Config(frequencyPlan *frequencyplans.FrequencyPlan) (*SX1301Conf | |||
conf := new(SX1301Config) | |||
|
|||
conf.LoRaWANPublic = true | |||
conf.ClockSource = frequencyPlan.ClockSource | |||
conf.ClockSource = pointers.Uint8(frequencyPlan.ClockSource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conf.ClockSource = pointers.Uint8(frequencyPlan.ClockSource) | |
conf.ClockSource = &frequencyPlan.ClockSource |
@@ -88,25 +89,24 @@ func TestSX1301Conf(t *testing.T) { | |||
}, | |||
SX1301Config{ | |||
LoRaWANPublic: true, | |||
ClockSource: 1, | |||
ClockSource: pointers.Uint8(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClockSource: pointers.Uint8(1), | |
ClockSource: func(v uint8) *uint8 { return &v }(1), |
AntennaGain: 0, | ||
Radios: []RFConfig{ | ||
{ | ||
Enable: true, | ||
Type: "SX1257", | ||
Frequency: 867500000, | ||
TxEnable: true, | ||
TxEnable: pointers.Bool(true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TxEnable: pointers.Bool(true), | |
TxEnable: func(v bool) *bool { return &v }(true), |
TxFreqMin: 863000000, | ||
TxFreqMax: 870000000, | ||
RSSIOffset: -166, | ||
RSSIOffset: pointers.Float32(-166), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place you actually may want to have a helper function, since there are 2 usages.
However, why not just define const defaultRSSIOffset = -166
and use &defaultRSSIOffset
here and below?
Closing this in favor of https://github.com/TheThingsIndustries/lorawan-stack/issues/2018 |
…ge/open-source
Summary
Closed #2130
Changes
omitempty
to necessary fields and set type-default values to them.Notes for Reviewers
Pending testing on metal.
Checklist
README.md
.CHANGELOG.md
.CONTRIBUTING.md
, there are no fixup commits left.