Skip to content

Commit

Permalink
Apply ColorTempPhysicalMaxMireds when ColorTemperatureMaximumMireds f… (
Browse files Browse the repository at this point in the history
#33983)

* Apply ColorTempPhysicalMaxMireds when ColorTemperatureMaximumMireds field is 0. Add tests

* Restyled by whitespace

* Restyled by prettier-yaml

* Change wait time to 1 sec as rate is calculated in step per second

* Add code comment, fix typo in test command

---------

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
jmartinez-silabs and restyled-commits authored Jun 18, 2024
1 parent dacf560 commit e22266b
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2693,11 +2693,16 @@ bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj,
return true;
}

// Per spec, colorTemperatureMinimumMireds field is limited to ColorTempPhysicalMinMireds and
// when colorTemperatureMinimumMireds field is 0, ColorTempPhysicalMinMireds shall be used (always >= to 0)
if (colorTemperatureMinimum < tempPhysicalMin)
{
colorTemperatureMinimum = tempPhysicalMin;
}
if (colorTemperatureMaximum > tempPhysicalMax)

// Per spec, colorTemperatureMaximumMireds field is limited to ColorTempPhysicalMaxMireds and
// when colorTemperatureMaximumMireds field is 0, ColorTempPhysicalMaxMireds shall be used
if ((colorTemperatureMaximum == 0) || (colorTemperatureMaximum > tempPhysicalMax))
{
colorTemperatureMaximum = tempPhysicalMax;
}
Expand Down Expand Up @@ -2804,11 +2809,16 @@ bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj,
Attributes::ColorTempPhysicalMinMireds::Get(endpoint, &tempPhysicalMin);
Attributes::ColorTempPhysicalMaxMireds::Get(endpoint, &tempPhysicalMax);

// Per spec, colorTemperatureMinimumMireds field is limited to ColorTempPhysicalMinMireds and
// when colorTemperatureMinimumMireds field is 0, ColorTempPhysicalMinMireds shall be used (always >= to 0)
if (colorTemperatureMinimum < tempPhysicalMin)
{
colorTemperatureMinimum = tempPhysicalMin;
}
if (colorTemperatureMaximum > tempPhysicalMax)

// Per spec, colorTemperatureMaximumMireds field is limited to ColorTempPhysicalMaxMireds and
// when colorTemperatureMaximumMireds field is 0, ColorTempPhysicalMaxMireds shall be used
if ((colorTemperatureMaximum == 0) || (colorTemperatureMaximum > tempPhysicalMax))
{
colorTemperatureMaximum = tempPhysicalMax;
}
Expand Down
79 changes: 79 additions & 0 deletions src/app/tests/suites/certification/Test_TC_CC_6_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,85 @@ tests:
constraints:
minValue: 0
maxValue: 3
- label:
"Step 6a: TH sends MoveColorTemperature command to DUT with MoveMode =
0x03(down), Rate = 65535 (max value) with
ColorTemperatureMinimumMireds of 0"
PICS: CC.S.F04 && CC.S.C4b.Rsp
command: MoveColorTemperature
arguments:
values:
- name: "MoveMode"
value: 3
- name: "Rate"
value: 65535
- name: "ColorTemperatureMinimumMireds"
value: 0
- name: "ColorTemperatureMaximumMireds"
value: ColorTempPhysicalMaxMiredsValue
- name: "OptionsMask"
value: 0
- name: "OptionsOverride"
value: 0

- label: "Wait 1s"
PICS: CC.S.F04
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 1000

- label: "Step 6b: TH reads ColorTemperatureMireds attribute from DUT."
PICS: CC.S.F04 && CC.S.A0007 && CC.S.C4b.Rsp
command: "readAttribute"
attribute: "ColorTemperatureMireds"
response:
value: ColorTempPhysicalMinMiredsValue
constraints:
minValue: ColorTempPhysicalMinMiredsValue
maxValue: ColorTempPhysicalMaxMiredsValue

- label:
"Step 7a: TH sends MoveColorTemperature command to DUT with MoveMode =
0x01(up), Rate = 65535 (max value) with ColorTemperatureMaximumMireds
of 0"
PICS: CC.S.F04 && CC.S.C4b.Rsp
command: MoveColorTemperature
arguments:
values:
- name: "MoveMode"
value: 1
- name: "Rate"
value: 65535
- name: "ColorTemperatureMinimumMireds"
value: ColorTempPhysicalMinMiredsValue
- name: "ColorTemperatureMaximumMireds"
value: 0
- name: "OptionsMask"
value: 0
- name: "OptionsOverride"
value: 0

- label: "Wait 1s"
PICS: CC.S.F04
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 1000

- label: "Step 7b: TH reads ColorTemperatureMireds attribute from DUT."
PICS: CC.S.F04 && CC.S.A0007 && CC.S.C4b.Rsp
command: "readAttribute"
attribute: "ColorTemperatureMireds"
response:
value: ColorTempPhysicalMaxMiredsValue
constraints:
minValue: ColorTempPhysicalMinMiredsValue
maxValue: ColorTempPhysicalMaxMiredsValue

- label: "Turn off light that we turned on"
PICS: OO.S.C00.Rsp
Expand Down
84 changes: 84 additions & 0 deletions src/app/tests/suites/certification/Test_TC_CC_6_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,90 @@ tests:
minValue: 0
maxValue: 3

- label:
"Step 5a: TH sends StepColorTemperature command to DUT with StepMode =
0x01 (up), StepSize = ColorTempPhysicalMaxMireds and TransitionTime =
0 (instant)."
PICS: CC.S.F04 && CC.S.C4c.Rsp
command: "StepColorTemperature"
arguments:
values:
- name: "StepMode"
value: 1
- name: "StepSize"
value: ColorTempPhysicalMaxMiredsValue
- name: "ColorTemperatureMinimumMireds"
value: ColorTempPhysicalMinMiredsValue
- name: "ColorTemperatureMaximumMireds"
value: 0
- name: "TransitionTime"
value: 0
- name: "OptionsMask"
value: 0
- name: "OptionsOverride"
value: 0

- label: "Wait 100ms"
PICS: CC.S.F04
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 100

- label: "Step 5b: TH reads ColorTemperatureMireds attribute from DUT."
PICS: CC.S.F04 && CC.S.A0007 && CC.S.C4c.Rsp
command: "readAttribute"
attribute: "ColorTemperatureMireds"
response:
value: ColorTempPhysicalMaxMiredsValue
constraints:
minValue: ColorTempPhysicalMinMiredsValue
maxValue: ColorTempPhysicalMaxMiredsValue

- label:
"Step 6a: TH sends StepColorTemperature command to DUT with StepMode =
0x03 (down), StepSize = ColorTempPhysicalMaxMireds and TransitionTime
= 0 (instant)."
PICS: CC.S.F04 && CC.S.C4c.Rsp
command: "StepColorTemperature"
arguments:
values:
- name: "StepMode"
value: 3
- name: "StepSize"
value: ColorTempPhysicalMaxMiredsValue
- name: "ColorTemperatureMinimumMireds"
value: 0
- name: "ColorTemperatureMaximumMireds"
value: ColorTempPhysicalMaxMiredsValue
- name: "TransitionTime"
value: 0
- name: "OptionsMask"
value: 0
- name: "OptionsOverride"
value: 0

- label: "Wait 100ms"
PICS: CC.S.F04
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 100

- label: "Step 6b: TH reads ColorTemperatureMireds attribute from DUT."
PICS: CC.S.F04 && CC.S.A0007 && CC.S.C4c.Rsp
command: "readAttribute"
attribute: "ColorTemperatureMireds"
response:
value: ColorTempPhysicalMinMiredsValue
constraints:
minValue: ColorTempPhysicalMinMiredsValue
maxValue: ColorTempPhysicalMaxMiredsValue

- label: "Turn Off light that we turned on"
PICS: OO.S.C00.Rsp
cluster: "On/Off"
Expand Down

0 comments on commit e22266b

Please sign in to comment.