use mediator for internal messaging

This commit is contained in:
2018-09-10 01:46:32 +02:00
parent 622074df2c
commit ec6c41f4a1
8 changed files with 60 additions and 57 deletions

View File

@@ -17,6 +17,7 @@ using namespace std::placeholders;
class MeshSprocket : public Sprocket {
public:
MeshNet* net;
MeshSprocket(){};
MeshSprocket(SprocketConfig cfg) : Sprocket(cfg) {
@@ -31,7 +32,11 @@ class MeshSprocket : public Sprocket {
} using Sprocket::activate;
virtual void onMessage(uint32_t from, String &msg) {
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;
sMsg.fromJsonString(msg);
sMsg.from = from;
publish(sMsg.topic, sMsg.payload);
};
void dispatch( uint32_t from, String &msg ) {