File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -355,9 +355,16 @@ void MqttManager::publishData(const std::vector<ConnectorData>& connectors)
355355 static const char * consumption_str[] = {" consumption_l1" , " consumption_l2" , " consumption_l3" };
356356 std::vector<float > currents = connector.meter ->getCurrents ();
357357 unsigned int nb_phases = connector.meter ->getNumberOfPhases ();
358- for (unsigned int i = 0 ; i < nb_phases ; i++)
358+ for (unsigned int i = 0 ; i < 3 ; i++)
359359 {
360- msg.AddMember (rapidjson::StringRef (consumption_str[i]), rapidjson::Value (currents[i]), msg.GetAllocator ());
360+ if (i < nb_phases)
361+ {
362+ msg.AddMember (rapidjson::StringRef (consumption_str[i]), rapidjson::Value (currents[i]), msg.GetAllocator ());
363+ }
364+ else
365+ {
366+ msg.AddMember (rapidjson::StringRef (consumption_str[i]), rapidjson::Value (0 ), msg.GetAllocator ());
367+ }
361368 }
362369
363370 rapidjson::StringBuffer buffer;
You can’t perform that action at this time.
0 commit comments