@@ -23,14 +23,14 @@ SOFTWARE.
2323*/
2424
2525#include " MqttManager.h"
26+ #include " MeterSimulator.h"
2627#include " SimulatedChargePointConfig.h"
2728#include " Topics.h"
28- #include " MeterSimulator.h"
2929
30- #include < openocpp/json.h>
3130#include < cstring>
3231#include < filesystem>
3332#include < iostream>
33+ #include < openocpp/json.h>
3434#include < sstream>
3535#include < thread>
3636
@@ -230,8 +230,10 @@ void MqttManager::start(unsigned int nb_phases, unsigned int max_charge_point_cu
230230 std::cout << " Subscribing to charge point's command topic: " << chargepoint_cmd_topic << std::endl;
231231 if (m_mqtt->subscribe (chargepoint_cmd_topic))
232232 {
233- std::cout << " Subscribing to charge point's connector topics: " << chargepoint_car_topics << " and " << chargepoint_tag_topics << " and " << chargepoint_faulted_topics << std::endl;
234- if (m_mqtt->subscribe (chargepoint_car_topics) && m_mqtt->subscribe (chargepoint_tag_topics) && m_mqtt->subscribe (chargepoint_faulted_topics))
233+ std::cout << " Subscribing to charge point's connector topics: " << chargepoint_car_topics << " and "
234+ << chargepoint_tag_topics << " and " << chargepoint_faulted_topics << std::endl;
235+ if (m_mqtt->subscribe (chargepoint_car_topics) && m_mqtt->subscribe (chargepoint_tag_topics) &&
236+ m_mqtt->subscribe (chargepoint_faulted_topics))
235237 {
236238 // Wait for disconnection or end of application
237239 std::cout << " Ready!" << std::endl;
@@ -343,14 +345,14 @@ void MqttManager::publishOcppConfig()
343345
344346 // Get vector of key/value for ocpp config
345347 std::vector<ocpp::types::CiStringType<50u >> keys;
346- std::vector<ocpp::types::KeyValue> values;
348+ std::vector<ocpp::types::KeyValue> values;
347349 std::vector<ocpp::types::CiStringType<50u >> unknown_values;
348350 m_config.ocppConfig ().getConfiguration (keys, values, unknown_values);
349351
350352 // Create the JSON message
351353 rapidjson::Document msg;
352354 msg.Parse (" {}" );
353- for (const ocpp::types::KeyValue keyValue : values)
355+ for (const ocpp::types::KeyValue& keyValue : values)
354356 {
355357 if (!keyValue.value .value ().empty ())
356358 {
@@ -400,9 +402,9 @@ void MqttManager::publishData(const std::vector<ConnectorData>& connectors)
400402 msg.AddMember (rapidjson::StringRef (" car_ready" ), rapidjson::Value (connector.car_ready ), msg.GetAllocator ());
401403
402404 static const char * consumption_str[] = {" consumption_l1" , " consumption_l2" , " consumption_l3" };
403- std::vector<float > currents = connector.meter ->getCurrents ();
404- unsigned int nb_phases = connector.meter ->getNumberOfPhases ();
405- for (unsigned int i = 0 ; i < 3 ; i++)
405+ std::vector<float > currents = connector.meter ->getCurrents ();
406+ unsigned int nb_phases = connector.meter ->getNumberOfPhases ();
407+ for (unsigned int i = 0 ; i < 3 ; i++)
406408 {
407409 if (i < nb_phases)
408410 {
@@ -431,7 +433,7 @@ std::string MqttManager::buildStatusMessage(const char* status, unsigned int nb_
431433 msg.Parse (" {}" );
432434#ifdef _MSC_VER
433435 msg.AddMember (rapidjson::StringRef (" pid" ), rapidjson::Value (static_cast <uint64_t >(GetCurrentProcessId ())), msg.GetAllocator ());
434- #else // _MSC_VER
436+ #else // _MSC_VER
435437 msg.AddMember (rapidjson::StringRef (" pid" ), rapidjson::Value (getpid ()), msg.GetAllocator ());
436438#endif // _MSC_VER
437439 msg.AddMember (rapidjson::StringRef (" status" ), rapidjson::Value (status, msg.GetAllocator ()).Move (), msg.GetAllocator ());
0 commit comments