-
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.
Create iterator to iterate over the supported-temperature-levels
- Loading branch information
1 parent
941ad24
commit 3103409
Showing
5 changed files
with
158 additions
and
38 deletions.
There are no files selected for viewing
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
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
66 changes: 66 additions & 0 deletions
66
examples/placeholder/linux/include/static-supported-temperature-levels-manager.h
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <app/clusters/temperature-control-server/supported-temperature-levels-manager.h> | ||
#include <app/util/af.h> | ||
#include <app/util/config.h> | ||
#include <cstring> | ||
|
||
namespace chip { | ||
namespace app { | ||
namespace Clusters { | ||
namespace TemperatureControl { | ||
|
||
/** | ||
* This implementation statically defines the options. | ||
*/ | ||
|
||
class StaticSupportedTemperatureLevelsManager : public SupportedTemperatureLevelsManager | ||
{ | ||
using TemperatureLevelStructType = Structs::TemperatureLevelStruct::Type; | ||
using storage_value_type = TemperatureLevelStructType; | ||
|
||
struct EndpointPair | ||
{ | ||
EndpointId mEndpointId; | ||
TemperatureLevelStructType * mData; | ||
int mSize; | ||
|
||
EndpointPair(EndpointId aEndpointId, TemperatureLevelStructType * aData, int aSize) : | ||
mEndpointId(aEndpointId), mData(aData), mSize(aSize) | ||
{} | ||
}; | ||
|
||
static storage_value_type temperatureLevelOptions[]; | ||
|
||
public: | ||
static const EndpointPair supportedOptionsByEndpoints[EMBER_AF_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; | ||
|
||
static TemperatureLevelStructType * data; | ||
|
||
~StaticSupportedTemperatureLevelsManager(){}; | ||
|
||
StaticSupportedTemperatureLevelsManager() {} | ||
}; | ||
|
||
} // namespace TemperatureControl | ||
} // namespace Clusters | ||
} // namespace app | ||
} // namespace chip |
65 changes: 65 additions & 0 deletions
65
examples/placeholder/linux/static-supported-temperature-levels-manager.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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* 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/config.h> | ||
#include <static-supported-temperature-levels-manager.h> | ||
|
||
using namespace std; | ||
using namespace chip; | ||
using namespace chip::app::Clusters; | ||
using namespace chip::app::Clusters::TemperatureControl; | ||
using chip::Protocols::InteractionModel::Status; | ||
|
||
using TemperatureLevelStructType = Structs::TemperatureLevelStruct::Type; | ||
using storage_value_type = TemperatureLevelStructType; | ||
namespace { | ||
Structs::TemperatureLevelStruct::Type buildTemperatureLevelStruct(const char * label, uint8_t temperatureLevel) | ||
{ | ||
Structs::TemperatureLevelStruct::Type option; | ||
option.label = CharSpan::fromCharString(label); | ||
option.temperatureLevel = temperatureLevel; | ||
return option; | ||
} | ||
} // namespace | ||
|
||
// TODO: Configure your options for each endpoint | ||
storage_value_type StaticSupportedTemperatureLevelsManager::temperatureLevelOptions[] = { | ||
buildTemperatureLevelStruct("wash Temperature", 1), buildTemperatureLevelStruct("rinse Temperature", 2), | ||
buildTemperatureLevelStruct("dry Temperature", 3) | ||
}; | ||
const StaticSupportedTemperatureLevelsManager::EndpointPair StaticSupportedTemperatureLevelsManager::supportedOptionsByEndpoints | ||
[EMBER_AF_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT] = { | ||
EndpointPair(1, StaticSupportedTemperatureLevelsManager::temperatureLevelOptions, 3) // Options for Endpoint 1 | ||
}; | ||
|
||
bool StaticSupportedTemperatureLevelsManager::SupportedTemperatureLevelsManager::Iterator::Next(TemperatureLevelStructType & item) | ||
{ | ||
for (auto & endpointPair : StaticSupportedTemperatureLevelsManager::supportedOptionsByEndpoints) | ||
{ | ||
if (endpointPair.mEndpointId == mEndpoint) | ||
{ | ||
if (endpointPair.mSize > mIndex) | ||
{ | ||
item = endpointPair.mData[mIndex]; | ||
mIndex++; | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} |
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