@@ -169,7 +169,9 @@ void WaterHeaterManagementDelegate::SetBoostState(BoostStateEnum boostState)
169
169
*/
170
170
Status WaterHeaterManagementDelegate::HandleBoost (uint32_t durationS, Optional<bool > oneShot, Optional<bool > emergencyBoost, Optional<int16_t > temporarySetpoint, Optional<chip::Percent> targetPercentage, Optional<chip::Percent> targetReheat)
171
171
{
172
- ChipLogProgress (AppServer, " WaterHeaterManagementDelegate::HandleBoost" );
172
+ Status status = Status::Success;
173
+
174
+ ChipLogProgress (AppServer, " HandleBoost" );
173
175
174
176
// Keep track of the boost command parameters
175
177
mBoostOneShot = oneShot;
@@ -189,7 +191,7 @@ Status WaterHeaterManagementDelegate::HandleBoost(uint32_t durationS, Optional<b
189
191
CHIP_ERROR err = DeviceLayer::SystemLayer ().StartTimer (System::Clock::Seconds32 (durationS), BoostTimerExpiry, this );
190
192
if (err != CHIP_NO_ERROR)
191
193
{
192
- ChipLogError (AppServer, " Unable to start a Boost timer: %" CHIP_ERROR_FORMAT, err.Format ());
194
+ ChipLogError (AppServer, " HandleBoost: Unable to start a Boost timer: %" CHIP_ERROR_FORMAT, err.Format ());
193
195
194
196
// Not a lot we can do -> just set the boost state to inactive
195
197
SetBoostState (BoostStateEnum::kInactive );
@@ -200,10 +202,23 @@ Status WaterHeaterManagementDelegate::HandleBoost(uint32_t durationS, Optional<b
200
202
// Now running a boost command
201
203
SetBoostState (BoostStateEnum::kActive );
202
204
203
- // See if the heat needs to be turned on or off as a result of this boost command
204
- CheckIfHeatNeedsToBeTurnedOnOrOff ();
205
+ if (mpWhmManufacturer != nullptr )
206
+ {
207
+ status = mpWhmManufacturer->BoostCommandStarted (durationS, oneShot, emergencyBoost, temporarySetpoint, targetPercentage, targetReheat);
208
+ }
209
+ else
210
+ {
211
+ status = Status::InvalidInState;
212
+ ChipLogError (AppServer, " HandleBoost: mpWhmManufacturer == nullptr" );
213
+ }
214
+
215
+ if (status == Status::Success)
216
+ {
217
+ // See if the heat needs to be turned on or off as a result of this boost command
218
+ status = CheckIfHeatNeedsToBeTurnedOnOrOff ();
219
+ }
205
220
206
- return Status::Success ;
221
+ return status ;
207
222
}
208
223
209
224
void WaterHeaterManagementDelegate::BoostTimerExpiry (System::Layer * systemLayer, void * delegate)
@@ -218,11 +233,20 @@ void WaterHeaterManagementDelegate::BoostTimerExpiry(System::Layer * systemLayer
218
233
*/
219
234
void WaterHeaterManagementDelegate::HandleBoostTimerExpiry ()
220
235
{
221
- ChipLogError (AppServer, " WaterHeaterManagementDelegate:: HandleBoostTimerExpiry" );
236
+ ChipLogError (AppServer, " HandleBoostTimerExpiry" );
222
237
223
238
// The PowerAdjustment is no longer in progress
224
239
SetBoostState (BoostStateEnum::kInactive );
225
240
241
+ if (mpWhmManufacturer != nullptr )
242
+ {
243
+ mpWhmManufacturer->BoostCommandFinished ();
244
+ }
245
+ else
246
+ {
247
+ ChipLogError (AppServer, " HandleBoostTimerExpiry: mpWhmManufacturer == nullptr" );
248
+ }
249
+
226
250
CheckIfHeatNeedsToBeTurnedOnOrOff ();
227
251
}
228
252
@@ -233,18 +257,30 @@ void WaterHeaterManagementDelegate::HandleBoostTimerExpiry()
233
257
*/
234
258
Status WaterHeaterManagementDelegate::HandleCancelBoost ()
235
259
{
236
- ChipLogProgress (AppServer, " WaterHeaterManagementDelegate::HandleCancelBoost" );
260
+ Status status = Status::Success;
261
+
262
+ ChipLogProgress (AppServer, " HandleCancelBoost" );
237
263
238
264
if (mBoostState == BoostStateEnum::kActive )
239
265
{
240
266
SetBoostState (BoostStateEnum::kInactive );
241
267
242
268
DeviceLayer::SystemLayer ().CancelTimer (BoostTimerExpiry, this );
243
269
244
- CheckIfHeatNeedsToBeTurnedOnOrOff ();
270
+ if (mpWhmManufacturer != nullptr )
271
+ {
272
+ status = mpWhmManufacturer->BoostCommandCancelled ();
273
+ }
274
+ else
275
+ {
276
+ status = Status::InvalidInState;
277
+ ChipLogError (AppServer, " HandleCancelBoost: mpWhmManufacturer == nullptr" );
278
+ }
279
+
280
+ status = CheckIfHeatNeedsToBeTurnedOnOrOff ();
245
281
}
246
282
247
- return Status::Success ;
283
+ return status ;
248
284
}
249
285
250
286
/* ********************************************************************************
@@ -387,8 +423,9 @@ bool WaterHeaterManagementDelegate::HasWaterTemperatureReachedTarget() const
387
423
return (mTankPercentage >= targetPercentage) && (mHotWaterTemperature >= targetTemperature);
388
424
}
389
425
390
- void WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff ()
426
+ Status WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff ()
391
427
{
428
+ Status status = Status::Success;
392
429
bool turningHeatOff = false ;
393
430
394
431
if (!HasWaterTemperatureReachedTarget ())
@@ -416,19 +453,20 @@ void WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff()
416
453
SetHeatDemand (heaterDemand);
417
454
418
455
// And turn the heating of the water tank on.
419
- mpWhmManufacturer->TurnHeatingOn ();
456
+ status = mpWhmManufacturer->TurnHeatingOn ();
420
457
}
421
458
else
422
459
{
423
- ChipLogError (Zcl, " WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff: Failed as mpWhmManufacturer == nullptr" );
460
+ status = Status::InvalidInState;
461
+ ChipLogError (AppServer, " CheckIfHeatNeedsToBeTurnedOnOrOff: Failed as mpWhmManufacturer == nullptr" );
424
462
}
425
463
}
426
464
}
427
465
else if (mBoostState == BoostStateEnum::kInactive && mode == ModeOff)
428
466
{
429
467
// The water temperature is not at the target temperature but there is no boost command in progress and the mode is Off
430
468
// so need to ensure the heating is turned off.
431
- ChipLogError (Zcl , " WaterHeaterManagementDelegate:: CheckIfHeatNeedsToBeTurnedOnOrOff turning heating off due to mode" );
469
+ ChipLogError (AppServer , " CheckIfHeatNeedsToBeTurnedOnOrOff turning heating off due to mode" );
432
470
433
471
SetHeatDemand (BitMask<WaterHeaterDemandBitmap>(0 ));
434
472
@@ -455,32 +493,45 @@ void WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff()
455
493
SetBoostState (BoostStateEnum::kInactive );
456
494
457
495
DeviceLayer::SystemLayer ().CancelTimer (BoostTimerExpiry, this );
496
+
497
+ if (mpWhmManufacturer != nullptr )
498
+ {
499
+ status = mpWhmManufacturer->BoostCommandCancelled ();
500
+ }
501
+ else
502
+ {
503
+ status = Status::InvalidInState;
504
+ ChipLogError (AppServer, " CheckIfHeatNeedsToBeTurnedOnOrOff: mpWhmManufacturer == nullptr" );
505
+ }
458
506
}
459
507
460
508
// Turn the heating off
461
509
if (mpWhmManufacturer != nullptr )
462
510
{
463
- mpWhmManufacturer->TurnHeatingOff ();
511
+ status = mpWhmManufacturer->TurnHeatingOff ();
464
512
}
465
513
else
466
514
{
467
- ChipLogError (Zcl, " WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff: Failed to turn the heating off as mpWhmManufacturer == nullptr" );
515
+ status = Status::InvalidInState;
516
+ ChipLogError (AppServer, " CheckIfHeatNeedsToBeTurnedOnOrOff: Failed to turn the heating off as mpWhmManufacturer == nullptr" );
468
517
}
469
518
}
519
+
520
+ return status;
470
521
}
471
522
472
523
void WaterHeaterManagementDelegate::SetWaterHeaterMode (uint8_t modeValue)
473
524
{
474
525
if (!mInstance ->IsSupportedMode (modeValue))
475
526
{
476
- ChipLogError (Zcl , " WaterHeaterManagementDelegate:: SetWaterHeaterMode bad mode" );
527
+ ChipLogError (AppServer , " SetWaterHeaterMode bad mode" );
477
528
return ;
478
529
}
479
530
480
531
Status status = mInstance ->UpdateCurrentMode (modeValue);
481
532
if (status != Status::Success)
482
533
{
483
- ChipLogError (Zcl , " WaterHeaterManagementDelegate:: SetWaterHeaterMode updateMode failed" );
534
+ ChipLogError (AppServer , " SetWaterHeaterMode updateMode failed" );
484
535
return ;
485
536
}
486
537
0 commit comments