Skip to content

Commit

Permalink
Move emberAfClusterInitCallback out from callback-stub.cpp (#31474)
Browse files Browse the repository at this point in the history
* Move emberAfClusterInitCallback out from callback-stub.cpp

* fixes matter idl test
  • Loading branch information
wqx6 authored and pull[bot] committed Feb 22, 2024
1 parent 3514afd commit 1108912
Show file tree
Hide file tree
Showing 16 changed files with 365 additions and 333 deletions.
1 change: 1 addition & 0 deletions build/chip/esp32/esp32_codegen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ macro(chip_app_component_codegen IDL_NAME)
OUTPUTS
"app/PluginApplicationCallbacks.h"
"app/callback-stub.cpp"
"app/cluster-init-callback.cpp"
OUTPUT_PATH APP_GEN_DIR
OUTPUT_FILES APP_GEN_FILES
)
Expand Down
8 changes: 6 additions & 2 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ set(SRC_DIRS_LIST
"${CMAKE_CURRENT_LIST_DIR}"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/src"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common"
Expand All @@ -38,9 +40,11 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/air-quality-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/test-cluster-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/boolean-state-configuration-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/energy-evse-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fault-injection-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fan-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server"
Expand All @@ -56,6 +60,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/color-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-state-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/mode-select-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/mode-base-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/low-power-server"
Expand Down Expand Up @@ -90,9 +95,8 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-synchronization-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/valve-configuration-and-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/dishwasher-alarm-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-dryer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/electrical-energy-measurement-server"
)

Expand Down
1 change: 1 addition & 0 deletions scripts/py_matter_idl/files.gni
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import("//build_overrides/chip.gni")
# Templates used for generation
matter_idl_generator_templates = [
"${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/CallbackStubSource.jinja",
"${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/ClusterInitCallbackSource.jinja",
"${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja",
"${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/tlvmeta/TLVMetaData_cpp.jinja",
"${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/tlvmeta/TLVMetaData_h.jinja",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <lib/support/Span.h>
#include <protocols/interaction_model/Constants.h>

using namespace chip;

// Cluster Init Functions
void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
{
switch (clusterId)
{
{%- for name in clusters | sort(attribute='name') | map(attribute='name') | unique %}
case app::Clusters::{{name}}::Id:
emberAf{{name}}ClusterInitCallback(endpoint);
break;
{%- endfor %}
default:
// Unrecognized cluster ID
break;
}
}

{%- for name in clusters | sort(attribute='name') | map(attribute='name') | unique %}
void __attribute__((weak)) emberAf{{name}}ClusterInitCallback(EndpointId endpoint)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <lib/support/Span.h>
#include <protocols/interaction_model/Constants.h>

using namespace chip;

// Cluster Init Functions
void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
{
switch (clusterId)
{
{%- for name in clusters | sort(attribute='name') | map(attribute='name') | unique %}
case app::Clusters::{{name}}::Id:
emberAf{{name}}ClusterInitCallback(endpoint);
break;
{%- endfor %}
default:
// Unrecognized cluster ID
break;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@ def internal_render_all(self):
'clusters': server_side_clusters(self.idl)
}
)

self.internal_render_one_output(
template_path="ClusterInitCallbackSource.jinja",
output_file_name="app/cluster-init-callback.cpp",
vars={
'clusters': server_side_clusters(self.idl)
}
)
3 changes: 3 additions & 0 deletions scripts/py_matter_idl/matter_idl/tests/available_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,17 @@ cpp-app:
inputs/several_clusters.matter:
app/PluginApplicationCallbacks.h: outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h
app/callback-stub.cpp: outputs/several_clusters/cpp-app/callback-stub.cpp
app/cluster-init-callback.cpp: outputs/several_clusters/cpp-app/cluster-init-callback.cpp

inputs/large_all_clusters_app.matter:
app/PluginApplicationCallbacks.h: outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h
app/callback-stub.cpp: outputs/large_all_clusters_app/cpp-app/callback-stub.cpp
app/cluster-init-callback.cpp: outputs/large_all_clusters_app/cpp-app/cluster-init-callback.cpp

inputs/large_lighting_app.matter:
app/PluginApplicationCallbacks.h: outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h
app/callback-stub.cpp: outputs/large_lighting_app/cpp-app/callback-stub.cpp
app/cluster-init-callback.cpp: outputs/large_lighting_app/cpp-app/cluster-init-callback.cpp

cpp-tlvmeta:
inputs/cluster_with_commands.matter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,209 +1,6 @@
#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <lib/support/Span.h>
#include <protocols/interaction_model/Constants.h>

using namespace chip;

// Cluster Init Functions
void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
{
switch (clusterId)
{
case app::Clusters::AccessControl::Id:
emberAfAccessControlClusterInitCallback(endpoint);
break;
case app::Clusters::AccountLogin::Id:
emberAfAccountLoginClusterInitCallback(endpoint);
break;
case app::Clusters::Actions::Id:
emberAfActionsClusterInitCallback(endpoint);
break;
case app::Clusters::AdministratorCommissioning::Id:
emberAfAdministratorCommissioningClusterInitCallback(endpoint);
break;
case app::Clusters::ApplicationBasic::Id:
emberAfApplicationBasicClusterInitCallback(endpoint);
break;
case app::Clusters::ApplicationLauncher::Id:
emberAfApplicationLauncherClusterInitCallback(endpoint);
break;
case app::Clusters::AudioOutput::Id:
emberAfAudioOutputClusterInitCallback(endpoint);
break;
case app::Clusters::BarrierControl::Id:
emberAfBarrierControlClusterInitCallback(endpoint);
break;
case app::Clusters::BasicInformation::Id:
emberAfBasicInformationClusterInitCallback(endpoint);
break;
case app::Clusters::BinaryInputBasic::Id:
emberAfBinaryInputBasicClusterInitCallback(endpoint);
break;
case app::Clusters::Binding::Id:
emberAfBindingClusterInitCallback(endpoint);
break;
case app::Clusters::BooleanState::Id:
emberAfBooleanStateClusterInitCallback(endpoint);
break;
case app::Clusters::Channel::Id:
emberAfChannelClusterInitCallback(endpoint);
break;
case app::Clusters::ColorControl::Id:
emberAfColorControlClusterInitCallback(endpoint);
break;
case app::Clusters::ContentLauncher::Id:
emberAfContentLauncherClusterInitCallback(endpoint);
break;
case app::Clusters::Descriptor::Id:
emberAfDescriptorClusterInitCallback(endpoint);
break;
case app::Clusters::DiagnosticLogs::Id:
emberAfDiagnosticLogsClusterInitCallback(endpoint);
break;
case app::Clusters::DoorLock::Id:
emberAfDoorLockClusterInitCallback(endpoint);
break;
case app::Clusters::ElectricalMeasurement::Id:
emberAfElectricalMeasurementClusterInitCallback(endpoint);
break;
case app::Clusters::EthernetNetworkDiagnostics::Id:
emberAfEthernetNetworkDiagnosticsClusterInitCallback(endpoint);
break;
case app::Clusters::FanControl::Id:
emberAfFanControlClusterInitCallback(endpoint);
break;
case app::Clusters::FaultInjection::Id:
emberAfFaultInjectionClusterInitCallback(endpoint);
break;
case app::Clusters::FixedLabel::Id:
emberAfFixedLabelClusterInitCallback(endpoint);
break;
case app::Clusters::FlowMeasurement::Id:
emberAfFlowMeasurementClusterInitCallback(endpoint);
break;
case app::Clusters::GeneralCommissioning::Id:
emberAfGeneralCommissioningClusterInitCallback(endpoint);
break;
case app::Clusters::GeneralDiagnostics::Id:
emberAfGeneralDiagnosticsClusterInitCallback(endpoint);
break;
case app::Clusters::GroupKeyManagement::Id:
emberAfGroupKeyManagementClusterInitCallback(endpoint);
break;
case app::Clusters::Groups::Id:
emberAfGroupsClusterInitCallback(endpoint);
break;
case app::Clusters::Identify::Id:
emberAfIdentifyClusterInitCallback(endpoint);
break;
case app::Clusters::IlluminanceMeasurement::Id:
emberAfIlluminanceMeasurementClusterInitCallback(endpoint);
break;
case app::Clusters::KeypadInput::Id:
emberAfKeypadInputClusterInitCallback(endpoint);
break;
case app::Clusters::LevelControl::Id:
emberAfLevelControlClusterInitCallback(endpoint);
break;
case app::Clusters::LocalizationConfiguration::Id:
emberAfLocalizationConfigurationClusterInitCallback(endpoint);
break;
case app::Clusters::LowPower::Id:
emberAfLowPowerClusterInitCallback(endpoint);
break;
case app::Clusters::MatterScenes::Id:
emberAfMatterScenesClusterInitCallback(endpoint);
break;
case app::Clusters::MediaInput::Id:
emberAfMediaInputClusterInitCallback(endpoint);
break;
case app::Clusters::MediaPlayback::Id:
emberAfMediaPlaybackClusterInitCallback(endpoint);
break;
case app::Clusters::ModeSelect::Id:
emberAfModeSelectClusterInitCallback(endpoint);
break;
case app::Clusters::NetworkCommissioning::Id:
emberAfNetworkCommissioningClusterInitCallback(endpoint);
break;
case app::Clusters::OccupancySensing::Id:
emberAfOccupancySensingClusterInitCallback(endpoint);
break;
case app::Clusters::OnOff::Id:
emberAfOnOffClusterInitCallback(endpoint);
break;
case app::Clusters::OnOffSwitchConfiguration::Id:
emberAfOnOffSwitchConfigurationClusterInitCallback(endpoint);
break;
case app::Clusters::OperationalCredentials::Id:
emberAfOperationalCredentialsClusterInitCallback(endpoint);
break;
case app::Clusters::OtaSoftwareUpdateRequestor::Id:
emberAfOtaSoftwareUpdateRequestorClusterInitCallback(endpoint);
break;
case app::Clusters::PowerSource::Id:
emberAfPowerSourceClusterInitCallback(endpoint);
break;
case app::Clusters::PowerSourceConfiguration::Id:
emberAfPowerSourceConfigurationClusterInitCallback(endpoint);
break;
case app::Clusters::PressureMeasurement::Id:
emberAfPressureMeasurementClusterInitCallback(endpoint);
break;
case app::Clusters::PumpConfigurationAndControl::Id:
emberAfPumpConfigurationAndControlClusterInitCallback(endpoint);
break;
case app::Clusters::RelativeHumidityMeasurement::Id:
emberAfRelativeHumidityMeasurementClusterInitCallback(endpoint);
break;
case app::Clusters::SoftwareDiagnostics::Id:
emberAfSoftwareDiagnosticsClusterInitCallback(endpoint);
break;
case app::Clusters::Switch::Id:
emberAfSwitchClusterInitCallback(endpoint);
break;
case app::Clusters::TargetNavigator::Id:
emberAfTargetNavigatorClusterInitCallback(endpoint);
break;
case app::Clusters::TemperatureMeasurement::Id:
emberAfTemperatureMeasurementClusterInitCallback(endpoint);
break;
case app::Clusters::Thermostat::Id:
emberAfThermostatClusterInitCallback(endpoint);
break;
case app::Clusters::ThermostatUserInterfaceConfiguration::Id:
emberAfThermostatUserInterfaceConfigurationClusterInitCallback(endpoint);
break;
case app::Clusters::ThreadNetworkDiagnostics::Id:
emberAfThreadNetworkDiagnosticsClusterInitCallback(endpoint);
break;
case app::Clusters::TimeFormatLocalization::Id:
emberAfTimeFormatLocalizationClusterInitCallback(endpoint);
break;
case app::Clusters::UnitLocalization::Id:
emberAfUnitLocalizationClusterInitCallback(endpoint);
break;
case app::Clusters::UnitTesting::Id:
emberAfUnitTestingClusterInitCallback(endpoint);
break;
case app::Clusters::UserLabel::Id:
emberAfUserLabelClusterInitCallback(endpoint);
break;
case app::Clusters::WakeOnLan::Id:
emberAfWakeOnLanClusterInitCallback(endpoint);
break;
case app::Clusters::WiFiNetworkDiagnostics::Id:
emberAfWiFiNetworkDiagnosticsClusterInitCallback(endpoint);
break;
case app::Clusters::WindowCovering::Id:
emberAfWindowCoveringClusterInitCallback(endpoint);
break;
default:
// Unrecognized cluster ID
break;
}
}
void __attribute__((weak)) emberAfAccessControlClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
Expand Down
Loading

0 comments on commit 1108912

Please sign in to comment.