MCPcopy Create free account
hub / github.com/c-jimenez/open-ocpp / start

Method start

src/ocpp16/centralsystem/CentralSystem.cpp:172–228  ·  view source on GitHub ↗

@copydoc bool ICentralSystem::start() */

Source from the content-addressed store, hash-verified

170
171/** @copydoc bool ICentralSystem::start() */
172bool CentralSystem::start()
173{
174 bool ret = false;
175
176 // Check if it is already started
177 if (!m_rpc_server)
178 {
179 LOG_INFO << "Starting OCPP stack v" << OPEN_OCPP_VERSION << " - Listen URL : " << m_stack_config.listenUrl();
180
181 // Load validator
182 ret = m_messages_validator.load(m_stack_config.jsonSchemasPath());
183 if (ret)
184 {
185 // Start uptime counter
186 if (m_uptime_timer)
187 {
188 m_uptime = 0;
189 m_internal_config->setKey(START_DATE_KEY, DateTime::now().str());
190 m_uptime_timer->start(std::chrono::seconds(1u));
191 }
192
193 // Allocate resources
194 m_ws_server = std::unique_ptr<ocpp::websockets::IWebsocketServer>(ocpp::websockets::WebsocketFactory::newServer());
195 m_rpc_server = std::make_unique<ocpp::rpc::RpcServer>(*m_ws_server, "ocpp1.6");
196 m_rpc_server->registerServerListener(*this);
197
198 // Configure websocket link
199 ocpp::websockets::IWebsocketServer::Credentials credentials;
200 credentials.http_basic_authent = m_stack_config.httpBasicAuthent();
201 credentials.tls12_cipher_list = m_stack_config.tlsv12CipherList();
202 credentials.tls13_cipher_list = m_stack_config.tlsv13CipherList();
203 credentials.ecdh_curve = m_stack_config.tlsEcdhCurve();
204 credentials.server_certificate = m_stack_config.tlsServerCertificate();
205 credentials.server_certificate_private_key = m_stack_config.tlsServerCertificatePrivateKey();
206 credentials.server_certificate_private_key_passphrase = m_stack_config.tlsServerCertificatePrivateKeyPassphrase();
207 credentials.server_certificate_ca = m_stack_config.tlsServerCertificateCa();
208 credentials.client_certificate_authent = m_stack_config.tlsClientCertificateAuthent();
209 credentials.encoded_pem_certificates = false;
210
211 // Start listening
212 ret = m_rpc_server->start(m_stack_config.listenUrl(),
213 credentials,
214 m_stack_config.webSocketPingInterval(),
215 m_stack_config.incomingRequestsFromCpThreadPoolSize());
216 }
217 else
218 {
219 LOG_ERROR << "Unable to load all the messages validators";
220 }
221 }
222 else
223 {
224 LOG_ERROR << "Stack already started";
225 }
226
227 return ret;
228}
229

Callers

nothing calls this directly

Calls 15

setKeyMethod · 0.80
strMethod · 0.80
listenUrlMethod · 0.45
loadMethod · 0.45
jsonSchemasPathMethod · 0.45
httpBasicAuthentMethod · 0.45
tlsv12CipherListMethod · 0.45
tlsv13CipherListMethod · 0.45
tlsEcdhCurveMethod · 0.45
tlsServerCertificateMethod · 0.45

Tested by

no test coverage detected