#ifndef _PAINLESS_MESH_CONNECTION_H_ #define _PAINLESS_MESH_CONNECTION_H_ #define _TASK_PRIORITY // Support for layered scheduling priority #define _TASK_STD_FUNCTION #include #ifdef ESP32 #include #elif defined(ESP8266) #include #endif // ESP32 #include "painlessmesh/buffer.hpp" #include "painlessmesh/configuration.hpp" #include "painlessmesh/layout.hpp" #include "painlessmesh/mesh.hpp" #ifndef PAINLESSMESH_ENABLE_ARDUINO_WIFI class MeshConnection; using painlessMesh = painlessmesh::Mesh; #endif class MeshConnection : public painlessmesh::layout::Neighbour, public std::enable_shared_from_this { public: AsyncClient *client; painlessmesh::Mesh *mesh; bool newConnection = true; bool connected = true; bool station = true; // Timestamp to be compared in manageConnections() to check response // for timeout uint32_t timeDelayLastRequested = 0; bool addMessage(TSTRING &message, bool priority = false); bool writeNext(); painlessmesh::buffer::ReceiveBuffer receiveBuffer; painlessmesh::buffer::SentBuffer sentBuffer; Task nodeSyncTask; Task timeSyncTask; Task readBufferTask; Task sentBufferTask; Task timeOutTask; MeshConnection(AsyncClient *client, painlessmesh::Mesh *pMesh, bool station); ~MeshConnection(); void initTCPCallbacks(); void initTasks(); void handleMessage(TSTRING msg, uint32_t receivedAt); void close(); friend painlessmesh::Mesh; }; #endif