Skip to content

Commit 988ea97

Browse files
SuGliderCopilot
andauthored
feat(matter): checks level to verify that it is valid
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d2b2060 commit 988ea97

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

libraries/Matter/src/MatterEndpoints/MatterTemperatureControlledCabinet.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,18 @@ bool MatterTemperatureControlledCabinet::setSelectedTemperatureLevel(uint8_t lev
571571
return false;
572572
}
573573

574+
// Validate that level is in supported levels array
575+
bool levelFound = false;
576+
for (uint16_t i = 0; i < supportedLevelsCount; i++) {
577+
if (supportedLevelsArray[i] == level) {
578+
levelFound = true;
579+
break;
580+
}
581+
}
582+
if (!levelFound) {
583+
log_e("Temperature level %u is not in the supported levels array", level);
584+
return false;
585+
}
574586
if (selectedTempLevel == level) {
575587
return true;
576588
}

0 commit comments

Comments
 (0)