mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-14 20:56:38 +01:00
check message validity
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user