6#include <ocpp/common/websocket/websocket.hpp>
7#include <ocpp/v2/messages/SetNetworkProfile.hpp>
8#include <ocpp/v2/ocpp_types.hpp>
18using WebsocketConnectionCallback = std::function<void(
19 int configuration_slot,
const NetworkConnectionProfile& network_connection_profile, OcppProtocolVersion version)>;
20using WebsocketConnectionFailedCallback = std::function<void(ConnectionFailedReason reason)>;
21using ConfigureNetworkConnectionProfileCallback = std::function<std::future<ConfigNetworkResult>(
22 const int32_t configuration_slot,
const NetworkConnectionProfile& network_connection_profile)>;
60 virtual std::optional<NetworkConnectionProfile>
85 virtual void connect(std::optional<int32_t> network_profile_slot = std::nullopt) = 0;
119 std::shared_ptr<EvseSecurity> evse_security;
121 std::shared_ptr<MessageLogging> logging;
123 std::unique_ptr<Websocket> websocket;
125 std::function<void(
const std::string& message)> message_callback;
127 std::optional<WebsocketConnectionCallback> websocket_connected_callback;
129 std::optional<WebsocketConnectionCallback> websocket_disconnected_callback;
131 std::optional<WebsocketConnectionFailedCallback> websocket_connection_failed_callback;
133 std::optional<ConfigureNetworkConnectionProfileCallback> configure_network_connection_profile_callback;
135 Everest::SteadyTimer websocket_timer;
136 std::optional<int32_t> pending_configuration_slot;
137 bool wants_to_be_connected;
138 int32_t active_network_configuration_priority;
139 int last_known_security_level;
141 std::vector<SetNetworkProfileRequest> cached_network_connection_profiles;
143 std::vector<int32_t> network_connection_slots;
144 OcppProtocolVersion connected_ocpp_version;
148 std::shared_ptr<MessageLogging> logging,
149 const std::function<
void(
const std::string& message)>& message_callback);
158 std::optional<NetworkConnectionProfile>
163 void connect(std::optional<int32_t> network_profile_slot = std::nullopt)
override;
173 void try_connect_websocket();
178 std::optional<WebsocketConnectionOptions> get_ws_connection_options(
const int32_t configuration_slot);
186 std::optional<ConfigNetworkResult>
191 void on_websocket_connected(OcppProtocolVersion protocol);
195 void on_websocket_disconnected();
200 void on_websocket_stopped_connecting(ocpp::WebsocketCloseReason reason);
206 int get_active_network_configuration_slot()
const;
213 int get_configuration_slot_from_priority(
const int priority);
220 int get_next_configuration_slot(int32_t configuration_slot);
223 void cache_network_connection_profiles();
227 void check_cache_for_invalid_security_profiles();
231 void remove_network_connection_profiles_below_actual_security_profile();
Definition: connectivity_manager.hpp:24
virtual const std::vector< int > & get_network_connection_slots() const =0
Get the network connection slots sorted by priority. Each item in the vector contains the configured ...
virtual std::optional< int32_t > get_priority_from_configuration_slot(const int configuration_slot) const =0
Get the priority of the given configuration slot.
virtual void set_websocket_authorization_key(const std::string &authorization_key)=0
Set the websocket authorization_key.
virtual bool is_websocket_connected()=0
Check if the websocket is connected.
virtual void set_websocket_connected_callback(WebsocketConnectionCallback callback)=0
Set the callback that is called when the websocket is connected.
virtual void set_websocket_connection_options_without_reconnect()=0
Set the websocket connection options without triggering a reconnect.
virtual void on_charging_station_certificate_changed()=0
Called when the charging station certificate is changed.
virtual std::optional< NetworkConnectionProfile > get_network_connection_profile(const int32_t configuration_slot) const =0
Gets the cached NetworkConnectionProfile based on the given configuration_slot. This returns the valu...
virtual void disconnect()=0
Disconnect the websocket.
virtual void connect(std::optional< int32_t > network_profile_slot=std::nullopt)=0
Connect to the websocket.
virtual void confirm_successful_connection()=0
Confirms the connection is successful so the security profile requirements can be handled.
virtual void set_websocket_disconnected_callback(WebsocketConnectionCallback callback)=0
Set the callback that is called when the websocket is disconnected.
virtual bool send_to_websocket(const std::string &message)=0
send a message over the websocket
virtual void set_websocket_connection_failed_callback(WebsocketConnectionFailedCallback callback)=0
Set the callback that is called when the websocket could not connect with a specific reason.
virtual void set_websocket_connection_options(const WebsocketConnectionOptions &connection_options)=0
Set the websocket connection_options.
virtual void set_configure_network_connection_profile_callback(ConfigureNetworkConnectionProfileCallback callback)=0
Set the callback that is called to configure a network connection profile when none is configured.
virtual void on_network_disconnected(OCPPInterfaceEnum ocpp_interface)=0
Can be called when a network is disconnected, for example when an ethernet cable is removed.
Definition: connectivity_manager.hpp:114
std::optional< int32_t > get_priority_from_configuration_slot(const int configuration_slot) const override
Get the priority of the given configuration slot.
Definition: connectivity_manager.cpp:94
void set_websocket_authorization_key(const std::string &authorization_key) override
Set the websocket authorization_key.
Definition: connectivity_manager.cpp:36
void on_charging_station_certificate_changed() override
Called when the charging station certificate is changed.
Definition: connectivity_manager.cpp:315
const std::vector< int > & get_network_connection_slots() const override
Get the network connection slots sorted by priority. Each item in the vector contains the configured ...
Definition: connectivity_manager.cpp:112
void confirm_successful_connection() override
Confirms the connection is successful so the security profile requirements can be handled.
Definition: connectivity_manager.cpp:151
void set_websocket_connection_failed_callback(WebsocketConnectionFailedCallback callback) override
Set the callback that is called when the websocket could not connect with a specific reason.
Definition: connectivity_manager.cpp:65
bool send_to_websocket(const std::string &message) override
send a message over the websocket
Definition: connectivity_manager.cpp:292
void set_websocket_connected_callback(WebsocketConnectionCallback callback) override
Set the callback that is called when the websocket is connected.
Definition: connectivity_manager.cpp:57
std::optional< NetworkConnectionProfile > get_network_connection_profile(const int32_t configuration_slot) const override
Gets the cached NetworkConnectionProfile based on the given configuration_slot. This returns the valu...
Definition: connectivity_manager.cpp:75
void set_websocket_connection_options_without_reconnect() override
Set the websocket connection options without triggering a reconnect.
Definition: connectivity_manager.cpp:49
void connect(std::optional< int32_t > network_profile_slot=std::nullopt) override
Connect to the websocket.
Definition: connectivity_manager.cpp:120
bool is_websocket_connected() override
Check if the websocket is connected.
Definition: connectivity_manager.cpp:116
void set_websocket_connection_options(const WebsocketConnectionOptions &connection_options) override
Set the websocket connection_options.
Definition: connectivity_manager.cpp:43
void set_websocket_disconnected_callback(WebsocketConnectionCallback callback) override
Set the callback that is called when the websocket is disconnected.
Definition: connectivity_manager.cpp:61
void disconnect() override
Disconnect the websocket.
Definition: connectivity_manager.cpp:143
void on_network_disconnected(OCPPInterfaceEnum ocpp_interface) override
Can be called when a network is disconnected, for example when an ethernet cable is removed.
Definition: connectivity_manager.cpp:300
void set_configure_network_connection_profile_callback(ConfigureNetworkConnectionProfileCallback callback) override
Set the callback that is called to configure a network connection profile when none is configured.
Definition: connectivity_manager.cpp:69
This class manages access to the device model representation and to the device model interface and pr...
Definition: device_model.hpp:96
Definition: websocket_base.hpp:18
Definition: ocpp_types.hpp:831