Skip to content

Commit

Permalink
- Adding support to determine if a data type is baseline type or not …
Browse files Browse the repository at this point in the history
…from the xml itself

- This is done by adding BASELINE column to the atomic table and then mapping it appropriately to isBaseline for the zcl_atomics helper
- Github: ZAP#1438
  • Loading branch information
brdandu committed Oct 28, 2024
1 parent 5db1e47 commit a407b2d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src-electron/db/db-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ exports.map = {
isChar: dbApi.fromDbBool(x.IS_CHAR),
isSigned: dbApi.fromDbBool(x.IS_SIGNED),
isComposite: dbApi.fromDbBool(x.IS_COMPOSITE),
isFloat: dbApi.fromDbBool(x.IS_FLOAT)
isFloat: dbApi.fromDbBool(x.IS_FLOAT),
isBaseline: dbApi.fromDbBool(x.IS_BASELINE)
}
},

Expand Down
3 changes: 2 additions & 1 deletion src-electron/db/query-atomic.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ SELECT
IS_CHAR,
IS_SIGNED,
IS_COMPOSITE,
IS_FLOAT
IS_FLOAT,
IS_BASELINE
FROM ATOMIC
`

Expand Down
5 changes: 3 additions & 2 deletions src-electron/db/query-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ INSERT OR IGNORE INTO GLOBAL_ATTRIBUTE_BIT (
async function insertAtomics(db, packageId, data) {
return dbApi.dbMultiInsert(
db,
'INSERT INTO ATOMIC (PACKAGE_REF, NAME, DESCRIPTION, ATOMIC_IDENTIFIER, ATOMIC_SIZE, IS_DISCRETE, IS_SIGNED, IS_STRING, IS_LONG, IS_CHAR, IS_COMPOSITE, IS_FLOAT) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
'INSERT INTO ATOMIC (PACKAGE_REF, NAME, DESCRIPTION, ATOMIC_IDENTIFIER, ATOMIC_SIZE, IS_DISCRETE, IS_SIGNED, IS_STRING, IS_LONG, IS_CHAR, IS_COMPOSITE, IS_FLOAT, IS_BASELINE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
data.map((at) => [
packageId,
at.name,
Expand All @@ -1018,7 +1018,8 @@ async function insertAtomics(db, packageId, data) {
at.isLong,
at.isChar,
at.isComposite,
at.isFloat
at.isFloat,
at.isBaseline
])
)
}
Expand Down
1 change: 1 addition & 0 deletions src-electron/db/zap-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ CREATE TABLE IF NOT EXISTS "ATOMIC" (
"IS_SIGNED" integer default false,
"IS_COMPOSITE" integer default false,
"IS_FLOAT" integer default false,
"IS_BASELINE" integer default false,
foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE
UNIQUE(PACKAGE_REF, NAME, ATOMIC_IDENTIFIER)
);
Expand Down
3 changes: 2 additions & 1 deletion src-electron/zcl/zcl-loader-silabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ function prepareAtomic(a) {
a.$.float == 'true' ||
a.$.name.toLowerCase() === 'single' ||
a.$.name.toLowerCase() === 'double' ||
a.$.name.toLowerCase() === 'float'
a.$.name.toLowerCase() === 'float',
isBaseline: a.$.baseline == 'true'
}
}
/**
Expand Down
6 changes: 6 additions & 0 deletions test/gen-matter-1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ test(
'return DecodeIntoEmberBuffer<double>(decoder, isNullable, out);'
)

// Testing baseline types based on xml defining them
expect(simpleTest).toContain('#DEFINE ZCL_BASELINE_INT32U_DATA_TYPE')
expect(simpleTest).toContain('#DEFINE ZCL_BASELINE_INT32S_DATA_TYPE')
expect(simpleTest).toContain('#DEFINE ZCL_BASELINE_CHAR_STRING_DATA_TYPE')
expect(simpleTest).toContain('#DEFINE ZCL_BASELINE_BOOLEAN_DATA_TYPE')

let deviceType = genResult.content['device-types.txt']
expect(deviceType).toContain(
'// device type: CHIP / 0x0105 => MA-colordimmerswitch // extension: '
Expand Down
7 changes: 7 additions & 0 deletions test/gen-template/matter/simple-test.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ switch (AttributeBaseType(metadata->attributeType))
return CHIP_IM_GLOBAL_STATUS(Failure);
}

// Extract all baseline types:
{{#zcl_atomics}}
{{#if isBaseline}}
#DEFINE ZCL_BASELINE_{{as_delimited_macro name}}_DATA_TYPE
{{/if}}
{{/zcl_atomics}}

46 changes: 23 additions & 23 deletions zcl-builtin/matter/data-model/chip/chip-types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,39 @@ limitations under the License.
<atomic>
<type id="0x00" description="No data" name="no_data" size="0" />
<!-- Base Data Types -->
<type id="0x10" description="Boolean" name="boolean" size="1" discrete="true" />
<type id="0x10" description="Boolean" name="boolean" size="1" discrete="true" baseline="true"/>
<type id="0x18" description="8-bit bitmap" name="bitmap8" size="1" discrete="true" />
<type id="0x19" description="16-bit bitmap" name="bitmap16" size="2" discrete="true" />
<type id="0x1A" description="24-bit bitmap" name="bitmap24" size="3" discrete="true" />
<type id="0x1B" description="32-bit bitmap" name="bitmap32" size="4" discrete="true" />
<type id="0x1F" description="64-bit bitmap" name="bitmap64" size="8" discrete="true" />
<type id="0x20" description="Unsigned 8-bit integer" name="int8u" size="1" analog="true" />
<type id="0x21" description="Unsigned 16-bit integer" name="int16u" size="2" analog="true" />
<type id="0x22" description="Unsigned 24-bit integer" name="int24u" size="3" analog="true" />
<type id="0x23" description="Unsigned 32-bit integer" name="int32u" size="4" analog="true" />
<type id="0x24" description="Unsigned 40-bit integer" name="int40u" size="5" analog="true" />
<type id="0x25" description="Unsigned 48-bit integer" name="int48u" size="6" analog="true" />
<type id="0x26" description="Unsigned 56-bit integer" name="int56u" size="7" analog="true" />
<type id="0x27" description="Unsigned 64-bit integer" name="int64u" size="8" analog="true" />
<type id="0x28" description="Signed 8-bit integer" name="int8s" size="1" analog="true" />
<type id="0x29" description="Signed 16-bit integer" name="int16s" size="2" analog="true" />
<type id="0x2A" description="Signed 24-bit integer" name="int24s" size="3" analog="true" />
<type id="0x2B" description="Signed 32-bit integer" name="int32s" size="4" analog="true" />
<type id="0x2C" description="Signed 40-bit integer" name="int40s" size="5" analog="true" />
<type id="0x2D" description="Signed 48-bit integer" name="int48s" size="6" analog="true" />
<type id="0x2E" description="Signed 56-bit integer" name="int56s" size="7" analog="true" />
<type id="0x2F" description="Signed 64-bit integer" name="int64s" size="8" analog="true" />
<type id="0x20" description="Unsigned 8-bit integer" name="int8u" size="1" analog="true" baseline="true"/>
<type id="0x21" description="Unsigned 16-bit integer" name="int16u" size="2" analog="true" baseline="true"/>
<type id="0x22" description="Unsigned 24-bit integer" name="int24u" size="3" analog="true" baseline="true"/>
<type id="0x23" description="Unsigned 32-bit integer" name="int32u" size="4" analog="true" baseline="true"/>
<type id="0x24" description="Unsigned 40-bit integer" name="int40u" size="5" analog="true" baseline="true"/>
<type id="0x25" description="Unsigned 48-bit integer" name="int48u" size="6" analog="true" baseline="true"/>
<type id="0x26" description="Unsigned 56-bit integer" name="int56u" size="7" analog="true" baseline="true"/>
<type id="0x27" description="Unsigned 64-bit integer" name="int64u" size="8" analog="true" baseline="true"/>
<type id="0x28" description="Signed 8-bit integer" name="int8s" size="1" analog="true" baseline="true"/>
<type id="0x29" description="Signed 16-bit integer" name="int16s" size="2" analog="true" baseline="true"/>
<type id="0x2A" description="Signed 24-bit integer" name="int24s" size="3" analog="true" baseline="true"/>
<type id="0x2B" description="Signed 32-bit integer" name="int32s" size="4" analog="true" baseline="true"/>
<type id="0x2C" description="Signed 40-bit integer" name="int40s" size="5" analog="true" baseline="true"/>
<type id="0x2D" description="Signed 48-bit integer" name="int48s" size="6" analog="true" baseline="true"/>
<type id="0x2E" description="Signed 56-bit integer" name="int56s" size="7" analog="true" baseline="true"/>
<type id="0x2F" description="Signed 64-bit integer" name="int64s" size="8" analog="true" baseline="true"/>
<type id="0x30" description="8-bit enumeration" name="enum8" size="1" discrete="true" />
<type id="0x31" description="16-bit enumeration" name="enum16" size="2" discrete="true" />
<type id="0x39" description="Single precision" name="single" size="4" analog="true" />
<type id="0x3A" description="Double precision" name="double" size="8" analog="true" />
<type id="0x41" description="Octet String" name="octet_string" composite="true"/>
<type id="0x43" description="Long Octet String" name="long_octet_string" composite="true"/>
<type id="0x39" description="Single precision" name="single" size="4" analog="true" baseline="true"/>
<type id="0x3A" description="Double precision" name="double" size="8" analog="true" baseline="true"/>
<type id="0x41" description="Octet String" name="octet_string" composite="true" baseline="true"/>
<type id="0x43" description="Long Octet String" name="long_octet_string" composite="true" baseline="true"/>
<type id="0x48" description="List" name="array" composite="true"/>
<type id="0x4C" description="Structure" name="struct" composite="true"/>
<!-- Derived Data Types -->
<type id="0x42" description="Character String" name="char_string" composite="true"/>
<type id="0x44" description="Long Character String" name="long_char_string" composite="true"/>
<type id="0x42" description="Character String" name="char_string" composite="true" baseline="true"/>
<type id="0x44" description="Long Character String" name="long_char_string" composite="true" baseline="true"/>
<type id="0xE0" description="Time of day" name="tod" size="4" analog="true" />
<type id="0xE1" description="Date" name="date" size="4" analog="true" />
<type id="0xE3" description="Epoch Microseconds" name="epoch_us" size="8" analog="true" />
Expand Down

0 comments on commit a407b2d

Please sign in to comment.