mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 13:25:03 +01:00
basic mesh node example app
This commit is contained in:
@@ -20,9 +20,10 @@ class MeshNet : public Network {
|
||||
painlessMesh mesh;
|
||||
Network* init(){
|
||||
Serial.println("init mesh");
|
||||
mesh.setDebugMsgTypes( ERROR | STARTUP | CONNECTION ); // set before init() so that you can see startup messages
|
||||
//mesh.setDebugMsgTypes( ERROR | MESH_STATUS | CONNECTION | SYNC | COMMUNICATION | GENERAL | MSG_TYPES | REMOTE ); // all types on
|
||||
mesh.setDebugMsgTypes( ERROR | STARTUP);
|
||||
mesh.init( MESH_PREFIX, MESH_PASSWORD, scheduler, MESH_PORT, WIFI_AP_STA, 11 );
|
||||
mesh.onReceive(bind(&MeshNet::receivedCallback,this, _1, _2));
|
||||
//mesh.onReceive(bind(&MeshNet::receivedCallback,this, _1, _2));
|
||||
mesh.onNewConnection(bind(&MeshNet::newConnectionCallback, this, _1));
|
||||
mesh.onChangedConnections(bind(&MeshNet::changedConnectionCallback, this));
|
||||
mesh.onNodeTimeAdjusted(bind(&MeshNet::nodeTimeAdjustedCallback, this, _1));
|
||||
@@ -32,8 +33,10 @@ class MeshNet : public Network {
|
||||
Network* connect(){
|
||||
return this;
|
||||
}
|
||||
void broadcast(String msg){
|
||||
mesh.sendBroadcast(msg);
|
||||
}
|
||||
void update(){
|
||||
Serial.println("update mesh");
|
||||
mesh.update();
|
||||
}
|
||||
void receivedCallback( uint32_t from, String &msg ) {
|
||||
@@ -41,6 +44,7 @@ class MeshNet : public Network {
|
||||
}
|
||||
|
||||
void newConnectionCallback(uint32_t nodeId) {
|
||||
id = nodeId;
|
||||
Serial.printf("--> startHere: New Connection, nodeId = %u\n", nodeId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user