Skip to content

Commit

Permalink
Fixed include paths
Browse files Browse the repository at this point in the history
Signed-off-by: AssemblyJohn <[email protected]>
  • Loading branch information
AssemblyJohn committed Apr 17, 2024
1 parent ddf79b6 commit bd52eea
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include <string>

namespace websocketpp_utils {
namespace ocpp {

static std::string const base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <stdexcept>
#include <string>

namespace websocketpp_utils {
namespace ocpp {

// TODO: figure out why this fixes horrible linking errors.

Expand Down
17 changes: 14 additions & 3 deletions include/ocpp/common/websocket/websocket_uri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@
#include <string>
#include <string_view>

#include <../3rd_party/websocketpp/uri.hpp>
#if LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP
#include <websocketpp/uri.hpp>
#else
#include <websocketpp_utils/uri.hpp>
#endif


namespace ocpp {

#if LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP
typedef websocketpp::uri ev_uri;
#else
typedef ocpp::uri ev_uri;
#endif

class Uri {
public:
Uri(){};
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ target_include_directories(ocpp
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_include_directories(ocpp
PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/3rd_party>
)

#############
# Logging configuration
#
Expand Down
4 changes: 2 additions & 2 deletions lib/ocpp/common/websocket/websocket_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest
#include <random>

#include <../3rd_party/websocketpp/base64.hpp>
#include <websocketpp_utils/base64.hpp>
#include <everest/logging.hpp>
#include <ocpp/common/websocket/websocket_base.hpp>
namespace ocpp {
Expand Down Expand Up @@ -111,7 +111,7 @@ std::optional<std::string> 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();
}
Expand Down
3 changes: 1 addition & 2 deletions lib/ocpp/common/websocket/websocket_libwebsockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions lib/ocpp/common/websocket/websocket_plain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand All @@ -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");
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ocpp/common/websocket/websocket_tls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand All @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ocpp/common/websocket/websocket_uri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit bd52eea

Please sign in to comment.