Skip to content

Commit

Permalink
Decouple ember functions from general diagnostics cluster (project-ch…
Browse files Browse the repository at this point in the history
…ip#37001)

* Decouple ember functions from general diagnostics cluster

* Optimize flash cost

* Add compile flag for each command

* Address review comments
  • Loading branch information
yufengwangca authored Jan 18, 2025
1 parent 9e23d47 commit 593861d
Show file tree
Hide file tree
Showing 8 changed files with 600 additions and 314 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,65 +577,6 @@ Protocols::InteractionModel::Status DispatchServerCommand(CommandHandler * apCom

} // namespace FaultInjection

namespace GeneralDiagnostics {

Protocols::InteractionModel::Status DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath,
TLV::TLVReader & aDataTlv)
{
CHIP_ERROR TLVError = CHIP_NO_ERROR;
bool wasHandled = false;
{
switch (aCommandPath.mCommandId)
{
case Commands::TestEventTrigger::Id: {
Commands::TestEventTrigger::DecodableType commandData;
TLVError = DataModel::Decode(aDataTlv, commandData);
if (TLVError == CHIP_NO_ERROR)
{
wasHandled = emberAfGeneralDiagnosticsClusterTestEventTriggerCallback(apCommandObj, aCommandPath, commandData);
}
break;
}
case Commands::TimeSnapshot::Id: {
Commands::TimeSnapshot::DecodableType commandData;
TLVError = DataModel::Decode(aDataTlv, commandData);
if (TLVError == CHIP_NO_ERROR)
{
wasHandled = emberAfGeneralDiagnosticsClusterTimeSnapshotCallback(apCommandObj, aCommandPath, commandData);
}
break;
}
case Commands::PayloadTestRequest::Id: {
Commands::PayloadTestRequest::DecodableType commandData;
TLVError = DataModel::Decode(aDataTlv, commandData);
if (TLVError == CHIP_NO_ERROR)
{
wasHandled = emberAfGeneralDiagnosticsClusterPayloadTestRequestCallback(apCommandObj, aCommandPath, commandData);
}
break;
}
default: {
// Unrecognized command ID, error status will apply.
ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI,
ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId));
return Protocols::InteractionModel::Status::UnsupportedCommand;
}
}
}

if (CHIP_NO_ERROR != TLVError || !wasHandled)
{
ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format());
return Protocols::InteractionModel::Status::InvalidCommand;
}

// We use success as a marker that no special handling is required
// This is to avoid having a std::optional which uses slightly more code.
return Protocols::InteractionModel::Status::Success;
}

} // namespace GeneralDiagnostics

namespace GroupKeyManagement {

Protocols::InteractionModel::Status DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath,
Expand Down Expand Up @@ -1975,9 +1916,6 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV:
case Clusters::FaultInjection::Id:
errorStatus = Clusters::FaultInjection::DispatchServerCommand(apCommandObj, aCommandPath, aReader);
break;
case Clusters::GeneralDiagnostics::Id:
errorStatus = Clusters::GeneralDiagnostics::DispatchServerCommand(apCommandObj, aCommandPath, aReader);
break;
case Clusters::GroupKeyManagement::Id:
errorStatus = Clusters::GroupKeyManagement::DispatchServerCommand(apCommandObj, aCommandPath, aReader);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,3 +586,264 @@
#define ZCL_USING_FAULT_INJECTION_CLUSTER_SERVER
#define MATTER_DM_PLUGIN_FAULT_INJECTION_SERVER
#define MATTER_DM_PLUGIN_FAULT_INJECTION

/**** Cluster Commands Flag ****/
// ActivatedCarbonFilterMonitoring Cluster Commands
#define ACTIVATED_CARBON_FILTER_MONITORING_ENABLE_RESET_CONDITION_CMD 1

// AdministratorCommissioning Cluster Commands
#define ADMINISTRATOR_COMMISSIONING_ENABLE_OPEN_COMMISSIONING_WINDOW_CMD 1
#define ADMINISTRATOR_COMMISSIONING_ENABLE_OPEN_BASIC_COMMISSIONING_WINDOW_CMD 1
#define ADMINISTRATOR_COMMISSIONING_ENABLE_REVOKE_COMMISSIONING_CMD 1

// BooleanStateConfiguration Cluster Commands
#define BOOLEAN_STATE_CONFIGURATION_ENABLE_SUPPRESS_ALARM_CMD 1
#define BOOLEAN_STATE_CONFIGURATION_ENABLE_ENABLE_DISABLE_ALARM_CMD 1

// ColorControl Cluster Commands
#define COLOR_CONTROL_ENABLE_MOVE_TO_HUE_CMD 1
#define COLOR_CONTROL_ENABLE_MOVE_HUE_CMD 1
#define COLOR_CONTROL_ENABLE_STEP_HUE_CMD 1
#define COLOR_CONTROL_ENABLE_MOVE_TO_SATURATION_CMD 1
#define COLOR_CONTROL_ENABLE_MOVE_SATURATION_CMD 1
#define COLOR_CONTROL_ENABLE_STEP_SATURATION_CMD 1
#define COLOR_CONTROL_ENABLE_MOVE_TO_HUE_AND_SATURATION_CMD 1
#define COLOR_CONTROL_ENABLE_MOVE_TO_COLOR_CMD 1
#define COLOR_CONTROL_ENABLE_MOVE_COLOR_CMD 1
#define COLOR_CONTROL_ENABLE_STEP_COLOR_CMD 1
#define COLOR_CONTROL_ENABLE_MOVE_TO_COLOR_TEMPERATURE_CMD 1
#define COLOR_CONTROL_ENABLE_ENHANCED_MOVE_TO_HUE_CMD 1
#define COLOR_CONTROL_ENABLE_ENHANCED_MOVE_HUE_CMD 1
#define COLOR_CONTROL_ENABLE_ENHANCED_STEP_HUE_CMD 1
#define COLOR_CONTROL_ENABLE_ENHANCED_MOVE_TO_HUE_AND_SATURATION_CMD 1
#define COLOR_CONTROL_ENABLE_COLOR_LOOP_SET_CMD 1
#define COLOR_CONTROL_ENABLE_STOP_MOVE_STEP_CMD 1
#define COLOR_CONTROL_ENABLE_MOVE_COLOR_TEMPERATURE_CMD 1
#define COLOR_CONTROL_ENABLE_STEP_COLOR_TEMPERATURE_CMD 1

// DeviceEnergyManagement Cluster Commands
#define DEVICE_ENERGY_MANAGEMENT_ENABLE_POWER_ADJUST_REQUEST_CMD 1
#define DEVICE_ENERGY_MANAGEMENT_ENABLE_CANCEL_POWER_ADJUST_REQUEST_CMD 1
#define DEVICE_ENERGY_MANAGEMENT_ENABLE_START_TIME_ADJUST_REQUEST_CMD 1
#define DEVICE_ENERGY_MANAGEMENT_ENABLE_PAUSE_REQUEST_CMD 1
#define DEVICE_ENERGY_MANAGEMENT_ENABLE_RESUME_REQUEST_CMD 1
#define DEVICE_ENERGY_MANAGEMENT_ENABLE_MODIFY_FORECAST_REQUEST_CMD 1
#define DEVICE_ENERGY_MANAGEMENT_ENABLE_REQUEST_CONSTRAINT_BASED_FORECAST_CMD 1
#define DEVICE_ENERGY_MANAGEMENT_ENABLE_CANCEL_REQUEST_CMD 1

// DeviceEnergyManagementMode Cluster Commands
#define DEVICE_ENERGY_MANAGEMENT_MODE_ENABLE_CHANGE_TO_MODE_CMD 1

// DiagnosticLogs Cluster Commands
#define DIAGNOSTIC_LOGS_ENABLE_RETRIEVE_LOGS_REQUEST_CMD 1

// DishwasherAlarm Cluster Commands
#define DISHWASHER_ALARM_ENABLE_RESET_CMD 1
#define DISHWASHER_ALARM_ENABLE_MODIFY_ENABLED_ALARMS_CMD 1

// DishwasherMode Cluster Commands
#define DISHWASHER_MODE_ENABLE_CHANGE_TO_MODE_CMD 1

// EnergyEvse Cluster Commands
#define ENERGY_EVSE_ENABLE_DISABLE_CMD 1
#define ENERGY_EVSE_ENABLE_ENABLE_CHARGING_CMD 1
#define ENERGY_EVSE_ENABLE_ENABLE_DISCHARGING_CMD 1
#define ENERGY_EVSE_ENABLE_START_DIAGNOSTICS_CMD 1
#define ENERGY_EVSE_ENABLE_SET_TARGETS_CMD 1
#define ENERGY_EVSE_ENABLE_GET_TARGETS_CMD 1
#define ENERGY_EVSE_ENABLE_CLEAR_TARGETS_CMD 1

// EnergyEvseMode Cluster Commands
#define ENERGY_EVSE_MODE_ENABLE_CHANGE_TO_MODE_CMD 1

// EthernetNetworkDiagnostics Cluster Commands
#define ETHERNET_NETWORK_DIAGNOSTICS_ENABLE_RESET_COUNTS_CMD 1

// FanControl Cluster Commands
#define FAN_CONTROL_ENABLE_STEP_CMD 1

// FaultInjection Cluster Commands
#define FAULT_INJECTION_ENABLE_FAIL_AT_FAULT_CMD 1
#define FAULT_INJECTION_ENABLE_FAIL_RANDOMLY_AT_FAULT_CMD 1

// GeneralCommissioning Cluster Commands
#define GENERAL_COMMISSIONING_ENABLE_ARM_FAIL_SAFE_CMD 1
#define GENERAL_COMMISSIONING_ENABLE_SET_REGULATORY_CONFIG_CMD 1
#define GENERAL_COMMISSIONING_ENABLE_COMMISSIONING_COMPLETE_CMD 1

// GeneralDiagnostics Cluster Commands
#define GENERAL_DIAGNOSTICS_ENABLE_TEST_EVENT_TRIGGER_CMD 1
#define GENERAL_DIAGNOSTICS_ENABLE_TIME_SNAPSHOT_CMD 1
#define GENERAL_DIAGNOSTICS_ENABLE_PAYLOAD_TEST_REQUEST_CMD 1

// GroupKeyManagement Cluster Commands
#define GROUP_KEY_MANAGEMENT_ENABLE_KEY_SET_WRITE_CMD 1
#define GROUP_KEY_MANAGEMENT_ENABLE_KEY_SET_READ_CMD 1
#define GROUP_KEY_MANAGEMENT_ENABLE_KEY_SET_REMOVE_CMD 1
#define GROUP_KEY_MANAGEMENT_ENABLE_KEY_SET_READ_ALL_INDICES_CMD 1

// Groups Cluster Commands
#define GROUPS_ENABLE_ADD_GROUP_CMD 1
#define GROUPS_ENABLE_VIEW_GROUP_CMD 1
#define GROUPS_ENABLE_GET_GROUP_MEMBERSHIP_CMD 1
#define GROUPS_ENABLE_REMOVE_GROUP_CMD 1
#define GROUPS_ENABLE_REMOVE_ALL_GROUPS_CMD 1
#define GROUPS_ENABLE_ADD_GROUP_IF_IDENTIFYING_CMD 1

// HepaFilterMonitoring Cluster Commands
#define HEPA_FILTER_MONITORING_ENABLE_RESET_CONDITION_CMD 1

// Identify Cluster Commands
#define IDENTIFY_ENABLE_IDENTIFY_CMD 1
#define IDENTIFY_ENABLE_TRIGGER_EFFECT_CMD 1

// LaundryWasherMode Cluster Commands
#define LAUNDRY_WASHER_MODE_ENABLE_CHANGE_TO_MODE_CMD 1

// LevelControl Cluster Commands
#define LEVEL_CONTROL_ENABLE_MOVE_TO_LEVEL_CMD 1
#define LEVEL_CONTROL_ENABLE_MOVE_CMD 1
#define LEVEL_CONTROL_ENABLE_STEP_CMD 1
#define LEVEL_CONTROL_ENABLE_STOP_CMD 1
#define LEVEL_CONTROL_ENABLE_MOVE_TO_LEVEL_WITH_ON_OFF_CMD 1
#define LEVEL_CONTROL_ENABLE_MOVE_WITH_ON_OFF_CMD 1
#define LEVEL_CONTROL_ENABLE_STEP_WITH_ON_OFF_CMD 1
#define LEVEL_CONTROL_ENABLE_STOP_WITH_ON_OFF_CMD 1

// LowPower Cluster Commands
#define LOW_POWER_ENABLE_SLEEP_CMD 1

// ModeSelect Cluster Commands
#define MODE_SELECT_ENABLE_CHANGE_TO_MODE_CMD 1

// NetworkCommissioning Cluster Commands
#define NETWORK_COMMISSIONING_ENABLE_SCAN_NETWORKS_CMD 1
#define NETWORK_COMMISSIONING_ENABLE_ADD_OR_UPDATE_WI_FI_NETWORK_CMD 1
#define NETWORK_COMMISSIONING_ENABLE_ADD_OR_UPDATE_THREAD_NETWORK_CMD 1
#define NETWORK_COMMISSIONING_ENABLE_REMOVE_NETWORK_CMD 1
#define NETWORK_COMMISSIONING_ENABLE_CONNECT_NETWORK_CMD 1
#define NETWORK_COMMISSIONING_ENABLE_REORDER_NETWORK_CMD 1

// OtaSoftwareUpdateRequestor Cluster Commands
#define OTA_SOFTWARE_UPDATE_REQUESTOR_ENABLE_ANNOUNCE_OTA_PROVIDER_CMD 1

// OnOff Cluster Commands
#define ON_OFF_ENABLE_OFF_CMD 1
#define ON_OFF_ENABLE_ON_CMD 1
#define ON_OFF_ENABLE_TOGGLE_CMD 1
#define ON_OFF_ENABLE_OFF_WITH_EFFECT_CMD 1
#define ON_OFF_ENABLE_ON_WITH_RECALL_GLOBAL_SCENE_CMD 1
#define ON_OFF_ENABLE_ON_WITH_TIMED_OFF_CMD 1

// OperationalCredentials Cluster Commands
#define OPERATIONAL_CREDENTIALS_ENABLE_ATTESTATION_REQUEST_CMD 1
#define OPERATIONAL_CREDENTIALS_ENABLE_CERTIFICATE_CHAIN_REQUEST_CMD 1
#define OPERATIONAL_CREDENTIALS_ENABLE_CSR_REQUEST_CMD 1
#define OPERATIONAL_CREDENTIALS_ENABLE_ADD_NOC_CMD 1
#define OPERATIONAL_CREDENTIALS_ENABLE_UPDATE_NOC_CMD 1
#define OPERATIONAL_CREDENTIALS_ENABLE_UPDATE_FABRIC_LABEL_CMD 1
#define OPERATIONAL_CREDENTIALS_ENABLE_REMOVE_FABRIC_CMD 1
#define OPERATIONAL_CREDENTIALS_ENABLE_ADD_TRUSTED_ROOT_CERTIFICATE_CMD 1

// OperationalState Cluster Commands
#define OPERATIONAL_STATE_ENABLE_PAUSE_CMD 1
#define OPERATIONAL_STATE_ENABLE_STOP_CMD 1
#define OPERATIONAL_STATE_ENABLE_START_CMD 1
#define OPERATIONAL_STATE_ENABLE_RESUME_CMD 1

// OvenCavityOperationalState Cluster Commands
#define OVEN_CAVITY_OPERATIONAL_STATE_ENABLE_PAUSE_CMD 1
#define OVEN_CAVITY_OPERATIONAL_STATE_ENABLE_STOP_CMD 1
#define OVEN_CAVITY_OPERATIONAL_STATE_ENABLE_START_CMD 1
#define OVEN_CAVITY_OPERATIONAL_STATE_ENABLE_RESUME_CMD 1

// OvenMode Cluster Commands
#define OVEN_MODE_ENABLE_CHANGE_TO_MODE_CMD 1

// RvcCleanMode Cluster Commands
#define RVC_CLEAN_MODE_ENABLE_CHANGE_TO_MODE_CMD 1

// RvcOperationalState Cluster Commands
#define RVC_OPERATIONAL_STATE_ENABLE_PAUSE_CMD 1
#define RVC_OPERATIONAL_STATE_ENABLE_RESUME_CMD 1
#define RVC_OPERATIONAL_STATE_ENABLE_GO_HOME_CMD 1

// RvcRunMode Cluster Commands
#define RVC_RUN_MODE_ENABLE_CHANGE_TO_MODE_CMD 1

// RefrigeratorAndTemperatureControlledCabinetMode Cluster Commands
#define REFRIGERATOR_AND_TEMPERATURE_CONTROLLED_CABINET_MODE_ENABLE_CHANGE_TO_MODE_CMD 1

// ScenesManagement Cluster Commands
#define SCENES_MANAGEMENT_ENABLE_ADD_SCENE_CMD 1
#define SCENES_MANAGEMENT_ENABLE_VIEW_SCENE_CMD 1
#define SCENES_MANAGEMENT_ENABLE_REMOVE_SCENE_CMD 1
#define SCENES_MANAGEMENT_ENABLE_REMOVE_ALL_SCENES_CMD 1
#define SCENES_MANAGEMENT_ENABLE_STORE_SCENE_CMD 1
#define SCENES_MANAGEMENT_ENABLE_RECALL_SCENE_CMD 1
#define SCENES_MANAGEMENT_ENABLE_GET_SCENE_MEMBERSHIP_CMD 1
#define SCENES_MANAGEMENT_ENABLE_COPY_SCENE_CMD 1

// SmokeCoAlarm Cluster Commands
#define SMOKE_CO_ALARM_ENABLE_SELF_TEST_REQUEST_CMD 1

// SoftwareDiagnostics Cluster Commands
#define SOFTWARE_DIAGNOSTICS_ENABLE_RESET_WATERMARKS_CMD 1

// TemperatureControl Cluster Commands
#define TEMPERATURE_CONTROL_ENABLE_SET_TEMPERATURE_CMD 1

// Thermostat Cluster Commands
#define THERMOSTAT_ENABLE_SETPOINT_RAISE_LOWER_CMD 1
#define THERMOSTAT_ENABLE_SET_ACTIVE_SCHEDULE_REQUEST_CMD 1
#define THERMOSTAT_ENABLE_SET_ACTIVE_PRESET_REQUEST_CMD 1
#define THERMOSTAT_ENABLE_ATOMIC_REQUEST_CMD 1

// ThreadNetworkDiagnostics Cluster Commands
#define THREAD_NETWORK_DIAGNOSTICS_ENABLE_RESET_COUNTS_CMD 1

// TimeSynchronization Cluster Commands
#define TIME_SYNCHRONIZATION_ENABLE_SET_UTC_TIME_CMD 1
#define TIME_SYNCHRONIZATION_ENABLE_SET_TRUSTED_TIME_SOURCE_CMD 1
#define TIME_SYNCHRONIZATION_ENABLE_SET_TIME_ZONE_CMD 1
#define TIME_SYNCHRONIZATION_ENABLE_SET_DST_OFFSET_CMD 1
#define TIME_SYNCHRONIZATION_ENABLE_SET_DEFAULT_NTP_CMD 1

// UnitTesting Cluster Commands
#define UNIT_TESTING_ENABLE_TEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_NOT_HANDLED_CMD 1
#define UNIT_TESTING_ENABLE_TEST_SPECIFIC_CMD 1
#define UNIT_TESTING_ENABLE_TEST_ADD_ARGUMENTS_CMD 1
#define UNIT_TESTING_ENABLE_TEST_STRUCT_ARGUMENT_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_NESTED_STRUCT_ARGUMENT_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_LIST_STRUCT_ARGUMENT_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_LIST_INT8_U_ARGUMENT_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_NESTED_STRUCT_LIST_ARGUMENT_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_LIST_NESTED_STRUCT_LIST_ARGUMENT_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_LIST_INT8_U_REVERSE_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_ENUMS_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_NULLABLE_OPTIONAL_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_SIMPLE_STRUCT_ECHO_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TIMED_INVOKE_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_SIMPLE_OPTIONAL_ARGUMENT_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_EMIT_TEST_EVENT_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_EMIT_TEST_FABRIC_SCOPED_EVENT_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_BATCH_HELPER_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_SECOND_BATCH_HELPER_REQUEST_CMD 1
#define UNIT_TESTING_ENABLE_TEST_DIFFERENT_VENDOR_MEI_REQUEST_CMD 1

// ValveConfigurationAndControl Cluster Commands
#define VALVE_CONFIGURATION_AND_CONTROL_ENABLE_OPEN_CMD 1
#define VALVE_CONFIGURATION_AND_CONTROL_ENABLE_CLOSE_CMD 1

// WiFiNetworkDiagnostics Cluster Commands
#define WI_FI_NETWORK_DIAGNOSTICS_ENABLE_RESET_COUNTS_CMD 1

// WindowCovering Cluster Commands
#define WINDOW_COVERING_ENABLE_UP_OR_OPEN_CMD 1
#define WINDOW_COVERING_ENABLE_DOWN_OR_CLOSE_CMD 1
#define WINDOW_COVERING_ENABLE_STOP_MOTION_CMD 1
#define WINDOW_COVERING_ENABLE_GO_TO_LIFT_VALUE_CMD 1
#define WINDOW_COVERING_ENABLE_GO_TO_LIFT_PERCENTAGE_CMD 1
#define WINDOW_COVERING_ENABLE_GO_TO_TILT_VALUE_CMD 1
#define WINDOW_COVERING_ENABLE_GO_TO_TILT_PERCENTAGE_CMD 1
Loading

0 comments on commit 593861d

Please sign in to comment.