#ifndef __MESHNET_H__ #define __MESHNET_H__ #ifdef ESP32 #include #elif defined(ESP8266) #include #endif // ESP32 #include #include #include "Network.h" using namespace std; using namespace std::placeholders; // FIXME non-mesh config should have it's own struct struct MeshConfig { int stationMode; int channel; int meshPort; const char* meshSSID; const char* meshPassword; const char* stationSSID; const char* stationPassword; const char* hostname; uint16_t debugTypes; }; class MeshNet : public Network { public: painlessMesh mesh; MeshConfig config; MeshNet(MeshConfig cfg); Network* init(); Network* connectStation(int); void update(); void newConnectionCallback(uint32_t nodeId); void changedConnectionCallback(); void nodeTimeAdjustedCallback(int32_t offset); void broadcast(String msg); void sendTo(uint32_t target, String msg); void onReceive(std::function); int isConnected(){ return WiFi.status() == WL_CONNECTED; } }; #endif