21
21
#include " AppConfig.h"
22
22
#include " AppEvent.h"
23
23
#include " LEDWidget.h"
24
+ #if SL_MATTER_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
24
25
#include < EnergyEvseMain.h>
26
+ #endif
27
+ #if SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
28
+ #include < WaterHeaterMain.h>
29
+ #endif
25
30
#include < app-common/zap-generated/cluster-enums.h>
26
31
#include < app-common/zap-generated/cluster-objects.h>
27
32
#include < app-common/zap-generated/ids/Attributes.h>
43
48
44
49
#include < platform/CHIPDeviceLayer.h>
45
50
51
+ #ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
52
+ #include < app/TestEventTriggerDelegate.h>
53
+
54
+ #if SL_MATTER_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER
55
+ #include < app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h>
56
+ #endif
57
+ #if SL_MATTER_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER
58
+ #include < app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h>
59
+ #endif
60
+ #if SL_MATTER_CONFIG_ENABLE_WATER_HEATER_MANAGEMENT_TRIGGER
61
+ #include < app/clusters/water-heater-management-server/WaterHeaterManagementTestEventTriggerHandler.h>
62
+ #endif
63
+ #if SL_MATTER_CONFIG_ENABLE_DEVICE_ENERGY_MANAGEMENT_TRIGGER
64
+ #include < app/clusters/device-energy-management-server/DeviceEnergyManagementTestEventTriggerHandler.h>
65
+ #endif
66
+
67
+ #endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
68
+
46
69
#if (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))
47
70
#define EVSE_LED 1
48
71
#else
53
76
#define APP_EVSE_SWITCH 1
54
77
55
78
namespace {
56
- LEDWidget sEvseLED ;
79
+ LEDWidget sEnergyManagementLED ;
57
80
}
58
81
59
82
using namespace chip ;
60
83
using namespace chip ::app;
61
84
using namespace chip ::app::Clusters;
62
85
using namespace chip ::app::Clusters::DeviceEnergyManagement;
63
86
using namespace chip ::app::Clusters::DeviceEnergyManagement::Attributes;
87
+ using namespace chip ::app::Clusters::WaterHeaterManagement;
64
88
using namespace ::chip::DeviceLayer;
65
89
using namespace ::chip::DeviceLayer::Silabs;
66
90
using namespace ::chip::DeviceLayer::Internal;
67
91
using namespace chip ::TLV;
68
92
93
+ #ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
94
+ static EnergyEvseTestEventTriggerHandler sEnergyEvseTestEventTriggerHandler ;
95
+ static EnergyReportingTestEventTriggerHandler sEnergyReportingTestEventTriggerHandler ;
96
+ static DeviceEnergyManagementTestEventTriggerHandler sDeviceEnergyManagementTestEventTriggerHandler ;
97
+ #endif
98
+
69
99
namespace chip {
70
100
namespace app {
71
101
namespace Clusters {
72
102
namespace DeviceEnergyManagement {
73
103
74
104
// Keep track of the parsed featureMap option
105
+ #if (SL_MATTER_CONFIG_DEM_SUPPORT_POWER_FORECAST_REPORTING) && (SL_MATTER_CONFIG_DEM_SUPPORT_STATE_FORECAST_REPORTING)
106
+ #error Cannot define SL_MATTER_CONFIG_DEM_SUPPORT_POWER_FORECAST_REPORTING and SL_MATTER_CONFIG_DEM_SUPPORT_STATE_FORECAST_REPORTING
107
+ #endif
108
+
109
+ #if SL_MATTER_CONFIG_DEM_SUPPORT_POWER_FORECAST_REPORTING
75
110
static chip::BitMask<Feature> sFeatureMap (Feature::kPowerAdjustment , Feature::kPowerForecastReporting ,
76
- Feature::kStateForecastReporting , Feature::kStartTimeAdjustment , Feature::kPausable ,
77
- Feature::kForecastAdjustment , Feature::kConstraintBasedAdjustment );
111
+ Feature::kStartTimeAdjustment , Feature::kPausable , Feature::kForecastAdjustment ,
112
+ Feature::kConstraintBasedAdjustment );
113
+ #elif SL_MATTER_CONFIG_DEM_SUPPORT_STATE_FORECAST_REPORTING
114
+ static chip::BitMask<Feature> sFeatureMap (Feature::kPowerAdjustment , Feature::kStateForecastReporting ,
115
+ Feature::kStartTimeAdjustment , Feature::kPausable , Feature::kForecastAdjustment ,
116
+ Feature::kConstraintBasedAdjustment );
117
+ #else
118
+ static chip::BitMask<Feature> sFeatureMap (Feature::kPowerAdjustment );
119
+ #endif
78
120
79
121
chip::BitMask<Feature> GetFeatureMapFromCmdLine ()
80
122
{
@@ -91,14 +133,33 @@ AppTask AppTask::sAppTask;
91
133
void ApplicationInit ()
92
134
{
93
135
chip::DeviceLayer::PlatformMgr ().LockChipStack ();
136
+ SILABS_LOG (" ==================================================" );
137
+ #if SL_MATTER_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
138
+ SILABS_LOG (" energy-management-example EVSE starting. featureMap 0x%08lx" , DeviceEnergyManagement::sFeatureMap .Raw ());
139
+
94
140
EvseApplicationInit ();
95
- sEvseLED .Init (EVSE_LED);
141
+ #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
142
+
143
+ #if SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
144
+ SILABS_LOG (" energy-management-example WaterHeater starting. featureMap 0x%08lx" , DeviceEnergyManagement::sFeatureMap .Raw ());
145
+
146
+ FullWhmApplicationInit ();
147
+ #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
148
+ SILABS_LOG (" ==================================================" );
149
+
150
+ sEnergyManagementLED .Init (EVSE_LED);
96
151
chip::DeviceLayer::PlatformMgr ().UnlockChipStack ();
97
152
}
98
153
void ApplicationShutdown ()
99
154
{
100
155
chip::DeviceLayer::PlatformMgr ().LockChipStack ();
156
+ #if SL_MATTER_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
101
157
EvseApplicationShutdown ();
158
+ #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
159
+
160
+ #if SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
161
+ FullWhmApplicationShutdown ();
162
+ #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
102
163
chip::DeviceLayer::PlatformMgr ().UnlockChipStack ();
103
164
}
104
165
@@ -108,7 +169,11 @@ CHIP_ERROR AppTask::Init()
108
169
chip::DeviceLayer::Silabs::GetPlatform ().SetButtonsCb (AppTask::ButtonEventHandler);
109
170
110
171
#ifdef DISPLAY_ENABLED
111
- GetLCD ().Init ((uint8_t *) " energy-management-App" );
172
+ #if SL_MATTER_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE
173
+ GetLCD ().Init ((uint8_t *) " energy-management-App (EVSE)" );
174
+ #elif SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE
175
+ GetLCD ().Init ((uint8_t *) " energy-management-App (WaterHeater)" );
176
+ #endif
112
177
#endif
113
178
114
179
err = BaseApplication::Init ();
@@ -120,6 +185,43 @@ CHIP_ERROR AppTask::Init()
120
185
121
186
ApplicationInit ();
122
187
188
+ #ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
189
+ TestEventTriggerDelegate * pTestEventDelegate = Server::GetInstance ().GetTestEventTriggerDelegate ();
190
+
191
+ #if SL_MATTER_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER
192
+ static EnergyEvseTestEventTriggerHandler sEnergyEvseTestEventTriggerHandler ;
193
+ if (pTestEventDelegate != nullptr )
194
+ {
195
+ VerifyOrDie (pTestEventDelegate->AddHandler (&sEnergyEvseTestEventTriggerHandler ) == CHIP_NO_ERROR);
196
+ }
197
+ #endif
198
+
199
+ #if SL_MATTER_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER
200
+ static EnergyReportingTestEventTriggerHandler sEnergyReportingTestEventTriggerHandler ;
201
+ if (pTestEventDelegate != nullptr )
202
+ {
203
+ VerifyOrDie (pTestEventDelegate->AddHandler (&sEnergyReportingTestEventTriggerHandler ) == CHIP_NO_ERROR);
204
+ }
205
+
206
+ #endif
207
+ #if SL_MATTER_CONFIG_ENABLE_WATER_HEATER_MANAGEMENT_TRIGGER
208
+ static WaterHeaterManagementTestEventTriggerHandler sWaterHeaterManagementTestEventTriggerHandler ;
209
+
210
+ if (pTestEventDelegate != nullptr )
211
+ {
212
+ VerifyOrDie (pTestEventDelegate->AddHandler (&sWaterHeaterManagementTestEventTriggerHandler ) == CHIP_NO_ERROR);
213
+ }
214
+ #endif
215
+ #if SL_MATTER_CONFIG_ENABLE_DEVICE_ENERGY_MANAGEMENT_TRIGGER
216
+ static DeviceEnergyManagementTestEventTriggerHandler sDeviceEnergyManagementTestEventTriggerHandler ;
217
+ if (pTestEventDelegate != nullptr )
218
+ {
219
+ VerifyOrDie (pTestEventDelegate->AddHandler (&sDeviceEnergyManagementTestEventTriggerHandler ) == CHIP_NO_ERROR);
220
+ }
221
+ #endif
222
+
223
+ #endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
224
+
123
225
// Update the LCD with the Stored value. Show QR Code if not provisioned
124
226
#ifdef DISPLAY_ENABLED
125
227
GetLCD ().WriteDemoUI (LightMgr ().IsLightOn ());
@@ -168,7 +270,7 @@ void AppTask::AppTaskMain(void * pvParameter)
168
270
}
169
271
}
170
272
171
- void AppTask::EvseActionEventHandler (AppEvent * aEvent)
273
+ void AppTask::EnergyManagementActionEventHandler (AppEvent * aEvent)
172
274
{
173
275
bool initiated = false ;
174
276
int32_t actor;
@@ -201,7 +303,7 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
201
303
202
304
if (button == APP_EVSE_SWITCH && btnAction == static_cast <uint8_t >(SilabsPlatform::ButtonAction::ButtonPressed))
203
305
{
204
- button_event.Handler = EvseActionEventHandler ;
306
+ button_event.Handler = EnergyManagementActionEventHandler ;
205
307
AppTask::GetAppTask ().PostEvent (&button_event);
206
308
}
207
309
else if (button == APP_FUNCTION_BUTTON)
0 commit comments