diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 47908d654006e9..2e5432dd4ec03f 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -165,3 +165,6 @@ jobs: - name: Build example Lighting App (external platform) run: scripts/examples/esp_example.sh lighting-app sdkconfig.ext_plat.defaults + + - name: Build example Energy Management App + run: scripts/examples/esp_example.sh energy-management-app sdkconfig.defaults diff --git a/examples/energy-management-app/esp32/main/CMakeLists.txt b/examples/energy-management-app/esp32/main/CMakeLists.txt index 1c7f2a5b782948..414163514b86e0 100644 --- a/examples/energy-management-app/esp32/main/CMakeLists.txt +++ b/examples/energy-management-app/esp32/main/CMakeLists.txt @@ -50,6 +50,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/barrier-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/energy-evse-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/device-energy-management-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" diff --git a/examples/energy-management-app/esp32/main/main.cpp b/examples/energy-management-app/esp32/main/main.cpp index 77899a45b58d03..4da39d1e871502 100644 --- a/examples/energy-management-app/esp32/main/main.cpp +++ b/examples/energy-management-app/esp32/main/main.cpp @@ -16,6 +16,7 @@ */ #include "DeviceCallbacks.h" +#include #include #include #include @@ -74,9 +75,11 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; -static EnergyEvseDelegate * gDelegate = nullptr; -static EnergyEvseManager * gInstance = nullptr; +static EnergyEvseDelegate * gEvseDelegate = nullptr; +static EnergyEvseManager * gEvseInstance = nullptr; static EVSEManufacturer * gEvseManufacturer = nullptr; +static DeviceEnergyManagementDelegate * gDEMDelegate = nullptr; +static DeviceEnergyManagementManager * gDEMInstance = nullptr; #if CONFIG_ENABLE_ESP_INSIGHTS_TRACE extern const char insights_auth_key_start[] asm("_binary_insights_auth_key_txt_start"); @@ -116,15 +119,40 @@ chip::Credentials::DeviceAttestationCredentialsProvider * get_dac_provider(void) } // namespace +EVSEManufacturer * EnergyEvse::GetEvseManufacturer() +{ + return gEvseManufacturer; +} + void ApplicationInit() { - if ((gDelegate == nullptr) && (gInstance == nullptr) && (gEvseManufacturer == nullptr)) + if ((gDEMDelegate == nullptr) && (gDEMInstance == nullptr)) + { + gDEMDelegate = new DeviceEnergyManagementDelegate(); + if (gDEMDelegate != nullptr) + { + gDEMInstance = new DeviceEnergyManagementManager( + EndpointId(ENERGY_EVSE_ENDPOINT), *gDEMDelegate, + BitMask( + DeviceEnergyManagement::Feature::kPowerAdjustment, DeviceEnergyManagement::Feature::kPowerForecastReporting, + DeviceEnergyManagement::Feature::kStateForecastReporting, DeviceEnergyManagement::Feature::kStartTimeAdjustment, + DeviceEnergyManagement::Feature::kPausable, DeviceEnergyManagement::Feature::kForecastAdjustment, + DeviceEnergyManagement::Feature::kConstraintBasedAdjustment)); + gDEMInstance->Init(); /* Register Attribute & Command handlers */ + } + } + else + { + ChipLogError(AppServer, "DEM Instance or Delegate already exist.") + } + + if ((gEvseDelegate == nullptr) && (gEvseInstance == nullptr) && (gEvseManufacturer == nullptr)) { - gDelegate = new EnergyEvseDelegate(); - if (gDelegate != nullptr) + gEvseDelegate = new EnergyEvseDelegate(); + if (gEvseDelegate != nullptr) { - gInstance = new EnergyEvseManager( - EndpointId(ENERGY_EVSE_ENDPOINT), *gDelegate, + gEvseInstance = new EnergyEvseManager( + EndpointId(ENERGY_EVSE_ENDPOINT), *gEvseDelegate, BitMask(EnergyEvse::Feature::kChargingPreferences, EnergyEvse::Feature::kPlugAndCharge, EnergyEvse::Feature::kRfid, EnergyEvse::Feature::kSoCReporting, EnergyEvse::Feature::kV2x), @@ -132,7 +160,7 @@ void ApplicationInit() OptionalAttributes::kSupportsRandomizationWindow, OptionalAttributes::kSupportsApproximateEvEfficiency), BitMask(OptionalCommands::kSupportsStartDiagnostics)); - gInstance->Init(); /* Register Attribute & Command handlers */ + gEvseInstance->Init(); /* Register Attribute & Command handlers */ } } else @@ -142,8 +170,8 @@ void ApplicationInit() if (gEvseManufacturer == nullptr) { - gEvseManufacturer = new EVSEManufacturer(); - gEvseManufacturer->Init(gInstance); + gEvseManufacturer = new EVSEManufacturer(gEvseInstance); + gEvseManufacturer->Init(); } else {