Skip to content

Conversation

@halimi
Copy link
Contributor

@halimi halimi commented Mar 25, 2025

Summary

References: #7380

Changes

  • RPC to set, unset MAC settings profile to batch of end devices

Testing

Steps

Prerequisites:

  • Batch of end-devices
  • At least 2 MAC settings profile

Tests:

  • Set MAC settings profile to batch of end devices
  • Unset MAC settings profile to batch of end devices
  • Set MAC settings profile to batch of end devices but some of the devices already have a different profile
  • Unset MAC settings profile to batch of end devices but the devices have a different profiles
Results

Set MAC settings profile to batch of end devices

POST http://localhost:1885/api/v3/ns/applications/myapp/devices/mac_settings_profile/batch
body:
{
  "application_ids": {
    "application_id": "myapp"
  },
  "mac_settings_profile_ids": {
    "application_ids": {
      "application_id": "myapp"
    },
    "profile_id": "mac22"
  },
  "device_ids": [
    "test-dev10",
    "test-dev11"
  ]
}

response:
{
  "end_devices": [
    {
      "ids": {
        "device_id": "test-dev10",
        "application_ids": {
          "application_id": "myapp"
        },
        "dev_eui": "6655443322110077",
        "join_eui": "1122334455667700"
      },
      "created_at": "2025-04-10T13:40:30.876332Z",
      "updated_at": "2025-04-10T13:43:19.427050Z",
      "mac_settings_profile_ids": {
        "application_ids": {
          "application_id": "myapp"
        },
        "profile_id": "mac22"
      }
    },
    {
      "ids": {
        "device_id": "test-dev11",
        "application_ids": {
          "application_id": "myapp"
        },
        "dev_eui": "7766554433221100",
        "join_eui": "1122334455667700"
      },
      "created_at": "2025-04-10T13:42:09.292151Z",
      "updated_at": "2025-04-10T13:43:19.427054Z",
      "mac_settings_profile_ids": {
        "application_ids": {
          "application_id": "myapp"
        },
        "profile_id": "mac22"
      }
    }
  ]
}

Unset MAC settings profile to batch of end devices

POST http://localhost:1885/api/v3/ns/applications/myapp/devices/mac_settings_profile/batch
body:
{
  "application_ids": {
    "application_id": "myapp"
  },
  "mac_settings_profile_ids": null,
  "device_ids": [
    "test-dev10",
    "test-dev11"
  ]
}

response:
{
  "end_devices": [
    {
      "ids": {
        "device_id": "test-dev10",
        "application_ids": {
          "application_id": "myapp"
        },
        "dev_eui": "6655443322110077",
        "join_eui": "1122334455667700"
      },
      "created_at": "2025-04-10T13:40:30.876332Z",
      "updated_at": "2025-04-10T13:51:31.969211Z",
      "mac_settings": {
        "rx2_data_rate_index": 0,
        "rx2_frequency": "869525000"
      }
    },
    {
      "ids": {
        "device_id": "test-dev11",
        "application_ids": {
          "application_id": "myapp"
        },
        "dev_eui": "7766554433221100",
        "join_eui": "1122334455667700"
      },
      "created_at": "2025-04-10T13:42:09.292151Z",
      "updated_at": "2025-04-10T13:51:31.969749Z",
      "mac_settings": {
        "rx2_data_rate_index": 0,
        "rx2_frequency": "869525000"
      }
    }
  ]
}

Set MAC settings profile to batch of end devices but some of the devices already have a different profile
First set a profile to one device

POST http://localhost:1885/api/v3/ns/applications/myapp/devices/mac_settings_profile/batch
body:
{
  "application_ids": {
    "application_id": "myapp"
  },
  "mac_settings_profile_ids": {
    "application_ids": {
      "application_id": "myapp"
    },
    "profile_id": "mac22"
  },
  "device_ids": [
    "test-dev10"
  ]
}

response:
{
  "application_ids": {
    "application_id": "myapp"
  },
  "mac_settings_profile_ids": {
    "application_ids": {
      "application_id": "myapp"
    },
    "profile_id": "mac22"
  },
  "device_ids": [
    "test-dev10"
  ]
}

Then set a different profile to all the devices

POST http://localhost:1885/api/v3/ns/applications/myapp/devices/mac_settings_profile/batch
body:
{
  "application_ids": {
    "application_id": "myapp"
  },
  "mac_settings_profile_ids": {
    "application_ids": {
      "application_id": "myapp"
    },
    "profile_id": "mac23"
  },
  "device_ids": [
    "test-dev10",
    "test-dev11"
  ]
}

response:
{
  "end_devices": [
    {
      "ids": {
        "device_id": "test-dev10",
        "application_ids": {
          "application_id": "myapp"
        },
        "dev_eui": "6655443322110077",
        "join_eui": "1122334455667700"
      },
      "created_at": "2025-04-10T13:40:30.876332Z",
      "updated_at": "2025-04-10T14:00:47.617664Z",
      "mac_settings_profile_ids": {
        "application_ids": {
          "application_id": "myapp"
        },
        "profile_id": "mac23"
      }
    },
    {
      "ids": {
        "device_id": "test-dev11",
        "application_ids": {
          "application_id": "myapp"
        },
        "dev_eui": "7766554433221100",
        "join_eui": "1122334455667700"
      },
      "created_at": "2025-04-10T13:42:09.292151Z",
      "updated_at": "2025-04-10T14:00:47.617672Z",
      "mac_settings_profile_ids": {
        "application_ids": {
          "application_id": "myapp"
        },
        "profile_id": "mac23"
      }
    }
  ]
}

Unset MAC settings profile to batch of end devices but the devices have a different profiles
First set a different profile to one device

POST http://localhost:1885/api/v3/ns/applications/myapp/devices/mac_settings_profile/batch
body:
{
  "application_ids": {
    "application_id": "myapp"
  },
  "mac_settings_profile_ids": {
    "application_ids": {
      "application_id": "myapp"
    },
    "profile_id": "mac22"
  },
  "device_ids": [
    "test-dev10"
  ]
}

response:
{
  "application_ids": {
    "application_id": "myapp"
  },
  "mac_settings_profile_ids": {
    "application_ids": {
      "application_id": "myapp"
    },
    "profile_id": "mac22"
  },
  "device_ids": [
    "test-dev10"
  ]
}

Then unset the profiles from all the devices

POST http://localhost:1885/api/v3/ns/applications/myapp/devices/mac_settings_profile/batch
body:
{
  "application_ids": {
    "application_id": "myapp"
  },
  "mac_settings_profile_ids": null,
  "device_ids": [
    "test-dev10",
    "test-dev11"
  ]
}

response:
{
  "end_devices": [
    {
      "ids": {
        "device_id": "test-dev10",
        "application_ids": {
          "application_id": "myapp"
        },
        "dev_eui": "6655443322110077",
        "join_eui": "1122334455667700"
      },
      "created_at": "2025-04-10T13:40:30.876332Z",
      "updated_at": "2025-04-10T14:19:37.939667Z",
      "mac_settings": {
        "rx2_data_rate_index": 0,
        "rx2_frequency": "869525000"
      }
    },
    {
      "ids": {
        "device_id": "test-dev11",
        "application_ids": {
          "application_id": "myapp"
        },
        "dev_eui": "7766554433221100",
        "join_eui": "1122334455667700"
      },
      "created_at": "2025-04-10T13:42:09.292151Z",
      "updated_at": "2025-04-10T14:19:37.940219Z",
      "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 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 25, 2025
@halimi halimi self-assigned this Mar 25, 2025
@halimi halimi added this to the v3.34.1 milestone Mar 25, 2025
@halimi halimi force-pushed the feature/batch-mac-settings-profile branch 2 times, most recently from 2933349 to a1c0cb2 Compare March 28, 2025 15:22
@halimi halimi force-pushed the feature/batch-mac-settings-profile branch 2 times, most recently from c029d79 to d9326e8 Compare April 8, 2025 08:29
@halimi halimi force-pushed the feature/batch-mac-settings-profile branch from 5d6538d to 20b4c6d Compare April 11, 2025 08:51
@halimi halimi marked this pull request as ready for review April 11, 2025 09:15
@halimi halimi requested a review from a team as a code owner April 11, 2025 09:15
@halimi halimi requested a review from johanstokking April 11, 2025 09:15
Copy link
Member

@johanstokking johanstokking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is a good demonstration of why we need V4 😁

@halimi
Copy link
Contributor Author

halimi commented Apr 11, 2025

This code is a good demonstration of why we need V4 😁

Yes, exactly :)

@halimi halimi merged commit 3f0176f into v3.34 Apr 11, 2025
15 of 16 checks passed
@halimi halimi deleted the feature/batch-mac-settings-profile branch April 11, 2025 13:21
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.

3 participants