Skip to content

Commit 78d6af8

Browse files
committed
Added BUILD.gn arguments to enable different feature support. Updated README. Added test event triggers.
1 parent 0512e28 commit 78d6af8

File tree

5 files changed

+150
-15
lines changed

5 files changed

+150
-15
lines changed

examples/energy-management-app/silabs/BUILD.gn

+27
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ import("${examples_common_plat_dir}/args.gni")
4747
declare_args() {
4848
# Dump memory usage at link time.
4949
chip_print_memory_usage = false
50+
51+
# Enable test event triggers by default: Disable these in production devices
52+
chip_enable_energy_evse_trigger = true
53+
chip_enable_energy_reporting_trigger = true
54+
chip_enable_water_heater_management_trigger = true
55+
chip_enable_device_energy_management_trigger = true
56+
57+
# Device Energy Management feature support - only one of these can be true
58+
# or both can be disabled if forecasting is not supported
59+
chip_dem_support_power_forecast_reporting = true
60+
chip_dem_support_state_forecast_reporting = false
61+
62+
# Only one of these examples should be enabled
63+
chip_enable_example_evse_device = true
64+
chip_enable_example_water_heater_device = false
65+
5066
}
5167

5268
if (slc_generate) {
@@ -135,6 +151,17 @@ silabs_executable("energy-management-app") {
135151
include_dirs = [ "include" ]
136152
defines = []
137153

154+
defines += [
155+
"CHIP_DEVICE_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER=${chip_enable_energy_evse_trigger}",
156+
"CHIP_DEVICE_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER=${chip_enable_energy_reporting_trigger}",
157+
"CHIP_DEVICE_CONFIG_ENABLE_WATER_HEATER_MANAGEMENT_TRIGGER=${chip_enable_water_heater_management_trigger}",
158+
"CHIP_DEVICE_CONFIG_ENABLE_DEVICE_ENERGY_MANAGEMENT_TRIGGER=${chip_enable_device_energy_management_trigger}",
159+
"CHIP_DEVICE_CONFIG_DEM_SUPPORT_POWER_FORECAST_REPORTING=${chip_dem_support_power_forecast_reporting}",
160+
"CHIP_DEVICE_CONFIG_DEM_SUPPORT_STATE_FORECAST_REPORTING=${chip_dem_support_state_forecast_reporting}",
161+
"CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE=${chip_enable_example_evse_device}",
162+
"CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE=${chip_enable_example_water_heater_device}",
163+
]
164+
138165
if (silabs_board == "BRD2704A") {
139166
defines += [ "SL_STATUS_LED=0" ]
140167
}

examples/energy-management-app/silabs/README.md

+21-5
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24.
3333
## Introduction
3434

3535
The EFR32 Energy Management example provides a baseline demonstration of a EVSE
36-
device, built using Matter and the Silicon Labs gecko SDK. It can be controlled
37-
by a Chip controller over an Openthread or Wifi network..
36+
or Water Heater device, built using Matter and the Silicon Labs gecko SDK. It
37+
can be controlled by a Chip controller over an Openthread or Wifi network.
3838

3939
The EFR32 device can be commissioned over Bluetooth Low Energy where the device
4040
and the Chip controller will exchange security information with the Rendez-vous
@@ -45,9 +45,9 @@ If the LCD is enabled, the LCD on the Silabs WSTK shows a QR Code containing the
4545
needed commissioning information for the BLE connection and starting the
4646
Rendez-vous procedure.
4747

48-
The EVSE example is intended to serve both as a means to explore the workings of
49-
Matter as well as a template for creating real products based on the Silicon
50-
Labs platform.
48+
The EVSE and Water Heater examples are intended to serve both as a means to
49+
explore the workings of Matter Energy Management as well as a template for
50+
creating real products based on the Silicon Labs platform.
5151

5252
## Building
5353

@@ -99,9 +99,25 @@ Labs platform.
9999
$ git submodule update --init
100100
$ source third_party/connectedhomeip/scripts/activate.sh
101101
$ export SILABS_BOARD=BRD4187C
102+
103+
To build the EVSE example
104+
102105
$ gn gen out/debug
103106
$ ninja -C out/debug
104107

108+
To build the Water Heater example you can change the args to gn gen (see
109+
BUILD.gn for arg options)
110+
111+
$ gn gen out/debug --args='chip_enable_example_evse_device=false chip_enable_example_water_heater_device=true'
112+
$ ninja -C out/debug
113+
114+
To change Device Energy Management feature support (e.g. Power forecast or
115+
State forecast reporting), you can change the args to gn gen (see BUILD.gn
116+
for arg options)
117+
118+
$ gn gen out/debug --args='chip_dem_support_state_forecast_reporting=true chip_dem_support_power_forecast_reporting=false'
119+
$ ninja -C out/debug
120+
105121
- To delete generated executable, libraries and object files use:
106122

107123
$ cd ~/connectedhomeip/examples/energy-management-app/silabs

examples/energy-management-app/silabs/include/AppTask.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "AppEvent.h"
3030
#include "BaseApplication.h"
31-
#include "EnergyEvseManager.h"
31+
3232
#include "FreeRTOS.h"
3333
#include "timers.h" // provides FreeRTOS timer support
3434
#include <ble/BLEEndPoint.h>
@@ -80,7 +80,7 @@ class AppTask : public BaseApplication
8080

8181
private:
8282
static AppTask sAppTask;
83-
static void EvseActionEventHandler(AppEvent * aEvent);
83+
static void EnergyManagementActionEventHandler(AppEvent * aEvent);
8484

8585
static void UpdateClusterState(intptr_t context);
8686

examples/energy-management-app/silabs/src/AppTask.cpp

+99-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
#include "AppConfig.h"
2222
#include "AppEvent.h"
2323
#include "LEDWidget.h"
24+
#if CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
2425
#include <EnergyEvseMain.h>
26+
#endif
27+
#if CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
28+
#include <WaterHeaterMain.h>
29+
#endif
2530
#include <app-common/zap-generated/cluster-enums.h>
2631
#include <app-common/zap-generated/cluster-objects.h>
2732
#include <app-common/zap-generated/ids/Attributes.h>
@@ -43,6 +48,19 @@
4348

4449
#include <platform/CHIPDeviceLayer.h>
4550

51+
#if CONFIG_CHIP_DEVICE_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER
52+
#include <app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h>
53+
#endif
54+
#if CONFIG_CHIP_DEVICE_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER
55+
#include <app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h>
56+
#endif
57+
#if CONFIG_CHIP_DEVICE_CONFIG_ENABLE_WATER_HEATER_MANAGEMENT_TRIGGER
58+
#include <app/clusters/water-heater-management-server/WaterHeaterManagementTestEventTriggerHandler.h>
59+
#endif
60+
#if CONFIG_CHIP_DEVICE_CONFIG_ENABLE_DEVICE_ENERGY_MANAGEMENT_TRIGGER
61+
#include <app/clusters/device-energy-management-server/DeviceEnergyManagementTestEventTriggerHandler.h>
62+
#endif
63+
4664
#if (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))
4765
#define EVSE_LED 1
4866
#else
@@ -53,14 +71,15 @@
5371
#define APP_EVSE_SWITCH 1
5472

5573
namespace {
56-
LEDWidget sEvseLED;
74+
LEDWidget sEnergyManagementLED;
5775
}
5876

5977
using namespace chip;
6078
using namespace chip::app;
6179
using namespace chip::app::Clusters;
6280
using namespace chip::app::Clusters::DeviceEnergyManagement;
6381
using namespace chip::app::Clusters::DeviceEnergyManagement::Attributes;
82+
using namespace chip::app::Clusters::WaterHeaterManagement;
6483
using namespace ::chip::DeviceLayer;
6584
using namespace ::chip::DeviceLayer::Silabs;
6685
using namespace ::chip::DeviceLayer::Internal;
@@ -72,9 +91,21 @@ namespace Clusters {
7291
namespace DeviceEnergyManagement {
7392

7493
// Keep track of the parsed featureMap option
94+
#if (CHIP_DEVICE_CONFIG_DEM_SUPPORT_POWER_FORECAST_REPORTING) && (CHIP_DEVICE_CONFIG_DEM_SUPPORT_STATE_FORECAST_REPORTING)
95+
#error Cannot define CHIP_DEVICE_CONFIG_DEM_SUPPORT_POWER_FORECAST_REPORTING and CHIP_DEVICE_CONFIG_DEM_SUPPORT_STATE_FORECAST_REPORTING
96+
#endif
97+
98+
#if CHIP_DEVICE_CONFIG_DEM_SUPPORT_POWER_FORECAST_REPORTING
7599
static chip::BitMask<Feature> sFeatureMap(Feature::kPowerAdjustment, Feature::kPowerForecastReporting,
76-
Feature::kStateForecastReporting, Feature::kStartTimeAdjustment, Feature::kPausable,
77-
Feature::kForecastAdjustment, Feature::kConstraintBasedAdjustment);
100+
Feature::kStartTimeAdjustment, Feature::kPausable, Feature::kForecastAdjustment,
101+
Feature::kConstraintBasedAdjustment);
102+
#elif CHIP_DEVICE_CONFIG_DEM_SUPPORT_STATE_FORECAST_REPORTING
103+
static chip::BitMask<Feature> sFeatureMap(Feature::kPowerAdjustment, Feature::kStateForecastReporting,
104+
Feature::kStartTimeAdjustment, Feature::kPausable, Feature::kForecastAdjustment,
105+
Feature::kConstraintBasedAdjustment);
106+
#else
107+
static chip::BitMask<Feature> sFeatureMap(Feature::kPowerAdjustment);
108+
#endif
78109

79110
chip::BitMask<Feature> GetFeatureMapFromCmdLine()
80111
{
@@ -91,14 +122,33 @@ AppTask AppTask::sAppTask;
91122
void ApplicationInit()
92123
{
93124
chip::DeviceLayer::PlatformMgr().LockChipStack();
125+
SILABS_LOG("==================================================");
126+
#if CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
127+
SILABS_LOG("energy-management-example EVSE starting. featureMap 0x%08lx", DeviceEnergyManagement::sFeatureMap.Raw());
128+
94129
EvseApplicationInit();
95-
sEvseLED.Init(EVSE_LED);
130+
#endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
131+
132+
#if CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
133+
SILABS_LOG("energy-management-example WaterHeater starting. featureMap 0x%08lx", DeviceEnergyManagement::sFeatureMap.Raw());
134+
135+
FullWhmApplicationInit();
136+
#endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
137+
SILABS_LOG("==================================================");
138+
139+
sEnergyManagementLED.Init(EVSE_LED);
96140
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
97141
}
98142
void ApplicationShutdown()
99143
{
100144
chip::DeviceLayer::PlatformMgr().LockChipStack();
145+
#if CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
101146
EvseApplicationShutdown();
147+
#endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
148+
149+
#if CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
150+
FullWhmApplicationShutdown();
151+
#endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
102152
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
103153
}
104154

@@ -108,7 +158,11 @@ CHIP_ERROR AppTask::Init()
108158
chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler);
109159

110160
#ifdef DISPLAY_ENABLED
111-
GetLCD().Init((uint8_t *) "energy-management-App");
161+
#if CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
162+
GetLCD().Init((uint8_t *) "energy-management-App (EVSE)");
163+
#elif CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
164+
GetLCD().Init((uint8_t *) "energy-management-App (WaterHeater)");
165+
#endif
112166
#endif
113167

114168
err = BaseApplication::Init();
@@ -120,6 +174,44 @@ CHIP_ERROR AppTask::Init()
120174

121175
ApplicationInit();
122176

177+
#if (CONFIG_CHIP_DEVICE_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER) || (CONFIG_CHIP_DEVICE_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER) || \
178+
(CONFIG_CHIP_DEVICE_CONFIG_ENABLE_WATER_HEATER_MANAGEMENT_TRIGGER) || \
179+
(CONFIG_CHIP_DEVICE_CONFIG_ENABLE_DEVICE_ENERGY_MANAGEMENT_TRIGGER)
180+
TestEventTriggerDelegate * pTestEventDelegate = Server::GetInstance().GetTestEventTriggerDelegate();
181+
#endif
182+
183+
#if CONFIG_CHIP_DEVICE_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER
184+
static EnergyEvseTestEventTriggerHandler sEnergyEvseTestEventTriggerHandler;
185+
if (pTestEventDelegate != nullptr)
186+
{
187+
VerifyOrDie(pTestEventDelegate->AddHandler(&sEnergyEvseTestEventTriggerHandler) == CHIP_NO_ERROR);
188+
}
189+
#endif
190+
191+
#if CONFIG_CHIP_DEVICE_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER
192+
static EnergyReportingTestEventTriggerHandler sEnergyReportingTestEventTriggerHandler;
193+
if (pTestEventDelegate != nullptr)
194+
{
195+
VerifyOrDie(pTestEventDelegate->AddHandler(&sEnergyReportingTestEventTriggerHandler) == CHIP_NO_ERROR);
196+
}
197+
198+
#endif
199+
#if CONFIG_CHIP_DEVICE_CONFIG_ENABLE_WATER_HEATER_MANAGEMENT_TRIGGER
200+
static WaterHeaterManagementTestEventTriggerHandler sWaterHeaterManagementTestEventTriggerHandler;
201+
202+
if (pTestEventDelegate != nullptr)
203+
{
204+
VerifyOrDie(pTestEventDelegate->AddHandler(&sWaterHeaterManagementTestEventTriggerHandler) == CHIP_NO_ERROR);
205+
}
206+
#endif
207+
#if CONFIG_CHIP_DEVICE_CONFIG_ENABLE_DEVICE_ENERGY_MANAGEMENT_TRIGGER
208+
static DeviceEnergyManagementTestEventTriggerHandler sDeviceEnergyManagementTestEventTriggerHandler;
209+
if (pTestEventDelegate != nullptr)
210+
{
211+
VerifyOrDie(pTestEventDelegate->AddHandler(&sDeviceEnergyManagementTestEventTriggerHandler) == CHIP_NO_ERROR);
212+
}
213+
#endif
214+
123215
// Update the LCD with the Stored value. Show QR Code if not provisioned
124216
#ifdef DISPLAY_ENABLED
125217
GetLCD().WriteDemoUI(LightMgr().IsLightOn());
@@ -168,7 +260,7 @@ void AppTask::AppTaskMain(void * pvParameter)
168260
}
169261
}
170262

171-
void AppTask::EvseActionEventHandler(AppEvent * aEvent)
263+
void AppTask::EnergyManagementActionEventHandler(AppEvent * aEvent)
172264
{
173265
bool initiated = false;
174266
int32_t actor;
@@ -201,7 +293,7 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
201293

202294
if (button == APP_EVSE_SWITCH && btnAction == static_cast<uint8_t>(SilabsPlatform::ButtonAction::ButtonPressed))
203295
{
204-
button_event.Handler = EvseActionEventHandler;
296+
button_event.Handler = EnergyManagementActionEventHandler;
205297
AppTask::GetAppTask().PostEvent(&button_event);
206298
}
207299
else if (button == APP_FUNCTION_BUTTON)

examples/platform/esp32/common/Esp32AppServer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <app/TestEventTriggerDelegate.h>
2323
#include <app/clusters/network-commissioning/network-commissioning.h>
2424
#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
25-
#include <app/clusters/water-heater-management-server/WaterHeaterManagementTestEventTriggerHandler.h>
25+
2626
#include <app/server/Dnssd.h>
2727
#include <app/server/Server.h>
2828
#include <platform/ESP32/NetworkCommissioningDriver.h>

0 commit comments

Comments
 (0)