Skip to content

Remove MAC settings profile reference on end device delete#7601

Merged
halimi merged 2 commits into
v3.34from
feature/mac-settings-profile-delete-device
Apr 30, 2025
Merged

Remove MAC settings profile reference on end device delete#7601
halimi merged 2 commits into
v3.34from
feature/mac-settings-profile-delete-device

Conversation

@halimi
Copy link
Copy Markdown
Contributor

@halimi halimi commented Apr 24, 2025

Summary

References: #7380

Remove the MAC settings profile reference (decrease the counter) when deleting an end device with MAC settings profile.

Changes

  • Remove MAC settings profile reference on end device delete
  • Remove MAC settings profile reference on batch of end devices delete

Testing

Steps
  • Create a MAC settings profile
  • Create a device with MAC settings profile
  • Check that the MAC settings profile end_devices_count shows 1
  • Delete the device
  • Check that the MAC settings profile end_devices_count shows 0
Results
  • Create a MAC settings profile
POST http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles

body:
{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac24"
    },
    "mac_settings": {
      "rx2_data_rate_index": 0,
      "rx2_frequency": "869525000"
    }
  }
}
  • Create a device with MAC settings profile
POST http://localhost:1885/api/v3/ns/applications/myapp/devices

body:
{
  "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": "0606554433221107",
      "device_id": "test-dev15",
      "application_ids": {
        "application_id": "myapp"
      }
    },
    "mac_settings_profile_ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac24"
    }
  },
  "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",
      "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 end_devices_count shows 1
GET http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles/mac24?field_mask=ids,mac_settings,end_devices_count

response:
{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac24"
    },
    "mac_settings": {
      "rx2_data_rate_index": 0,
      "rx2_frequency": "869525000"
    },
    "end_devices_count": 1
  }
}
  • Delete the device
DELETE http://localhost:1885/api/v3/ns/applications/myapp/devices/test-dev15
  • Check that the MAC settings profile end_devices_count shows 0
GET http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles/mac24?field_mask=ids,mac_settings,end_devices_count

response:
{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac24"
    },
    "mac_settings": {
      "rx2_data_rate_index": 0,
      "rx2_frequency": "869525000"
    }
  }
}
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.

@github-actions github-actions Bot added the c/network server This is related to the Network Server label Apr 24, 2025
@halimi halimi self-assigned this Apr 24, 2025
@halimi halimi added this to the v3.34.2 milestone Apr 24, 2025
@github-actions github-actions Bot added the compat/db This could affect Database compatibility label Apr 28, 2025
@halimi halimi force-pushed the feature/mac-settings-profile-delete-device branch from acf0bce to 39324af Compare April 28, 2025 20:00
@halimi halimi marked this pull request as ready for review April 28, 2025 21:25
@halimi halimi requested a review from a team as a code owner April 28, 2025 21:25
@halimi halimi requested a review from johanstokking April 28, 2025 21:25
@halimi halimi force-pushed the feature/mac-settings-profile-delete-device branch from 39324af to b14a57b Compare April 29, 2025 13:00
@halimi halimi merged commit 3b2442c into v3.34 Apr 30, 2025
14 of 21 checks passed
@halimi halimi deleted the feature/mac-settings-profile-delete-device branch April 30, 2025 08:36
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants