blob: 533fb23aac79b5ac477694519010d874b30a8580 [file] [log] [blame]
#include "DeviceTypes.h"
#include "FakeAttributeAccess.h"
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/callback.h>
#include <app/data-model/Nullable.h>
#include <app/util/attribute-storage.h>
#include <app/util/config.h>
#include <app/util/endpoint-config-api.h>
#include <devices/Types.h>
#include <lib/core/DataModelTypes.h>
#include <lib/support/CHIPMem.h> // For chip::Platform
using chip::app::DataModel::Nullable;
using namespace chef;
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
#ifdef MATTER_DM_PLUGIN_AIR_QUALITY_SERVER
#include "chef-air-quality.h"
#endif // MATTER_DM_PLUGIN_AIR_QUALITY_SERVER
#if defined(MATTER_DM_PLUGIN_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_OZONE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_PM2__5_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_FORMALDEHYDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_PM1_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER)
#include "chef-concentration-measurement.h"
#endif
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
#include "resource-monitoring/chef-resource-monitoring-delegates.h"
#endif
#if defined(MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER) || defined(MATTER_DM_PLUGIN_RVC_CLEAN_MODE_SERVER)
#include "chef-rvc-mode-delegate.h"
#endif
#ifdef MATTER_DM_PLUGIN_REFRIGERATOR_AND_TEMPERATURE_CONTROLLED_CABINET_MODE_SERVER
#include "refrigerator-and-temperature-controlled-cabinet-mode/tcc-mode.h"
#endif // MATTER_DM_PLUGIN_REFRIGERATOR_AND_TEMPERATURE_CONTROLLED_CABINET_MODE_SERVER
#ifdef MATTER_DM_PLUGIN_PUMP_CONFIGURATION_AND_CONTROL_SERVER
#ifdef MATTER_DM_PLUGIN_ON_OFF_SERVER
#include "chef-pump.h"
#endif // MATTER_DM_PLUGIN_ON_OFF_SERVER
#endif // MATTER_DM_PLUGIN_PUMP_CONFIGURATION_AND_CONTROL_SERVER
#if MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT > 0
#include <app/clusters/identify-server/identify-server.h>
namespace {
// TODO: Move this to a standalone cluster cpp file.
constexpr size_t kIdentifyTableSize = MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT;
static_assert(kIdentifyTableSize <= kEmberInvalidEndpointIndex, "Identify table size error");
std::unique_ptr<struct Identify> gIdentifyInstanceTable[kIdentifyTableSize];
void InitIdentifyCluster()
{
const uint16_t endpointCount = emberAfEndpointCount();
for (uint16_t endpointIndex = 0; endpointIndex < endpointCount; endpointIndex++)
{
chip::EndpointId endpointId = emberAfEndpointFromIndex(endpointIndex);
if (endpointId == kInvalidEndpointId)
{
continue;
}
// Check if endpoint has Identify cluster enabled
uint16_t epIndex = emberAfGetClusterServerEndpointIndex(endpointId, chip::app::Clusters::Identify::Id,
MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT);
if (epIndex >= kIdentifyTableSize)
continue;
gIdentifyInstanceTable[epIndex] =
std::make_unique<struct Identify>(endpointId, nullptr, nullptr, chip::app::Clusters::Identify::IdentifyTypeEnum::kNone);
}
}
} // namespace
#endif // MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT
#if MATTER_DM_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT > 0
#include "content-launch/chef-content-launch-delegate.h"
#endif // MATTER_DM_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT
#if MATTER_DM_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT > 0
#include "application-basic/chef-application-basic-delegate.h"
#endif // MATTER_DM_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT
#if MATTER_DM_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT > 0
#include "application-launch/chef-application-launch-delegate.h"
#endif // MATTER_DM_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT
namespace {
// Please refer to https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces
constexpr const uint8_t kNamespaceRefrigerator = 0x41;
// Refrigerator Namespace: 0x41, tag 0x00 (Refrigerator)
constexpr const uint8_t kTagRefrigerator = 0x00;
// Refrigerator Namespace: 0x41, tag 0x01 (Freezer)
constexpr const uint8_t kTagFreezer = 0x01;
const Clusters::Descriptor::Structs::SemanticTagStruct::Type gRefrigeratorTagList[] = { { .namespaceID = kNamespaceRefrigerator,
.tag = kTagRefrigerator } };
const Clusters::Descriptor::Structs::SemanticTagStruct::Type gFreezerTagList[] = { { .namespaceID = kNamespaceRefrigerator,
.tag = kTagFreezer } };
} // namespace
namespace PostionSemanticTag {
constexpr const uint8_t kNamespace = 0x08; // Common Position Namespace
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kLeft = { .namespaceID = kNamespace, .tag = 0x00 };
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kRight = { .namespaceID = kNamespace, .tag = 0x01 };
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kTop = { .namespaceID = kNamespace, .tag = 0x02 };
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kBottom = { .namespaceID = kNamespace, .tag = 0x03 };
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kMiddle = { .namespaceID = kNamespace, .tag = 0x04 };
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kTopTagList[] = { PostionSemanticTag::kTop };
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kLeftTagList[] = { PostionSemanticTag::kLeft };
} // namespace PostionSemanticTag
namespace NumberSemanticTag {
constexpr const uint8_t kNamespace = 0x07; // Common Number Namespace
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kOne = { .namespaceID = kNamespace, .tag = 0x01 };
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kTwo = { .namespaceID = kNamespace, .tag = 0x02 };
} // namespace NumberSemanticTag
namespace GenericSwitch { // Tag lists for rootnode_genericswitch_9866e35d0b app
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kEp1TagList[] = { PostionSemanticTag::kTop, NumberSemanticTag::kOne };
const Clusters::Descriptor::Structs::SemanticTagStruct::Type kEp2TagList[] = { PostionSemanticTag::kBottom,
NumberSemanticTag::kTwo };
} // namespace GenericSwitch
#ifdef MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER
#include "chef-rvc-operational-state-delegate.h"
#endif
#ifdef MATTER_DM_PLUGIN_DISHWASHER_MODE_SERVER
#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_FAN_CONTROL_SERVER
#include "chef-fan-control-manager.h"
#endif // MATTER_DM_PLUGIN_FAN_CONTROL_SERVER
#ifdef MATTER_DM_PLUGIN_TEMPERATURE_CONTROL_SERVER
#include "temperature-control/static-supported-temperature-levels.h"
#endif // MATTER_DM_PLUGIN_TEMPERATURE_CONTROL_SERVER
#ifdef MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
#include "window-covering/chef-window-covering.h"
#endif // MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
#ifdef MATTER_DM_PLUGIN_OVEN_MODE_SERVER
#include "oven-mode/chef-oven-mode.h"
#endif // MATTER_DM_PLUGIN_OVEN_MODE_SERVER
#ifdef MATTER_DM_PLUGIN_OVEN_CAVITY_OPERATIONAL_STATE_SERVER
#include "oven-cavity-operational-state/chef-oven-cavity-operational-state.h"
#endif // MATTER_DM_PLUGIN_OVEN_CAVITY_OPERATIONAL_STATE_SERVER
#ifdef MATTER_DM_PLUGIN_MICROWAVE_OVEN_MODE_SERVER
#include "microwave-oven-mode/chef-microwave-oven-mode.h"
#endif // MATTER_DM_PLUGIN_MICROWAVE_OVEN_MODE_SERVER
#ifdef MATTER_DM_PLUGIN_MICROWAVE_OVEN_CONTROL_SERVER
#include "microwave-oven-control/chef-microwave-oven-control.h"
#endif // MATTER_DM_PLUGIN_MICROWAVE_OVEN_CONTROL_SERVER
#if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT > 0
#include "laundry-dryer-controls/chef-laundry-dryer-controls-delegate.h"
#endif // #if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT
Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength)
{
switch (clusterId)
{
#ifdef MATTER_DM_PLUGIN_AIR_QUALITY_SERVER
case chip::app::Clusters::AirQuality::Id:
return chefAirQualityReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
#endif
#if defined(MATTER_DM_PLUGIN_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_OZONE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_PM2__5_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_FORMALDEHYDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_PM1_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER)
case chip::app::Clusters::CarbonMonoxideConcentrationMeasurement::Id:
case chip::app::Clusters::CarbonDioxideConcentrationMeasurement::Id:
case chip::app::Clusters::NitrogenDioxideConcentrationMeasurement::Id:
case chip::app::Clusters::OzoneConcentrationMeasurement::Id:
case chip::app::Clusters::FormaldehydeConcentrationMeasurement::Id:
case chip::app::Clusters::Pm1ConcentrationMeasurement::Id:
case chip::app::Clusters::Pm25ConcentrationMeasurement::Id:
case chip::app::Clusters::Pm10ConcentrationMeasurement::Id:
case chip::app::Clusters::RadonConcentrationMeasurement::Id:
case chip::app::Clusters::TotalVolatileOrganicCompoundsConcentrationMeasurement::Id:
return chefConcentrationMeasurementReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
#endif
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
case chip::app::Clusters::HepaFilterMonitoring::Id:
case chip::app::Clusters::ActivatedCarbonFilterMonitoring::Id:
return chefResourceMonitoringExternalReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
#endif
#ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER
case chip::app::Clusters::RvcRunMode::Id:
return chefRvcRunModeReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
#endif
#ifdef MATTER_DM_PLUGIN_RVC_CLEAN_MODE_SERVER
case chip::app::Clusters::RvcCleanMode::Id:
return chefRvcCleanModeReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
#endif
#ifdef MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER
case chip::app::Clusters::RvcOperationalState::Id:
return chefRvcOperationalStateReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
#endif
#ifdef MATTER_DM_PLUGIN_REFRIGERATOR_AND_TEMPERATURE_CONTROLLED_CABINET_MODE_SERVER
case chip::app::Clusters::RefrigeratorAndTemperatureControlledCabinetMode::Id:
return chefRefrigeratorAndTemperatureControlledCabinetModeExternalReadCallback(endpoint, clusterId, attributeMetadata,
buffer, maxReadLength);
#endif
#ifdef MATTER_DM_PLUGIN_DISHWASHER_MODE_SERVER
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);
#endif // MATTER_DM_PLUGIN_OPERATIONAL_STATE_SERVER
default:
break;
}
return Protocols::InteractionModel::Status::Success;
}
/*
*
Thread 3 "rootnode_airqua" hit Breakpoint 1, emberAfExternalAttributeWriteCallback (endpoint=1, clusterId=91,
attributeMetadata=0x555555791f30 <(anonymous namespace)::generatedAttributes+1904>, buffer=0x7ffff68464ac "\001")
at /home/erwinpan/matter/erwinpan1/master_1124_airqualitysensor/examples/chef/common/stubs.cpp:22
(gdb) p *attributeMetadata
$1 = {defaultValue = {ptrToDefaultValue = 0x0, defaultValue = 0, ptrToMinMaxValue = 0x0}, attributeId = 0, size = 1, attributeType =
48 '0', mask = 16 '\020'} (gdb)
*/
Protocols::InteractionModel::Status emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer)
{
switch (clusterId)
{
#ifdef MATTER_DM_PLUGIN_AIR_QUALITY_SERVER
case chip::app::Clusters::AirQuality::Id:
return chefAirQualityWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
#endif
#if defined(MATTER_DM_PLUGIN_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_OZONE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_PM2__5_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_FORMALDEHYDE_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_PM1_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER) || \
defined(MATTER_DM_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER)
case chip::app::Clusters::CarbonMonoxideConcentrationMeasurement::Id:
case chip::app::Clusters::CarbonDioxideConcentrationMeasurement::Id:
case chip::app::Clusters::NitrogenDioxideConcentrationMeasurement::Id:
case chip::app::Clusters::OzoneConcentrationMeasurement::Id:
case chip::app::Clusters::FormaldehydeConcentrationMeasurement::Id:
case chip::app::Clusters::Pm1ConcentrationMeasurement::Id:
case chip::app::Clusters::Pm25ConcentrationMeasurement::Id:
case chip::app::Clusters::Pm10ConcentrationMeasurement::Id:
case chip::app::Clusters::RadonConcentrationMeasurement::Id:
case chip::app::Clusters::TotalVolatileOrganicCompoundsConcentrationMeasurement::Id:
return chefConcentrationMeasurementWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
#endif
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
case chip::app::Clusters::HepaFilterMonitoring::Id:
case chip::app::Clusters::ActivatedCarbonFilterMonitoring::Id:
return chefResourceMonitoringExternalWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
#endif
#ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER
case chip::app::Clusters::RvcRunMode::Id:
return chefRvcRunModeWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
#endif
#ifdef MATTER_DM_PLUGIN_RVC_CLEAN_MODE_SERVER
case chip::app::Clusters::RvcCleanMode::Id:
return chefRvcCleanModeWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
#endif
#ifdef MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER
case chip::app::Clusters::RvcOperationalState::Id:
return chefRvcOperationalStateWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
#endif
#ifdef MATTER_DM_PLUGIN_REFRIGERATOR_AND_TEMPERATURE_CONTROLLED_CABINET_MODE_SERVER
case chip::app::Clusters::RefrigeratorAndTemperatureControlledCabinetMode::Id:
return chefRefrigeratorAndTemperatureControlledCabinetModeExternalWriteCallback(endpoint, clusterId, attributeMetadata,
buffer);
#endif
#ifdef MATTER_DM_PLUGIN_DISHWASHER_MODE_SERVER
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);
#endif // MATTER_DM_PLUGIN_OPERATIONAL_STATE_SERVER
default:
break;
}
return Protocols::InteractionModel::Status::Success;
}
void emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId) {}
void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
uint8_t * value)
{
ClusterId clusterId = attributePath.mClusterId;
AttributeId attributeId = attributePath.mAttributeId;
ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));
if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "OnOff attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", ChipLogValueMEI(attributeId),
type, *value, size);
#ifdef MATTER_DM_PLUGIN_FAN_CONTROL_SERVER // Handle OnOff for fan
#ifdef MATTER_DM_PLUGIN_ON_OFF_SERVER
HandleOnOffAttributeChangeForFan(attributePath.mEndpointId, bool(*value));
#endif // MATTER_DM_PLUGIN_ON_OFF_SERVER
#endif // MATTER_DM_PLUGIN_FAN_CONTROL_SERVER
#ifdef MATTER_DM_PLUGIN_PUMP_CONFIGURATION_AND_CONTROL_SERVER
#ifdef MATTER_DM_PLUGIN_ON_OFF_SERVER
if (chef::DeviceTypes::EndpointHasDeviceType(attributePath.mEndpointId, Device::kPumpDeviceTypeId))
{
chef::pump::postOnOff(attributePath.mEndpointId, bool(*value));
}
#endif // #ifdef MATTER_DM_PLUGIN_ON_OFF_SERVER
#endif // MATTER_DM_PLUGIN_PUMP_CONFIGURATION_AND_CONTROL_SERVER
}
else if (clusterId == LevelControl::Id)
{
ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u",
ChipLogValueMEI(attributeId), type, *value, size);
#ifdef MATTER_DM_PLUGIN_PUMP_CONFIGURATION_AND_CONTROL_SERVER
#ifdef MATTER_DM_PLUGIN_ON_OFF_SERVER
#ifdef MATTER_DM_PLUGIN_LEVEL_CONTROL_SERVER
if (chef::DeviceTypes::EndpointHasDeviceType(attributePath.mEndpointId, Device::kPumpDeviceTypeId))
{
chef::pump::postMoveToLevel(attributePath.mEndpointId, *value);
}
#endif // MATTER_DM_PLUGIN_LEVEL_CONTROL_SERVER
#endif // #ifdef MATTER_DM_PLUGIN_ON_OFF_SERVER
#endif // MATTER_DM_PLUGIN_PUMP_CONFIGURATION_AND_CONTROL_SERVER
// WIP Apply attribute change to Light
}
#ifdef MATTER_DM_PLUGIN_FAN_CONTROL_SERVER
else if (clusterId == FanControl::Id)
{
HandleFanControlAttributeChange(attributeId, type, size, value);
}
#endif // MATTER_DM_PLUGIN_FAN_CONTROL_SERVER
}
/** @brief OnOff Cluster Init
*
* This function is called when a specific cluster is initialized. It gives the
* application an opportunity to take care of cluster initialization procedures.
* It is called exactly once for each endpoint where cluster is present.
*
* TODO Issue #3841
* emberAfOnOffClusterInitCallback happens before the stack initialize the cluster
* attributes to the default value.
* The logic here expects something similar to the deprecated Plugins callback
* emberAfPluginOnOffClusterServerPostInitCallback.
*
*/
void emberAfOnOffClusterInitCallback(EndpointId endpoint) {}
#ifdef MATTER_DM_PLUGIN_CHANNEL_SERVER
#include "channel/ChannelManager.h"
static ChannelManager channelManager[MATTER_DM_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT];
void emberAfChannelClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: Channel::SetDefaultDelegate");
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Channel::Id, MATTER_DM_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT);
if (ep < MATTER_DM_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT)
{
channelManager[ep].SetEndpoint(endpoint);
Channel::SetDefaultDelegate(endpoint, &channelManager[ep]);
}
}
#endif
#ifdef MATTER_DM_PLUGIN_KEYPAD_INPUT_SERVER
#include "keypad-input/KeypadInputManager.h"
static KeypadInputManager keypadInputManager[MATTER_DM_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT];
void emberAfKeypadInputClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: KeypadInput::SetDefaultDelegate");
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, KeypadInput::Id, MATTER_DM_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT);
KeypadInput::SetDefaultDelegate(endpoint, &keypadInputManager[ep]);
}
#endif
#ifdef MATTER_DM_PLUGIN_LOW_POWER_SERVER
#include "low-power/LowPowerManager.h"
static LowPowerManager lowPowerManager[MATTER_DM_LOW_POWER_CLUSTER_SERVER_ENDPOINT_COUNT];
void emberAfLowPowerClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: LowPower::SetDefaultDelegate");
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, LowPower::Id, MATTER_DM_LOW_POWER_CLUSTER_SERVER_ENDPOINT_COUNT);
LowPower::SetDefaultDelegate(endpoint, &lowPowerManager[ep]);
}
#endif
#ifdef MATTER_DM_PLUGIN_TARGET_NAVIGATOR_SERVER
#include "target-navigator/TargetNavigatorManager.h"
static TargetNavigatorManager targetNavigatorManager[MATTER_DM_TARGET_NAVIGATOR_CLUSTER_SERVER_ENDPOINT_COUNT];
void emberAfTargetNavigatorClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: TargetNavigator::SetDefaultDelegate");
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, TargetNavigator::Id,
MATTER_DM_TARGET_NAVIGATOR_CLUSTER_SERVER_ENDPOINT_COUNT);
TargetNavigator::SetDefaultDelegate(endpoint, &targetNavigatorManager[ep]);
}
#endif
#ifdef MATTER_DM_PLUGIN_WAKE_ON_LAN_SERVER
#include "wake-on-lan/WakeOnLanManager.h"
static WakeOnLanManager wakeOnLanManager;
void emberAfWakeOnLanClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: WakeOnLanManager::SetDefaultDelegate");
WakeOnLan::SetDefaultDelegate(endpoint, &wakeOnLanManager);
}
#endif
/**
* This initializer is for the application having refrigerator on EP1 and child
* temperatureControlledCabinet endpoints on EP2 and EP3.
*/
void RefrigeratorTemperatureControlledCabinetInit()
{
EndpointId kRefEndpointId = DeviceTypes::ExpectedEndpointId::kRefrigerator;
EndpointId kColdCabinetEndpointId = DeviceTypes::ExpectedEndpointId::kColdCabinetPartOfRefrigerator;
EndpointId kFreezeCabinetEndpointId = DeviceTypes::ExpectedEndpointId::kFreezeCabinetPartOfRefrigerator;
if (!DeviceTypes::EndpointHasDeviceType(kRefEndpointId, Device::kRefrigeratorDeviceTypeId))
{
return;
}
ChipLogDetail(NotSpecified, "Refrigerator device type on EP: %d", kRefEndpointId);
TEMPORARY_RETURN_IGNORED SetTreeCompositionForEndpoint(kRefEndpointId);
if (DeviceTypes::EndpointHasDeviceType(kColdCabinetEndpointId, Device::kTemperatureControlledCabinetDeviceTypeId))
{
ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kColdCabinetEndpointId);
TEMPORARY_RETURN_IGNORED SetParentEndpointForEndpoint(kColdCabinetEndpointId, kRefEndpointId);
TEMPORARY_RETURN_IGNORED SetTagList(
kColdCabinetEndpointId, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(gRefrigeratorTagList));
}
if (DeviceTypes::EndpointHasDeviceType(kFreezeCabinetEndpointId, Device::kTemperatureControlledCabinetDeviceTypeId))
{
ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kFreezeCabinetEndpointId);
TEMPORARY_RETURN_IGNORED SetParentEndpointForEndpoint(kFreezeCabinetEndpointId, kRefEndpointId);
TEMPORARY_RETURN_IGNORED SetTagList(kFreezeCabinetEndpointId,
Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(gFreezerTagList));
}
}
/**
* This initializer is for the application having cooktop. The cooktop can be a part of an oven
* or standalone cooktop.
* Standalone Cooktop: Cooktop on EP1 and optional CookSurface on EP2.
* Cooktop part of Oven: Oven on EP1, Cooktop on EP3 and optional CookSurface on EP4.
*/
void CooktopCookSurfaceInit(EndpointId kCooktopEpId)
{
TEMPORARY_RETURN_IGNORED SetTreeCompositionForEndpoint(kCooktopEpId);
switch (kCooktopEpId)
{
case DeviceTypes::ExpectedEndpointId::kCooktopStandAlone:
if (DeviceTypes::EndpointHasDeviceType(kCooktopEpId, Device::kCooktopDeviceTypeId))
{
ChipLogDetail(NotSpecified, "Cooktop device type on EP: %d", kCooktopEpId);
EndpointId kCookSurfaceEpId = DeviceTypes::ExpectedEndpointId::kCookSurfacePartOfCooktop;
if (DeviceTypes::EndpointHasDeviceType(kCookSurfaceEpId, Device::kCookSurfaceDeviceTypeId))
{
ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId);
TEMPORARY_RETURN_IGNORED SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId);
TEMPORARY_RETURN_IGNORED SetTagList(
kCookSurfaceEpId,
Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(PostionSemanticTag::kLeftTagList));
}
}
break;
case DeviceTypes::ExpectedEndpointId::kCooktopPartOfOven:
EndpointId kOvenEpId = DeviceTypes::ExpectedEndpointId::kOven;
if (DeviceTypes::EndpointHasDeviceType(kCooktopEpId, Device::kCooktopDeviceTypeId) &&
DeviceTypes::EndpointHasDeviceType(kOvenEpId, Device::kOvenDeviceTypeId))
{
ChipLogDetail(NotSpecified, "Cooktop device type on EP: %d", kCooktopEpId);
TEMPORARY_RETURN_IGNORED SetParentEndpointForEndpoint(kCooktopEpId, kOvenEpId);
EndpointId kCookSurfaceEpId = DeviceTypes::ExpectedEndpointId::kCookSurfacePartOfCooktopOven;
if (DeviceTypes::EndpointHasDeviceType(kCookSurfaceEpId, Device::kCookSurfaceDeviceTypeId))
{
ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId);
TEMPORARY_RETURN_IGNORED SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId);
TEMPORARY_RETURN_IGNORED SetTagList(
kCookSurfaceEpId,
Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(PostionSemanticTag::kLeftTagList));
}
}
}
}
/**
* This initializer is for the application having oven on EP1 and child endpoints -
* temperatureControlledCabinet on EP2, cooktop on EP3 and cooksurface on EP4.
*/
void OvenTemperatureControlledCabinetCooktopCookSurfaceInit()
{
EndpointId kOvenEpId = DeviceTypes::ExpectedEndpointId::kOven;
EndpointId kTemperatureControlledCabinetEpId = DeviceTypes::ExpectedEndpointId::kTopCabinetPartOfOven;
EndpointId kCooktopEpId = DeviceTypes::ExpectedEndpointId::kCooktopPartOfOven;
if (!DeviceTypes::EndpointHasDeviceType(kOvenEpId, Device::kOvenDeviceTypeId))
{
return;
}
ChipLogDetail(NotSpecified, "Oven device type on EP: %d", kOvenEpId);
TEMPORARY_RETURN_IGNORED SetTreeCompositionForEndpoint(kOvenEpId);
if (DeviceTypes::EndpointHasDeviceType(kTemperatureControlledCabinetEpId, Device::kTemperatureControlledCabinetDeviceTypeId))
{
ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId);
TEMPORARY_RETURN_IGNORED SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId);
TEMPORARY_RETURN_IGNORED SetTagList(
kTemperatureControlledCabinetEpId,
Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(PostionSemanticTag::kTopTagList));
#ifdef MATTER_DM_PLUGIN_OVEN_CAVITY_OPERATIONAL_STATE_SERVER
Clusters::OvenCavityOperationalState::InitChefOvenCavityOperationalStateCluster();
#endif // MATTER_DM_PLUGIN_OVEN_CAVITY_OPERATIONAL_STATE_SERVER
}
CooktopCookSurfaceInit(kCooktopEpId);
}
/**
* This initializer is for the generic switch application rootnode_genericswitch_9866e35d0b. To not have this initialiser affect
* new generic switch chef app, use a different set of endpoints.
*/
void GenericSwitchInit()
{
if (DeviceTypes::EndpointHasDeviceType(1, Device::kGenericSwitchDeviceTypeId))
{
LogErrorOnFailure(SetTagList(1, Span(GenericSwitch::kEp1TagList)));
}
if (DeviceTypes::EndpointHasDeviceType(2, Device::kGenericSwitchDeviceTypeId))
{
LogErrorOnFailure(SetTagList(2, Span(GenericSwitch::kEp2TagList)));
}
}
/**
* This initializer is for the laundry dryer application rootnode_laundrydryer_01796fe396. To not have this initialiser affect
* new laundry dryer chef apps, use a different endpoint.
*/
void LaundryDryerInit()
{
static bool called = false;
VerifyOrDieWithMsg(!called, Zcl, "Error: LaundryDryerInit called more than once");
called = true;
#if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT > 0
// Only initialises Laundry Dryer Controls. Other clusters are initialised through ember calls.
if (DeviceTypes::EndpointHasDeviceType(1, Device::kLaundryDryerDeviceTypeId))
{
Platform::New<LaundryDryerControls::Chef::ChefDelegate>()->Register(1);
}
#endif // #if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT
}
/*
* This initializer is for the casting video player application rootnode_castingvideoplayer_contentapp_34699714e7. To not have this
* initialiser affect new apps video player device types, use different endpoints.
*/
void CastingvideoplayerContentappInit()
{
static bool called = false;
VerifyOrDieWithMsg(!called, Zcl, "Error: CastingvideoplayerContentappInit called more than once");
called = true;
#if (MATTER_DM_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT > 0) && \
(MATTER_DM_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT > 0) && \
(MATTER_DM_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT > 0)
chip::EndpointId kPlatformEndpoint = 1;
chip::EndpointId kAppAEndpoint = 2;
static constexpr uint16_t kAllowedVendorList[] = { 0xFFF1 };
if (!DeviceTypes::EndpointHasDeviceType(kPlatformEndpoint, Device::kCastingVideoPlayerDeviceTypeId) ||
!DeviceTypes::EndpointHasDeviceType(kAppAEndpoint, Device::kContentAppDeviceTypeId))
{
return;
}
ChipLogProgress(NotSpecified, "This is a Casting Video Player Platform");
// Content Launcher Delegates
Platform::New<ContentLauncher::Chef::ChefDelegate>(kPlatformEndpoint)->Register();
Platform::New<ContentLauncher::Chef::ChefDelegate>(kAppAEndpoint)->Register();
// App basic delegates
ApplicationBasic::Chef::ChefDelegate * appABasic =
Platform::New<ApplicationBasic::Chef::ChefDelegate>(kAppAEndpoint, // Endpoint ID
"TEST_VENDOR", // vendorName
0xFFF1, // catalogVendorId
"Application_A_ID", // applicationId
"Application_A_Name", // applicationName
"Version_1", // applicationVersion
Span<const uint16_t>(kAllowedVendorList), // allowedVendorList
32768 // productId
);
appABasic->Register();
// Application Launcher Delegates
ApplicationLauncher::Chef::PlatformDelegate * platformLauncher =
Platform::New<ApplicationLauncher::Chef::PlatformDelegate>(kPlatformEndpoint, Span<const uint16_t>(kAllowedVendorList));
platformLauncher->Register();
ApplicationLauncher::Chef::AppDelegate * appALauncher =
Platform::New<ApplicationLauncher::Chef::AppDelegate>(kAppAEndpoint, appABasic);
appALauncher->Register();
VerifyOrDie(platformLauncher->AddAppDelegate(appALauncher) == CHIP_NO_ERROR);
appALauncher->setPlatformDelegate(platformLauncher);
#endif
}
void ApplicationInit()
{
ChipLogProgress(NotSpecified, "Chef Application Init !!!");
RefrigeratorTemperatureControlledCabinetInit();
OvenTemperatureControlledCabinetCooktopCookSurfaceInit();
GenericSwitchInit();
LaundryDryerInit();
CastingvideoplayerContentappInit();
#ifdef MATTER_DM_PLUGIN_PUMP_CONFIGURATION_AND_CONTROL_SERVER
#ifdef MATTER_DM_PLUGIN_ON_OFF_SERVER
chef::pump::init();
#endif // MATTER_DM_PLUGIN_ON_OFF_SERVER
#endif // MATTER_DM_PLUGIN_PUMP_CONFIGURATION_AND_CONTROL_SERVER
#ifdef MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
ChipLogProgress(NotSpecified, "Initializing WindowCovering cluster delegate.");
ChefWindowCovering::InitChefWindowCoveringCluster();
#endif // MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
#ifdef MATTER_DM_PLUGIN_OVEN_MODE_SERVER
ChipLogProgress(NotSpecified, "Initializing OvenMode cluster.");
ChefOvenMode::InitChefOvenModeCluster();
#endif // MATTER_DM_PLUGIN_OVEN_MODE_SERVER
#ifdef MATTER_DM_PLUGIN_MICROWAVE_OVEN_MODE_SERVER
ChipLogProgress(NotSpecified, "Initializing MicrowaveOvenMode cluster.");
ChefMicrowaveOvenMode::InitChefMicrowaveOvenModeCluster();
#endif // MATTER_DM_PLUGIN_MICROWAVE_OVEN_MODE_SERVER
#ifdef MATTER_DM_PLUGIN_MICROWAVE_OVEN_CONTROL_SERVER
ChipLogProgress(NotSpecified, "Initializing MicrowaveOvenControl cluster.");
InitChefMicrowaveOvenControlCluster();
#endif // MATTER_DM_PLUGIN_MICROWAVE_OVEN_CONTROL_SERVER
#if MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT > 0
InitIdentifyCluster();
#endif // MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT
chip::app::Clusters::Chef::RegisterAttributeAccessor();
}
void ApplicationShutdown()
{
ChipLogProgress(NotSpecified, "Chef Application Down !!!");
}
// No-op function, used to force linking this file,
// instead of the weak functions from other files
extern "C" void chef_include_stubs_impl(void) {}