Skip to content

Commit 19d541d

Browse files
authored
Merge pull request #4 from c-jimenez/dev/force_faulted
add MQTT topic to force cp status to faulted
2 parents 28adf1b + c917a08 commit 19d541d

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ The expected command payload is :
330330
}
331331
```
332332

333-
Each connector of the simulated Charge Point are listening to the following topic to simulate interaction with a user resenting an RFID card : **cp_simu/cps/simu_cp_XXX/connectors/N/id_tag** where **N** stands for the connector number.
333+
Each connector of the simulated Charge Point are listening to the following topic to simulate interaction with a user resenting an RFID card : **cp_simu/cps/simu_cp_XXX/connectors/N/id_tag** where **N** stands for the connector number.
334334

335335
The expected command payload is :
336336

@@ -339,3 +339,13 @@ The expected command payload is :
339339
"id": "ID_TAG"
340340
}
341341
```
342+
343+
Each connector of the simulated Charge Point are listening to the following topic to force the Charge Point in faulted status : **cp_simu/cps/simu_cp_XXX/connectors/N/faulted** where **N** stands for the connector number.
344+
345+
The expected command payload is :
346+
347+
```
348+
{
349+
"faulted": false
350+
}
351+
```

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ docker-build-cp-simulator:
108108

109109

110110
run-simu:
111-
docker run $(DOCKER_INTERACTIVE) --rm --network=host --name ocpp-simu $(DOCKER_SIMULATOR_IMAGE)
111+
docker run $(DOCKER_INTERACTIVE) --rm --network=host --name ocpp-simu $(DOCKER_SIMULATOR_IMAGE) -c test_ocpp
112112

113113
run-launcher:
114114
docker run $(DOCKER_INTERACTIVE) --rm --network=host --name ocpp-launcher --entrypoint /cp_simulator/launcher $(DOCKER_SIMULATOR_IMAGE)

src/chargepoint/mqtt/MqttManager.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void MqttManager::mqttMessageReceived(const char* topic, const std::string& mess
157157
}
158158
}
159159
}
160-
else
160+
else if (topic_path.filename().compare("id_tag") == 0)
161161
{
162162
if (payload.HasMember("id"))
163163
{
@@ -168,6 +168,17 @@ void MqttManager::mqttMessageReceived(const char* topic, const std::string& mess
168168
}
169169
}
170170
}
171+
else if (topic_path.filename().compare("faulted") == 0)
172+
{
173+
if (payload.HasMember("faulted"))
174+
{
175+
rapidjson::Value& faulted = payload["faulted"];
176+
if (faulted.IsBool())
177+
{
178+
connector_data.fault_pending = faulted.GetBool();
179+
}
180+
}
181+
}
171182
}
172183
else
173184
{
@@ -184,11 +195,12 @@ void MqttManager::start(unsigned int nb_phases, unsigned int max_charge_point_cu
184195
std::string chargepoint_topic(CHARGE_POINTS_TOPIC);
185196
chargepoint_topic += m_config.stackConfig().chargePointIdentifier() + "/";
186197

187-
std::string chargepoint_cmd_topic = chargepoint_topic + "cmd";
188-
std::string chargepoint_car_topics = chargepoint_topic + "connectors/+/car";
189-
std::string chargepoint_tag_topics = chargepoint_topic + "connectors/+/id_tag";
190-
m_status_topic = chargepoint_topic + "status";
191-
m_connectors_topic = chargepoint_topic + "connectors/";
198+
std::string chargepoint_cmd_topic = chargepoint_topic + "cmd";
199+
std::string chargepoint_car_topics = chargepoint_topic + "connectors/+/car";
200+
std::string chargepoint_tag_topics = chargepoint_topic + "connectors/+/id_tag";
201+
std::string chargepoint_faulted_topics = chargepoint_topic + "connectors/+/faulted";
202+
m_status_topic = chargepoint_topic + "status";
203+
m_connectors_topic = chargepoint_topic + "connectors/";
192204

193205
// MQTT client
194206
m_mqtt = IMqttClient::create(m_config.stackConfig().chargePointIdentifier());
@@ -208,8 +220,8 @@ void MqttManager::start(unsigned int nb_phases, unsigned int max_charge_point_cu
208220
std::cout << "Subscribing to charge point's command topic: " << chargepoint_cmd_topic << std::endl;
209221
if (m_mqtt->subscribe(chargepoint_cmd_topic))
210222
{
211-
std::cout << "Subscribing to charge point's connector topics: " << chargepoint_car_topics << " and " << chargepoint_tag_topics << std::endl;
212-
if (m_mqtt->subscribe(chargepoint_car_topics) && m_mqtt->subscribe(chargepoint_tag_topics))
223+
std::cout << "Subscribing to charge point's connector topics: " << chargepoint_car_topics << " and " << chargepoint_tag_topics << " and " << chargepoint_faulted_topics << std::endl;
224+
if (m_mqtt->subscribe(chargepoint_car_topics) && m_mqtt->subscribe(chargepoint_tag_topics) && m_mqtt->subscribe(chargepoint_faulted_topics))
213225
{
214226
// Wait for disconnection or end of application
215227
std::cout << "Ready!" << std::endl;

0 commit comments

Comments
 (0)