Skip to content

Commit 01260d5

Browse files
committed
[wip] some more PR changes
Signed-off-by: Soumya Subramanya <s.subramanya@alfen.com>
1 parent 70d574e commit 01260d5

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

include/ocpp/v201/charge_point.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ class ChargePoint : ocpp::ChargingStationBase {
267267

268268
bool send(CallError call_error);
269269

270+
ConfigNetworkResult config_network_profile_result;
271+
270272
// internal helper functions
271273

272274
/// @brief Initialize the websocket connection.

include/ocpp/v201/ocpp_types.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,11 @@ void from_json(const json& j, NetworkConnectionProfile& k);
861861
/// \returns an output stream with the NetworkConnectionProfile written to
862862
std::ostream& operator<<(std::ostream& os, const NetworkConnectionProfile& k);
863863

864+
/// @brief The result of a configuration of a network profile.
864865
struct ConfigNetworkResult {
865-
std::optional<CiString<32>> interface_adress;
866-
bool success;
866+
NetworkConnectionProfile network_profile; ///< network profile used to configure the connection to the BO
867+
std::optional<CiString<32>> interface_address; ///< ip address or interface string
868+
bool success; ///< true if the configuration was sucessful
867869
};
868870
struct SetMonitoringData {
869871
float value;

lib/ocpp/v201/charge_point.cpp

+25-14
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const auto DEFAULT_MAX_MESSAGE_SIZE = 65000;
2626
bool Callbacks::all_callbacks_valid() const {
2727
return this->is_reset_allowed_callback != nullptr and this->reset_callback != nullptr and
2828
this->stop_transaction_callback != nullptr and this->pause_charging_callback != nullptr and
29-
// this->connector_effective_operative_status_changed_callback != nullptr and
29+
this->connector_effective_operative_status_changed_callback != nullptr and
3030
this->get_log_request_callback != nullptr and this->unlock_connector_callback != nullptr and
3131
this->remote_start_transaction_callback != nullptr and this->is_reservation_for_token_callback != nullptr and
3232
this->update_firmware_request_callback != nullptr and
@@ -691,6 +691,21 @@ void ChargePoint::init_websocket(std::optional<std::string> config_slot) {
691691
return;
692692
case std::future_status::ready:
693693
EVLOG_info << "ready!";
694+
// store the future output
695+
this->config_network_profile_result = config_status.get();
696+
697+
if (!this->config_network_profile_result.success) {
698+
EVLOG_warning
699+
<< "NetworkConnectionProfile could not be retrieved or configuration of network with the given "
700+
"profile failed";
701+
this->websocket_timer.timeout(
702+
[this]() {
703+
this->next_network_configuration_priority();
704+
this->start_websocket();
705+
},
706+
WEBSOCKET_INIT_DELAY);
707+
return;
708+
}
694709
break;
695710
}
696711
}
@@ -3021,25 +3036,21 @@ void ChargePoint::set_connector_operative_status(int32_t evse_id, int32_t connec
30213036
}
30223037

30233038
bool ChargePoint::on_try_switch_network_connection_profile(const std::string configuration_slot) {
3024-
EVLOG_info << "=============on_try_switch_network_profile============" << configuration_slot;
3039+
EVLOG_info << "=============on_try_switch_network_profile============" << configuration_slot;
30253040

30263041
// check if the configuration slot is valid
3027-
try
3028-
{
3029-
//call disconnect
3030-
this->disconnect_websocket(); //normal close
3031-
while (!this->is_offline())
3032-
{
3042+
try {
3043+
// call disconnect
3044+
this->disconnect_websocket(); // normal close
3045+
while (!this->is_offline()) {
30333046
/* code */
30343047
}
3035-
3036-
//call connect with the config_slot option
3048+
3049+
// call connect with the config_slot option
30373050
this->connect_websocket(configuration_slot);
30383051
return true;
3039-
3040-
}
3041-
catch(std::exception &e)
3042-
{
3052+
3053+
} catch (std::exception& e) {
30433054
EVLOG_info << "ERROR===============>";
30443055
return false;
30453056
}

0 commit comments

Comments
 (0)