@@ -289,8 +289,6 @@ void mocpp_initialize(Connection& connection, const char *bootNotificationCreden
289289 new AuthorizationService (*context, filesystem)));
290290 model.setReservationService (std::unique_ptr<ReservationService>(
291291 new ReservationService (*context, MO_NUMCONNECTORS)));
292- model.setResetService (std::unique_ptr<ResetService>(
293- new ResetService (*context)));
294292
295293#if MO_ENABLE_V201
296294 model.setVariableService (std::unique_ptr<VariableService>(
@@ -299,6 +297,18 @@ void mocpp_initialize(Connection& connection, const char *bootNotificationCreden
299297 new TransactionService (*context)));
300298#endif
301299
300+ #if MO_ENABLE_V201
301+ if (version.major == 2 ) {
302+ // depends on VariableService
303+ model.setResetServiceV201 (std::unique_ptr<Ocpp201::ResetService>(
304+ new Ocpp201::ResetService (*context)));
305+ } else
306+ #endif
307+ {
308+ model.setResetService (std::unique_ptr<ResetService>(
309+ new ResetService (*context)));
310+ }
311+
302312 std::unique_ptr<CertificateStore> certStoreUse;
303313 if (certStore) {
304314 certStoreUse = std::move (certStore);
@@ -322,8 +332,7 @@ void mocpp_initialize(Connection& connection, const char *bootNotificationCreden
322332#endif // MO_PLATFORM == MO_PLATFORM_ARDUINO && !defined(MO_CUSTOM_UPDATER)
323333
324334#if MO_PLATFORM == MO_PLATFORM_ARDUINO && (defined(ESP32) || defined(ESP8266))
325- if (!model.getResetService ()->getExecuteReset ())
326- model.getResetService ()->setExecuteReset (makeDefaultResetFn ());
335+ setOnResetExecute (makeDefaultResetFn ());
327336#endif
328337
329338 model.getBootService ()->setChargePointCredentials (bootNotificationCredentials);
@@ -883,6 +892,15 @@ void setOnResetNotify(std::function<bool(bool)> onResetNotify) {
883892 return ;
884893 }
885894
895+ #if MO_ENABLE_V201
896+ if (context->getVersion ().major == 2 ) {
897+ if (auto rService = context->getModel ().getResetServiceV201 ()) {
898+ rService->setNotifyReset ([onResetNotify] (ResetType) {return onResetNotify (true );});
899+ }
900+ return ;
901+ }
902+ #endif
903+
886904 if (auto rService = context->getModel ().getResetService ()) {
887905 rService->setPreReset (onResetNotify);
888906 }
@@ -894,6 +912,15 @@ void setOnResetExecute(std::function<void(bool)> onResetExecute) {
894912 return ;
895913 }
896914
915+ #if MO_ENABLE_V201
916+ if (context->getVersion ().major == 2 ) {
917+ if (auto rService = context->getModel ().getResetServiceV201 ()) {
918+ rService->setExecuteReset ([onResetExecute] () {onResetExecute (true ); return true ;});
919+ }
920+ return ;
921+ }
922+ #endif
923+
897924 if (auto rService = context->getModel ().getResetService ()) {
898925 rService->setExecuteReset (onResetExecute);
899926 }
0 commit comments