Skip to content

Commit

Permalink
Endpoint Composition - Adding helper which has a NULL placeholder + t…
Browse files Browse the repository at this point in the history
…ests (project-chip#1259)

* fixing helper to have a NULL placeholder and adding tests
  • Loading branch information
paulr34 authored Feb 6, 2024
1 parent 6d43705 commit c2ae75e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
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')
} 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

0 comments on commit c2ae75e

Please sign in to comment.