Skip to content

Commit

Permalink
Removed websocket++ as a dependency (#846)
Browse files Browse the repository at this point in the history
* Removed websocket++ as a dependency

---------

Signed-off-by: AssemblyJohn <[email protected]>
  • Loading branch information
AssemblyJohn authored Oct 30, 2024
1 parent a6f88c8 commit 6a00102
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 966 deletions.
16 changes: 5 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ option(BUILD_TESTING "Build unit tests, used if standalone project" OFF)
option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF)
option(LIBOCPP16_BUILD_EXAMPLES "Build charge_point binary" OFF)
option(OCPP_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT})
option(LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP "Usage of deprecated websocket++ instead of libwebsockets" OFF)
option(LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP "Websocket++ has been removed from the project" OFF)

option(LIBOCPP_ENABLE_V16 "Enable OCPP 1.6 in the ocpp library" ON)
option(LIBOCPP_ENABLE_V201 "Enable OCPP 2.0.1 in the ocpp library" ON)
Expand All @@ -25,6 +25,10 @@ if((NOT LIBOCPP_ENABLE_V16) AND (NOT LIBOCPP_ENABLE_V201))
message(FATAL_ERROR "At least one of LIBOCPP_ENABLE_V16 and LIBOCPP_ENABLE_V201 needs to be ON")
endif()

if(LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP)
message(FATAL_ERROR "Websocket++ has been removed")
endif()

if((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} OR ${PROJECT_NAME}_BUILD_TESTING) AND BUILD_TESTING)
set(LIBOCPP_BUILD_TESTING ON)
endif()
Expand All @@ -39,12 +43,6 @@ if(NOT DISABLE_EDM)

# In EDM mode, we can't install exports (because the dependencies usually do not install their exports)
set(OCPP_INSTALL OFF)

if(LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP)
# FIXME (aw): websocketpp doesn't play well with EDM/CPM
add_library(websocketpp::websocketpp INTERFACE IMPORTED)
set_target_properties(websocketpp::websocketpp PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${websocketpp_SOURCE_DIR}")
endif()
else()
find_package(date REQUIRED)
find_package(nlohmann_json REQUIRED)
Expand All @@ -54,10 +52,6 @@ else()
find_package(everest-timer REQUIRED)
find_package(everest-log REQUIRED)
find_package(everest-evse_security REQUIRED)

if(LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP)
find_package(websocketpp REQUIRED)
endif()
endif()

# config and auxillary files
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,7 @@ In order to use the TPM keys, it is mandatory to use the default libwebsocket im
## Support for websocket++
The old websocket++ implementation has been deprecated. For enabling websocket++ support use the following cmake option:
```bash
cmake .. -DLIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP=ON
```
The old websocket++ implementation has been removed. Enabling websocket++ will prevent compilation from starting.
### Support for iface
Expand Down
4 changes: 0 additions & 4 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ date:
git: https://github.com/HowardHinnant/date.git
git_tag: v3.0.1
options: ["BUILD_TZ_LIB ON", "HAS_REMOTE_API 0", "USE_AUTOLOAD 0", "USE_SYSTEM_TZ_DB ON"]
websocketpp:
git: https://github.com/zaphoyd/websocketpp.git
git_tag: 0.8.2
cmake_condition: "LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP"
libevse-security:
git: https://github.com/EVerest/libevse-security.git
git_tag: v0.8.0
Expand Down
8 changes: 4 additions & 4 deletions include/ocpp/common/websocket/websocket_libwebsockets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ struct ConnectionData;
struct WebsocketMessage;

/// \brief Experimental libwebsockets TLS connection
class WebsocketTlsTPM final : public WebsocketBase {
class WebsocketLibwebsockets final : public WebsocketBase {
public:
/// \brief Creates a new Websocket object with the providede \p connection_options
explicit WebsocketTlsTPM(const WebsocketConnectionOptions& connection_options,
std::shared_ptr<EvseSecurity> evse_security);
explicit WebsocketLibwebsockets(const WebsocketConnectionOptions& connection_options,
std::shared_ptr<EvseSecurity> evse_security);

~WebsocketTlsTPM();
~WebsocketLibwebsockets();

void set_connection_options(const WebsocketConnectionOptions& connection_options) override;

Expand Down
77 changes: 0 additions & 77 deletions include/ocpp/common/websocket/websocket_plain.hpp

This file was deleted.

87 changes: 0 additions & 87 deletions include/ocpp/common/websocket/websocket_tls.hpp

This file was deleted.

9 changes: 0 additions & 9 deletions include/ocpp/common/websocket/websocket_uri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,11 @@
#include <string>
#include <string_view>

#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
12 changes: 0 additions & 12 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,6 @@ target_link_libraries(ocpp
date::date-tz
)

if(LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP)
target_link_libraries(ocpp
PUBLIC
websocketpp::websocketpp
)

target_compile_definitions(ocpp
PRIVATE
LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP
)
endif()

if(LIBOCPP_USE_BOOST_FILESYSTEM)
find_package(Boost REQUIRED COMPONENTS filesystem)
target_link_libraries(ocpp
Expand Down
8 changes: 0 additions & 8 deletions lib/ocpp/common/websocket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@ target_sources(ocpp
websocket.cpp
websocket_libwebsockets.cpp
)

if(LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP)
target_sources(ocpp
PRIVATE
websocket_plain.cpp
websocket_tls.cpp
)
endif()
16 changes: 1 addition & 15 deletions lib/ocpp/common/websocket/websocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
#include <ocpp/common/websocket/websocket.hpp>
#include <ocpp/v16/types.hpp>

#ifdef LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP
#include <ocpp/common/websocket/websocket_plain.hpp>
#include <ocpp/common/websocket/websocket_tls.hpp>
#else
#include <ocpp/common/websocket/websocket_libwebsockets.hpp>
#endif

#include <boost/algorithm/string.hpp>

Expand All @@ -21,16 +16,7 @@ namespace ocpp {
Websocket::Websocket(const WebsocketConnectionOptions& connection_options, std::shared_ptr<EvseSecurity> evse_security,
std::shared_ptr<MessageLogging> logging) :
logging(logging) {

#ifdef LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP
if (connection_options.security_profile <= 1) {
this->websocket = std::make_unique<WebsocketPlain>(connection_options);
} else if (connection_options.security_profile >= 2) {
this->websocket = std::make_unique<WebsocketTLS>(connection_options, evse_security);
}
#else
this->websocket = std::make_unique<WebsocketTlsTPM>(connection_options, evse_security);
#endif
this->websocket = std::make_unique<WebsocketLibwebsockets>(connection_options, evse_security);
}

Websocket::~Websocket() {
Expand Down
Loading

0 comments on commit 6a00102

Please sign in to comment.