1010#include < functional>
1111#include < future>
1212#include < optional>
13+
1314namespace ocpp {
1415namespace v2 {
15-
1616class DeviceModelAbstract ;
17+ }
1718
1819// / \brief The result of a configuration of a network profile.
1920struct ConfigNetworkResult {
@@ -22,15 +23,24 @@ struct ConfigNetworkResult {
2223};
2324
2425using WebsocketConnectionCallback =
25- std::function<void (int configuration_slot, const NetworkConnectionProfile& network_connection_profile,
26+ std::function<void (int configuration_slot, const ocpp::v2:: NetworkConnectionProfile& network_connection_profile,
2627 const OcppProtocolVersion version)>;
2728using WebsocketConnectionFailedCallback = std::function<void (ConnectionFailedReason reason)>;
2829using ConfigureNetworkConnectionProfileCallback = std::function<std::future<ConfigNetworkResult>(
29- const std::int32_t configuration_slot, const NetworkConnectionProfile& network_connection_profile)>;
30+ const std::int32_t configuration_slot, const ocpp::v2:: NetworkConnectionProfile& network_connection_profile)>;
3031
3132class ConnectivityManagerInterface {
3233public:
3334 virtual ~ConnectivityManagerInterface () = default ;
35+
36+ // / \brief Set the \p callback that is called when a message is received from the websocket
37+ // /
38+ virtual void set_message_callback (const std::function<void (const std::string& message)>& callback) = 0;
39+
40+ // / \brief Set the logger \p logging
41+ // /
42+ virtual void set_logging (std::shared_ptr<MessageLogging> logging) = 0;
43+
3444 // / \brief Set the websocket \p authorization_key
3545 // /
3646 virtual void set_websocket_authorization_key (const std::string& authorization_key) = 0;
@@ -63,7 +73,7 @@ class ConnectivityManagerInterface {
6373 // / \brief Gets the cached NetworkConnectionProfile based on the given \p configuration_slot.
6474 // / This returns the value from the cached network connection profiles.
6575 // / \return Returns a profile if the slot is found
66- virtual std::optional<NetworkConnectionProfile>
76+ virtual std::optional<ocpp::v2:: NetworkConnectionProfile>
6777 get_network_connection_profile (const std::int32_t configuration_slot) const = 0 ;
6878
6979 // / \brief Get the priority of the given configuration slot.
@@ -107,7 +117,7 @@ class ConnectivityManagerInterface {
107117 // /
108118 // / \param ocpp_interface The interface that is disconnected.
109119 // /
110- virtual void on_network_disconnected (OCPPInterfaceEnum ocpp_interface) = 0;
120+ virtual void on_network_disconnected (ocpp::v2:: OCPPInterfaceEnum ocpp_interface) = 0;
111121
112122 // / \brief Called when the charging station certificate is changed
113123 // /
@@ -120,7 +130,7 @@ class ConnectivityManagerInterface {
120130class ConnectivityManager : public ConnectivityManagerInterface {
121131private:
122132 // / \brief Reference to the device model
123- DeviceModelAbstract& device_model;
133+ ocpp::v2:: DeviceModelAbstract& device_model;
124134 // / \brief Pointer to the evse security class
125135 std::shared_ptr<EvseSecurity> evse_security;
126136 // / \brief Pointer to the logger
@@ -144,32 +154,33 @@ class ConnectivityManager : public ConnectivityManagerInterface {
144154 std::int32_t active_network_configuration_priority;
145155 int last_known_security_level;
146156 // / @brief Local cached network connection profiles
147- std::vector<SetNetworkProfileRequest> cached_network_connection_profiles;
157+ std::vector<ocpp::v2:: SetNetworkProfileRequest> cached_network_connection_profiles;
148158 // / @brief local cached network connection priorities
149159 std::vector<std::int32_t > network_connection_slots;
150160 OcppProtocolVersion connected_ocpp_version;
151161
152162public:
153- ConnectivityManager (DeviceModelAbstract& device_model, std::shared_ptr<EvseSecurity> evse_security,
154- std::shared_ptr<MessageLogging> logging,
155- const std::function<void (const std::string& message)>& message_callback);
163+ ConnectivityManager (ocpp::v2::DeviceModelAbstract& device_model, std::shared_ptr<EvseSecurity> evse_security);
156164
165+ void set_message_callback (const std::function<void (const std::string& message)>& callback) override ;
166+ void set_logging (std::shared_ptr<MessageLogging> logging) override ;
157167 void set_websocket_authorization_key (const std::string& authorization_key) override ;
158168 void set_websocket_connection_options (const WebsocketConnectionOptions& connection_options) override ;
159169 void set_websocket_connection_options_without_reconnect () override ;
160170 void set_websocket_connected_callback (WebsocketConnectionCallback callback) override ;
161171 void set_websocket_disconnected_callback (WebsocketConnectionCallback callback) override ;
162172 void set_websocket_connection_failed_callback (WebsocketConnectionFailedCallback callback) override ;
163173 void set_configure_network_connection_profile_callback (ConfigureNetworkConnectionProfileCallback callback) override ;
164- std::optional<NetworkConnectionProfile>
174+ std::optional<ocpp::v2:: NetworkConnectionProfile>
165175 get_network_connection_profile (const std::int32_t configuration_slot) const override ;
166- std::optional<std::int32_t > get_priority_from_configuration_slot (const int configuration_slot) const override ;
176+ std::optional<std::int32_t >
177+ get_priority_from_configuration_slot (const std::int32_t configuration_slot) const override ;
167178 const std::vector<int >& get_network_connection_slots () const override ;
168179 bool is_websocket_connected () override ;
169180 void connect (std::optional<std::int32_t > network_profile_slot = std::nullopt ) override ;
170181 void disconnect () override ;
171182 bool send_to_websocket (const std::string& message) override ;
172- void on_network_disconnected (OCPPInterfaceEnum ocpp_interface) override ;
183+ void on_network_disconnected (ocpp::v2:: OCPPInterfaceEnum ocpp_interface) override ;
173184 void on_charging_station_certificate_changed () override ;
174185 void confirm_successful_connection () override ;
175186
@@ -190,7 +201,7 @@ class ConnectivityManager : public ConnectivityManagerInterface {
190201 // / \return The network configuration containing the network interface to use, nullptr if the request failed or the
191202 // / callback is not configured
192203 std::optional<ConfigNetworkResult>
193- handle_configure_network_connection_profile_callback (int slot, const NetworkConnectionProfile& profile);
204+ handle_configure_network_connection_profile_callback (int slot, const ocpp::v2:: NetworkConnectionProfile& profile);
194205
195206 // / \brief Function invoked when the web socket connected with the \p security_profile
196207 // /
@@ -237,5 +248,4 @@ class ConnectivityManager : public ConnectivityManagerInterface {
237248 void remove_network_connection_profiles_below_actual_security_profile ();
238249};
239250
240- } // namespace v2
241251} // namespace ocpp
0 commit comments