diff --git a/3rd_party/websocketpp/base64.hpp b/3rd_party/websocketpp_utils/base64.hpp similarity index 99% rename from 3rd_party/websocketpp/base64.hpp rename to 3rd_party/websocketpp_utils/base64.hpp index 7c91d9f2ce..97d522c309 100644 --- a/3rd_party/websocketpp/base64.hpp +++ b/3rd_party/websocketpp_utils/base64.hpp @@ -38,7 +38,7 @@ #include -namespace websocketpp_utils { +namespace ocpp { static std::string const base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" diff --git a/3rd_party/websocketpp/uri.hpp b/3rd_party/websocketpp_utils/uri.hpp similarity index 99% rename from 3rd_party/websocketpp/uri.hpp rename to 3rd_party/websocketpp_utils/uri.hpp index e33e479091..e5895c1757 100644 --- a/3rd_party/websocketpp/uri.hpp +++ b/3rd_party/websocketpp_utils/uri.hpp @@ -33,7 +33,7 @@ #include #include -namespace websocketpp_utils { +namespace ocpp { // TODO: figure out why this fixes horrible linking errors. diff --git a/include/ocpp/common/websocket/websocket_uri.hpp b/include/ocpp/common/websocket/websocket_uri.hpp index c4475250c5..40eac9ca77 100644 --- a/include/ocpp/common/websocket/websocket_uri.hpp +++ b/include/ocpp/common/websocket/websocket_uri.hpp @@ -6,10 +6,21 @@ #include #include -#include <../3rd_party/websocketpp/uri.hpp> +#if LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP +#include +#else +#include +#endif + namespace ocpp { +#if LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP +typedef websocketpp::uri ev_uri; +#else +typedef ocpp::uri ev_uri; +#endif + class Uri { public: Uri(){}; @@ -54,8 +65,8 @@ class Uri { return uri.str(); } - websocketpp_utils::uri get_websocketpp_uri() { // FIXME: wrap needed `websocketpp:uri` functionality inside `Uri` - return websocketpp_utils::uri(this->secure, this->host, this->port, + ev_uri get_websocketpp_uri() { // FIXME: wrap needed `websocketpp:uri` functionality inside `Uri` + return ev_uri(this->secure, this->host, this->port, this->path_without_chargepoint_id /* is normalized with ending slash */ + this->chargepoint_id); } diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index e5b58c9e70..73770a64c2 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -63,6 +63,11 @@ target_include_directories(ocpp $ ) +target_include_directories(ocpp + PRIVATE + $ +) + ############# # Logging configuration # diff --git a/lib/ocpp/common/websocket/websocket_base.cpp b/lib/ocpp/common/websocket/websocket_base.cpp index cd59ef3a76..57ede307a1 100644 --- a/lib/ocpp/common/websocket/websocket_base.cpp +++ b/lib/ocpp/common/websocket/websocket_base.cpp @@ -2,7 +2,7 @@ // Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest #include -#include <../3rd_party/websocketpp/base64.hpp> +#include #include #include namespace ocpp { @@ -111,7 +111,7 @@ std::optional WebsocketBase::getAuthorizationHeader() { this->connection_options.csms_uri.get_chargepoint_id() + ":" + authorization_key.value(); // TODO (ioan): replace with libevse-security usage - auth_header.emplace(std::string("Basic ") + websocketpp_utils::base64_encode(plain_auth_header)); + auth_header.emplace(std::string("Basic ") + ocpp::base64_encode(plain_auth_header)); EVLOG_debug << "Basic Auth header: " << auth_header.value(); } diff --git a/lib/ocpp/common/websocket/websocket_libwebsockets.cpp b/lib/ocpp/common/websocket/websocket_libwebsockets.cpp index 9c05f818e8..a72aa99504 100644 --- a/lib/ocpp/common/websocket/websocket_libwebsockets.cpp +++ b/lib/ocpp/common/websocket/websocket_libwebsockets.cpp @@ -415,8 +415,7 @@ void WebsocketTlsTPM::client_loop() { local_data->bind_thread(std::this_thread::get_id()); // lws_set_log_level(LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO | LLL_DEBUG | LLL_PARSER | LLL_HEADER | LLL_EXT | - // LLL_CLIENT | LLL_LATENCY | LLL_THREAD | LLL_USER, nullptr); - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE, nullptr); + // LLL_CLIENT | LLL_LATENCY | LLL_THREAD | LLL_USER, nullptr); lws_context_creation_info info; memset(&info, 0, sizeof(lws_context_creation_info)); diff --git a/lib/ocpp/common/websocket/websocket_plain.cpp b/lib/ocpp/common/websocket/websocket_plain.cpp index 6188099526..c882d00fee 100644 --- a/lib/ocpp/common/websocket/websocket_plain.cpp +++ b/lib/ocpp/common/websocket/websocket_plain.cpp @@ -248,7 +248,7 @@ void WebsocketPlain::on_close_plain(client* c, websocketpp::connection_hdl hdl) << "), reason: " << con->get_remote_close_reason(); // dont reconnect on normal code if (con->get_remote_close_code() != websocketpp::close::status::normal) { - this->reconnect(error_code, this->get_reconnect_interval()); + this->reconnect(this->get_reconnect_interval()); } else { this->closed_callback(value_to_close_reason(con->get_remote_close_code())); } @@ -268,7 +268,7 @@ void WebsocketPlain::on_fail_plain(client* c, websocketpp::connection_hdl hdl) { // -1 indicates to always attempt to reconnect if (this->connection_options.max_connection_attempts == -1 or this->connection_attempts <= this->connection_options.max_connection_attempts) { - this->reconnect(ec, this->get_reconnect_interval()); + this->reconnect(this->get_reconnect_interval()); } else { this->close(WebsocketCloseReason::Normal, "Connection failed"); } diff --git a/lib/ocpp/common/websocket/websocket_tls.cpp b/lib/ocpp/common/websocket/websocket_tls.cpp index 6fb782bc3b..57c000fd37 100644 --- a/lib/ocpp/common/websocket/websocket_tls.cpp +++ b/lib/ocpp/common/websocket/websocket_tls.cpp @@ -338,7 +338,7 @@ void WebsocketTLS::on_close_tls(tls_client* c, websocketpp::connection_hdl hdl) << "), reason: " << con->get_remote_close_reason(); // dont reconnect on normal close if (con->get_remote_close_code() != websocketpp::close::status::normal) { - this->reconnect(error_code, this->get_reconnect_interval()); + this->reconnect(this->get_reconnect_interval()); } else { this->closed_callback(value_to_close_reason(con->get_remote_close_code())); } @@ -357,7 +357,7 @@ void WebsocketTLS::on_fail_tls(tls_client* c, websocketpp::connection_hdl hdl) { // -1 indicates to always attempt to reconnect if (this->connection_options.max_connection_attempts == -1 or this->connection_attempts <= this->connection_options.max_connection_attempts) { - this->reconnect(ec, this->get_reconnect_interval()); + this->reconnect(this->get_reconnect_interval()); } else { this->close(WebsocketCloseReason::Normal, "Connection failed"); } diff --git a/lib/ocpp/common/websocket/websocket_uri.cpp b/lib/ocpp/common/websocket/websocket_uri.cpp index f627a0e659..dc0cc3e328 100644 --- a/lib/ocpp/common/websocket/websocket_uri.cpp +++ b/lib/ocpp/common/websocket/websocket_uri.cpp @@ -49,7 +49,7 @@ Uri Uri::parse_and_validate(std::string uri, std::string chargepoint_id, int sec uri = "ws://" + uri; } - auto uri_temp = websocketpp_utils::uri(uri); + auto uri_temp = ev_uri(uri); if (!uri_temp.get_valid()) { throw std::invalid_argument("given `uri` is invalid"); }