Skip to content

Commit dc9997e

Browse files
authored
Temperature type (#1330)
* check if temperature is a signed type
1 parent d036c1d commit dc9997e

File tree

8 files changed

+10
-5
lines changed

8 files changed

+10
-5
lines changed

src-electron/generator/helper-endpointconfig.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,15 +651,14 @@ function determineAttributeDefaultValue(
651651
typeSize,
652652
isNullable
653653
) {
654-
if (specifiedDefault !== null || !isNullable) {
654+
if (specifiedDefault && (specifiedDefault !== null || !isNullable)) {
655655
return specifiedDefault
656656
}
657657

658658
if (types.isString(type)) {
659659
// Handled elsewhere.
660660
return null
661661
}
662-
663662
if (types.isSignedInteger(type)) {
664663
return '0x80' + '00'.repeat(typeSize - 1)
665664
}

src-electron/util/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ function isSignedInteger(type) {
286286
case 'int48s':
287287
case 'int56s':
288288
case 'int64s':
289+
case 'temperature':
289290
return true
290291
default:
291292
return false

test/endpoint-config.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ test(
216216
'#define FIXED_PROFILE_IDS { 0x0107, 0x0104, 0x0104 }'
217217
)
218218
expect(epc).toContain('#define FIXED_ENDPOINT_TYPES { 0, 1, 2 }')
219-
expect(epc).toContain('#define GENERATED_DEFAULTS_COUNT (12)')
219+
expect(epc).toContain('#define GENERATED_DEFAULTS_COUNT (19)')
220220
expect(epc).toContain(
221221
`17, 'T', 'e', 's', 't', ' ', 'm', 'a', 'n', 'u', 'f', 'a', 'c', 't', 'u', 'r', 'e', 'r',`
222222
)

test/gen-matter-4.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ test(
179179
.attributeCount = 22, \\
180180
.clusterId = 0x00000028, \\
181181
},\\`)
182+
expect(ept).toContain(
183+
' { 0x00000000, ZAP_TYPE(TEMPERATURE), 2, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x8000) },'
184+
)
182185
},
183186
testUtil.timeout.long()
184187
)

test/resource/matter-all-clusters.zap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,7 @@
22912291
"0x0000 | | server | 1 | 0 => GetWeeklyScheduleResponse"
22922292
],
22932293
"attributes": [
2294-
"+ | 0x0000 | | server | RAM | | | | 1 | 0 | 65344 | 0 => LocalTemperature [int16s]",
2294+
"+ | 0x0000 | | server | RAM | | | | 1 | 0 | 65344 | 0 => LocalTemperature [temperature]",
22952295
"+ | 0x0003 | | server | RAM | | | 0x02BC | 1 | 0 | 65344 | 0 => AbsMinHeatSetpointLimit [int16s]",
22962296
"+ | 0x0004 | | server | RAM | | | 0x0BB8 | 1 | 0 | 65344 | 0 => AbsMaxHeatSetpointLimit [int16s]",
22972297
"+ | 0x0005 | | server | RAM | | | 0x0640 | 1 | 0 | 65344 | 0 => AbsMinCoolSetpointLimit [int16s]",

test/resource/old-matter/chip-types.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,6 @@ limitations under the License.
8282
<type id="0xFD" description="IPv6 Prefix" name="ipv6pre" composite="true"/>
8383
<type id="0xFE" description="Hardware Address" name="hwadr" composite="true"/>
8484
<type id="0xFF" description="Unknown" name="unknown" size="0" />
85+
<type id="0xD8" description="Temperature" name="temperature" size="2" analog="true" signed="true" />
8586
</atomic>
8687
</configurator>

zcl-builtin/matter/data-model/chip/chip-types.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,6 @@ limitations under the License.
8181
<type id="0xFD" description="IPv6 Prefix" name="ipv6pre" composite="true"/>
8282
<type id="0xFE" description="Hardware Address" name="hwadr" composite="true"/>
8383
<type id="0xFF" description="Unknown" name="unknown" size="0" />
84+
<type id="0xD8" description="Temperature" name="temperature" size="2" analog="true" signed="true" />
8485
</atomic>
8586
</configurator>

zcl-builtin/matter/data-model/chip/thermostat-cluster.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ limitations under the License.
114114
<client tick="false" init="false">true</client>
115115
<server tick="false" init="false">true</server>
116116
<globalAttribute side="either" code="0xFFFD" value="5"/>
117-
<attribute side="server" code="0x0000" define="LOCAL_TEMPERATURE" type="INT16S" min="0x954D" max="0x7FFF" writable="false" reportable="true" optional="false" isNullable="true">LocalTemperature</attribute>
117+
<attribute side="server" code="0x0000" define="LOCAL_TEMPERATURE" type="TEMPERATURE" min="0x954D" max="0x7FFF" writable="false" reportable="true" optional="false" isNullable="true">LocalTemperature</attribute>
118118
<attribute side="server" code="0x0001" define="OUTDOOR_TEMPERATURE" type="INT16S" min="0x954D" max="0x7FFF" writable="false" optional="true" isNullable="true">OutdoorTemperature</attribute>
119119
<attribute side="server" code="0x0002" define="THERMOSTAT_OCCUPANCY" type="BITMAP8" min="0x00" max="0x01" writable="false" default="0x01" optional="true">Occupancy</attribute>
120120
<!-- OCCUPANCY -->

0 commit comments

Comments
 (0)