10000 Exclude Features with Disallowed Conformance from Bitmaps by ethanzhouyc · Pull Request #1524 · project-chip/zap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Exclude Features with Disallowed Conformance from Bitmaps #1524

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -20121,6 +20121,7 @@ This module provides the APIs for dotdot Loading
* [~parseFeatureFlags(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseFeatureFlags) ⇒
* [~parseConformanceFromXML(operand)](#module_Loader API_ Loader APIs..parseConformanceFromXML) ⇒
* [~parseConformanceRecursively(operand, depth, parentJoinChar)](#module_Loader API_ Loader APIs..parseConformanceRecursively) ⇒
* [~hasAllowedFeatures(features)](#module_Loader API_ Loader APIs..hasAllowedFeatures) ⇒
* [~parseUiOptions(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseUiOptions) ⇒
* [~parseOptions(db)](#module_Loader API_ Loader APIs..parseOptions) ⇒
* [~parseTextOptions(db, pkgRef, textOptions)](#module_Loader API_ Loader APIs..parseTextOptions) ⇒
Expand Down Expand Up @@ -21531,6 +21532,18 @@ When they appear, stop recursing and return the name inside directly
| depth | <code>\*</code> | <code>0</code> |
| parentJoinChar | <code>\*</code> | |

<a name="module_Loader API_ Loader APIs..hasAllowedFeatures"></a>

### Loader API: Loader APIs~hasAllowedFeatures(features) ⇒
Check if any feature in the cluster has conformance other than disallowed

**Kind**: inner method of [<code>Loader API: Loader APIs</code>](#module_Loader API_ Loader APIs)
**Returns**: true if any feature has allowed conformance, false otherwise

| Param | Type |
| --- | --- |
| features | <code>\*</code> |

<a name="module_Loader API_ Loader APIs..parseUiOptions"></a>

### Loader API: Loader APIs~parseUiOptions(db, packageId, featureFlags) ⇒
Expand Down Expand Up @@ -21955,6 +21968,7 @@ This module provides the APIs for new data model loading
* [~parseFeatureFlags(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseFeatureFlags) ⇒
* [~parseConformanceFromXML(operand)](#module_Loader API_ Loader APIs..parseConformanceFromXML) ⇒
* [~parseConformanceRecursively(operand, depth, parentJoinChar)](#module_Loader API_ Loader APIs..parseConformanceRecursively) ⇒
* [~hasAllowedFeatures(features)](#module_Loader API_ Loader APIs..hasAllowedFeatures) ⇒
* [~parseUiOptions(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseUiOptions) ⇒
* [~parseOptions(db)](#module_Loader API_ Loader APIs..parseOptions) ⇒
* [~parseTextOptions(db, pkgRef, textOptions)](#module_Loader API_ Loader APIs..parseTextOptions) ⇒
Expand Down Expand Up @@ -23365,6 +23379,18 @@ When they appear, stop recursing and return the name inside directly
| depth | <code>\*</code> | <code>0</code> |
| parentJoinChar | <code>\*</code> | |

<a name="module_Loader API_ Loader APIs..hasAllowedFeatures"></a>

### Loader API: Loader APIs~hasAllowedFeatures(features) ⇒
Check if any feature in the cluster has conformance other than disallowed

**Kind**: inner method of [<code>Loader API: Loader APIs</code>](#module_Loader API_ Loader APIs)
**Returns**: true if any feature has allowed conformance, false otherwise

| Param | Type |
| --- | --- |
| features | <code>\*</code> |

<a name="module_Loader API_ Loader APIs..parseUiOptions"></a>

### Loader API: Loader APIs~parseUiOptions(db, packageId, featureFlags) ⇒
Expand Down Expand Up @@ -23789,6 +23815,7 @@ This module provides the APIs for ZCL/Data-Model loading.
* [~parseFeatureFlags(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseFeatureFlags) ⇒
* [~parseConformanceFromXML(operand)](#module_Loader API_ Loader APIs..parseConformanceFromXML) ⇒
* [~parseConformanceRecursively(operand, depth, parentJoinChar)](#module_Loader API_ Loader APIs..parseConformanceRecursively) ⇒
* [~hasAllowedFeatures(features)](#module_Loader API_ Loader APIs..hasAllowedFeatures) ⇒
* [~parseUiOptions(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseUiOptions) ⇒
* [~parseOptions(db)](#module_Loader API_ Loader APIs..parseOptions) ⇒
* [~parseTextOptions(db, pkgRef, textOptions)](#module_Loader API_ Loader APIs..parseTextOptions) ⇒
Expand Down Expand Up @@ -25199,6 +25226,18 @@ When they appear, stop recursing and return the name inside directly
| depth | <code>\*</code> | <code>0</code> |
| parentJoinChar | <code>\*</code> | |

<a name="module_Loader API_ Loader APIs..hasAllowedFeatures"></a>

### Loader API: Loader APIs~hasAllowedFeatures(features) ⇒
Check if any feature in the cluster has conformance other than disallowed

**Kind**: inner method of [<code>Loader API: Loader APIs</code>](#module_Loader API_ Loader APIs)
**Returns**: true if any feature has allowed conformance, false otherwise

| Param | Type |
| --- | --- |
| features | <code>\*</code> |

<a name="module_Loader API_ Loader APIs..parseUiOptions"></a>

### Loader API: Loader APIs~parseUiOptions(db, packageId, featureFlags) ⇒
Expand Down Expand Up @@ -25623,6 +25662,7 @@ This module provides the APIs for for common functionality related to loading.
* [~parseFeatureFlags(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseFeatureFlags) ⇒
* [~parseConformanceFromXML(operand)](#module_Loader API_ Loader APIs..parseConformanceFromXML) ⇒
* [~parseConformanceRecursively(operand, depth, parentJoinChar)](#module_Loader API_ Loader APIs..parseConformanceRecursively) ⇒
* [~hasAllowedFeatures(features)](#module_Loader API_ Loader APIs..hasAllowedFeatures) ⇒
* [~parseUiOptions(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseUiOptions) ⇒
* [~parseOptions(db)](#module_Loader API_ Loader APIs..parseOptions) ⇒
* [~parseTextOptions(db, pkgRef, textOptions)](#module_Loader API_ Loader APIs..parseTextOptions) ⇒
Expand Down Expand Up @@ -27033,6 +27073,18 @@ When they appear, stop recursing and return the name inside directly
| depth | <code>\*</code> | <code>0</code> |
| parentJoinChar | <code>\*</code> | |

<a name="module_Loader API_ Loader APIs..hasAllowedFeatures"></a>

### Loader API: Loader APIs~hasAllowedFeatures(features) ⇒
Check if any feature in the cluster has conformance other than disallowed

**Kind**: inner method of [<code>Loader API: Loader APIs</code>](#module_Loader API_ Loader APIs)
**Returns**: true if any feature has allowed conformance, false otherwise

| Param | Type |
| --- | --- |
| features | <code>\*</code> |

<a name="module_Loader API_ Loader APIs..parseUiOptions"></a>

### Loader API: Loader APIs~parseUiOptions(db, packageId, featureFlags) ⇒
Expand Down
56 changes: 39 additions & 17 deletions src-electron/zcl/zcl-loader-silabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1524,13 +1524,16 @@ async function processBitmapFields(
'feature' in data.features[0]
) {
data.features[0].feature.forEach((item) => {
bitmapFields.push({
bitmapName: 'Feature',
bitmapClusterCode: [{ $: { code: data.code[0] } }],
name: item.$.name,
mask: 1 << item.$.bit,
fieldIdentifier: item.$.bit
})
// do not add feature to bitmapFields if it has disallowed conformance
if (parseConformanceFromXML(item) != 'X') {
bitmapFields.push({
bitmapName: 'Feature',
bitmapClusterCode: [{ $: { code: data.code[0] } }],
name: item.$.name,
mask: 1 << item.$.bit,
fieldIdentifier: item.$.bit
})
}
})
}
return queryLoader.insertBitmapFields(
Expand Down Expand Up @@ -1954,17 +1957,20 @@ async function processParsedZclData(
// Treating features in a cluster as a bitmap
if (featureClusters.length > 0) {
featureClusters.forEach((fc) => {
Batch5.push(
processBitmap(db, filePath, packageId, knownPackages, [
{
$: {
name: 'Feature',
type: 'BITMAP32',
cluster_code: [fc.code[0]]
// only add bitmap if the cluster has allowed features to avoid empty bitmaps
if (hasAllowedFeatures(fc.features)) {
Batch5.push(
processBitmap(db, filePath, packageId, knownPackages, [
{
$: {
name: 'Feature',
type: 'BITMAP32',
cluster_code: [fc.code[0]]
}
}
}
])
)
])
)
}
})
}
if (dbEnum.zclType.struct in toplevel) {
Expand Down Expand Up @@ -2387,6 +2393,22 @@ function parseConformanceRecursively(operand, depth = 0, parentJoinChar = '') {
}
}

/**
* Check if any feature in the cluster has conformance other than disallowed
*
* @param {*} features
* @returns true if any feature has allowed conformance, false otherwise
*/
function hasAllowedFeatures(features) {
if (features.length > 0 && features[0] && features[0].feature) {
return features[0].feature.some((feature) => {
return parseConformanceFromXML(feature) != 'X'
})
} else {
return false
}
}

/**
* Inside the `zcl.json` can be a `featureFlags` key, which is
* a general purpose object. It contains keys, that map to objects.
Expand Down
Loading
0