Skip to content

Commit 0c34e76

Browse files
authored
Merge pull request #80 from c-jimenez/release/v0.9.0
Release/v0.9.0
2 parents 535cca9 + bd18e23 commit 0c34e76

File tree

179 files changed

+1330
-755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+1330
-755
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v1
45+
uses: github/codeql-action/init@v2
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -66,4 +66,4 @@ jobs:
6666
make clang-native
6767
6868
- name: Perform CodeQL Analysis
69-
uses: github/codeql-action/analyze@v1
69+
uses: github/codeql-action/analyze@v2

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 0.8.0
8+
VERSION 0.9.0
99
)
1010

1111
# Definitions for Version.h file

schemas/SignedFirmwareStatusNotificationResponse.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@
66
"type": "object",
77
"properties": {},
88
"additionalProperties": false
9-
}
109
}

src/centralsystem/CentralSystem.cpp

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ CentralSystem::CentralSystem(const ocpp::config::ICentralSystemConfig& st
6969
m_database(),
7070
m_internal_config(m_database),
7171
m_messages_converter(),
72+
m_messages_validator(),
7273
m_ws_server(),
7374
m_rpc_server(),
7475
m_uptime_timer(*m_timer_pool.get(), "Uptime timer"),
@@ -164,31 +165,40 @@ bool CentralSystem::start()
164165
{
165166
LOG_INFO << "Starting OCPP stack v" << OPEN_OCPP_VERSION << " - Listen URL : " << m_stack_config.listenUrl();
166167

167-
// Start uptime counter
168-
m_uptime = 0;
169-
m_internal_config.setKey(START_DATE_KEY, DateTime::now().str());
170-
m_uptime_timer.start(std::chrono::seconds(1u));
171-
172-
// Allocate resources
173-
m_ws_server = std::unique_ptr<ocpp::websockets::IWebsocketServer>(ocpp::websockets::WebsocketFactory::newServer());
174-
m_rpc_server = std::make_unique<ocpp::rpc::RpcServer>(*m_ws_server, "ocpp1.6");
175-
m_rpc_server->registerServerListener(*this);
176-
177-
// Configure websocket link
178-
ocpp::websockets::IWebsocketServer::Credentials credentials;
179-
credentials.http_basic_authent = m_stack_config.httpBasicAuthent();
180-
credentials.tls12_cipher_list = m_stack_config.tlsv12CipherList();
181-
credentials.tls13_cipher_list = m_stack_config.tlsv13CipherList();
182-
credentials.ecdh_curve = m_stack_config.tlsEcdhCurve();
183-
credentials.server_certificate = m_stack_config.tlsServerCertificate();
184-
credentials.server_certificate_private_key = m_stack_config.tlsServerCertificatePrivateKey();
185-
credentials.server_certificate_private_key_passphrase = m_stack_config.tlsServerCertificatePrivateKeyPassphrase();
186-
credentials.server_certificate_ca = m_stack_config.tlsServerCertificateCa();
187-
credentials.client_certificate_authent = m_stack_config.tlsClientCertificateAuthent();
188-
credentials.encoded_pem_certificates = false;
189-
190-
// Start listening
191-
ret = m_rpc_server->start(m_stack_config.listenUrl(), credentials, m_stack_config.webSocketPingInterval());
168+
// Load validator
169+
ret = m_messages_validator.load(m_stack_config.jsonSchemasPath());
170+
if (ret)
171+
{
172+
// Start uptime counter
173+
m_uptime = 0;
174+
m_internal_config.setKey(START_DATE_KEY, DateTime::now().str());
175+
m_uptime_timer.start(std::chrono::seconds(1u));
176+
177+
// Allocate resources
178+
m_ws_server = std::unique_ptr<ocpp::websockets::IWebsocketServer>(ocpp::websockets::WebsocketFactory::newServer());
179+
m_rpc_server = std::make_unique<ocpp::rpc::RpcServer>(*m_ws_server, "ocpp1.6");
180+
m_rpc_server->registerServerListener(*this);
181+
182+
// Configure websocket link
183+
ocpp::websockets::IWebsocketServer::Credentials credentials;
184+
credentials.http_basic_authent = m_stack_config.httpBasicAuthent();
185+
credentials.tls12_cipher_list = m_stack_config.tlsv12CipherList();
186+
credentials.tls13_cipher_list = m_stack_config.tlsv13CipherList();
187+
credentials.ecdh_curve = m_stack_config.tlsEcdhCurve();
188+
credentials.server_certificate = m_stack_config.tlsServerCertificate();
189+
credentials.server_certificate_private_key = m_stack_config.tlsServerCertificatePrivateKey();
190+
credentials.server_certificate_private_key_passphrase = m_stack_config.tlsServerCertificatePrivateKeyPassphrase();
191+
credentials.server_certificate_ca = m_stack_config.tlsServerCertificateCa();
192+
credentials.client_certificate_authent = m_stack_config.tlsClientCertificateAuthent();
193+
credentials.encoded_pem_certificates = false;
194+
195+
// Start listening
196+
ret = m_rpc_server->start(m_stack_config.listenUrl(), credentials, m_stack_config.webSocketPingInterval());
197+
}
198+
else
199+
{
200+
LOG_ERROR << "Unable to load all the messages validators";
201+
}
192202
}
193203
else
194204
{
@@ -252,7 +262,7 @@ void CentralSystem::rpcClientConnected(const std::string& chargepoint_id, std::s
252262

253263
// Instanciate proxy
254264
std::shared_ptr<ICentralSystem::IChargePoint> chargepoint(
255-
new ChargePointProxy(*this, chargepoint_id, client, m_stack_config.jsonSchemasPath(), m_messages_converter, m_stack_config));
265+
new ChargePointProxy(*this, chargepoint_id, client, m_messages_validator, m_messages_converter, m_stack_config));
256266

257267
// Notify connection
258268
m_events_handler.chargePointConnected(chargepoint);

src/centralsystem/CentralSystem.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ You should have received a copy of the GNU Lesser General Public License
1616
along with OpenOCPP. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#ifndef CENTRALSYSTEM_H
20-
#define CENTRALSYSTEM_H
19+
#ifndef OPENOCPP_CENTRALSYSTEM_H
20+
#define OPENOCPP_CENTRALSYSTEM_H
2121

2222
#include "Database.h"
2323
#include "ICentralSystem.h"
2424
#include "InternalConfigManager.h"
2525
#include "MessagesConverter.h"
26+
#include "MessagesValidator.h"
2627
#include "RpcServer.h"
2728
#include "Timer.h"
2829

@@ -95,6 +96,8 @@ class CentralSystem : public ICentralSystem, public ocpp::rpc::RpcServer::IListe
9596

9697
/** @brief Messages converter */
9798
ocpp::messages::MessagesConverter m_messages_converter;
99+
/** @brief Messages validator */
100+
ocpp::messages::MessagesValidator m_messages_validator;
98101

99102
/** @brief Websocket server */
100103
std::unique_ptr<ocpp::websockets::IWebsocketServer> m_ws_server;
@@ -119,4 +122,4 @@ class CentralSystem : public ICentralSystem, public ocpp::rpc::RpcServer::IListe
119122
} // namespace centralsystem
120123
} // namespace ocpp
121124

122-
#endif // CENTRALSYSTEM_H
125+
#endif // OPENOCPP_CENTRALSYSTEM_H

src/centralsystem/chargepoint/ChargePointHandler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ You should have received a copy of the GNU Lesser General Public License
1616
along with OpenOCPP. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#ifndef CHARGEPOINTHANDLER_H
20-
#define CHARGEPOINTHANDLER_H
19+
#ifndef OPENOCPP_CHARGEPOINTHANDLER_H
20+
#define OPENOCPP_CHARGEPOINTHANDLER_H
2121

2222
#include "Authorize.h"
2323
#include "BootNotification.h"
@@ -248,4 +248,4 @@ class ChargePointHandler
248248
} // namespace centralsystem
249249
} // namespace ocpp
250250

251-
#endif // CHARGEPOINTHANDLER_H
251+
#endif // OPENOCPP_CHARGEPOINTHANDLER_H

src/centralsystem/chargepoint/ChargePointProxy.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ namespace centralsystem
5858
ChargePointProxy::ChargePointProxy(ICentralSystem& central_system,
5959
const std::string& identifier,
6060
std::shared_ptr<ocpp::rpc::RpcServer::Client> rpc,
61-
const std::string& schemas_path,
61+
const ocpp::messages::MessagesValidator& messages_validator,
6262
ocpp::messages::MessagesConverter& messages_converter,
6363
const ocpp::config::ICentralSystemConfig& stack_config)
6464
: m_central_system(central_system),
6565
m_identifier(identifier),
6666
m_rpc(rpc),
67-
m_msg_dispatcher(schemas_path),
68-
m_msg_sender(*m_rpc, messages_converter, stack_config.callRequestTimeout()),
67+
m_msg_dispatcher(messages_validator),
68+
m_msg_sender(*m_rpc, messages_converter, messages_validator, stack_config.callRequestTimeout()),
6969
m_handler(m_identifier, messages_converter, m_msg_dispatcher, stack_config)
7070
{
7171
m_rpc->registerSpy(*this);
@@ -77,6 +77,12 @@ ChargePointProxy::~ChargePointProxy() { }
7777

7878
// ICentralSystem::IChargePoint interface
7979

80+
/** @copydoc const std::string& ICentralSystem::IChargePoint::ipAddress() const */
81+
const std::string& ChargePointProxy::ipAddress() const
82+
{
83+
return m_rpc->ipAddress();
84+
}
85+
8086
/** @copydoc void ICentralSystem::IChargePoint::setTimeout(std::chrono::milliseconds) */
8187
void ChargePointProxy::setTimeout(std::chrono::milliseconds timeout)
8288
{

src/centralsystem/chargepoint/ChargePointProxy.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ You should have received a copy of the GNU Lesser General Public License
1616
along with OpenOCPP. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#ifndef CHARGEPOINTPROXY_H
20-
#define CHARGEPOINTPROXY_H
19+
#ifndef OPENOCPP_CHARGEPOINTPROXY_H
20+
#define OPENOCPP_CHARGEPOINTPROXY_H
2121

2222
#include "ChargePointHandler.h"
2323
#include "GenericMessageSender.h"
2424
#include "ICentralSystem.h"
2525
#include "MessageDispatcher.h"
26+
#include "MessagesValidator.h"
2627
#include "RpcServer.h"
2728

2829
#include <memory>
@@ -41,14 +42,14 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc::
4142
* @param central_system Central System instance associated to the charge point
4243
* @param identifier Charge point's identifier
4344
* @param rpc RPC connection with the charge point
44-
* @param schemas_path Path to the JSON schemas needed to validate payloads
45+
* @param messages_validator JSON schemas needed to validate payloads
4546
* @param messages_converter Converter from/to OCPP to/from JSON messages
4647
* @param stack_config Stack configuration
4748
*/
4849
ChargePointProxy(ICentralSystem& central_system,
4950
const std::string& identifier,
5051
std::shared_ptr<ocpp::rpc::RpcServer::Client> rpc,
51-
const std::string& schemas_path,
52+
const ocpp::messages::MessagesValidator& messages_validator,
5253
ocpp::messages::MessagesConverter& messages_converter,
5354
const ocpp::config::ICentralSystemConfig& stack_config);
5455
/** @brief Destructor */
@@ -59,6 +60,9 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc::
5960
/** @copydoc ICentralSystem&& ICentralSystem::IChargePoint::centralSystem() */
6061
ICentralSystem& centralSystem() override { return m_central_system; }
6162

63+
/** @copydoc const std::string& ICentralSystem::IChargePoint::ipAddress() const */
64+
const std::string& ipAddress() const override;
65+
6266
/** @copydoc const std::string& ICentralSystem::IChargePoint::identifier() const */
6367
const std::string& identifier() const override { return m_identifier; }
6468

@@ -298,4 +302,4 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc::
298302
} // namespace centralsystem
299303
} // namespace ocpp
300304

301-
#endif // CHARGEPOINTPROXY_H
305+
#endif // OPENOCPP_CHARGEPOINTPROXY_H

src/centralsystem/config/InternalConfigKeys.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ You should have received a copy of the GNU Lesser General Public License
1616
along with OpenOCPP. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#ifndef INTERNALCONFIGKEYS_H
20-
#define INTERNALCONFIGKEYS_H
19+
#ifndef OPENOCPP_INTERNALCONFIGKEYS_H
20+
#define OPENOCPP_INTERNALCONFIGKEYS_H
2121

2222
namespace ocpp
2323
{
@@ -36,4 +36,4 @@ static constexpr const char* TOTAL_UPTIME_KEY = "TotalUpTime";
3636
} // namespace centralsystem
3737
} // namespace ocpp
3838

39-
#endif // INTERNALCONFIGKEYS_H
39+
#endif // OPENOCPP_INTERNALCONFIGKEYS_H

src/centralsystem/interface/ICentralSystem.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ You should have received a copy of the GNU Lesser General Public License
1616
along with OpenOCPP. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#ifndef ICENTRALSYSTEM_H
20-
#define ICENTRALSYSTEM_H
19+
#ifndef OPENOCPP_ICENTRALSYSTEM_H
20+
#define OPENOCPP_ICENTRALSYSTEM_H
2121

2222
#include "AuthorizationData.h"
2323
#include "Certificate.h"
@@ -125,6 +125,12 @@ class ICentralSystem
125125
*/
126126
virtual ICentralSystem& centralSystem() = 0;
127127

128+
/**
129+
* @brief Get the IP address of the charge point
130+
* @return IP address of the charge point
131+
*/
132+
virtual const std::string& ipAddress() const = 0;
133+
128134
/**
129135
* @brief Get the charge point identifier
130136
* @return charge point identifier
@@ -432,4 +438,4 @@ class ICentralSystem
432438
} // namespace centralsystem
433439
} // namespace ocpp
434440

435-
#endif // ICENTRALSYSTEM_H
441+
#endif // OPENOCPP_ICENTRALSYSTEM_H

0 commit comments

Comments
 (0)