Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jadhavrohit924 committed Jul 13, 2023
1 parent 7af001e commit c009659
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14280,7 +14280,7 @@
"name": "Refrigerator Alarm",
"code": 87,
"mfgCode": null,
"define": "REFRIGERATOR_ALARM",
"define": "REFRIGERATOR_ALARM_CLUSTER",
"side": "client",
"enabled": 0,
"attributes": [
Expand Down Expand Up @@ -14322,7 +14322,7 @@
"name": "Refrigerator Alarm",
"code": 87,
"mfgCode": null,
"define": "REFRIGERATOR_ALARM",
"define": "REFRIGERATOR_ALARM_CLUSTER",
"side": "server",
"enabled": 1,
"attributes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@

#include <app/clusters/temperature-control-server/supported-temperature-levels-manager.h>
#include <app/util/af.h>
<<<<<<< HEAD
#include <zap-generated/gen_config.h>
=======
#include <app/util/config.h>
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)

namespace chip {
Expand All @@ -35,11 +32,13 @@ namespace TemperatureControl {
* This implementation statically defines the options.
*/

<<<<<<< HEAD
class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsIteratorDelegate
=======
class StaticSupportedTemperatureLevels : public SupportedTemperatureLevelsIterator
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)
=======
class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsIteratorDelegate
>>>>>>> 569182fe4e (Addressed review comments)
{
struct EndpointPair
{
Expand All @@ -59,19 +58,15 @@ class StaticSupportedTemperatureLevels : public SupportedTemperatureLevelsIterat
public:
static const EndpointPair supportedOptionsByEndpoints[EMBER_AF_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT];

<<<<<<< HEAD
uint8_t Size() override;

CHIP_ERROR Next(chip::MutableCharSpan & item) override;

~AppSupportedTemperatureLevelsDelegate() {}
=======
int Size() override;

bool Next(chip::MutableCharSpan & item) override;
CHIP_ERROR Next(chip::MutableCharSpan & item) override;

~StaticSupportedTemperatureLevels() {}
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)
};

} // namespace TemperatureControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@
* limitations under the License.
*/

<<<<<<< HEAD
#include <static-supported-temperature-levels.h>
#include <zap-generated/gen_config.h>
=======
#include <app/util/config.h>
#include <static-supported-temperature-levels.h>
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)

using namespace std;
using namespace chip;
Expand All @@ -31,7 +26,6 @@ using namespace chip::app::Clusters::TemperatureControl;
using chip::Protocols::InteractionModel::Status;

// TODO: Configure your options for each endpoint
<<<<<<< HEAD
chip::CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { chip::CharSpan("Hot", 3),
chip::CharSpan("Warm", 4),
chip::CharSpan("Freezing", 8) };
Expand All @@ -47,16 +41,20 @@ uint8_t AppSupportedTemperatureLevelsDelegate::Size()
=======
chip::CharSpan StaticSupportedTemperatureLevels::temperatureLevelOptions[] = { chip::CharSpan("Cold", 4), chip::CharSpan("Warm", 4),
chip::CharSpan("Hot", 3) };
=======
chip::CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { chip::CharSpan("Hot", 3),
chip::CharSpan("Warm", 4),
chip::CharSpan("Freezing", 8) };
>>>>>>> 569182fe4e (Addressed review comments)

const StaticSupportedTemperatureLevels::EndpointPair
StaticSupportedTemperatureLevels::supportedOptionsByEndpoints[EMBER_AF_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT] = {
EndpointPair(1, StaticSupportedTemperatureLevels::temperatureLevelOptions, 3) // Options for Endpoint 1
const AppSupportedTemperatureLevelsDelegate::EndpointPair AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints
[EMBER_AF_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT] = {
EndpointPair(1, AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions, 3) // Options for Endpoint 1
};

int StaticSupportedTemperatureLevels::Size()
uint8_t AppSupportedTemperatureLevelsDelegate::Size()
{
for (auto & endpointPair : StaticSupportedTemperatureLevels::supportedOptionsByEndpoints)
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)
{
if (endpointPair.mEndpointId == mEndpoint)
{
Expand All @@ -66,15 +64,9 @@ int StaticSupportedTemperatureLevels::Size()
return 0;
}

<<<<<<< HEAD
CHIP_ERROR AppSupportedTemperatureLevelsDelegate::Next(chip::MutableCharSpan & item)
{
for (auto & endpointPair : AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints)
=======
bool StaticSupportedTemperatureLevels::Next(chip::MutableCharSpan & item)
{
for (auto & endpointPair : StaticSupportedTemperatureLevels::supportedOptionsByEndpoints)
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)
{
if (endpointPair.mEndpointId == mEndpoint)
{
Expand All @@ -84,7 +76,6 @@ bool StaticSupportedTemperatureLevels::Next(chip::MutableCharSpan & item)
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "Error copying char span to mutable char span %s", chip::ErrorStr(err));
<<<<<<< HEAD
return err;
}
mIndex++;
Expand All @@ -93,13 +84,4 @@ bool StaticSupportedTemperatureLevels::Next(chip::MutableCharSpan & item)
}
}
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
=======
}
mIndex++;
return true;
}
}
}
return false;
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)
}
8 changes: 0 additions & 8 deletions examples/all-clusters-app/ameba/main/chipinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ app::Clusters::NetworkCommissioning::Instance
sWiFiNetworkCommissioningInstance(kNetworkCommissioningEndpointMain /* Endpoint Id */,
&(NetworkCommissioning::AmebaWiFiDriver::GetInstance()));

<<<<<<< HEAD
app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupportedTemperatureLevelsDelegate;
=======
app::Clusters::TemperatureControl::StaticSupportedTemperatureLevels instance;
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)
} // namespace

void NetWorkCommissioningInstInit()
Expand Down Expand Up @@ -148,11 +144,7 @@ static void InitServer(intptr_t context)
#if CONFIG_ENABLE_CHIP_SHELL
InitBindingHandler();
#endif
<<<<<<< HEAD
app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate);
=======
app::Clusters::TemperatureControl::SupportedTemperatureLevelsIterator::SetInstance(&instance);
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)
}

extern "C" void ChipTest(void)
Expand Down
2 changes: 2 additions & 0 deletions examples/all-clusters-app/nxp/mw320/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ mw320_sdk("sdk") {
"${examples_plat_dir}/app/project_include",
"${chip_root}/src/app/util",
"${chip_root}/examples/all-clusters-app/nxp/mw320/include",
"${chip_root}/examples/all-clusters-app/all-clusters-common/include",
]

sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp",
"include/CHIPProjectConfig.h",
"include/FreeRTOSConfig.h",
]
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-minimal-app/asr/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ asr_executable("clusters_minimal_app") {
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp",
"${examples_plat_dir}/CHIPDeviceManager.cpp",
"${examples_plat_dir}/LEDWidget.cpp",
"${examples_plat_dir}/init_Matter.cpp",
Expand Down
33 changes: 0 additions & 33 deletions examples/placeholder/linux/static-supported-temperature-levels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

#include <app/util/config.h>
#include <static-supported-temperature-levels.h>
<<<<<<< HEAD
#include <zap-generated/gen_config.h>
=======
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)

using namespace std;
using namespace chip;
Expand All @@ -30,7 +27,6 @@ using namespace chip::app::Clusters::TemperatureControl;
using chip::Protocols::InteractionModel::Status;

// TODO: Configure your options for each endpoint
<<<<<<< HEAD
chip::CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { chip::CharSpan("Hot", 3),
chip::CharSpan("Warm", 4),
chip::CharSpan("Cold", 4) };
Expand All @@ -41,21 +37,8 @@ const AppSupportedTemperatureLevelsDelegate::EndpointPair AppSupportedTemperatur
};

uint8_t AppSupportedTemperatureLevelsDelegate::Size()
{
for (auto & endpointPair : AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints)
=======
chip::CharSpan StaticSupportedTemperatureLevels::temperatureLevelOptions[] = { chip::CharSpan("Cold", 4), chip::CharSpan("Warm", 4),
chip::CharSpan("Hot", 3) };

const StaticSupportedTemperatureLevels::EndpointPair
StaticSupportedTemperatureLevels::supportedOptionsByEndpoints[EMBER_AF_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT] = {
EndpointPair(1, StaticSupportedTemperatureLevels::temperatureLevelOptions, 3) // Options for Endpoint 1
};

int StaticSupportedTemperatureLevels::Size()
{
for (auto & endpointPair : StaticSupportedTemperatureLevels::supportedOptionsByEndpoints)
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)
{
if (endpointPair.mEndpointId == mEndpoint)
{
Expand All @@ -65,21 +48,14 @@ int StaticSupportedTemperatureLevels::Size()
return 0;
}

<<<<<<< HEAD
CHIP_ERROR AppSupportedTemperatureLevelsDelegate::Next(chip::MutableCharSpan & item)
{
for (auto & endpointPair : AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints)
=======
bool StaticSupportedTemperatureLevels::Next(chip::CharSpan & item)
{
for (auto & endpointPair : StaticSupportedTemperatureLevels::supportedOptionsByEndpoints)
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)
{
if (endpointPair.mEndpointId == mEndpoint)
{
if (endpointPair.mSize > mIndex)
{
<<<<<<< HEAD
CHIP_ERROR err = chip::CopyCharSpanToMutableCharSpan(endpointPair.mTemperatureLevels[mIndex], item);
if (err != CHIP_NO_ERROR)
{
Expand All @@ -92,13 +68,4 @@ bool StaticSupportedTemperatureLevels::Next(chip::CharSpan & item)
}
}
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
=======
item = endpointPair.mTemperatureLevels[mIndex];
mIndex++;
return true;
}
}
}
return false;
>>>>>>> 07d46e3ba1 (Restructure server implementation to match spec)
}
1 change: 1 addition & 0 deletions examples/shell/cc13x4_26x4/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ ti_simplelink_executable("shell_app") {
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp",
"main/AppTask.cpp",
"main/main.cpp",
]
Expand Down
5 changes: 1 addition & 4 deletions examples/shell/standalone/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ assert(chip_build_tools)
project_dir = "./.."

executable("chip-shell") {
sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp",
"main.cpp",
]
sources = [ "main.cpp" ]

deps = [
"${chip_root}/src/lib/shell",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ namespace chip {
namespace app {
namespace Clusters {
namespace TemperatureControl {
static SupportedTemperatureLevelsIterator * sInstance = nullptr;
static SupportedTemperatureLevelsIteratorDelegate * sInstance = nullptr;

SupportedTemperatureLevelsIterator * SupportedTemperatureLevelsIterator::GetInstance()
SupportedTemperatureLevelsIteratorDelegate * SupportedTemperatureLevelsIteratorDelegate::GetInstance()
{
return sInstance;
}

void SupportedTemperatureLevelsIterator::SetInstance(SupportedTemperatureLevelsIterator * instance)
void SupportedTemperatureLevelsIteratorDelegate::SetInstance(SupportedTemperatureLevelsIteratorDelegate * instance)
{
sInstance = instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class SupportedTemperatureLevelsIteratorDelegate

virtual CHIP_ERROR Next(chip::MutableCharSpan & item) = 0;

static SupportedTemperatureLevelsIteratorDelegate * GetInstance();

static void SetInstance(SupportedTemperatureLevelsIteratorDelegate * instance);

protected:
EndpointId mEndpoint;
uint8_t mIndex;
Expand Down

0 comments on commit c009659

Please sign in to comment.