@@ -83,6 +83,7 @@ Status EnergyEvseDelegate::Disable()
83
83
/* update MaximumDischargeCurrent to 0 */
84
84
SetMaximumDischargeCurrent (0 );
85
85
86
+ NotifyApplicationStateChange ();
86
87
// TODO: Generate events
87
88
88
89
return Status::Success;
@@ -102,31 +103,31 @@ Status EnergyEvseDelegate::EnableCharging(const DataModel::Nullable<uint32_t> &
102
103
103
104
if (maximumChargeCurrent < kMinimumChargeCurrent || maximumChargeCurrent > kMaximumChargeCurrent )
104
105
{
105
- ChipLogError (NotSpecified , " Maximum Current outside limits" );
106
+ ChipLogError (AppServer , " Maximum Current outside limits" );
106
107
return Status::ConstraintError;
107
108
}
108
109
109
110
if (minimumChargeCurrent < kMinimumChargeCurrent || minimumChargeCurrent > kMaximumChargeCurrent )
110
111
{
111
- ChipLogError (NotSpecified , " Maximum Current outside limits" );
112
+ ChipLogError (AppServer , " Maximum Current outside limits" );
112
113
return Status::ConstraintError;
113
114
}
114
115
115
116
if (minimumChargeCurrent > maximumChargeCurrent)
116
117
{
117
- ChipLogError (NotSpecified , " Minium Current > Maximum Current!" );
118
+ ChipLogError (AppServer , " Minium Current > Maximum Current!" );
118
119
return Status::ConstraintError;
119
120
}
120
121
121
122
if (chargingEnabledUntil.IsNull ())
122
123
{
123
124
/* Charging enabled indefinitely */
124
- ChipLogError (NotSpecified , " Charging enabled indefinitely" );
125
+ ChipLogError (AppServer , " Charging enabled indefinitely" );
125
126
}
126
127
else
127
128
{
128
129
/* check chargingEnabledUntil is in the future */
129
- ChipLogError (NotSpecified , " Charging enabled until: %lu" , static_cast <long unsigned int >(chargingEnabledUntil.Value ()));
130
+ ChipLogError (AppServer , " Charging enabled until: %lu" , static_cast <long unsigned int >(chargingEnabledUntil.Value ()));
130
131
// TODO
131
132
// if (checkChargingEnabled)
132
133
}
@@ -169,6 +170,8 @@ Status EnergyEvseDelegate::EnableCharging(const DataModel::Nullable<uint32_t> &
169
170
170
171
// TODO: Generate events
171
172
173
+ NotifyApplicationStateChange ();
174
+
172
175
return this ->ComputeMaxChargeCurrentLimit ();
173
176
}
174
177
@@ -188,6 +191,8 @@ Status EnergyEvseDelegate::EnableDischarging(const DataModel::Nullable<uint32_t>
188
191
189
192
// TODO: Generate events
190
193
194
+ NotifyApplicationStateChange ();
195
+
191
196
return Status::Success;
192
197
}
193
198
@@ -199,25 +204,42 @@ Status EnergyEvseDelegate::StartDiagnostics()
199
204
/* For EVSE manufacturers to customize */
200
205
ChipLogProgress (AppServer, " EnergyEvseDelegate::StartDiagnostics()" );
201
206
202
- /* update SupplyState */
207
+ /* update SupplyState to indicate in Diagnostics mode */
203
208
SetSupplyState (SupplyStateEnum::kDisabledDiagnostics );
204
209
205
210
// TODO: Generate events
206
211
212
+ // TODO: Notify Application to implement Diagnostics
213
+
214
+ NotifyApplicationStateChange ();
215
+
207
216
return Status::Success;
208
217
}
209
218
210
219
/* ---------------------------------------------------------------------------
211
- * FUNCTIONS BELOW:
212
- * - EVSE Hardware interface
220
+ * EVSE Hardware interface below
221
+ */
222
+
223
+ /* *
224
+ * @brief Called by EVSE Hardware to register a callback handler mechanism
213
225
*
214
- * SetMaxHardwareCurrentLimit( currentmA )
215
- * SetCircuitCapacity( currentmA )
216
- * SetCableAssemblyLimit( currentmA )
217
- * SetState( EVSEStateEnum )
218
- * SetFault
226
+ * This is normally called at start-up.
219
227
*
228
+ * @param EVSECallbackFunct - function pointer to call
229
+ * @param intptr_t - optional context to provide back to callback handler
220
230
*/
231
+ Status EnergyEvseDelegate::HwRegisterEvseCallbackHandler (EVSECallbackFunc handler, intptr_t arg)
232
+ {
233
+ if (mCallbacks .handler != nullptr )
234
+ {
235
+ ChipLogError (AppServer, " Callback handler already initialized" );
236
+ return Status::Failure;
237
+ }
238
+ mCallbacks .handler = handler;
239
+ mCallbacks .arg = arg;
240
+
241
+ return Status::Success;
242
+ }
221
243
222
244
/* *
223
245
* @brief Called by EVSE Hardware to notify the delegate of the maximum
@@ -420,17 +442,18 @@ Status EnergyEvseDelegate::HwSetVehicleID(const CharSpan & newValue)
420
442
421
443
/* *
422
444
* @brief Called to compute the safe charging current limit
445
+ *
446
+ * mActualChargingCurrentLimit is the minimum of:
447
+ * - MaxHardwareCurrentLimit (of the hardware)
448
+ * - CircuitCapacity (set by the electrician - less than the hardware)
449
+ * - CableAssemblyLimit (detected when the cable is inserted)
450
+ * - MaximumChargeCurrent (from charging command)
451
+ * - UserMaximumChargeCurrent (could dynamically change)
452
+ *
423
453
*/
424
454
Status EnergyEvseDelegate::ComputeMaxChargeCurrentLimit ()
425
455
{
426
456
int64_t oldValue;
427
- /* mActualChargingCurrentLimit is the minimum of:
428
- * - MaxHardwareCurrentLimit (of the hardware)
429
- * - CircuitCapacity (set by the electrician - less than the hardware)
430
- * - CableAssemblyLimit (detected when the cable is inserted)
431
- * - MaximumChargeCurrent (from charging command)
432
- * - UserMaximumChargeCurrent (could dynamically change)
433
- */
434
457
435
458
oldValue = mActualChargingCurrentLimit ;
436
459
mActualChargingCurrentLimit = mMaxHardwareCurrentLimit ;
@@ -448,11 +471,42 @@ Status EnergyEvseDelegate::ComputeMaxChargeCurrentLimit()
448
471
MatterReportingAttributeChangeCallback (mEndpointId , EnergyEvse::Id, MaximumChargeCurrent::Id);
449
472
450
473
/* Call the EV Charger hardware current limit callback */
451
- // TODO
474
+ NotifyApplicationCurrentLimitChange ( mMaximumChargeCurrent );
452
475
}
453
476
return Status::Success;
454
477
}
455
478
479
+ Status EnergyEvseDelegate::NotifyApplicationCurrentLimitChange (int64_t maximumChargeCurrent)
480
+ {
481
+ EVSECbInfo cbInfo;
482
+
483
+ cbInfo.type = EVSECallbackType::ChargeCurrentChanged;
484
+ cbInfo.ChargingCurrent .maximumChargeCurrent = maximumChargeCurrent;
485
+
486
+ if (mCallbacks .handler != nullptr )
487
+ {
488
+ mCallbacks .handler (&cbInfo, mCallbacks .arg );
489
+ }
490
+
491
+ return Status::Success;
492
+ }
493
+
494
+ Status EnergyEvseDelegate::NotifyApplicationStateChange (void )
495
+ {
496
+ EVSECbInfo cbInfo;
497
+
498
+ cbInfo.type = EVSECallbackType::StateChanged;
499
+ cbInfo.StateChange .state = mState ;
500
+ cbInfo.StateChange .supplyState = mSupplyState ;
501
+
502
+ if (mCallbacks .handler != nullptr )
503
+ {
504
+ mCallbacks .handler (&cbInfo, mCallbacks .arg );
505
+ }
506
+
507
+ return Status::Success;
508
+ }
509
+
456
510
/* *
457
511
* Attribute methods
458
512
*/
0 commit comments