@@ -1264,10 +1264,13 @@ EmberEventControl * ColorControlServer::configureHSVEventControl(EndpointId endp
1264
1264
* @param saturation Target saturation
1265
1265
* @param transitionTime Transition time in 10th of seconds
1266
1266
* @return Status::Success When successful,
1267
- * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a saturation transition state.
1267
+ * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a saturation transition state,
1268
+ * Status::ConstraintError if the saturation or tansitionTime are above maximum.
1268
1269
*/
1269
1270
Status ColorControlServer::moveToSaturation (EndpointId endpoint, uint8_t saturation, uint16_t transitionTime)
1270
1271
{
1272
+ VerifyOrReturnError (saturation <= MAX_SATURATION_VALUE, Status::ConstraintError);
1273
+ VerifyOrReturnError (transitionTime <= kMaxTransitionTime , Status::ConstraintError);
1271
1274
Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState (endpoint);
1272
1275
VerifyOrReturnError (nullptr != colorSaturationTransitionState, Status::UnsupportedEndpoint);
1273
1276
@@ -1307,6 +1310,7 @@ Status ColorControlServer::moveToSaturation(EndpointId endpoint, uint8_t saturat
1307
1310
* was called by MoveHue command and rate is a uint8 value.
1308
1311
* @return Status::Success When successful,
1309
1312
* Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a saturation transition state,
1313
+ * Status::ConstraintError if the hue, saturation or transitionTime, are above maximum.
1310
1314
*/
1311
1315
Status ColorControlServer::moveToHueAndSaturation (EndpointId endpoint, uint16_t hue, uint8_t saturation, uint16_t transitionTime,
1312
1316
bool isEnhanced)
@@ -1315,6 +1319,10 @@ Status ColorControlServer::moveToHueAndSaturation(EndpointId endpoint, uint16_t
1315
1319
uint16_t halfWay = isEnhanced ? HALF_MAX_UINT16T : HALF_MAX_UINT8T;
1316
1320
bool moveUp;
1317
1321
1322
+ VerifyOrReturnError ((isEnhanced || hue <= MAX_HUE_VALUE), Status::ConstraintError);
1323
+ VerifyOrReturnError (saturation <= MAX_SATURATION_VALUE, Status::ConstraintError);
1324
+ VerifyOrReturnError (transitionTime <= kMaxTransitionTime , Status::ConstraintError);
1325
+
1318
1326
uint16_t epIndex = getEndpointIndex (endpoint);
1319
1327
Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionStateByIndex (epIndex);
1320
1328
ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionStateByIndex (epIndex);
@@ -1502,10 +1510,11 @@ Status ColorControlServer::moveToHueCommand(EndpointId endpoint, uint16_t hue, D
1502
1510
bool isEnhanced)
1503
1511
{
1504
1512
MATTER_TRACE_SCOPE (" moveToHue" , " ColorControl" );
1505
- VerifyOrReturnValue (moveDirection != DirectionEnum::kUnknownEnumValue , Status::InvalidCommand);
1506
-
1507
1513
// Command Parameters constraint checks:
1508
1514
VerifyOrReturnValue ((isEnhanced || hue <= MAX_HUE_VALUE), Status::ConstraintError);
1515
+ VerifyOrReturnValue (transitionTime <= kMaxTransitionTime , Status::ConstraintError);
1516
+
1517
+ VerifyOrReturnValue (moveDirection != DirectionEnum::kUnknownEnumValue , Status::InvalidCommand);
1509
1518
1510
1519
ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState (endpoint);
1511
1520
VerifyOrReturnValue (colorHueTransitionState != nullptr , Status::UnsupportedEndpoint);
@@ -1612,7 +1621,6 @@ Status ColorControlServer::moveToHueCommand(EndpointId endpoint, uint16_t hue, D
1612
1621
* was called by MoveHue command and rate is a uint8 value.
1613
1622
* @return Status::Success when successful,
1614
1623
* Status::ConstraintError when the other parameters are outside their defined value range.
1615
-
1616
1624
*/
1617
1625
Status ColorControlServer::moveToHueAndSaturationCommand (EndpointId endpoint, uint16_t hue, uint8_t saturation,
1618
1626
uint16_t transitionTime, BitMask<OptionsBitmap> optionsMask,
@@ -1622,6 +1630,7 @@ Status ColorControlServer::moveToHueAndSaturationCommand(EndpointId endpoint, ui
1622
1630
// Command Parameters constraint checks:
1623
1631
VerifyOrReturnValue ((isEnhanced || hue <= MAX_HUE_VALUE), Status::ConstraintError);
1624
1632
VerifyOrReturnValue (saturation <= MAX_SATURATION_VALUE, Status::ConstraintError);
1633
+ VerifyOrReturnValue (transitionTime <= kMaxTransitionTime , Status::ConstraintError);
1625
1634
1626
1635
VerifyOrReturnValue (shouldExecuteIfOff (endpoint, optionsMask, optionsOverride), Status::Success);
1627
1636
@@ -1646,12 +1655,19 @@ Status ColorControlServer::moveToHueAndSaturationCommand(EndpointId endpoint, ui
1646
1655
* @return Status::Success when successful,
1647
1656
* Status::InvalidCommand when StepSize is 0 or an unknown HueStepMode is provided
1648
1657
* Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a hue transition state.
1658
+ * Status::ConstraintError when the other parameters are outside their defined value range.
1649
1659
*/
1650
1660
Status ColorControlServer::stepHueCommand (EndpointId endpoint, HueStepMode stepMode, uint16_t stepSize, uint16_t transitionTime,
1651
1661
BitMask<OptionsBitmap> optionsMask, BitMask<OptionsBitmap> optionsOverride,
1652
1662
bool isEnhanced)
1653
1663
{
1654
1664
MATTER_TRACE_SCOPE (" stepHue" , " ColorControl" );
1665
+ // Command Parameters constraint checks:
1666
+ // The non-enhanced variant passed a uint8 type for transitionTime and the full range (0-255) is allowed
1667
+ if (isEnhanced)
1668
+ {
1669
+ VerifyOrReturnValue (transitionTime <= kMaxTransitionTime , Status::ConstraintError);
1670
+ }
1655
1671
// Confirm validity of the step mode and step size received
1656
1672
VerifyOrReturnValue (stepMode != HueStepMode::kUnknownEnumValue , Status::InvalidCommand);
1657
1673
VerifyOrReturnValue (stepSize != 0 , Status::InvalidCommand);
@@ -1787,14 +1803,16 @@ Status ColorControlServer::moveSaturationCommand(EndpointId endpoint, const Comm
1787
1803
* @param commandData Struct containing the parameters of the command.
1788
1804
* @return Status::Success when successful,
1789
1805
* Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a saturation transition state (verified in
1790
- * moveToSaturation function) Status::ConstraintError when a command parameters is outside its defined value range.
1806
+ * moveToSaturation function)
1807
+ * Status::ConstraintError when a command parameter is outside its defined value range.
1791
1808
*/
1792
1809
Status ColorControlServer::moveToSaturationCommand (EndpointId endpoint,
1793
1810
const Commands::MoveToSaturation::DecodableType & commandData)
1794
1811
{
1795
1812
MATTER_TRACE_SCOPE (" moveToSaturation" , " ColorControl" );
1796
1813
// Command Parameters constraint checks:
1797
1814
VerifyOrReturnValue (commandData.saturation <= MAX_SATURATION_VALUE, Status::ConstraintError);
1815
+ VerifyOrReturnValue (commandData.transitionTime <= kMaxTransitionTime , Status::ConstraintError);
1798
1816
1799
1817
VerifyOrReturnValue (shouldExecuteIfOff (endpoint, commandData.optionsMask , commandData.optionsOverride ), Status::Success);
1800
1818
Status status = moveToSaturation (endpoint, commandData.saturation , commandData.transitionTime );
@@ -1810,7 +1828,7 @@ Status ColorControlServer::moveToSaturationCommand(EndpointId endpoint,
1810
1828
* @param commandData Struct containing the parameters of the command.
1811
1829
* @return Status::Success when successful,
1812
1830
* Status::InvalidCommand when a step size of 0 or an unknown SaturationStepMode is provided
1813
- * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a saturation transition state.
1831
+ * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a saturation transition state,
1814
1832
*/
1815
1833
Status ColorControlServer::stepSaturationCommand (EndpointId endpoint, const Commands::StepSaturation::DecodableType & commandData)
1816
1834
{
@@ -1861,7 +1879,7 @@ Status ColorControlServer::stepSaturationCommand(EndpointId endpoint, const Comm
1861
1879
* @param commandData Struct containing the parameters of the command.
1862
1880
* @return Status::Success when successful,
1863
1881
* Status::InvalidCommand when an unknown action or direction is provided
1864
- * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a hue transition state.
1882
+ * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a hue transition state,
1865
1883
*/
1866
1884
Status ColorControlServer::colorLoopCommand (EndpointId endpoint, const Commands::ColorLoopSet::DecodableType & commandData)
1867
1885
{
@@ -2146,10 +2164,18 @@ EmberEventControl * ColorControlServer::configureXYEventControl(EndpointId endpo
2146
2164
* @param colorX target X
2147
2165
* @param colorY target Y
2148
2166
* @param transitionTime transition time in 10th of seconds
2149
- * @return Status::Success if successful,Status::UnsupportedEndpoint XY is not supported on the endpoint
2167
+ * @return Status::Success if successful,
2168
+ * @return Status::Success when successful,
2169
+ * Status::UnsupportedEndpoint XY is not supported on the endpoint,
2170
+ * Status::ConstraintError when a command parameter is outside its defined value range.
2150
2171
*/
2151
2172
Status ColorControlServer::moveToColor (EndpointId endpoint, uint16_t colorX, uint16_t colorY, uint16_t transitionTime)
2152
2173
{
2174
+ // Command Parameters constraint checks:
2175
+ VerifyOrReturnValue (colorX <= MAX_CIE_XY_VALUE, Status::ConstraintError);
2176
+ VerifyOrReturnValue (colorY <= MAX_CIE_XY_VALUE, Status::ConstraintError);
2177
+ VerifyOrReturnValue (transitionTime <= kMaxTransitionTime , Status::ConstraintError);
2178
+
2153
2179
uint16_t epIndex = getEndpointIndex (endpoint);
2154
2180
Color16uTransitionState * colorXTransitionState = getXTransitionStateByIndex (epIndex);
2155
2181
Color16uTransitionState * colorYTransitionState = getYTransitionStateByIndex (epIndex);
@@ -2201,9 +2227,15 @@ Status ColorControlServer::moveToColor(EndpointId endpoint, uint16_t colorX, uin
2201
2227
* @return Status::Success when successful,
2202
2228
* Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a Color XY transition state (verified in
2203
2229
* moveToColor function),
2230
+ * Status::ConstraintError when a command parameter is outside its defined value range.
2204
2231
*/
2205
2232
Status ColorControlServer::moveToColorCommand (EndpointId endpoint, const Commands::MoveToColor::DecodableType & commandData)
2206
2233
{
2234
+ // Command Parameters constraint checks:
2235
+ VerifyOrReturnValue (commandData.colorX <= MAX_CIE_XY_VALUE, Status::ConstraintError);
2236
+ VerifyOrReturnValue (commandData.colorY <= MAX_CIE_XY_VALUE, Status::ConstraintError);
2237
+ VerifyOrReturnValue (commandData.transitionTime <= kMaxTransitionTime , Status::ConstraintError);
2238
+
2207
2239
VerifyOrReturnValue (shouldExecuteIfOff (endpoint, commandData.optionsMask , commandData.optionsOverride ), Status::Success);
2208
2240
2209
2241
Status status = moveToColor (endpoint, commandData.colorX , commandData.colorY , commandData.transitionTime );
@@ -2302,10 +2334,14 @@ Status ColorControlServer::moveColorCommand(EndpointId endpoint, const Commands:
2302
2334
* @param commandData Struct containing the parameters of the command
2303
2335
* @return Status::Success when successful,
2304
2336
* Status::InvalidCommand when a step X and Y of 0 is provided
2305
- * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a Color XY transition state.
2337
+ * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a Color XY transition state,
2338
+ * Status::ConstraintError when a command parameter is outside its defined value range.
2306
2339
*/
2307
2340
Status ColorControlServer::stepColorCommand (EndpointId endpoint, const Commands::StepColor::DecodableType & commandData)
2308
2341
{
2342
+ // Command Parameters constraint checks:
2343
+ VerifyOrReturnValue (commandData.transitionTime <= kMaxTransitionTime , Status::ConstraintError);
2344
+
2309
2345
VerifyOrReturnValue (commandData.stepX != 0 || commandData.stepY != 0 , Status::InvalidCommand);
2310
2346
2311
2347
uint16_t epIndex = getEndpointIndex (endpoint);
@@ -2440,8 +2476,11 @@ ColorControlServer::Color16uTransitionState * ColorControlServer::getTempTransit
2440
2476
*/
2441
2477
Status ColorControlServer::moveToColorTemp (EndpointId aEndpoint, uint16_t colorTemperature, uint16_t transitionTime)
2442
2478
{
2443
- EndpointId endpoint = aEndpoint;
2479
+ // Command Parameters constraint checks:
2480
+ VerifyOrReturnValue (colorTemperature <= kMaxColorTemperatureMireds , Status::ConstraintError);
2481
+ VerifyOrReturnValue (transitionTime <= kMaxTransitionTime , Status::ConstraintError);
2444
2482
2483
+ EndpointId endpoint = aEndpoint;
2445
2484
Color16uTransitionState * colorTempTransitionState = getTempTransitionState (endpoint);
2446
2485
VerifyOrReturnError (nullptr != colorTempTransitionState, Status::UnsupportedEndpoint);
2447
2486
@@ -2638,10 +2677,15 @@ void ColorControlServer::updateTempCommand(EndpointId endpoint)
2638
2677
* @return Status::Success when successful,
2639
2678
* Status::InvalidCommand when a rate of 0 for a non-stop move or an unknown HueMoveMode is provided
2640
2679
* Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a color temp transition state.
2680
+ * Status::ConstraintError when a command parameter is outside its defined value range.
2641
2681
*/
2642
2682
Status ColorControlServer::moveColorTempCommand (EndpointId endpoint,
2643
2683
const Commands::MoveColorTemperature::DecodableType & commandData)
2644
2684
{
2685
+ // Command Parameters constraint checks:
2686
+ VerifyOrReturnValue (commandData.colorTemperatureMinimumMireds <= kMaxColorTemperatureMireds , Status::ConstraintError);
2687
+ VerifyOrReturnValue (commandData.colorTemperatureMaximumMireds <= kMaxColorTemperatureMireds , Status::ConstraintError);
2688
+
2645
2689
// check moveMode and rate before any operation is done on the transition states
2646
2690
// rate value is ignored if the MoveMode is stop
2647
2691
VerifyOrReturnValue (commandData.moveMode != HueMoveMode::kUnknownEnumValue , Status::InvalidCommand);
@@ -2734,11 +2778,16 @@ Status ColorControlServer::moveColorTempCommand(EndpointId endpoint,
2734
2778
* @param commandData Struct containing the parameters of the command.
2735
2779
* @return Status::Success when successful,
2736
2780
* Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a color XY transition state (verified in
2737
- * moveToColorTemp function).
2781
+ * moveToColorTemp function),
2782
+ * Status::ConstraintError when a command parameter is outside its defined value range.
2738
2783
*/
2739
2784
Status ColorControlServer::moveToColorTempCommand (EndpointId endpoint,
2740
2785
const Commands::MoveToColorTemperature::DecodableType & commandData)
2741
2786
{
2787
+ // Command Parameters constraint checks:
2788
+ VerifyOrReturnValue (commandData.colorTemperatureMireds <= kMaxColorTemperatureMireds , Status::ConstraintError);
2789
+ VerifyOrReturnValue (commandData.transitionTime <= kMaxTransitionTime , Status::ConstraintError);
2790
+
2742
2791
VerifyOrReturnValue (shouldExecuteIfOff (endpoint, commandData.optionsMask , commandData.optionsOverride ), Status::Success);
2743
2792
2744
2793
Status status = moveToColorTemp (endpoint, commandData.colorTemperatureMireds , commandData.transitionTime );
@@ -2754,11 +2803,17 @@ Status ColorControlServer::moveToColorTempCommand(EndpointId endpoint,
2754
2803
* @param commandData Struct containing the parameters of the command
2755
2804
* @return Status::Success when successful,
2756
2805
* Status::InvalidCommand when stepSize is 0 or an unknown stepMode is provided
2757
- * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a color temp transition state.
2806
+ * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a color temp transition state,
2807
+ * Status::ConstraintError when a command parameter is outside its defined value range.
2758
2808
*/
2759
2809
Status ColorControlServer::stepColorTempCommand (EndpointId endpoint,
2760
2810
const Commands::StepColorTemperature::DecodableType & commandData)
2761
2811
{
2812
+ // Command Parameters constraint checks:
2813
+ VerifyOrReturnValue (commandData.transitionTime <= kMaxTransitionTime , Status::ConstraintError);
2814
+ VerifyOrReturnValue (commandData.colorTemperatureMinimumMireds <= kMaxColorTemperatureMireds , Status::ConstraintError);
2815
+ VerifyOrReturnValue (commandData.colorTemperatureMaximumMireds <= kMaxColorTemperatureMireds , Status::ConstraintError);
2816
+
2762
2817
// Confirm validity of the step mode and step size received
2763
2818
VerifyOrReturnValue (commandData.stepMode != HueStepMode::kUnknownEnumValue , Status::InvalidCommand);
2764
2819
VerifyOrReturnValue (commandData.stepSize != 0 , Status::InvalidCommand);
0 commit comments