Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.5.8 #228

Merged
merged 9 commits into from
Feb 6, 2025
2 changes: 1 addition & 1 deletion 3rdparty/libwebsockets/lib/core-net/client/connect4.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ lws_client_connect_4_established(struct lws *wsi, struct lws *wsi_piggyback,
if (wsi->a.vhost->http.http_proxy_port) {
const char *cpa;

cpa = lws_wsi_client_stash_item(wsi, CIS_ADDRESS,
cpa = lws_wsi_client_stash_item(wsi, CIS_HOST,
_WSI_TOKEN_CLIENT_PEER_ADDRESS);
if (!cpa)
goto failed;
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
cmake_minimum_required(VERSION 3.13)

project(OpenOCPP DESCRIPTION "Open Source C++ implementation of the OCPP 1.6 protocol"
VERSION 1.5.7
VERSION 1.5.8
)

# Definitions for Version.h file
Expand Down
6 changes: 6 additions & 0 deletions src/centralsystem/chargepoint/ChargePointHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::HeartbeatReq& reque
// Empty request
(void)request;

// Notify request
if (m_handler)
{
m_handler->heartbeat();
}

// Prepare response
response.currentTime = DateTime::now();

Expand Down
5 changes: 5 additions & 0 deletions src/centralsystem/interface/IChargePointRequestHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class IChargePointRequestHandler
/** @brief Called to notify the disconnection of the charge point */
virtual void disconnected() = 0;

/**
* @brief Called when an heartbeat has been received
*/
virtual void heartbeat() { }

/**
* @brief Called to get authorization informations for an id tag
* @param id_tag Id tag to check
Expand Down
3 changes: 2 additions & 1 deletion src/chargepoint/iso15118/Iso15118Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertifica

// Notify handler to get the list of installed certificates
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>> certificates;
m_events_handler.iso15118GetInstalledCertificates(v2g_root_certificate, mo_root_certificate, v2g_certificate_chain, oem_root_certificate, certificates);
m_events_handler.iso15118GetInstalledCertificates(
v2g_root_certificate, mo_root_certificate, v2g_certificate_chain, oem_root_certificate, certificates);
if (!certificates.empty())
{
// Compute hashes for each certificate
Expand Down
20 changes: 18 additions & 2 deletions src/chargepoint/status/StatusManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,15 @@ void StatusManager::bootNotificationProcess()

// Configure hearbeat
std::chrono::seconds interval(boot_conf.interval);
m_ocpp_config.heartbeatInterval(interval);
if(boot_conf.interval == 0)
{
interval = m_ocpp_config.heartbeatInterval();
}
else
{
m_ocpp_config.heartbeatInterval(interval);
}

m_heartbeat_timer.start(std::chrono::milliseconds(interval));
}
else
Expand Down Expand Up @@ -551,7 +559,15 @@ void StatusManager::sendBootNotification()

// Restart hearbeat timer
std::chrono::seconds interval(boot_conf.interval);
m_ocpp_config.heartbeatInterval(interval);
if(boot_conf.interval == 0)
{
interval = m_ocpp_config.heartbeatInterval();
}
else
{
m_ocpp_config.heartbeatInterval(interval);
}

m_heartbeat_timer.restart(std::chrono::milliseconds(interval));

// Save registration status
Expand Down
20 changes: 7 additions & 13 deletions src/messages/IMessageConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,25 +290,19 @@ class IMessageConverter
class MessageType##ReqConverter : public IMessageConverter<MessageType##Req> \
{ \
public: \
IMessageConverter<MessageType##Req>* clone() const override \
{ \
return new MessageType##ReqConverter(); \
} \
IMessageConverter<MessageType##Req>* clone() const override { return new MessageType##ReqConverter(); } \
bool fromJson(const rapidjson::Value& json, MessageType##Req& data, std::string& error_code, std::string& error_message) override; \
bool toJson(const MessageType##Req& data, rapidjson::Document& json) override; \
}; \
class MessageType##ConfConverter : public IMessageConverter<MessageType##Conf> \
{ \
public: \
IMessageConverter<MessageType##Conf>* clone() const override \
{ \
return new MessageType##ConfConverter(); \
} \
bool fromJson(const rapidjson::Value& json, \
MessageType##Conf& data, \
std::string& error_code, \
std::string& error_message) override; \
bool toJson(const MessageType##Conf& data, rapidjson::Document& json) override; \
IMessageConverter<MessageType##Conf>* clone() const override { return new MessageType##ConfConverter(); } \
bool fromJson(const rapidjson::Value& json, \
MessageType##Conf& data, \
std::string& error_code, \
std::string& error_message) override; \
bool toJson(const MessageType##Conf& data, rapidjson::Document& json) override; \
};

} // namespace messages
Expand Down
2 changes: 2 additions & 0 deletions src/websockets/IWebsocketClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class IWebsocketClient
/** @brief Skip server name check in certificates for TLS connections
* (Warning : enabling this feature is not recommended in production) */
bool skip_server_name_check;
/** @brief Server name (used for server certificate check) */
std::string server_name;
};
};

Expand Down
11 changes: 9 additions & 2 deletions src/websockets/libwebsockets/LibWebsocketClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,15 @@ void LibWebsocketClient::connectCallback(struct lws_sorted_usec_list* sul) noexc
i.context = client->m_context;
i.address = client->m_url.address().c_str();
i.path = client->m_url.path().c_str();
i.host = i.address;
i.origin = i.address;
if (client->m_credentials.server_name.empty())
{
i.host = i.address;
}
else
{
i.host = client->m_credentials.server_name.c_str();
}
i.origin = i.address;
if (client->m_url.protocol() == "wss")
{
i.ssl_connection = LCCSCF_USE_SSL;
Expand Down
13 changes: 10 additions & 3 deletions src/websockets/libwebsockets/LibWebsocketClientPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void LibWebsocketClientPool::process()

// Dummy vhost to handle context related events
struct lws_protocols protocols[] = {{"LibWebsocketClientPool", &LibWebsocketClientPool::eventCallback, 0, 0, 0, this, 0},
LWS_PROTOCOL_LIST_TERM};
LWS_PROTOCOL_LIST_TERM};
struct lws_context_creation_info vhost_info;
memset(&vhost_info, 0, sizeof(vhost_info));
vhost_info.protocols = protocols;
Expand Down Expand Up @@ -537,8 +537,15 @@ void LibWebsocketClientPool::Client::connectCallback(struct lws_sorted_usec_list
connect_info.vhost = client->m_vhost;
connect_info.address = client->m_url.address().c_str();
connect_info.path = client->m_url.path().c_str();
connect_info.host = connect_info.address;
connect_info.origin = connect_info.address;
if (client->m_credentials.server_name.empty())
{
connect_info.host = connect_info.address;
}
else
{
connect_info.host = client->m_credentials.server_name.c_str();
}
connect_info.origin = connect_info.address;
if (client->m_url.protocol() == "wss")
{
connect_info.ssl_connection = LCCSCF_USE_SSL;
Expand Down
5 changes: 1 addition & 4 deletions tests/tools/test_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,5 @@ TEST_SUITE("Database class test suite")
CHECK_EQ(query.get(), nullptr);
}

TEST_CASE("Cleanup")
{
std::filesystem::remove(test_database_path);
}
TEST_CASE("Cleanup") { std::filesystem::remove(test_database_path); }
}
5 changes: 1 addition & 4 deletions tests/tools/test_logs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@ TEST_SUITE("Database class test suite")
CHECK_FALSE(query->next());
}

TEST_CASE("Cleanup")
{
std::filesystem::remove(test_database_path);
}
TEST_CASE("Cleanup") { std::filesystem::remove(test_database_path); }
}

#endif // EXTERNAL_LOGGER
Loading