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

zapTypeToDecodableClusterObjectType does not throw on ambiguous types #13578

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/bridge-app/bridge-common/bridge-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/pump-app/pump-common/pump-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ server cluster OperationalCredentials = 62 {

server cluster SoftwareDiagnostics = 52 {
info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute int64u currentHeapHighWatermark = 3;
Expand Down
2 changes: 1 addition & 1 deletion examples/thermostat/thermostat-common/thermostat.matter
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/window-app/common/window-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ server cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ CHIP_ERROR SoftwareDiagosticsAttrAccess::ReadThreadMetrics(AttributeValueEncoder
class SoftwareDiagnosticsDelegate : public DeviceLayer::SoftwareDiagnosticsDelegate
{
// Gets called when a software fault that has taken place on the Node.
void OnSoftwareFaultDetected(SoftwareDiagnostics::Structs::SoftwareFault::Type & softwareFault) override
void OnSoftwareFaultDetected(SoftwareDiagnostics::Structs::SoftwareFaultStruct::Type & softwareFault) override
{
ChipLogProgress(Zcl, "SoftwareDiagnosticsDelegate: OnSoftwareFaultDetected");

Expand Down
27 changes: 23 additions & 4 deletions src/app/zap-templates/templates/app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,20 +398,39 @@ async function zapTypeToClusterObjectType(type, isDecodable, options)
const ns = options.hash.ns ? ('chip::app::Clusters::' + nsValueToNamespace(options.hash.ns) + '::') : '';
const typeChecker = async (method) => zclHelper[method](this.global.db, type, pkgId).then(zclType => zclType != 'unknown');

if (await typeChecker('isEnum')) {
const types = {
isEnum : await typeChecker('isEnum'),
isBitmap : await typeChecker('isBitmap'),
isEvent : await typeChecker('isEvent'),
isStruct : await typeChecker('isStruct'),
};

const typesCount = Object.values(types).filter(isType => isType).length;
if (typesCount > 1) {
let error = type + ' is ambiguous: \n';
Object.entries(types).forEach(([ key, value ]) => {
if (value) {
error += '\t' + key + ': ' + value + '\n';
}
});
throw error;
}

if (types.isEnum) {
return ns + type;
}

if (await typeChecker('isBitmap')) {
if (types.isBitmap) {
return 'chip::BitFlags<' + ns + type + '>';
}

if (await typeChecker('isStruct')) {
if (types.isStruct) {
passByReference = true;
return ns + 'Structs::' + type + '::' + (isDecodable ? 'DecodableType' : 'Type');
}

if (await typeChecker('isEvent')) {
if (types.isEvent) {
passByReference = true;
return ns + 'Events::' + type + '::' + (isDecodable ? 'DecodableType' : 'Type');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ limitations under the License.
<item name="6G" value="0x3"/>
<item name="60G" value="0x4"/>
</enum>
<bitmap name="SecurityType" type="BITMAP8">
<bitmap name="WiFiSecurity" type="BITMAP8">
<field name="Unencrypted" mask="0x1"/>
<field name="WEP-PERSONAL" mask="0x2"/>
<field name="WPA-PERSONAL" mask="0x4"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ limitations under the License.
<item name="StackFreeMinimum" type="INT32U"/>
<item name="StackSize" type="INT32U"/>
</struct>
<struct name="SoftwareFault">
<struct name="SoftwareFaultStruct">
<cluster code="0x0034"/>
<item name="Id" type="INT64U"/>
<item name="Name" type="CHAR_STRING" length="8"/>
Expand All @@ -45,7 +45,7 @@ limitations under the License.
</command>
<event side="server" code="0x00" name="SoftwareFault" priority="info" optional="true">
<description>Indicate the last software fault that has taken place on the Node.</description>
<field id="0" name="SoftwareFault" type="SoftwareFault"/>
<field id="0" name="SoftwareFault" type="SoftwareFaultStruct"/>
</event>
</cluster>
<bitmap name="SoftwareDiagnosticsFeature" type="BITMAP32">
Expand Down
2 changes: 1 addition & 1 deletion src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2647,7 +2647,7 @@ client cluster SoftwareDiagnostics = 52 {
}

info event SoftwareFault = 0 {
SoftwareFault softwareFault = 0;
SoftwareFaultStruct softwareFault = 0;
}

readonly attribute ThreadMetrics threadMetrics[] = 0;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/include/platform/DiagnosticDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ class SoftwareDiagnosticsDelegate
* @brief
* Called when a software fault that has taken place on the Node.
*/
virtual void OnSoftwareFaultDetected(chip::app::Clusters::SoftwareDiagnostics::Structs::SoftwareFault::Type & softwareFault) {}
virtual void
OnSoftwareFaultDetected(chip::app::Clusters::SoftwareDiagnostics::Structs::SoftwareFaultStruct::Type & softwareFault)
{}
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Linux/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ void PlatformManagerImpl::HandleSoftwareFault(uint32_t EventId)

if (delegate != nullptr)
{
SoftwareDiagnostics::Structs::SoftwareFault::Type softwareFault;
SoftwareDiagnostics::Structs::SoftwareFaultStruct::Type softwareFault;
char threadName[kMaxThreadNameLength + 1];

softwareFault.id = gettid();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions zzz_generated/app-common/app-common/zap-generated/enums.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading