openevse_esp32_firmware
openevse_esp32_firmware copied to clipboard
Update OCPP lib, fix building on Windows
This PR updates the OpenEVSE OCPP integration to the latest version and contains a fix for building on Windows (see #708, sorry for not creating a separate PR).
In the latest version I changed the class structure of Configs so that they are represented by an interface instead of only a concrete class. This allows to wrap OpenEVSE configs into an adapter (OcppConfigAdapter) which implements the Configuration interface and to pass this adapter to the OCPP lib. Now, the OCPP lib accesses the OpenEVSE configs directly instead of only synchronizing OpenEVSE configs with OCPP configs. This also means that there is a "single source of truth" - the value of each config exists in only one place now.
A special case is updating the OCPP backend URL. If this is done by the user through the GUI, it should apply immediately, resetting the WebSocket connection and reconnecting to the new URL. When the OCPP backend changes the URL, then the connection shouldn't reset immediately, but wait for the next reboot. But when the OcppConfigAdapter updates the OpenEVSE config, the config_changed() handler in app_config.cpp gets triggered and finally the notifyConfigChanged in ocpp.cpp. In this case the WebSocket reconnect is suppressed by setting the variable synchronizationLock and resetting it afterwards.
Still, I think that managing the configs has become much simpler now.
Btw. I renamed the library into MicroOcpp. This PR also reflects this change. Moreover, the previous class name ArduinoOcppTask has become outdated and I changed it into OcppTask. The same goes for the logo of the OCPP panel for which I will open a separate PR in the gui repo.
The Windows fix is related to generating staticFiles array in extra_script.py. When running on Windows it concatenates dir and filename with \ which leads to compilation errors in the web_server_static_files.h header. E.g. I got the string "/assets\components-aa3d0296.js", but the patch changes all \ into / in the final step of generating the staticFiles array.
TL;DR:
- [x] Adopt new project name of OCPP lib
- [x] Rename
ArduinoOcppTaskintoOcppTask - [x] Pass OpenEVSE configs to OCPP lib instead of synchronizing config objects of both projects
- [x] Fix generating paths on Windows (#708)
- [x] Replace AO-logo in GUI by official OCPP logo by the OCA (https://github.com/OpenEVSE/openevse-gui-v2/pull/13)
Thanks for accepting the PR in the gui repo. I think there's no real dependency between both PRs so I leave the gui update to #748.
Needs #796 to be merged to fix divert_sim build error