1212#include < optional>
1313namespace ocpp {
1414namespace v2 {
15-
1615class DeviceModel ;
16+ }
1717
1818// / \brief The result of a configuration of a network profile.
1919struct ConfigNetworkResult {
@@ -22,15 +22,24 @@ struct ConfigNetworkResult {
2222};
2323
2424using WebsocketConnectionCallback =
25- std::function<void (int configuration_slot, const NetworkConnectionProfile& network_connection_profile,
25+ std::function<void (int configuration_slot, const ocpp::v2:: NetworkConnectionProfile& network_connection_profile,
2626 const OcppProtocolVersion version)>;
2727using WebsocketConnectionFailedCallback = std::function<void (ConnectionFailedReason reason)>;
2828using ConfigureNetworkConnectionProfileCallback = std::function<std::future<ConfigNetworkResult>(
29- const std::int32_t configuration_slot, const NetworkConnectionProfile& network_connection_profile)>;
29+ const std::int32_t configuration_slot, const ocpp::v2:: NetworkConnectionProfile& network_connection_profile)>;
3030
3131class ConnectivityManagerInterface {
3232public:
3333 virtual ~ConnectivityManagerInterface () = default ;
34+
35+ // / \brief Set the \p callback that is called when a message is received from the websocket
36+ // /
37+ virtual void set_message_callback (const std::function<void (const std::string& message)>& callback) = 0;
38+
39+ // / \brief Set the logger \p logging
40+ // /
41+ virtual void set_logging (std::shared_ptr<MessageLogging> logging) = 0;
42+
3443 // / \brief Set the websocket \p authorization_key
3544 // /
3645 virtual void set_websocket_authorization_key (const std::string& authorization_key) = 0;
@@ -63,7 +72,7 @@ class ConnectivityManagerInterface {
6372 // / \brief Gets the cached NetworkConnectionProfile based on the given \p configuration_slot.
6473 // / This returns the value from the cached network connection profiles.
6574 // / \return Returns a profile if the slot is found
66- virtual std::optional<NetworkConnectionProfile>
75+ virtual std::optional<ocpp::v2:: NetworkConnectionProfile>
6776 get_network_connection_profile (const std::int32_t configuration_slot) const = 0 ;
6877
6978 // / \brief Get the priority of the given configuration slot.
@@ -107,7 +116,7 @@ class ConnectivityManagerInterface {
107116 // /
108117 // / \param ocpp_interface The interface that is disconnected.
109118 // /
110- virtual void on_network_disconnected (OCPPInterfaceEnum ocpp_interface) = 0;
119+ virtual void on_network_disconnected (ocpp::v2:: OCPPInterfaceEnum ocpp_interface) = 0;
111120
112121 // / \brief Called when the charging station certificate is changed
113122 // /
@@ -120,7 +129,7 @@ class ConnectivityManagerInterface {
120129class ConnectivityManager : public ConnectivityManagerInterface {
121130private:
122131 // / \brief Reference to the device model
123- DeviceModel& device_model;
132+ ocpp::v2:: DeviceModel& device_model;
124133 // / \brief Pointer to the evse security class
125134 std::shared_ptr<EvseSecurity> evse_security;
126135 // / \brief Pointer to the logger
@@ -144,32 +153,33 @@ class ConnectivityManager : public ConnectivityManagerInterface {
144153 std::int32_t active_network_configuration_priority;
145154 int last_known_security_level;
146155 // / @brief Local cached network connection profiles
147- std::vector<SetNetworkProfileRequest> cached_network_connection_profiles;
156+ std::vector<ocpp::v2:: SetNetworkProfileRequest> cached_network_connection_profiles;
148157 // / @brief local cached network connection priorities
149158 std::vector<std::int32_t > network_connection_slots;
150159 OcppProtocolVersion connected_ocpp_version;
151160
152161public:
153- ConnectivityManager (DeviceModel& 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);
162+ ConnectivityManager (ocpp::v2::DeviceModel& device_model, std::shared_ptr<EvseSecurity> evse_security);
156163
164+ void set_message_callback (const std::function<void (const std::string& message)>& callback) override ;
165+ void set_logging (std::shared_ptr<MessageLogging> logging) override ;
157166 void set_websocket_authorization_key (const std::string& authorization_key) override ;
158167 void set_websocket_connection_options (const WebsocketConnectionOptions& connection_options) override ;
159168 void set_websocket_connection_options_without_reconnect () override ;
160169 void set_websocket_connected_callback (WebsocketConnectionCallback callback) override ;
161170 void set_websocket_disconnected_callback (WebsocketConnectionCallback callback) override ;
162171 void set_websocket_connection_failed_callback (WebsocketConnectionFailedCallback callback) override ;
163172 void set_configure_network_connection_profile_callback (ConfigureNetworkConnectionProfileCallback callback) override ;
164- std::optional<NetworkConnectionProfile>
173+ std::optional<ocpp::v2:: NetworkConnectionProfile>
165174 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 ;
175+ std::optional<std::int32_t >
176+ get_priority_from_configuration_slot (const std::int32_t configuration_slot) const override ;
167177 const std::vector<int >& get_network_connection_slots () const override ;
168178 bool is_websocket_connected () override ;
169179 void connect (std::optional<std::int32_t > network_profile_slot = std::nullopt ) override ;
170180 void disconnect () override ;
171181 bool send_to_websocket (const std::string& message) override ;
172- void on_network_disconnected (OCPPInterfaceEnum ocpp_interface) override ;
182+ void on_network_disconnected (ocpp::v2:: OCPPInterfaceEnum ocpp_interface) override ;
173183 void on_charging_station_certificate_changed () override ;
174184 void confirm_successful_connection () override ;
175185
@@ -190,7 +200,7 @@ class ConnectivityManager : public ConnectivityManagerInterface {
190200 // / \return The network configuration containing the network interface to use, nullptr if the request failed or the
191201 // / callback is not configured
192202 std::optional<ConfigNetworkResult>
193- handle_configure_network_connection_profile_callback (int slot, const NetworkConnectionProfile& profile);
203+ handle_configure_network_connection_profile_callback (int slot, const ocpp::v2:: NetworkConnectionProfile& profile);
194204
195205 // / \brief Function invoked when the web socket connected with the \p security_profile
196206 // /
@@ -237,5 +247,4 @@ class ConnectivityManager : public ConnectivityManagerInterface {
237247 void remove_network_connection_profiles_below_actual_security_profile ();
238248};
239249
240- } // namespace v2
241250} // namespace ocpp
0 commit comments