-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove KeypadLockout, TemperatureDisplayMode weak enums (#25149)
- Loading branch information
1 parent
f5e49f2
commit ffff1ca
Showing
3 changed files
with
58 additions
and
49 deletions.
There are no files selected for viewing
87 changes: 58 additions & 29 deletions
87
...at-user-interface-configuration-server/thermostat-user-interface-configuration-server.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,85 @@ | ||
#include <app/util/af.h> | ||
/** | ||
* | ||
* Copyright (c) 2021-2023 Project CHIP Authors | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <app/util/af-event.h> | ||
#include <app/util/attribute-storage.h> | ||
#include <app/util/af.h> | ||
|
||
#include <app-common/zap-generated/attributes/Accessors.h> | ||
#include <app-common/zap-generated/callback.h> | ||
#include <app-common/zap-generated/cluster-objects.h> | ||
#include <app-common/zap-generated/enums.h> | ||
#include <app-common/zap-generated/ids/Attributes.h> | ||
#include <app/CommandHandler.h> | ||
#include <app/ConcreteAttributePath.h> | ||
#include <app/ConcreteCommandPath.h> | ||
#include <app/util/error-mapping.h> | ||
#include <lib/core/CHIPEncoding.h> | ||
|
||
using namespace chip; | ||
using namespace chip::app; | ||
using namespace chip::app::Clusters; | ||
using namespace chip::app::Clusters::ThermostatUserInterfaceConfiguration; | ||
using chip::Protocols::InteractionModel::Status; | ||
|
||
namespace { | ||
// | ||
// Those types are defined as drafts in | ||
// src/app/zap-templates/zcl/data-model/draft/types/thermostat-user-interface-configuration.xml | ||
// | ||
enum class TemperatureDisplayMode : uint8_t | ||
{ | ||
kCelsius = 0x0, | ||
kFahrenheit = 0x1, | ||
}; | ||
|
||
enum class KeypadLockout : uint8_t | ||
{ | ||
kNoLockout = 0x0, | ||
kLevelOneLockout = 0x1, | ||
kLevelTwoLockout = 0x2, | ||
kLevelThreeLockout = 0x3, | ||
kLevelFourLockout = 0x4, | ||
kLevelFiveLockout = 0x5, | ||
}; | ||
|
||
} // namespace | ||
|
||
Protocols::InteractionModel::Status MatterThermostatUserInterfaceConfigurationClusterServerPreAttributeChangedCallback( | ||
const app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value) | ||
Status MatterThermostatUserInterfaceConfigurationClusterServerPreAttributeChangedCallback( | ||
const ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value) | ||
{ | ||
if (size != 0) | ||
{ | ||
if (ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::Id == attributePath.mAttributeId) | ||
if (Attributes::TemperatureDisplayMode::Id == attributePath.mAttributeId) | ||
{ | ||
EmberAfTemperatureDisplayMode mode = static_cast<EmberAfTemperatureDisplayMode>(chip::Encoding::Get8(value)); | ||
if ((EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_CELSIUS != mode) && (EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_FAHRENHEIT != mode)) | ||
auto mode = static_cast<TemperatureDisplayMode>(chip::Encoding::Get8(value)); | ||
if ((TemperatureDisplayMode::kCelsius != mode) && (TemperatureDisplayMode::kFahrenheit != mode)) | ||
{ | ||
return Protocols::InteractionModel::Status::Failure; | ||
return Status::Failure; | ||
} | ||
} | ||
else if (ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::Id == attributePath.mAttributeId) | ||
else if (Attributes::KeypadLockout::Id == attributePath.mAttributeId) | ||
{ | ||
EmberAfKeypadLockout lockout = static_cast<EmberAfKeypadLockout>(chip::Encoding::Get8(value)); | ||
if ((EMBER_ZCL_KEYPAD_LOCKOUT_NO_LOCKOUT != lockout) && (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_ONE_LOCKOUT != lockout) && | ||
(EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_TWO_LOCKOUT != lockout) && | ||
(EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_THREE_LOCKOUT != lockout) && | ||
(EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_FOUR_LOCKOUT != lockout) && (EMBER_ZCL_KEYPAD_LOCKOUT_LEVELFIVE_LOCKOUT != lockout)) | ||
auto lockout = static_cast<KeypadLockout>(chip::Encoding::Get8(value)); | ||
if ((KeypadLockout::kNoLockout != lockout) && (KeypadLockout::kLevelOneLockout != lockout) && | ||
(KeypadLockout::kLevelTwoLockout != lockout) && (KeypadLockout::kLevelThreeLockout != lockout) && | ||
(KeypadLockout::kLevelFourLockout != lockout) && (KeypadLockout::kLevelFiveLockout != lockout)) | ||
{ | ||
return Protocols::InteractionModel::Status::Failure; | ||
return Status::Failure; | ||
} | ||
} | ||
else if (ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId) | ||
else if (Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId) | ||
{ | ||
uint8_t prog = chip::Encoding::Get8(value); | ||
auto prog = chip::Encoding::Get8(value); | ||
if (prog > 1) | ||
{ | ||
return Protocols::InteractionModel::Status::Failure; | ||
return Status::Failure; | ||
} | ||
} | ||
} | ||
|
||
return Protocols::InteractionModel::Status::Success; | ||
return Status::Success; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.