Skip to content
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

Refactor Matter-specific code into a separate file #1488

Open
ethanzhouyc opened this issue Nov 21, 2024 · 0 comments
Open

Refactor Matter-specific code into a separate file #1488

ethanzhouyc opened this issue Nov 21, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ethanzhouyc
Copy link
Collaborator

ethanzhouyc commented Nov 21, 2024

Issue:
ZAP backend functions include Matter-specific logic, such as handling featureMap shown below, which contains Matter terminology from Matter spec and is irrelevant to Zigbee. However, these functions support both Zigbee and Matter.

Solution:
All Matter-specific code should be encapsulated into functions and moved to a separate file for improved modularity and maintainability.

// Looking for the feature map attribute in matter and setting it as per
  // the device types if default value is 0
  if (
    staticAttribute.code == 0xfffc &&
    staticAttribute.name == 'FeatureMap' &&
    staticAttribute.defaultValue == 0
  ) {
    let featureMapDefaultValue = staticAttribute.defaultValue
    let featuresOnEndpointTypeAndCluster =
      await queryDeviceType.selectDeviceTypeFeaturesByEndpointTypeIdAndClusterId(
        db,
        endpointTypeId,
        clusterRef
      )
    // only set featureMap bit to 1 for mandatory features
    let featureMapBitsToBeEnabled = featuresOnEndpointTypeAndCluster
      .filter((f) => f.conformance == 'M')
      .map((f) => f.featureBit)
    featureMapBitsToBeEnabled.forEach(
      (featureBit) =>
        (featureMapDefaultValue = featureMapDefaultValue | (1 << featureBit))
    )
    staticAttribute.defaultValue = featureMapDefaultValue
  }
@ethanzhouyc ethanzhouyc added the enhancement New feature or request label Nov 21, 2024
@ethanzhouyc ethanzhouyc changed the title Matter specific code should be moved to a separate file Refactor Matter-specific code into a separate file Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant