mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 13:25:03 +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());
|
//Serial.printf("MeshSprocket onMessage: received from %u msg=%s\n", from, msg.c_str());
|
||||||
SprocketMessage sMsg;
|
SprocketMessage sMsg;
|
||||||
sMsg.fromJsonString(msg);
|
sMsg.fromJsonString(msg);
|
||||||
|
if(sMsg.valid){
|
||||||
sMsg.from = from;
|
sMsg.from = from;
|
||||||
publish(sMsg.topic, sMsg.payload);
|
publish(sMsg.topic, sMsg.payload);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void dispatch( uint32_t from, String &msg ) {
|
void dispatch( uint32_t from, String &msg ) {
|
||||||
Sprocket::dispatch(from, msg);
|
SprocketMessage sMsg;
|
||||||
onMessage(from, msg);
|
sMsg.fromJsonString(msg);
|
||||||
|
if(sMsg.valid){
|
||||||
|
sMsg.from = from;
|
||||||
|
publish(sMsg.topic, sMsg.payload);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class MeshManPlugin : public Plugin {
|
|||||||
subscribe("mesh/heartbeat", std::bind(&MeshManPlugin::gotHeartbeat, this, std::placeholders::_1));
|
subscribe("mesh/heartbeat", std::bind(&MeshManPlugin::gotHeartbeat, this, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
void gotHeartbeat(String msg){
|
void gotHeartbeat(String msg){
|
||||||
Serial.println(String("Got heartbeat: ") + msg);
|
Serial.println(String("MeshManPlugin / Heartbeat: ") + msg);
|
||||||
}
|
}
|
||||||
void getMeshConnections(AsyncWebServerRequest *request) {
|
void getMeshConnections(AsyncWebServerRequest *request) {
|
||||||
request->send(200, "text/plain", net->mesh.subConnectionJson());
|
request->send(200, "text/plain", net->mesh.subConnectionJson());
|
||||||
|
|||||||
Reference in New Issue
Block a user