Skip to content

Commit f7b2f44

Browse files
authored
Merge pull request #228 from c-jimenez/develop
v1.5.8
2 parents e409c11 + d64f056 commit f7b2f44

File tree

12 files changed

+63
-31
lines changed

12 files changed

+63
-31
lines changed

3rdparty/libwebsockets/lib/core-net/client/connect4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ lws_client_connect_4_established(struct lws *wsi, struct lws *wsi_piggyback,
5757
if (wsi->a.vhost->http.http_proxy_port) {
5858
const char *cpa;
5959

60-
cpa = lws_wsi_client_stash_item(wsi, CIS_ADDRESS,
60+
cpa = lws_wsi_client_stash_item(wsi, CIS_HOST,
6161
_WSI_TOKEN_CLIENT_PEER_ADDRESS);
6262
if (!cpa)
6363
goto failed;

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
cmake_minimum_required(VERSION 3.13)
66

77
project(OpenOCPP DESCRIPTION "Open Source C++ implementation of the OCPP 1.6 protocol"
8-
VERSION 1.5.7
8+
VERSION 1.5.8
99
)
1010

1111
# Definitions for Version.h file

src/centralsystem/chargepoint/ChargePointHandler.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::HeartbeatReq& reque
341341
// Empty request
342342
(void)request;
343343

344+
// Notify request
345+
if (m_handler)
346+
{
347+
m_handler->heartbeat();
348+
}
349+
344350
// Prepare response
345351
response.currentTime = DateTime::now();
346352

src/centralsystem/interface/IChargePointRequestHandler.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ class IChargePointRequestHandler
4444
/** @brief Called to notify the disconnection of the charge point */
4545
virtual void disconnected() = 0;
4646

47+
/**
48+
* @brief Called when an heartbeat has been received
49+
*/
50+
virtual void heartbeat() { }
51+
4752
/**
4853
* @brief Called to get authorization informations for an id tag
4954
* @param id_tag Id tag to check

src/chargepoint/iso15118/Iso15118Manager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertifica
375375

376376
// Notify handler to get the list of installed certificates
377377
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>> certificates;
378-
m_events_handler.iso15118GetInstalledCertificates(v2g_root_certificate, mo_root_certificate, v2g_certificate_chain, oem_root_certificate, certificates);
378+
m_events_handler.iso15118GetInstalledCertificates(
379+
v2g_root_certificate, mo_root_certificate, v2g_certificate_chain, oem_root_certificate, certificates);
379380
if (!certificates.empty())
380381
{
381382
// Compute hashes for each certificate

src/chargepoint/status/StatusManager.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,15 @@ void StatusManager::bootNotificationProcess()
434434

435435
// Configure hearbeat
436436
std::chrono::seconds interval(boot_conf.interval);
437-
m_ocpp_config.heartbeatInterval(interval);
437+
if(boot_conf.interval == 0)
438+
{
439+
interval = m_ocpp_config.heartbeatInterval();
440+
}
441+
else
442+
{
443+
m_ocpp_config.heartbeatInterval(interval);
444+
}
445+
438446
m_heartbeat_timer.start(std::chrono::milliseconds(interval));
439447
}
440448
else
@@ -551,7 +559,15 @@ void StatusManager::sendBootNotification()
551559

552560
// Restart hearbeat timer
553561
std::chrono::seconds interval(boot_conf.interval);
554-
m_ocpp_config.heartbeatInterval(interval);
562+
if(boot_conf.interval == 0)
563+
{
564+
interval = m_ocpp_config.heartbeatInterval();
565+
}
566+
else
567+
{
568+
m_ocpp_config.heartbeatInterval(interval);
569+
}
570+
555571
m_heartbeat_timer.restart(std::chrono::milliseconds(interval));
556572

557573
// Save registration status

src/messages/IMessageConverter.h

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -290,25 +290,19 @@ class IMessageConverter
290290
class MessageType##ReqConverter : public IMessageConverter<MessageType##Req> \
291291
{ \
292292
public: \
293-
IMessageConverter<MessageType##Req>* clone() const override \
294-
{ \
295-
return new MessageType##ReqConverter(); \
296-
} \
293+
IMessageConverter<MessageType##Req>* clone() const override { return new MessageType##ReqConverter(); } \
297294
bool fromJson(const rapidjson::Value& json, MessageType##Req& data, std::string& error_code, std::string& error_message) override; \
298295
bool toJson(const MessageType##Req& data, rapidjson::Document& json) override; \
299296
}; \
300297
class MessageType##ConfConverter : public IMessageConverter<MessageType##Conf> \
301298
{ \
302299
public: \
303-
IMessageConverter<MessageType##Conf>* clone() const override \
304-
{ \
305-
return new MessageType##ConfConverter(); \
306-
} \
307-
bool fromJson(const rapidjson::Value& json, \
308-
MessageType##Conf& data, \
309-
std::string& error_code, \
310-
std::string& error_message) override; \
311-
bool toJson(const MessageType##Conf& data, rapidjson::Document& json) override; \
300+
IMessageConverter<MessageType##Conf>* clone() const override { return new MessageType##ConfConverter(); } \
301+
bool fromJson(const rapidjson::Value& json, \
302+
MessageType##Conf& data, \
303+
std::string& error_code, \
304+
std::string& error_message) override; \
305+
bool toJson(const MessageType##Conf& data, rapidjson::Document& json) override; \
312306
};
313307

314308
} // namespace messages

src/websockets/IWebsocketClient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ class IWebsocketClient
149149
/** @brief Skip server name check in certificates for TLS connections
150150
* (Warning : enabling this feature is not recommended in production) */
151151
bool skip_server_name_check;
152+
/** @brief Server name (used for server certificate check) */
153+
std::string server_name;
152154
};
153155
};
154156

src/websockets/libwebsockets/LibWebsocketClient.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,15 @@ void LibWebsocketClient::connectCallback(struct lws_sorted_usec_list* sul) noexc
358358
i.context = client->m_context;
359359
i.address = client->m_url.address().c_str();
360360
i.path = client->m_url.path().c_str();
361-
i.host = i.address;
362-
i.origin = i.address;
361+
if (client->m_credentials.server_name.empty())
362+
{
363+
i.host = i.address;
364+
}
365+
else
366+
{
367+
i.host = client->m_credentials.server_name.c_str();
368+
}
369+
i.origin = i.address;
363370
if (client->m_url.protocol() == "wss")
364371
{
365372
i.ssl_connection = LCCSCF_USE_SSL;

src/websockets/libwebsockets/LibWebsocketClientPool.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void LibWebsocketClientPool::process()
147147

148148
// Dummy vhost to handle context related events
149149
struct lws_protocols protocols[] = {{"LibWebsocketClientPool", &LibWebsocketClientPool::eventCallback, 0, 0, 0, this, 0},
150-
LWS_PROTOCOL_LIST_TERM};
150+
LWS_PROTOCOL_LIST_TERM};
151151
struct lws_context_creation_info vhost_info;
152152
memset(&vhost_info, 0, sizeof(vhost_info));
153153
vhost_info.protocols = protocols;
@@ -537,8 +537,15 @@ void LibWebsocketClientPool::Client::connectCallback(struct lws_sorted_usec_list
537537
connect_info.vhost = client->m_vhost;
538538
connect_info.address = client->m_url.address().c_str();
539539
connect_info.path = client->m_url.path().c_str();
540-
connect_info.host = connect_info.address;
541-
connect_info.origin = connect_info.address;
540+
if (client->m_credentials.server_name.empty())
541+
{
542+
connect_info.host = connect_info.address;
543+
}
544+
else
545+
{
546+
connect_info.host = client->m_credentials.server_name.c_str();
547+
}
548+
connect_info.origin = connect_info.address;
542549
if (client->m_url.protocol() == "wss")
543550
{
544551
connect_info.ssl_connection = LCCSCF_USE_SSL;

0 commit comments

Comments
 (0)