Skip to content

Commit

Permalink
Merge branch 'master' into Silabs_Identiy_endpoints_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak-Shaha authored Oct 28, 2024
2 parents 6ef5f28 + 928efd7 commit aa4c17f
Show file tree
Hide file tree
Showing 117 changed files with 13,271 additions and 2,647 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: ghcr.io/project-chip/chip-build-efr32:85
image: ghcr.io/project-chip/chip-build-efr32:89
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@
[submodule "third_party/lwip/repo"]
path = third_party/lwip/repo
url = https://github.com/lwip-tcpip/lwip.git
excluded-platforms = darwin
[submodule "third_party/abseil-cpp/src"]
path = third_party/abseil-cpp/src
url = https://github.com/abseil/abseil-cpp.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ const CharSpan LaundryWasherControlDelegate::spinSpeedsNameOptions[] = {
};

const NumberOfRinsesEnum LaundryWasherControlDelegate::supportRinsesOptions[] = {
NumberOfRinsesEnum::kNone,
NumberOfRinsesEnum::kNormal,
NumberOfRinsesEnum::kExtra,
NumberOfRinsesEnum::kMax,
};

LaundryWasherControlDelegate LaundryWasherControlDelegate::instance;
Expand Down
57 changes: 57 additions & 0 deletions examples/chef/common/chef-laundry-washer-mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ template <typename T>
using List = chip::app::DataModel::List<T>;
using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::Type;

#ifdef MATTER_DM_PLUGIN_LAUNDRY_WASHER_MODE_SERVER
static LaundryWasherModeDelegate * gLaundryWasherModeDelegate = nullptr;
static ModeBase::Instance * gLaundryWasherModeInstance = nullptr;

Expand Down Expand Up @@ -94,6 +95,61 @@ void LaundryWasherMode::Shutdown()
}
}

chip::Protocols::InteractionModel::Status chefLaundryWasherModeWriteCallback(chip::EndpointId endpointId, chip::ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer)
{
VerifyOrReturnError(endpointId == 1 || gLaundryWasherModeInstance != nullptr,
chip::Protocols::InteractionModel::Status::Failure);

chip::Protocols::InteractionModel::Status ret;
chip::AttributeId attributeId = attributeMetadata->attributeId;

switch (attributeId)
{
case chip::app::Clusters::LaundryWasherMode::Attributes::CurrentMode::Id: {
uint8_t m = buffer[0];
ret = gLaundryWasherModeInstance->UpdateCurrentMode(m);
if (chip::Protocols::InteractionModel::Status::Success != ret)
{
ChipLogError(DeviceLayer, "Invalid Attribute Update status: %d", static_cast<int>(ret));
}
}
break;
default:
ret = chip::Protocols::InteractionModel::Status::UnsupportedWrite;
ChipLogError(DeviceLayer, "Unsupported Attribute ID: %d", static_cast<int>(attributeId));
break;
}

return ret;
}

chip::Protocols::InteractionModel::Status chefLaundryWasherModeReadCallback(chip::EndpointId endpointId, chip::ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength)
{
VerifyOrReturnValue(maxReadLength > 0, chip::Protocols::InteractionModel::Status::ResourceExhausted);

chip::Protocols::InteractionModel::Status ret = chip::Protocols::InteractionModel::Status::Success;
chip::AttributeId attributeId = attributeMetadata->attributeId;

switch (attributeId)
{
case chip::app::Clusters::LaundryWasherMode::Attributes::CurrentMode::Id: {
*buffer = gLaundryWasherModeInstance->GetCurrentMode();
ChipLogDetail(DeviceLayer, "Reading LaundryWasherMode CurrentMode : %d", static_cast<int>(attributeId));
}
break;
default:
ret = chip::Protocols::InteractionModel::Status::UnsupportedRead;
ChipLogDetail(DeviceLayer, "Unsupported attributeId %d from reading RvcCleanMode", static_cast<int>(attributeId));
break;
}

return ret;
}

void emberAfLaundryWasherModeClusterInitCallback(chip::EndpointId endpointId)
{
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
Expand All @@ -103,3 +159,4 @@ void emberAfLaundryWasherModeClusterInitCallback(chip::EndpointId endpointId)
new ModeBase::Instance(gLaundryWasherModeDelegate, 0x1, LaundryWasherMode::Id, chip::to_underlying(Feature::kOnOff));
gLaundryWasherModeInstance->Init();
}
#endif // MATTER_DM_PLUGIN_LAUNDRY_WASHER_MODE_SERVER
9 changes: 9 additions & 0 deletions examples/chef/common/chef-laundry-washer-mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ void Shutdown();
} // namespace Clusters
} // namespace app
} // namespace chip

#ifdef MATTER_DM_PLUGIN_LAUNDRY_WASHER_MODE_SERVER
chip::Protocols::InteractionModel::Status chefLaundryWasherModeWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer);
chip::Protocols::InteractionModel::Status chefLaundryWasherModeReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength);
#endif // MATTER_DM_PLUGIN_LAUNDRY_WASHER_MODE_SERVER
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
*
* Copyright (c) 2024 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>

#ifdef MATTER_DM_PLUGIN_TEMPERATURE_CONTROL_SERVER
#include "static-supported-temperature-levels.h"
#include <app/clusters/temperature-control-server/supported-temperature-levels-manager.h>

using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::TemperatureControl;
using chip::Protocols::InteractionModel::Status;

app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupportedTemperatureLevelsDelegate;

CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { "Low"_span, "Medium"_span, "High"_span };

const AppSupportedTemperatureLevelsDelegate::EndpointPair AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints
[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT] = { EndpointPair(
1 /* endpointId */, AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions,
ArraySize(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)) };

uint8_t AppSupportedTemperatureLevelsDelegate::Size()
{
for (auto & endpointPair : AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints)
{
if (endpointPair.mEndpointId == mEndpoint)
{
return endpointPair.mSize;
}
}
return 0;
}

CHIP_ERROR AppSupportedTemperatureLevelsDelegate::Next(MutableCharSpan & item)
{
for (auto & endpointPair : AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints)
{
if (endpointPair.mEndpointId == mEndpoint)
{
if (endpointPair.mSize > mIndex)
{
CHIP_ERROR err = CopyCharSpanToMutableCharSpan(endpointPair.mTemperatureLevels[mIndex], item);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "Error copying char span to mutable char span %s", ErrorStr(err));
return err;
}
mIndex++;
return CHIP_NO_ERROR;
}
}
}
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
}
void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint)
{
static_assert(MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT == 1, "This cluster is only enabled for endpoint 1");

chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate);
}
#endif // MATTER_DM_PLUGIN_TEMPERATURE_CONTROL_SERVER
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
*
* Copyright (c) 2024 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/config.h>

namespace chip {
namespace app {
namespace Clusters {
namespace TemperatureControl {

class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsIteratorDelegate
{
struct EndpointPair
{
EndpointId mEndpointId;
CharSpan * mTemperatureLevels;
uint8_t mSize;

EndpointPair(EndpointId aEndpointId, CharSpan * TemperatureLevels, uint8_t size) :
mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size)
{}
};

static CharSpan temperatureLevelOptions[3];
static const EndpointPair supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT];

public:
uint8_t Size() override;

CHIP_ERROR Next(MutableCharSpan & item) override;

~AppSupportedTemperatureLevelsDelegate() {}
};

} // namespace TemperatureControl
} // namespace Clusters
} // namespace app
} // namespace chip
20 changes: 20 additions & 0 deletions examples/chef/common/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,22 @@ const Clusters::Descriptor::Structs::SemanticTagStruct::Type freezerTagList[]
#include "chef-dishwasher-mode-delegate-impl.h"
#endif // MATTER_DM_PLUGIN_DISHWASHER_MODE_SERVER

#ifdef MATTER_DM_PLUGIN_LAUNDRY_WASHER_MODE_SERVER
#include "chef-laundry-washer-mode.h"
#endif // MATTER_DM_PLUGIN_LAUNDRY_WASHER_MODE_SERVER

#ifdef MATTER_DM_PLUGIN_LAUNDRY_WASHER_CONTROLS_SERVER
#include "chef-laundry-washer-controls-delegate-impl.h"
#endif // MATTER_DM_PLUGIN_LAUNDRY_WASHER_CONTROLS_SERVER

#ifdef MATTER_DM_PLUGIN_OPERATIONAL_STATE_SERVER
#include "chef-operational-state-delegate-impl.h"
#endif // MATTER_DM_PLUGIN_OPERATIONAL_STATE_SERVER

#ifdef MATTER_DM_PLUGIN_TEMPERATURE_CONTROL_SERVER
#include "temperature-control/static-supported-temperature-levels.h"
#endif // MATTER_DM_PLUGIN_TEMPERATURE_CONTROL_SERVER

Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength)
Expand Down Expand Up @@ -124,6 +136,10 @@ Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(Endpoin
case chip::app::Clusters::DishwasherMode::Id:
return chefDishwasherModeReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
#endif // MATTER_DM_PLUGIN_DISHWASHER_MODE_SERVER
#ifdef MATTER_DM_PLUGIN_LAUNDRY_WASHER_MODE_SERVER
case chip::app::Clusters::LaundryWasherMode::Id:
return chefLaundryWasherModeReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
#endif // MATTER_DM_PLUGIN_LAUNDRY_WASHER_MODE_SERVER
#ifdef MATTER_DM_PLUGIN_OPERATIONAL_STATE_SERVER
case chip::app::Clusters::OperationalState::Id:
return chefOperationalStateReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
Expand Down Expand Up @@ -202,6 +218,10 @@ Protocols::InteractionModel::Status emberAfExternalAttributeWriteCallback(Endpoi
case chip::app::Clusters::DishwasherMode::Id:
return chefDishwasherModeWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
#endif // MATTER_DM_PLUGIN_DISHWASHER_MODE_SERVER
#ifdef MATTER_DM_PLUGIN_LAUNDRY_WASHER_MODE_SERVER
case chip::app::Clusters::LaundryWasherMode::Id:
return chefLaundryWasherModeWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
#endif // MATTER_DM_PLUGIN_LAUNDRY_WASHER_MODE_SERVER
#ifdef MATTER_DM_PLUGIN_OPERATIONAL_STATE_SERVER
case chip::app::Clusters::OperationalState::Id:
return chefOperationalStateWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
Expand Down
Loading

0 comments on commit aa4c17f

Please sign in to comment.