3#ifndef OCPP_WEBSOCKET_TLS_TPM_HPP
4#define OCPP_WEBSOCKET_TLS_TPM_HPP
6#include <ocpp/common/evse_security.hpp>
7#include <ocpp/common/safe_queue.hpp>
8#include <ocpp/common/websocket/websocket_base.hpp>
19struct WebsocketMessage;
26 std::shared_ptr<EvseSecurity> evse_security);
36 void close(
const WebsocketCloseReason code,
const std::string& reason)
override;
38 bool send(
const std::string& message)
override;
48 int process_callback(
void* wsi_ptr,
int callback_reason,
void* user,
void* in,
size_t len);
51 bool is_trying_to_connect_internal();
52 void close_internal(
const WebsocketCloseReason code,
const std::string& reason);
57 bool initialize_connection_options(std::shared_ptr<ConnectionData>& new_connection_data);
59 bool tls_init(
struct ssl_ctx_st* ctx,
const std::string& path_chain,
const std::string& path_key,
bool custom_key,
60 std::optional<std::string>& password);
63 void thread_websocket_client_loop(std::shared_ptr<ConnectionData> local_data);
67 void thread_websocket_message_recv_loop(std::shared_ptr<ConnectionData> local_data);
70 void thread_deferred_callback_queue();
82 void on_conn_writable();
85 void on_conn_message(std::string&& message);
90 void poll_message(
const std::shared_ptr<WebsocketMessage>& msg);
93 void push_deferred_callback(
const std::function<
void()>& callback);
96 void safe_close_threads();
99 void clear_all_queues();
102 std::shared_ptr<EvseSecurity> evse_security;
105 Everest::SteadyTimer reconnect_timer_tpm;
106 std::unique_ptr<std::thread> websocket_thread;
107 std::shared_ptr<ConnectionData> conn_data;
112 std::unique_ptr<std::thread> recv_message_thread;
114 std::string recv_buffered_message;
116 std::unique_ptr<std::thread> deferred_callback_thread;
117 SafeQueue<std::function<void()>> deferred_callback_queue;
118 std::atomic_bool stop_deferred_handler;
120 OcppProtocolVersion connected_ocpp_version;
Thread safe message queue. Holds a conditional variable that can be waited upon. Will take up the wai...
Definition: safe_queue.hpp:15
contains a websocket abstraction
Definition: websocket_base.hpp:46
Experimental libwebsockets TLS connection.
Definition: websocket_libwebsockets.hpp:22
WebsocketLibwebsockets(const WebsocketConnectionOptions &connection_options, std::shared_ptr< EvseSecurity > evse_security)
Creates a new Websocket object with the providede connection_options.
Definition: websocket_libwebsockets.cpp:339
bool start_connecting() override
Starts the connection attempts. It will init the websocket processing thread.
Definition: websocket_libwebsockets.cpp:943
void reconnect(long delay) override
reconnect the websocket after the delay
Definition: websocket_libwebsockets.cpp:1029
bool is_trying_to_connect()
Indicates if the websocket has a valid connection data and is trying to connect/reconnect internally ...
Definition: websocket_libwebsockets.cpp:932
bool send(const std::string &message) override
send a message over the websocket
Definition: websocket_libwebsockets.cpp:1158
void close(const WebsocketCloseReason code, const std::string &reason) override
closes the websocket
Definition: websocket_libwebsockets.cpp:1000
void set_connection_options(const WebsocketConnectionOptions &connection_options) override
sets this connection_options to the given connection_options and resets the connection_attempts
Definition: websocket_libwebsockets.cpp:378
void ping() override
send a websocket ping
Definition: websocket_libwebsockets.cpp:1173
Current connection data, sets the internal state of the.
Definition: websocket_libwebsockets.cpp:81
Definition: websocket_base.hpp:18