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

Endpoint Composition - Adding helper which has a NULL placeholder + tests #1259

Merged
merged 4 commits into from
Feb 6, 2024
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
14 changes: 9 additions & 5 deletions src-electron/generator/helper-endpointconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,15 @@ function endpoint_fixed_profile_id_array(options) {
* @returns C array including the { } brackets
*/
function endpoint_fixed_parent_id_array(options) {
return (
'{ ' +
this.endpoints.map((ep) => ep.parentEndpointIdentifier).join(', ') +
' }'
)
let parentIds = []
this.endpoints.forEach((ep) => {
if (ep.parentEndpointIdentifier == null) {
parentIds.push('NULL')
Copy link
Collaborator

Choose a reason for hiding this comment

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

You are hard-coding C NULL here. Not the biggest evil, but I thought we have this externalized somewhere?

} else {
parentIds.push(ep.parentEndpointIdentifier)
}
})
return '{ ' + parentIds.join(', ') + ' }'
}

/**
Expand Down
2 changes: 2 additions & 0 deletions test/gen-matter-4.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ test(
expect(ept).toContain(
'#define FIXED_PROFILE_IDS { 0x0103, 0x0103, 0x0103, 0x0103 }'
)
expect(ept).toContain('#define FIXED_PARENT_IDS { NULL, 0, 1, NULL }')
expect(ept).toContain(
'#define FIXED_DEVICE_TYPES {{0x00000016,1},{0x00000100,1},{0x00000100,1},{0x0000F002,1}}'
)
Expand Down Expand Up @@ -264,6 +265,7 @@ test(
expect(ept).toContain(
'#define FIXED_PROFILE_IDS { 0x0103, 0x0103, 0x0103, 0x0103 }'
)
expect(ept).toContain('#define FIXED_PARENT_IDS { NULL, NULL, NULL, NULL }')
expect(ept).toContain(
'#define FIXED_DEVICE_TYPES {{0x00000016,1},{0x00000100,1},{0x00000100,1},{0x0000F002,1}}'
)
Expand Down
3 changes: 3 additions & 0 deletions test/gen-template/matter/endpoint-config.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE,
// Array of profile ids
#define FIXED_PROFILE_IDS {{endpoint_fixed_profile_id_array}}

// Array of parent endpoint ids
#define FIXED_PARENT_IDS {{endpoint_fixed_parent_id_array}}

// Array of device types
#define FIXED_DEVICE_TYPES {{endpoint_fixed_device_type_array}}

Expand Down
3 changes: 3 additions & 0 deletions test/gen-template/matter3/endpoint_config.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE,
// Array of profile ids
#define FIXED_PROFILE_IDS {{endpoint_fixed_profile_id_array}}

/ Array of parent endpoint ids
#define FIXED_PARENT_IDS {{endpoint_fixed_parent_id_array}}

// Array of device types
#define FIXED_DEVICE_TYPES {{endpoint_fixed_device_type_array}}

Expand Down
Loading