Skip to content

Commit 967c982

Browse files
committed
Fixed the issues with ambiguous base methods
1 parent a0cce3e commit 967c982

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/app/clusters/thermostat-server/apple-thermostat-extension-delegate.h

+4-8
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@
88

99
#pragma once
1010

11-
#include "apple-thermostat-extension-server.h"
12-
1311
#include <app-common/zap-generated/cluster-objects.h>
1412
#include <protocols/interaction_model/StatusCode.h>
1513

16-
//using ApplePresetInternalStruct = chip::app::Clusters::Thermostat::ApplePresetInternalStruct;
17-
1814
namespace chip {
1915
namespace app {
2016
namespace Clusters {
@@ -68,7 +64,7 @@ class Delegate
6864
* @param[out] presetType The preset type at the given index in the list.
6965
* @return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED if the index is out of range for the preset types list.
7066
*/
71-
virtual CHIP_ERROR GetApplePresetTypeAtIndex(size_t index, Structs::ApplePresetTypeStruct::Type & presetType) = 0;
67+
virtual CHIP_ERROR GetApplePresetTypeAtIndex(size_t index, ApplePresetInternalStruct & presetType) = 0;
7268

7369
/**
7470
* @brief Get the AppleNumberOfPresets attribute value.
@@ -84,7 +80,7 @@ class Delegate
8480
* @param[out] preset The preset at the given index in the list.
8581
* @return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED if the index is out of range for the presets list.
8682
*/
87-
virtual CHIP_ERROR GetApplePresetAtIndex(size_t index, Structs::ApplePresetStruct::Type & preset) = 0;
83+
virtual CHIP_ERROR GetApplePresetAtIndex(size_t index, ApplePresetInternalStruct & preset) = 0;
8884

8985
/**
9086
* @brief Get the Apple active preset handle.
@@ -119,7 +115,7 @@ class Delegate
119115
* @return CHIP_NO_ERROR if the preset was appended to the list successfully.
120116
* @return CHIP_ERROR if there was an error adding the preset to the list.
121117
*/
122-
virtual CHIP_ERROR AppendToPendingPresetList(Structs::ApplePresetStruct::Type & preset) = 0;
118+
virtual CHIP_ERROR AppendToPendingPresetList(ApplePresetInternalStruct & preset) = 0;
123119

124120
/**
125121
* @brief Get the Preset at a given index in the pending presets list. The callee needs to copy the
@@ -129,7 +125,7 @@ class Delegate
129125
* @param[out] preset The preset at the given index in the list.
130126
* @return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED if the index is out of range for the pending presets list.
131127
*/
132-
virtual CHIP_ERROR GetPendingPresetAtIndex(size_t index, Structs::ApplePresetStruct::Type & preset) = 0;
128+
virtual CHIP_ERROR GetPendingPresetAtIndex(size_t index, ApplePresetInternalStruct & preset) = 0;
133129

134130
/**
135131
* @brief Returns the count of preset entries in the pending presets list that have the matching presetHandle.

src/app/clusters/thermostat-server/apple-thermostat-extension-server.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
5959
* @return true If the preset is valid i.e the PresetHandle if not null fits within size constraints and the presetScenario enum
6060
* value is valid. Otherwise, return false.
6161
*/
62-
bool IsValidPresetEntry(ApplePresetInternalStruct & preset)
62+
bool IsValidPresetEntry(ApplePresetStruct::Type & preset)
6363
{
6464
// If the presetHandle is not null, the size of the handle should not exceed 16 bytes.
65-
if (!preset.GetPresetHandleData().IsNull() && preset.GetPresetHandleData().Value().size() > kAppleActivePresetHandleSize)
65+
if (!preset.presetHandle.IsNull() && preset.presetHandle.Value().size() > kAppleActivePresetHandleSize)
6666
{
6767
return false;
6868
}
6969

7070
// Return true if the preset scenario is valid, false otherwise.
71-
return (preset.GetPresetScenario() != ApplePresetScenarioEnum::kUnknownEnumValue);
71+
return (preset.presetScenario != ApplePresetScenarioEnum::kUnknownEnumValue);
7272
}
7373

7474
void AppleThermostatExtAttrAccess::SetThermostatAttrAccess(ThermostatAttrAccess * thermostatAttrAccessPtr)
@@ -249,7 +249,7 @@ CHIP_ERROR AppleThermostatExtAttrAccess::Write(const ConcreteDataAttributePath &
249249
auto iter = newPresets.begin();
250250
while (iter.Next())
251251
{
252-
ApplePresetInternalStruct preset = ApplePresetInternalStruct(iter.GetValue());
252+
ApplePresetStruct::Type preset = iter.GetValue();
253253
if (IsValidPresetEntry(preset))
254254
{
255255
ReturnErrorOnFailure(delegate->AppendToPendingPresetList(preset));
@@ -266,7 +266,7 @@ CHIP_ERROR AppleThermostatExtAttrAccess::Write(const ConcreteDataAttributePath &
266266
// If the list operation is AppendItem, call the delegate to append to the list of pending presets.
267267
if (aPath.mListOp == ConcreteDataAttributePath::ListOperation::AppendItem)
268268
{
269-
ApplePresetInternalStruct preset;
269+
ApplePresetStruct::Type preset;
270270
ReturnErrorOnFailure(aDecoder.Decode(preset));
271271
if (IsValidPresetEntry(preset))
272272
{
@@ -437,9 +437,9 @@ void ExtendTimer(EndpointId endpoint, uint16_t timeoutSeconds)
437437
*
438438
* @return true If the preset is built-in, false otherwise.
439439
*/
440-
bool IsBuiltIn(const ApplePresetInternalStruct preset)
440+
bool IsBuiltIn(ApplePresetInternalStruct preset)
441441
{
442-
return preset.builtIn.ValueOr(false);
442+
return preset.GetBuiltIn().ValueOr(false);
443443
}
444444

445445
/**
@@ -854,7 +854,7 @@ bool emberAfThermostatClusterAppleCommitPresetsSchedulesRequestCallback(
854854

855855
// #8. Find the number of presets in the pending preset list that match the preset handle. If there are more than 2
856856
// entries, return CONSTRAINT_ERROR.
857-
uint8_t count = delegate->CountPresetInPendingListWithPresetHandle(pendingPreset.presetHandle.Value());
857+
uint8_t count = delegate->CountPresetInPendingListWithPresetHandle(pendingPreset.GetPresetHandleData().Value());
858858
if (count >= 2)
859859
{
860860
return sendResponseAndCleanUp(delegate, endpoint, commandObj, commandPath, Status::ConstraintError);

src/app/clusters/thermostat-server/apple-thermostat-extension-server.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace app {
2525
namespace Clusters {
2626
namespace Thermostat {
2727

28-
struct ApplePresetInternalStruct : public Structs::ApplePresetStruct::Type
28+
struct ApplePresetInternalStruct : protected Structs::ApplePresetStruct::Type
2929
{
3030
public:
3131
ApplePresetInternalStruct() = default;
@@ -44,6 +44,8 @@ struct ApplePresetInternalStruct : public Structs::ApplePresetStruct::Type
4444
int16_t GetHeatingSetpoint();
4545
DataModel::Nullable<bool> GetBuiltIn();
4646

47+
using Structs::ApplePresetStruct::Type::Encode;
48+
4749
private:
4850
ByteSpan presetHandleData;
4951
};

0 commit comments

Comments
 (0)