Skip to content
代码片段 群组 项目
提交 136cfcb8 编辑于 作者: Thuc Tran's avatar Thuc Tran
浏览文件

Add support for showing what profile a profileId corresponds to if the...

Add support for showing what profile a profileId corresponds to if the zcl.json includes a profilesCode xml
上级 5f8ef67d
No related branches found
No related tags found
无相关合并请求
......@@ -61,6 +61,10 @@ async function collectDataFromJsonFile(metadataFile, data) {
f = util.locateRelativeFilePath(fileLocations, obj.manufacturersXml)
if (f != null) returnObject.manufacturersXml = f
// Profiles XML File
f = util.locateRelativeFilePath(fileLocations, obj.profilesXml)
if (f != null) returnObject.profilesXml = f
// Zcl XSD file
f = util.locateRelativeFilePath(fileLocations, obj.zclSchema)
if (f != null) returnObject.zclSchema = f
......@@ -130,6 +134,13 @@ async function collectDataFromPropertiesFile(metadataFile, data) {
)
if (f != null) returnObject.manufacturersXml = f
// Profiles XML file.
f = util.locateRelativeFilePath(
fileLocations,
zclProps.profilesXml
)
if (f != null) returnObject.profilesXml = f
// Zcl XSD file
f = util.locateRelativeFilePath(fileLocations, zclProps.zclSchema)
if (f != null) returnObject.zclSchema = f
......@@ -938,6 +949,30 @@ async function parseManufacturerData(db, packageId, manufacturersXml) {
)
}
/**
* Parses the profiles xml.
*
* @param {*} db
* @param {*} ctx
* @returns Promise of a parsed profiles file.
*/
async function parseProfilesData(db, packageId, profilesXml) {
let data = await fsp.readFile(profilesXml)
let profilesMap = await util.parseXml(data)
return queryPackage.insertOptionsKeyValues(
db,
packageId,
dbEnum.packageOptionCategory.profileCodes,
profilesMap.map.mapping.map((datum) => {
let profilePair = datum['$']
return { code: profilePair['code'], label: profilePair['translation'] }
})
)
}
/**
* Parses the ZCL Schema
* @param {*} db
......@@ -1253,6 +1288,9 @@ async function loadSilabsZcl(db, metafile, isJson = false) {
if (ctx.manufacturersXml) {
await parseManufacturerData(db, ctx.packageId, ctx.manufacturersXml)
}
if (ctx.profilesXml) {
await parseProfilesData(db, ctx.packageId, ctx.profilesXml)
}
if (ctx.supportCustomZclDevice) {
await processCustomZclDeviceType(db, ctx.packageId)
}
......
......@@ -38,6 +38,7 @@ exports.packageOptionCategory = {
manufacturerCodes: 'manufacturerCodes',
typeMap: 'typeMap',
generator: 'generator',
profileCodes: 'profileCodes'
}
exports.side = {
......@@ -109,6 +110,7 @@ exports.generatorOptions = {
exports.sessionOption = {
defaultResponsePolicy: 'defaultResponsePolicy',
manufacturerCodes: 'manufacturerCodes',
profileCodes: 'profileCodes'
}
// When SDK supports a custom device, these are the default values for it.
......
......@@ -38,6 +38,10 @@ function initLoad(store) {
key: 'manufacturerCodes',
type: 'object',
})
store.dispatch('zap/loadOptions', {
key: 'profileCodes',
type: 'object',
})
store.dispatch('zap/loadSessionKeyValues')
let promises = []
......
......@@ -33,12 +33,13 @@ limitations under the License.
/>
<q-input
label="Profile ID"
v-model="shownEndpoint.profileIdentifier"
v-model="computedProfileId"
ref="profile"
outlined
filled
class="col"
:rules="[reqPosInt]"
@input="setProfileId"
/>
<q-select
label="Device"
......@@ -207,7 +208,26 @@ export default {
get() {
return this.shownEndpoint.deviceTypeRefAndDeviceIdPair
}
}
},
computedProfileId: {
get() {
let profileOption =
this.profileCodesOptions == null
? null
: this.profileCodesOptions.find((o) => o.optionCode === this.shownEndpoint.profileIdentifier)
return profileOption
? profileOption.optionCode + ' (' + profileOption.optionLabel + ')'
: this.shownEndpoint.profileIdentifier
}
},
profileCodesOptions: {
get() {
return this.$store.state.zap.genericOptions[
DbEnum.sessionOption.profileCodes
]
},
},
},
methods: {
getSmallestUnusedEndpointId() {
......@@ -226,6 +246,9 @@ export default {
}
return id
},
setProfileId(value) {
this.shownEndpoint.profileIdentifier = value
},
setDeviceTypeCallback(value) {
let deviceTypeRef = value.deviceTypeRef
let profileId = this.shownEndpoint.profileIdentifier
......
......@@ -27,6 +27,7 @@
],
"zclSchema": "../shared/schema/zcl.xsd",
"manufacturersXml": "../shared/manufacturers.xml",
"profilesXml": "../shared/profiles.xml",
"options": {
"text": {
"defaultResponsePolicy": ["Always", "Conditional", "Never"]
......
<?xml version="1.0"?>
<!--
Copyright (c) 2008,2020 Silicon Labs.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<map>
<mapping code="0x0000" translation="ZigBee device profile"/>
<mapping code="0x0101" translation="Industrial plant monitoring"/>
<mapping code="0x0103" translation="Test profile 1"/>
<mapping code="0x0104" translation="Home automation"/>
<mapping code="0x0105" translation="Commercial building automation"/>
<mapping code="0x0106" translation="Wireless sensor networks"/>
<mapping code="0x0107" translation="Telecom Applications"/>
<mapping code="0x0108" translation="Personal, Home &amp; Hospital Care"/>
<mapping code="0x0109" translation="Smart Energy"/>
<mapping code="0x7F01" translation="Test profile 2"/>
<mapping code="0x7F02" translation="Gateway Specification profile"/>
<mapping code="0xA1E0" translation="Green Power"/>
</map>
......@@ -19,6 +19,7 @@ xmlFile=\
green-power.xml, green-power-devices.xml
manufacturersXml=../shared/manufacturers.xml
profilesXml=../shared/profiles.xml
zclSchema=./schema/zcl.xsd
zclValidation=./schema/zcl-validation.js
......
......@@ -29,6 +29,7 @@
"zclSchema": "../shared/schema/zcl.xsd",
"supportCustomZclDevice": true,
"manufacturersXml": "../shared/manufacturers.xml",
"profilesXml": "../shared/profiles.xml",
"zclValidation": "./schema/zcl-validation.js",
"options": {
"text": {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册