Skip to content

Commit

Permalink
ns: Validate MAC settings profile
Browse files Browse the repository at this point in the history
  • Loading branch information
halimi committed Feb 19, 2025
1 parent c43414f commit a3f3793
Show file tree
Hide file tree
Showing 3 changed files with 421 additions and 5 deletions.
28 changes: 24 additions & 4 deletions pkg/networkserver/grpc_deviceregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,30 @@ func (ns *NetworkServer) Set(ctx context.Context, req *ttnpb.SetEndDeviceRequest
return nil, err
}

fps, err := ns.FrequencyPlansStore(ctx)
if err != nil {
return nil, err
}

if st.HasSetField(
"mac_settings_profile_ids",
"mac_settings_profile_ids.application_ids",
"mac_settings_profile_ids.application_ids.application_id",
"mac_settings_profile_ids.profile_id",
) {
if st.HasSetField(macSettingsFields...) {
return nil, newInvalidFieldValueError("mac_settings")
}
profile, err := ns.macSettingsProfiles.Get(ctx, st.Device.MacSettingsProfileIds, []string{"mac_settings"})
if err != nil {
return nil, err
}

if err = validateProfile(profile, st, fps); err != nil {
return nil, err
}
}

if err := validateADR(st); err != nil {
return nil, err
}
Expand Down Expand Up @@ -472,10 +496,6 @@ func (ns *NetworkServer) Set(ctx context.Context, req *ttnpb.SetEndDeviceRequest
"pending_mac_state.desired_parameters.rx2_data_rate_index",
"supports_class_b",
) {
fps, err := ns.FrequencyPlansStore(ctx)
if err != nil {
return nil, err
}
if err := validateBandSpecifications(st, fps); err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit a3f3793

Please sign in to comment.