Skip to content

Associate MAC settings profile #7515

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 12 commits into from
Mar 14, 2025
Merged

Conversation

halimi
Copy link
Contributor

@halimi halimi commented Feb 19, 2025

Summary

References: #7380

Changes

  • Associate MAC settings profile to an end device
  • Validate the associated MAC settings profile according to the end device's FrequencyPlan and Band
  • Use the profile settings during uplink and downlink messages

Testing

Steps

The best way to test this to use a real end device.

Prerequisite:

  • Create an application and end device
  • Connect a gateway and the end device to the TTS

Test steps:

  • Create a MAC settings profile
  • Assign the profile to the end device
  • Send uplinks and downlinks and verify everything works

Negative tests:

  • Assign a mac settings profile and device mac settings at the same time -> it should fail, they are mutually exclusive
  • Assign a mac settings profile that contains invalid settings for the end device -> validation should fail
Results

Create a MAC settings profile

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

{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac1"
    },
    "mac_settings": {
      "rx2_data_rate_index": 0,
      "rx2_frequency": "869525000"
    }
  }
}

Assign the profile to the end device

PUT http://localhost:1885/api/v3/ns/applications/myapp/devices/arduino-mkr

{
  "end_device": {
    "ids": {
      "device_id": "arduino-mkr",
      "application_ids": {
        "application_id": "myapp"
      }
    },
    "lorawan_version": "MAC_V1_0_3",
    "lorawan_phy_version": "PHY_V1_0_3_REV_A",
    "frequency_plan_id": "EU_863_870_TTN",
    "supports_join": true,
    "mac_settings_profile_ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac1"
    }
  },
  "field_mask": {
    "paths": [
      "supports_join",
      "lorawan_version",
      "lorawan_phy_version",
      "ids.device_id",
      "ids.application_ids.application_id",
      "mac_settings_profile_ids"
    ]
  }
}

Assign a mac settings profile and device mac settings at the same time -> it should fail, they are mutually exclusive

PUT http://localhost:1885/api/v3/ns/applications/myapp/devices/arduino-mkr

{
  "end_device": {
    "ids": {
      "device_id": "arduino-mkr",
      "application_ids": {
        "application_id": "myapp"
      }
    },
    "lorawan_version": "MAC_V1_0_3",
    "lorawan_phy_version": "PHY_V1_0_3_REV_A",
    "frequency_plan_id": "EU_863_870_TTN",
    "supports_join": true,
    "mac_settings": {
      "rx1_delay": 5,
      "rx2_data_rate_index": 0,
      "rx2_frequency": "869525000",
      "supports_32_bit_f_cnt": true
    },
    "mac_settings_profile_ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac1"
    }
  },
  "field_mask": {
    "paths": [
      "supports_join",
      "lorawan_version",
      "lorawan_phy_version",
      "ids.device_id",
      "ids.application_ids.application_id",
      "mac_settings_profile_ids",
      "mac_settings.rx1_delay",
      "mac_settings.rx2_data_rate_index",
      "mac_settings.rx2_frequency",
      "mac_settings.supports_32_bit_f_cnt"
    ]
  }
}

Assign a mac settings profile that contains invalid settings for the end device -> validation should fail

PUT http://localhost:1885/api/v3/ns/applications/myapp/mac_settings_profiles/mac1

{
  "mac_settings_profile": {
    "ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac1"
    },
    "mac_settings": {
      "rx1_delay": 5,
      "rx2_data_rate_index": 0,
      "rx2_frequency": "869525000",
      "supports_32_bit_f_cnt": true,
      "uplink_dwell_time": true
    }
  },
  "field_mask": {
    "paths": [
      "mac_settings.rx1_delay",
      "mac_settings.rx2_data_rate_index",
      "mac_settings.rx2_frequency",
      "mac_settings.supports_32_bit_f_cnt",
      "mac_settings.uplink_dwell_time"
    ]
  }
}

PUT http://localhost:1885/api/v3/ns/applications/myapp/devices/arduino-mkr

{
  "end_device": {
    "ids": {
      "device_id": "arduino-mkr",
      "application_ids": {
        "application_id": "myapp"
      }
    },
    "lorawan_version": "MAC_V1_0_3",
    "lorawan_phy_version": "PHY_V1_0_3_REV_A",
    "frequency_plan_id": "EU_863_870_TTN",
    "supports_join": true,
    "mac_settings_profile_ids": {
      "application_ids": {
        "application_id": "myapp"
      },
      "profile_id": "mac1"
    }
  },
  "field_mask": {
    "paths": [
      "supports_join",
      "lorawan_version",
      "lorawan_phy_version",
      "ids.device_id",
      "ids.application_ids.application_id",
      "mac_settings_profile_ids"
    ]
  }
}
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 Feb 19, 2025
@halimi halimi added this to the v3.34.1 milestone Feb 19, 2025
@halimi halimi force-pushed the feature/assign-mac-settings-profile branch from 01cdfec to cbdcd17 Compare March 3, 2025 09:56
@github-actions github-actions bot added the c/network server This is related to the Network Server label Mar 3, 2025
@halimi halimi force-pushed the feature/assign-mac-settings-profile branch from 4f7020c to 1917c73 Compare March 3, 2025 11:51
@halimi halimi marked this pull request as ready for review March 10, 2025 09:33
@halimi halimi requested a review from a team as a code owner March 10, 2025 09:33
@halimi halimi requested a review from johanstokking March 10, 2025 09:33
@halimi halimi mentioned this pull request Mar 11, 2025
7 tasks
@halimi halimi requested a review from johanstokking March 14, 2025 15:55
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.

Great stuff

@halimi halimi merged commit 6f14901 into v3.34 Mar 14, 2025
19 of 24 checks passed
@halimi halimi deleted the feature/assign-mac-settings-profile branch March 14, 2025 17:27
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants