-
Notifications
You must be signed in to change notification settings - Fork 3
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
Set MAC state for devices with active session #14
Conversation
pkg/source/ttnv2/source.go
Outdated
if deviceHasSession && deviceSupportsJoin { | ||
v3dev.MACState = &ttnpb.MACState{ | ||
DeviceClass: ttnpb.CLASS_A, | ||
LoRaWANVersion: ttnpb.MAC_V1_0_2, | ||
CurrentParameters: ttnpb.MACParameters{ | ||
Rx1Delay: ttnpb.RX_DELAY_1, | ||
}, | ||
} | ||
} else { | ||
v3dev.MACSettings.Rx1Delay = &ttnpb.RxDelayValue{ | ||
Value: ttnpb.RX_DELAY_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.
if deviceHasSession && deviceSupportsJoin { | |
v3dev.MACState = &ttnpb.MACState{ | |
DeviceClass: ttnpb.CLASS_A, | |
LoRaWANVersion: ttnpb.MAC_V1_0_2, | |
CurrentParameters: ttnpb.MACParameters{ | |
Rx1Delay: ttnpb.RX_DELAY_1, | |
}, | |
} | |
} else { | |
v3dev.MACSettings.Rx1Delay = &ttnpb.RxDelayValue{ | |
Value: ttnpb.RX_DELAY_1, | |
} | |
} | |
if deviceHasSession { | |
v3dev.MACState = &ttnpb.MACState{ | |
DeviceClass: ttnpb.CLASS_A, | |
LoRaWANVersion: ttnpb.MAC_V1_0_2, | |
CurrentParameters: ttnpb.MACParameters{ | |
Rx1Delay: ttnpb.RX_DELAY_1, | |
}, | |
} | |
} | |
if !deviceSupportsJoin { | |
v3dev.MACSettings.Rx1Delay = &ttnpb.RxDelayValue{ | |
Value: ttnpb.RX_DELAY_1, | |
} | |
} |
If In fact, I think the best approach is CLI using https://github.com/TheThingsNetwork/lorawan-stack/blob/b4c8dcda48ba9b43e383a7e09e909c4607cbd565/pkg/networkserver/mac/utils.go#L548-L601 to generate a MAC state, doing all the adjustments for v2 and then setting that |
4f739fe
to
e5caad0
Compare
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 looks good, but the tool should be careful with the field paths sent to NS - if the tool sends top-level mac_state
, then the created device will end up with a corrupted MAC state and will be unusable
And, to reiterate, I think the cleanest approach would be:
|
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.
LGTM
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.
A possible improvement is to not set mac-state.desired-parameters
, such that v3 NS would compute that by itself and modify the state accordingly, but I'm not sure we should do that.
For example, that would mean that immediately after migration v3 NS would try to reconfigure device to use RX1 Delay of 5 seconds(v3 default) via MAC commands, @johanstokking @htdvisser - what do you think?
IMO it's safest not to do that and just let the device stay with exact same configuration as v2 to minimize chance of potential issues. Users can set mac-state.desired-parameters.rx1-delay
if necessary
Yeah good point. What are the other settings that we should consider, besides RX1 delay? As for this particular instance, I do think that we should reconfigure the RX1 delay to TTS' default. |
Updated according to our discussion with @rvolosatovs. Will proceed with testing after NS supports importing device sessions. |
@@ -210,5 +209,8 @@ func (s *Source) RangeDevices(appID string, f func(source.Source, string) error) | |||
|
|||
// Close implements the Source interface. | |||
func (s *Source) Close() error { | |||
return s.client.Close() | |||
if s.client != 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.
I don't really like the fact that we lazy-initialize client
with the first application ID that is seen by Source
. Is there a good reason for that?
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.
Lazy initialization is removed as part of #13
Blocked by TheThingsNetwork/lorawan-stack#2472 |
6902562
to
7f3518e
Compare
pkg/source/ttnv2/source.go
Outdated
v3dev.MACState.DeviceClass = ttnpb.CLASS_A | ||
v3dev.MACState.LoRaWANVersion = ttnpb.MAC_V1_0_2 | ||
v3dev.MACState.CurrentParameters.Rx1Delay = ttnpb.RX_DELAY_1 | ||
v3dev.MACState.DesiredParameters = ttnpb.MACParameters{} |
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.
You should not need to be doing this. Instead, this should be covered by the field mask.
Only relevant fields in mac_state.current_parameters
and in top-level mac_state
should be specified
7f3518e
to
e3988a4
Compare
@neoaggelos if this is ready for review, request them. |
I am currently testing against the changes in TheThingsNetwork/lorawan-stack#3680, will request review when ready. |
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.
I don't see the fieldmask in the diff and don't know where to find it, but I assume that is correct
e3988a4
to
5aa1a1a
Compare
FYI, TheThingsNetwork/lorawan-stack#3680 is still not merged. |
Summary
References https://github.com/TheThingsIndustries/lorawan-stack/issues/2417
Changes
OTAAdevices with a session, setcurrent parameters instead ofMAC state.This is only relevant for the Rx1 Delay for devices exported from TTNv2Testing
Test with devices from TTN
OTAA device, without a session -> Sets mac_settings.rx1_delay
OTAA device with session -> Sets mac_state.current_parameters.rx1_delay
ABP devices -> Sets mac_settings.rx1_delay
Checklist
CHANGELOG.md
.