mesh mqtt gateway example

This commit is contained in:
2018-06-10 21:42:57 +02:00
parent 0e6d7f7f3d
commit 73e9f4af8f
7 changed files with 164 additions and 82 deletions

View File

@@ -2,7 +2,7 @@
#define __MESHNET_H__
#include <painlessMesh.h>
#include <WiFiClient.h>
#include "Network.h"
using namespace std;
@@ -13,15 +13,13 @@ using namespace std::placeholders;
#define MESH_PASSWORD "somethingSneaky"
#define MESH_PORT 5555
class MeshNet : public Network {
public:
painlessMesh mesh;
Network* init(){
Serial.println("init mesh");
//mesh.setDebugMsgTypes( ERROR | MESH_STATUS | CONNECTION | SYNC | COMMUNICATION | GENERAL | MSG_TYPES | REMOTE ); // all types on
mesh.setDebugMsgTypes( ERROR | STARTUP);
mesh.setDebugMsgTypes( ERROR | STARTUP | CONNECTION);
mesh.init( MESH_PREFIX, MESH_PASSWORD, scheduler, MESH_PORT, WIFI_AP_STA, 11 );
//mesh.onReceive(bind(&MeshNet::receivedCallback,this, _1, _2));
mesh.onNewConnection(bind(&MeshNet::newConnectionCallback, this, _1));
@@ -31,6 +29,9 @@ class MeshNet : public Network {
return this;
}
Network* connect(){
Serial.println("connect station");
mesh.stationManual("tErAx1d", "ramalamadingdong");
mesh.setHostname("MeshNode");
return this;
}
void broadcast(String msg){