55
66#include " ocpp.h"
77
8- #include " debug.h"
98#include " app_config.h"
109
1110#include < ArduinoOcpp.h> // Facade for ArduinoOcpp
1211#include < ArduinoOcpp/SimpleOcppOperationFactory.h> // define behavior for incoming req messages
1312
14- #include < ArduinoOcpp/Core/OcppEngine.h> // only for outputting debug messages to SteVe
15- #include < ArduinoOcpp/MessagesV16/DataTransfer.h> // only for outputting debug messages to SteVe
13+ #include < ArduinoOcpp/Core/OcppEngine.h>
1614
1715#include " emonesp.h" // for DEFAULT_VOLTAGE
1816
@@ -31,21 +29,20 @@ ArduinoOcppTask::~ArduinoOcppTask() {
3129}
3230
3331void ArduinoOcppTask::begin (EvseManager &evse, LcdTask &lcd) {
34- Serial.println (" [ArduinoOcppTask] begin!" );
3532
3633 this ->evse = &evse;
3734 this ->lcd = &lcd;
3835
39- loadOcppLibrary ();
36+ initializeArduinoOcpp ();
4037 loadEvseBehavior ();
4138
4239 instance = this ; // cannot be in constructer because object is invalid before .begin()
4340 MicroTask.startTask (this );
4441}
4542
46- void ArduinoOcppTask::loadOcppLibrary () {
43+ void ArduinoOcppTask::initializeArduinoOcpp () {
4744
48- if (config_ocpp_enabled () && !ocppLibraryLoaded ) {
45+ if (config_ocpp_enabled () && !arduinoOcppInitialized ) {
4946
5047 String url = getCentralSystemUrl ();
5148
@@ -67,7 +64,7 @@ void ArduinoOcppTask::loadOcppLibrary() {
6764 LCD_DISPLAY (" OCPP connected!" );
6865 });
6966
70- ocppLibraryLoaded = true ;
67+ arduinoOcppInitialized = true ;
7168 }
7269}
7370
@@ -77,7 +74,7 @@ void ArduinoOcppTask::setup() {
7774
7875void ArduinoOcppTask::loadEvseBehavior () {
7976
80- if (!ocppLibraryLoaded ) {
77+ if (!arduinoOcppInitialized ) {
8178 return ;
8279 }
8380
@@ -110,18 +107,6 @@ void ArduinoOcppTask::loadEvseBehavior() {
110107 * CP behavior definition: How will plugging and unplugging the EV start or stop OCPP transactions
111108 */
112109
113- if (!config_ocpp_enabled ()) {
114- // ocpp off
115- onVehicleConnect = [] () {};
116- onVehicleDisconnect = [] () {};
117- inferClaimTransactionActive = [] (EvseState& evseState, EvseProperties& evseProperties) {};
118- inferClaimTransactionActiveOffline = [] (EvseState& evseState, EvseProperties& evseProperties) {};
119- inferClaimTransactionInactive = [] (EvseState& evseState, EvseProperties& evseProperties) {};
120- inferClaimSmartCharging = [evse = evse] (EvseState& evseState, EvseProperties& evseProperties, float charging_limit) {};
121- updateEvseClaim ();
122- return ;
123- }
124-
125110 onVehicleConnect = [this ] () {
126111 if (getTransactionId () < 0 ) {
127112 if (!ocpp_idTag.isEmpty ()) {
@@ -157,7 +142,7 @@ void ArduinoOcppTask::loadEvseBehavior() {
157142
158143 setOnRemoteStartTransactionSendConf ([this , onVehicleConnect = onVehicleConnect] (JsonObject payload) {
159144 if (!operationIsAccepted (payload)){
160- if (DEBUG_OUT) Serial. print ( F ( " RemoteStartTransaction rejected! Do nothing\n " ));
145+ // RemoteStartTransaction rejected! Do nothing
161146 return ;
162147 }
163148
@@ -177,7 +162,7 @@ void ArduinoOcppTask::loadEvseBehavior() {
177162
178163 setOnRemoteStopTransactionSendConf ([this ](JsonObject payload) {
179164 if (!operationIsAccepted (payload)){
180- if (DEBUG_OUT) Serial. print ( F ( " RemoteStopTransaction rejected! There is no transaction with given ID. Do nothing\n " ));
165+ // RemoteStopTransaction rejected! There is no transaction with given ID. Do nothing
181166 return ;
182167 }
183168
@@ -194,8 +179,8 @@ unsigned long ArduinoOcppTask::loop(MicroTasks::WakeReason reason) {
194179 return 5000 ;
195180 }
196181
197- if (!ocppLibraryLoaded ) {
198- loadOcppLibrary ();
182+ if (!arduinoOcppInitialized ) {
183+ initializeArduinoOcpp ();
199184 loadEvseBehavior ();
200185
201186 return 50 ;
@@ -219,8 +204,8 @@ unsigned long ArduinoOcppTask::loop(MicroTasks::WakeReason reason) {
219204 return 50 ;
220205}
221206
222- void ArduinoOcppTask::OcppLibrary_loop () {
223- if (ocppLibraryLoaded ) {
207+ void ArduinoOcppTask::poll () {
208+ if (arduinoOcppInitialized ) {
224209 if (config_ocpp_enabled ()) {
225210 OCPP_loop ();
226211 } else {
@@ -306,14 +291,14 @@ String ArduinoOcppTask::getCentralSystemUrl() {
306291 return url;
307292}
308293
309- void ArduinoOcppTask::notifyReconfigured () {
294+ void ArduinoOcppTask::notifyConfigChanged () {
310295 if (instance) {
311296 instance->reconfigure ();
312297 }
313298}
314299
315300void ArduinoOcppTask::reconfigure () {
316- if (ocppLibraryLoaded ) {
301+ if (arduinoOcppInitialized ) {
317302 if (config_ocpp_enabled ()) {
318303 String mUrl = getCentralSystemUrl ();
319304 ocppSocket->reconnect (mUrl );
@@ -322,7 +307,7 @@ void ArduinoOcppTask::reconfigure() {
322307 ocppSocket->reconnect (emptyUrl);
323308 }
324309 } else {
325- loadOcppLibrary ();
310+ initializeArduinoOcpp ();
326311 }
327312 loadEvseBehavior ();
328313}
0 commit comments