Skip to content

Commit

Permalink
Expose device class for device types. (#1180)
Browse files Browse the repository at this point in the history
Also fixes endpoint-config codegen for the device type array: These are 32-bit
values, not 16-bit.
  • Loading branch information
bzbarsky-apple authored Oct 24, 2023
1 parent db4a29d commit 4084573
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions src-electron/db/db-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ exports.map = {
label: x.NAME,
name: x.NAME,
caption: x.DESCRIPTION,
class: x.CLASS,
}
},

Expand Down
8 changes: 4 additions & 4 deletions src-electron/db/query-device-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function selectAllDeviceTypes(db, packageId) {
return dbApi
.dbAll(
db,
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION FROM DEVICE_TYPE WHERE PACKAGE_REF = ? ORDER BY DOMAIN, CODE',
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS FROM DEVICE_TYPE WHERE PACKAGE_REF = ? ORDER BY DOMAIN, CODE',
[packageId]
)
.then((rows) => rows.map(dbMapping.map.deviceType))
Expand All @@ -51,7 +51,7 @@ async function selectDeviceTypeById(db, id) {
return dbApi
.dbGet(
db,
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION FROM DEVICE_TYPE WHERE DEVICE_TYPE_ID = ?',
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS FROM DEVICE_TYPE WHERE DEVICE_TYPE_ID = ?',
[id]
)
.then(dbMapping.map.deviceType)
Expand All @@ -70,7 +70,7 @@ async function selectDeviceTypeByCodeAndName(db, packageId, code, name) {
return dbApi
.dbGet(
db,
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION FROM DEVICE_TYPE WHERE CODE = ? AND NAME = ? AND PACKAGE_REF = ? ',
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS FROM DEVICE_TYPE WHERE CODE = ? AND NAME = ? AND PACKAGE_REF = ? ',
[code, name, packageId]
)
.then(dbMapping.map.deviceType)
Expand All @@ -89,7 +89,7 @@ async function selectDeviceTypeByCode(db, packageId, code) {
return dbApi
.dbGet(
db,
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION FROM DEVICE_TYPE WHERE CODE = ? AND PACKAGE_REF = ? ',
'SELECT DEVICE_TYPE_ID, DOMAIN, CODE, PROFILE_ID, NAME, DESCRIPTION, CLASS FROM DEVICE_TYPE WHERE CODE = ? AND PACKAGE_REF = ? ',
[code, packageId]
)
.then(dbMapping.map.deviceType)
Expand Down
2 changes: 1 addition & 1 deletion src-electron/generator/helper-endpointconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ async function endpoint_fixed_device_type_array(options) {
ret +=
'{' +
'0x' +
bin.int16ToHex(deviceList[i].deviceId) +
bin.int32ToHex(deviceList[i].deviceId) +
',' +
deviceList[i].deviceVersion.toString() +
endpointIdentifier +
Expand Down
12 changes: 6 additions & 6 deletions test/gen-matter-4.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ test(
'#define FIXED_PROFILE_IDS { 0x0103, 0x0103, 0x0103, 0x0103 }'
)
expect(ept).toContain(
'#define FIXED_DEVICE_TYPES {{0x0016,1},{0x0100,1},{0x0100,1},{0xF002,1}}'
'#define FIXED_DEVICE_TYPES {{0x00000016,1},{0x00000100,1},{0x00000100,1},{0x0000F002,1}}'
)
expect(ept).toContain(
'#define FIXED_DEVICE_TYPES_WITH_ENDPOINT {{0x0016,1,0},{0x0100,1,1},{0x0100,1,2},{0xF002,1,65534}}'
'#define FIXED_DEVICE_TYPES_WITH_ENDPOINT {{0x00000016,1,0},{0x00000100,1,1},{0x00000100,1,2},{0x0000F002,1,65534}}'
)
expect(ept).toContain('#define FIXED_DEVICE_TYPE_OFFSETS { 0,1,2,3}')
expect(ept).toContain('#define FIXED_DEVICE_TYPE_LENGTHS { 1,1,1,1}')
Expand Down Expand Up @@ -265,10 +265,10 @@ test(
'#define FIXED_PROFILE_IDS { 0x0103, 0x0103, 0x0103, 0x0103 }'
)
expect(ept).toContain(
'#define FIXED_DEVICE_TYPES {{0x0016,1},{0x0100,1},{0x0100,1},{0xF002,1}}'
'#define FIXED_DEVICE_TYPES {{0x00000016,1},{0x00000100,1},{0x00000100,1},{0x0000F002,1}}'
)
expect(ept).toContain(
'#define FIXED_DEVICE_TYPES_WITH_ENDPOINT {{0x0016,1,0},{0x0100,1,1},{0x0100,1,2},{0xF002,1,65534}}'
'#define FIXED_DEVICE_TYPES_WITH_ENDPOINT {{0x00000016,1,0},{0x00000100,1,1},{0x00000100,1,2},{0x0000F002,1,65534}}'
)
expect(ept).toContain('#define FIXED_DEVICE_TYPE_OFFSETS { 0,1,2,3}')
expect(ept).toContain('#define FIXED_DEVICE_TYPE_LENGTHS { 1,1,1,1}')
Expand Down Expand Up @@ -314,10 +314,10 @@ test(
let ept = genResult.content['endpoint_config.h']

expect(ept).toContain(
'#define FIXED_DEVICE_TYPES {{0x0016,1},{0x0101,2},{0x0100,1},{0x0101,1},{0x0100,1},{0xF002,1}}'
'#define FIXED_DEVICE_TYPES {{0x00000016,1},{0x00000101,2},{0x00000100,1},{0x00000101,1},{0x00000100,1},{0x0000F002,1}}'
)
expect(ept).toContain(
'#define FIXED_DEVICE_TYPES_WITH_ENDPOINT {{0x0016,1,0},{0x0101,2,1},{0x0100,1,1},{0x0101,1,2},{0x0100,1,2},{0xF002,1,65534}}'
'#define FIXED_DEVICE_TYPES_WITH_ENDPOINT {{0x00000016,1,0},{0x00000101,2,1},{0x00000100,1,1},{0x00000101,1,2},{0x00000100,1,2},{0x0000F002,1,65534}}'
)
expect(ept).toContain('#define FIXED_DEVICE_TYPE_OFFSETS { 0,1,3,5}')
expect(ept).toContain('#define FIXED_DEVICE_TYPE_LENGTHS { 1,2,2,1}')
Expand Down

0 comments on commit 4084573

Please sign in to comment.