check message validity

This commit is contained in:
2018-09-16 17:09:36 +02:00
parent ec6c41f4a1
commit db5a67229e
2 changed files with 11 additions and 5 deletions

View File

@@ -35,13 +35,19 @@ class MeshSprocket : public Sprocket {
//Serial.printf("MeshSprocket onMessage: received from %u msg=%s\n", from, msg.c_str());
SprocketMessage sMsg;
sMsg.fromJsonString(msg);
sMsg.from = from;
publish(sMsg.topic, sMsg.payload);
if(sMsg.valid){
sMsg.from = from;
publish(sMsg.topic, sMsg.payload);
}
};
void dispatch( uint32_t from, String &msg ) {
Sprocket::dispatch(from, msg);
onMessage(from, msg);
SprocketMessage sMsg;
sMsg.fromJsonString(msg);
if(sMsg.valid){
sMsg.from = from;
publish(sMsg.topic, sMsg.payload);
}
}
void loop() {

View File

@@ -31,7 +31,7 @@ class MeshManPlugin : public Plugin {
subscribe("mesh/heartbeat", std::bind(&MeshManPlugin::gotHeartbeat, this, std::placeholders::_1));
}
void gotHeartbeat(String msg){
Serial.println(String("Got heartbeat: ") + msg);
Serial.println(String("MeshManPlugin / Heartbeat: ") + msg);
}
void getMeshConnections(AsyncWebServerRequest *request) {
request->send(200, "text/plain", net->mesh.subConnectionJson());