@@ -64,7 +64,7 @@ Status EnergyEvseDelegate::Disable()
64
64
break ;
65
65
66
66
default :
67
- ChipLogError (AppServer, " Unexpected EVSE hardware state\n " );
67
+ ChipLogError (AppServer, " Unexpected EVSE hardware state" );
68
68
SetState (StateEnum::kFault );
69
69
break ;
70
70
}
@@ -138,10 +138,13 @@ Status EnergyEvseDelegate::EnableCharging(const DataModel::Nullable<uint32_t> &
138
138
switch (mHwState )
139
139
{
140
140
case StateEnum::kNotPluggedIn :
141
+ // TODO handle errors here
141
142
SetState (StateEnum::kNotPluggedIn );
142
143
break ;
143
144
144
145
case StateEnum::kPluggedInNoDemand :
146
+ // TODO handle errors here
147
+ // TODO REFACTOR per Andrei's comment in PR30857 - can we collapse this switch statement?
145
148
SetState (StateEnum::kPluggedInNoDemand );
146
149
break ;
147
150
@@ -151,12 +154,12 @@ Status EnergyEvseDelegate::EnableCharging(const DataModel::Nullable<uint32_t> &
151
154
break ;
152
155
153
156
default :
154
- ChipLogError (AppServer, " Unexpected EVSE hardware state\n " );
157
+ ChipLogError (AppServer, " Unexpected EVSE hardware state" );
155
158
SetState (StateEnum::kFault );
156
159
break ;
157
160
}
158
161
159
- /* update SupplyState */
162
+ /* update SupplyState to say that charging is now enabled */
160
163
SetSupplyState (SupplyStateEnum::kChargingEnabled );
161
164
162
165
/* If it looks ok, store the min & max charging current */
@@ -208,7 +211,6 @@ Status EnergyEvseDelegate::StartDiagnostics()
208
211
* FUNCTIONS BELOW:
209
212
* - EVSE Hardware interface
210
213
*
211
- * RegisterEvseHardwareCallback( callbackType, callbackFnc )
212
214
* SetMaxHardwareCurrentLimit( currentmA )
213
215
* SetCircuitCapacity( currentmA )
214
216
* SetCableAssemblyLimit( currentmA )
@@ -217,25 +219,13 @@ Status EnergyEvseDelegate::StartDiagnostics()
217
219
*
218
220
*/
219
221
220
- /* *
221
- * @brief Called by EVSE Hardware to register a callback
222
- *
223
- * @param Callback function
224
- */
225
- #if 0
226
- Status EnergyEvseDelegate::HwRegisterEvseHardwareCallback(int Callback) // TODO
227
- {
228
- // TODO
229
- return CHIP_NO_ERROR;
230
- }
231
- #endif
232
222
/* *
233
223
* @brief Called by EVSE Hardware to notify the delegate of the maximum
234
224
* current limit supported by the hardware.
235
225
*
236
226
* This is normally called at start-up.
237
227
*
238
- * @param currentmA
228
+ * @param currentmA - Maximum current limit supported by the hardware
239
229
*/
240
230
Status EnergyEvseDelegate::HwSetMaxHardwareCurrentLimit (int64_t currentmA)
241
231
{
@@ -257,7 +247,7 @@ Status EnergyEvseDelegate::HwSetMaxHardwareCurrentLimit(int64_t currentmA)
257
247
* This is normally called at start-up when reading from DIP-switch
258
248
* settings.
259
249
*
260
- * @param currentmA
250
+ * @param currentmA - Maximum current limit specified by electrician
261
251
*/
262
252
Status EnergyEvseDelegate::HwSetCircuitCapacity (int64_t currentmA)
263
253
{
@@ -282,7 +272,7 @@ Status EnergyEvseDelegate::HwSetCircuitCapacity(int64_t currentmA)
282
272
* using different resistors, which results in different voltages
283
273
* measured by the EVSE.
284
274
*
285
- * @param currentmA
275
+ * @param currentmA - Maximum current limit detected from Cable assembly
286
276
*/
287
277
Status EnergyEvseDelegate::HwSetCableAssemblyLimit (int64_t currentmA)
288
278
{
@@ -298,17 +288,17 @@ Status EnergyEvseDelegate::HwSetCableAssemblyLimit(int64_t currentmA)
298
288
}
299
289
300
290
/* *
301
- * @brief Called by EVSE Hardware to indicate a fault
291
+ * @brief Called by EVSE Hardware to indicate if EV is detected
302
292
*
303
- * @param StateEnum
293
+ * The only allowed states that the EVSE hardware can set are:
294
+ * kNotPluggedIn
295
+ * kPluggedInNoDemand
296
+ * kPluggedInDemand
297
+ *
298
+ * @param StateEnum - the state of the EV being plugged in and asking for demand etc
304
299
*/
305
300
Status EnergyEvseDelegate::HwSetState (StateEnum state)
306
301
{
307
- /* the only allowed states that the EVSE hardware can set are:
308
- * kNotPluggedIn
309
- * kPluggedInNoDemand
310
- * kPluggedInDemand
311
- */
312
302
switch (state)
313
303
{
314
304
case StateEnum::kNotPluggedIn :
@@ -336,7 +326,7 @@ Status EnergyEvseDelegate::HwSetState(StateEnum state)
336
326
/* *
337
327
* @brief Called by EVSE Hardware to indicate a fault
338
328
*
339
- * @param FaultStateEnum
329
+ * @param FaultStateEnum - the fault condition detected
340
330
*/
341
331
Status EnergyEvseDelegate::HwSetFault (FaultStateEnum fault)
342
332
{
@@ -382,6 +372,7 @@ Status EnergyEvseDelegate::HwSetRFID(ByteSpan uid)
382
372
383
373
return Status::Success;
384
374
}
375
+
385
376
/* *
386
377
* @brief Called by EVSE Hardware to share the VehicleID
387
378
*
@@ -393,31 +384,33 @@ Status EnergyEvseDelegate::HwSetRFID(ByteSpan uid)
393
384
Status EnergyEvseDelegate::HwSetVehicleID (const CharSpan & newValue)
394
385
{
395
386
// TODO this code to be refactored - See Issue #30993
396
- if (mVehicleID .IsNull () || ! newValue.data_equal (mVehicleID .Value ()))
387
+ if (! mVehicleID .IsNull () && newValue.data_equal (mVehicleID .Value ()))
397
388
{
398
- /* create a copy of the string so the callee doesn't have to keep it */
399
- char * destinationBuffer = new char [kMaxVehicleIDBufSize ];
400
-
401
- MutableCharSpan destinationString (destinationBuffer, kMaxVehicleIDBufSize );
402
- CHIP_ERROR err = CopyCharSpanToMutableCharSpan (newValue, destinationString);
403
- if (err != CHIP_NO_ERROR)
404
- {
405
- ChipLogError (AppServer, " HwSetVehicleID - could not copy vehicleID" );
406
- delete[] destinationBuffer;
407
- return Status::Failure;
408
- }
389
+ return Status::Success;
390
+ }
409
391
410
- if (!mVehicleID .IsNull ())
411
- {
412
- delete[] mVehicleID .Value ().data ();
413
- }
392
+ /* create a copy of the string so the callee doesn't have to keep it */
393
+ char * destinationBuffer = new char [kMaxVehicleIDBufSize ];
414
394
415
- mVehicleID = MakeNullable (static_cast <CharSpan>(destinationString));
395
+ MutableCharSpan destinationString (destinationBuffer, kMaxVehicleIDBufSize );
396
+ CHIP_ERROR err = CopyCharSpanToMutableCharSpan (newValue, destinationString);
397
+ if (err != CHIP_NO_ERROR)
398
+ {
399
+ ChipLogError (AppServer, " HwSetVehicleID - could not copy vehicleID" );
400
+ delete[] destinationBuffer;
401
+ return Status::Failure;
402
+ }
416
403
417
- ChipLogDetail (AppServer, " VehicleID updated" );
418
- MatterReportingAttributeChangeCallback (mEndpointId , EnergyEvse::Id, VehicleID::Id);
404
+ if (!mVehicleID .IsNull ())
405
+ {
406
+ delete[] mVehicleID .Value ().data ();
419
407
}
420
408
409
+ mVehicleID = MakeNullable (static_cast <CharSpan>(destinationString));
410
+
411
+ ChipLogDetail (AppServer, " VehicleID updated %.*s" , static_cast <int >(mVehicleID .Value ().size ()), mVehicleID .Value ().data ());
412
+ MatterReportingAttributeChangeCallback (mEndpointId , EnergyEvse::Id, VehicleID::Id);
413
+
421
414
return Status::Success;
422
415
}
423
416
@@ -468,6 +461,7 @@ StateEnum EnergyEvseDelegate::GetState()
468
461
{
469
462
return mState ;
470
463
}
464
+
471
465
CHIP_ERROR EnergyEvseDelegate::SetState (StateEnum newValue)
472
466
{
473
467
StateEnum oldValue = mState ;
@@ -479,7 +473,7 @@ CHIP_ERROR EnergyEvseDelegate::SetState(StateEnum newValue)
479
473
mState = newValue;
480
474
if (oldValue != mState )
481
475
{
482
- ChipLogDetail (AppServer, " State updated to %d" , ( int ) mState );
476
+ ChipLogDetail (AppServer, " State updated to %d" , static_cast < int >( mState ) );
483
477
MatterReportingAttributeChangeCallback (mEndpointId , EnergyEvse::Id, State::Id);
484
478
}
485
479
@@ -491,6 +485,7 @@ SupplyStateEnum EnergyEvseDelegate::GetSupplyState()
491
485
{
492
486
return mSupplyState ;
493
487
}
488
+
494
489
CHIP_ERROR EnergyEvseDelegate::SetSupplyState (SupplyStateEnum newValue)
495
490
{
496
491
SupplyStateEnum oldValue = mSupplyState ;
@@ -503,7 +498,7 @@ CHIP_ERROR EnergyEvseDelegate::SetSupplyState(SupplyStateEnum newValue)
503
498
mSupplyState = newValue;
504
499
if (oldValue != mSupplyState )
505
500
{
506
- ChipLogDetail (AppServer, " SupplyState updated to %d" , ( int ) mSupplyState );
501
+ ChipLogDetail (AppServer, " SupplyState updated to %d" , static_cast < int >( mSupplyState ) );
507
502
MatterReportingAttributeChangeCallback (mEndpointId , EnergyEvse::Id, SupplyState::Id);
508
503
}
509
504
return CHIP_NO_ERROR;
@@ -514,6 +509,7 @@ FaultStateEnum EnergyEvseDelegate::GetFaultState()
514
509
{
515
510
return mFaultState ;
516
511
}
512
+
517
513
CHIP_ERROR EnergyEvseDelegate::SetFaultState (FaultStateEnum newValue)
518
514
{
519
515
FaultStateEnum oldValue = mFaultState ;
@@ -526,7 +522,7 @@ CHIP_ERROR EnergyEvseDelegate::SetFaultState(FaultStateEnum newValue)
526
522
mFaultState = newValue;
527
523
if (oldValue != mFaultState )
528
524
{
529
- ChipLogDetail (AppServer, " FaultState updated to %d" , ( int ) mFaultState );
525
+ ChipLogDetail (AppServer, " FaultState updated to %d" , static_cast < int >( mFaultState ) );
530
526
MatterReportingAttributeChangeCallback (mEndpointId , EnergyEvse::Id, FaultState::Id);
531
527
}
532
528
return CHIP_NO_ERROR;
@@ -537,6 +533,7 @@ DataModel::Nullable<uint32_t> EnergyEvseDelegate::GetChargingEnabledUntil()
537
533
{
538
534
return mChargingEnabledUntil ;
539
535
}
536
+
540
537
CHIP_ERROR EnergyEvseDelegate::SetChargingEnabledUntil (uint32_t newValue)
541
538
{
542
539
DataModel::Nullable<uint32_t > oldValue = mChargingEnabledUntil ;
@@ -550,11 +547,13 @@ CHIP_ERROR EnergyEvseDelegate::SetChargingEnabledUntil(uint32_t newValue)
550
547
}
551
548
return CHIP_NO_ERROR;
552
549
}
550
+
553
551
/* DischargingEnabledUntil */
554
552
DataModel::Nullable<uint32_t > EnergyEvseDelegate::GetDischargingEnabledUntil ()
555
553
{
556
554
return mDischargingEnabledUntil ;
557
555
}
556
+
558
557
CHIP_ERROR EnergyEvseDelegate::SetDischargingEnabledUntil (uint32_t newValue)
559
558
{
560
559
DataModel::Nullable<uint32_t > oldValue = mDischargingEnabledUntil ;
@@ -568,11 +567,13 @@ CHIP_ERROR EnergyEvseDelegate::SetDischargingEnabledUntil(uint32_t newValue)
568
567
}
569
568
return CHIP_NO_ERROR;
570
569
}
570
+
571
571
/* CircuitCapacity */
572
572
int64_t EnergyEvseDelegate::GetCircuitCapacity ()
573
573
{
574
574
return mCircuitCapacity ;
575
575
}
576
+
576
577
CHIP_ERROR EnergyEvseDelegate::SetCircuitCapacity (int64_t newValue)
577
578
{
578
579
int64_t oldValue = mCircuitCapacity ;
@@ -590,11 +591,13 @@ CHIP_ERROR EnergyEvseDelegate::SetCircuitCapacity(int64_t newValue)
590
591
}
591
592
return CHIP_NO_ERROR;
592
593
}
594
+
593
595
/* MinimumChargeCurrent */
594
596
int64_t EnergyEvseDelegate::GetMinimumChargeCurrent ()
595
597
{
596
598
return mMinimumChargeCurrent ;
597
599
}
600
+
598
601
CHIP_ERROR EnergyEvseDelegate::SetMinimumChargeCurrent (int64_t newValue)
599
602
{
600
603
int64_t oldValue = mMinimumChargeCurrent ;
@@ -618,6 +621,7 @@ int64_t EnergyEvseDelegate::GetMaximumChargeCurrent()
618
621
{
619
622
return mMaximumChargeCurrent ;
620
623
}
624
+
621
625
CHIP_ERROR EnergyEvseDelegate::SetMaximumChargeCurrent (int64_t newValue)
622
626
{
623
627
int64_t oldValue = mMaximumChargeCurrent ;
@@ -635,11 +639,13 @@ CHIP_ERROR EnergyEvseDelegate::SetMaximumChargeCurrent(int64_t newValue)
635
639
}
636
640
return CHIP_NO_ERROR;
637
641
}
642
+
638
643
/* MaximumDischargeCurrent */
639
644
int64_t EnergyEvseDelegate::GetMaximumDischargeCurrent ()
640
645
{
641
646
return mMaximumDischargeCurrent ;
642
647
}
648
+
643
649
CHIP_ERROR EnergyEvseDelegate::SetMaximumDischargeCurrent (int64_t newValue)
644
650
{
645
651
int64_t oldValue = mMaximumDischargeCurrent ;
@@ -657,11 +663,13 @@ CHIP_ERROR EnergyEvseDelegate::SetMaximumDischargeCurrent(int64_t newValue)
657
663
}
658
664
return CHIP_NO_ERROR;
659
665
}
666
+
660
667
/* UserMaximumChargeCurrent */
661
668
int64_t EnergyEvseDelegate::GetUserMaximumChargeCurrent ()
662
669
{
663
670
return mUserMaximumChargeCurrent ;
664
671
}
672
+
665
673
CHIP_ERROR EnergyEvseDelegate::SetUserMaximumChargeCurrent (int64_t newValue)
666
674
{
667
675
if ((newValue < 0 ) || (newValue > kMaximumChargeCurrent ))
@@ -679,11 +687,13 @@ CHIP_ERROR EnergyEvseDelegate::SetUserMaximumChargeCurrent(int64_t newValue)
679
687
680
688
return CHIP_NO_ERROR;
681
689
}
690
+
682
691
/* RandomizationDelayWindow */
683
692
uint32_t EnergyEvseDelegate::GetRandomizationDelayWindow ()
684
693
{
685
694
return mRandomizationDelayWindow ;
686
695
}
696
+
687
697
CHIP_ERROR EnergyEvseDelegate::SetRandomizationDelayWindow (uint32_t newValue)
688
698
{
689
699
uint32_t oldValue = mRandomizationDelayWindow ;
@@ -733,6 +743,7 @@ DataModel::Nullable<uint16_t> EnergyEvseDelegate::GetApproximateEVEfficiency()
733
743
{
734
744
return mApproximateEVEfficiency ;
735
745
}
746
+
736
747
CHIP_ERROR EnergyEvseDelegate::SetApproximateEVEfficiency (uint16_t newValue)
737
748
{
738
749
DataModel::Nullable<uint16_t > oldValue = mApproximateEVEfficiency ;
0 commit comments