Skip to content

Disassociate MAC settings profile #7544

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

Merged
merged 15 commits into from
Mar 27, 2025
Merged

Conversation

halimi
Copy link
Contributor

@halimi halimi commented Mar 11, 2025

Summary

References: #7380

Changes

  • Disassociate MAC settings profile from a device
  • Count associated devices in the MAC settings profile
  • Don't allow to delete a MAC settings profile when it is used

Testing

Steps
  • Associate a MAC settings profile to an end device
  • Check that the MAC settings profile counted the associated end device
  • Try to delete the MAC settings profile -> it should fail because it is used
  • Disassociate the MAC settings profile from the end device
  • Check that the MAC Settings profile doesn't count the associated end device
  • Delete the MAC settings profile -> it should be successful
Results

Associate a MAC settings profile to an end device

POST http://localhost:1885/api/v3/ns/applications/myapp/devices

Data:
{
  "end_device": {
    "version_ids": {
      "brand_id": "the-things-industries",
      "model_id": "generic-node-sensor-edition",
      "hardware_version": "1.1",
      "firmware_version": "1.0",
      "band_id": "EU_863_870"
    },
    "frequency_plan_id": "EU_863_870_TTN",
    "supports_join": true,
    "lorawan_version": "MAC_V1_0_3",
    "lorawan_phy_version": "PHY_V1_0_3_REV_A",
    "ids": {
      "join_eui": "1122334455667700",
      "dev_eui": "5544332211007766",
      "device_id": "test-dev9",
      "application_ids": {
        "application_id": "myapp"
      }
    },
    "mac_settings_profile_ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac2"
    }
  },
  "field_mask": {
    "paths": [
      "version_ids.brand_id",
      "version_ids.model_id",
      "version_ids.hardware_version",
      "version_ids.firmware_version",
      "version_ids.band_id",
      "supports_join",
      "supports_class_b",
      "supports_class_c",
      "lorawan_version",
      "lorawan_phy_version",
      "frequency_plan_id",
      "ids.join_eui",
      "ids.dev_eui",
      "ids.device_id",
      "ids.application_ids.application_id",
      "mac_settings_profile_ids.application_ids",
      "mac_settings_profile_ids.application_ids.application_id",
      "mac_settings_profile_ids.profile_id"
    ]
  }
}

Check that the MAC settings profile counted the associated end device

GET http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles/mac2?field_mask=ids,mac_settings,end_devices_count

Response:
{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac2"
    },
    "mac_settings": {
      "rx2_data_rate_index": 0,
      "rx2_frequency": "869525000"
    },
    "end_devices_count": 1
  }
}

Try to delete the MAC settings profile -> it should fail because it is used

DELETE http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles/mac2

Response:
{
  "code": 9,
  "message": "error:pkg/networkserver:mac_settings_profile_used (MAC settings profile is used)",
  "details": [
    {
      "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
      "namespace": "pkg/networkserver",
      "name": "mac_settings_profile_used",
      "message_format": "MAC settings profile is used",
      "correlation_id": "bd154e46eb2643af8921ebf3af93a5ee",
      "code": 9
    }
  ]
}

Disassociate the MAC settings profile from the end device

PUT http://localhost:1885/api/v3/ns/applications/myapp/devices/test-dev9

Data:
{
  "ids": {
    "device_id": "test-dev9",
    "application_ids": {
      "application_id": "myapp"
    }
  },
  "mac_settings_profile_ids": null,
  "field_mask": {
    "paths": [
      "ids.device_id",
      "ids.application_ids.application_id",
      "mac_settings_profile_ids"
    ]
  }
}

Check that the MAC Settings profile doesn't count the associated end device

GET http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles/mac2?field_mask=ids,mac_settings,end_devices_count

Response:
{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac2"
    },
    "mac_settings": {
      "rx2_data_rate_index": 0,
      "rx2_frequency": "869525000",
      "supports_32_bit_f_cnt": true
    }
  }
}

Delete the MAC settings profile -> it should be successful

DELETE http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles/mac2
Regressions

...

Notes for Reviewers

...

Checklist

  • Scope: The referenced issue is addressed, there are no unrelated changes.
  • Compatibility: The changes are backwards compatible with existing API, storage, configuration and CLI, according to the compatibility commitments in README.md for the chosen target branch.
  • Documentation: Relevant documentation is added or updated.
  • Testing: The steps/process to test this feature are clearly explained including testing for regressions.
  • Infrastructure: If infrastructural changes (e.g., new RPC, configuration) are needed, a separate issue is created in the infrastructural repositories.
  • Changelog: Significant features, behavior changes, deprecations and fixes are added to CHANGELOG.md.
  • Commits: Commit messages follow guidelines in CONTRIBUTING.md, there are no fixup commits left.

@halimi halimi self-assigned this Mar 11, 2025
@halimi halimi added this to the v3.34.1 milestone Mar 11, 2025
@github-actions github-actions bot added c/network server This is related to the Network Server compat/db This could affect Database compatibility ui/web This is related to a web interface labels Mar 11, 2025
@halimi halimi force-pushed the feature/unassign-mac-settings-profile branch from 5ef08fd to 61ac78b Compare March 18, 2025 12:56
@halimi halimi force-pushed the feature/unassign-mac-settings-profile branch from 864f5c6 to 3025dc5 Compare March 20, 2025 10:44
@halimi halimi marked this pull request as ready for review March 20, 2025 11:48
@halimi halimi requested a review from a team as a code owner March 20, 2025 11:48
@halimi halimi requested a review from johanstokking March 20, 2025 11:48
@halimi halimi requested a review from johanstokking March 25, 2025 17:30
@halimi halimi requested a review from johanstokking March 26, 2025 13:27
@halimi halimi force-pushed the feature/unassign-mac-settings-profile branch from 8de03dc to 786b146 Compare March 26, 2025 15:45
@halimi halimi force-pushed the feature/unassign-mac-settings-profile branch from 786b146 to ea0c8f0 Compare March 26, 2025 15:54
@halimi halimi merged commit f6a2267 into v3.34 Mar 27, 2025
15 of 16 checks passed
@halimi halimi deleted the feature/unassign-mac-settings-profile branch March 27, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/network server This is related to the Network Server compat/db This could affect Database compatibility ui/web This is related to a web interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants