From 53053eb688c87ab59aabd2b23a32a190e4836470 Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Mon, 3 Sep 2018 01:57:14 +0200 Subject: [PATCH] add default callbacks for mesh to sprocket --- src/base/MeshSprocket.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/base/MeshSprocket.h b/src/base/MeshSprocket.h index fbb3ab5..7db8d34 100644 --- a/src/base/MeshSprocket.h +++ b/src/base/MeshSprocket.h @@ -9,6 +9,7 @@ #include #include #include "config.h" +#include "utils_print.h" using namespace std; using namespace std::placeholders; @@ -25,9 +26,19 @@ class MeshSprocket : public Sprocket { Sprocket::activate(scheduler, network); net = static_cast(network); net->onReceive(bind(&MeshSprocket::dispatch,this, _1, _2)); + net->mesh.onNewConnection(bind(&MeshSprocket::newConnection,this, _1)); + net->mesh.onChangedConnections(bind(&MeshSprocket::connectionChanged,this)); + return this; } using Sprocket::activate; + virtual void newConnection(uint32_t nodeId){ + PRINT_MSG(Serial, "MeshSprocket", "connected to %u", nodeId); + } + virtual void connectionChanged(){ + PRINT_MSG(Serial, "MeshSprocket", "connection changed"); + } + virtual void onMessage(uint32_t from, String &msg) { Serial.printf("MeshSprocket onMessage: received from %u msg=%s\n", from, msg.c_str()); };