AlteriomPainlessMesh v2.1.1
Easy ESP32/ESP8266 mesh networking with Alteriom IoT extensions
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
painlessmesh::Connection Class Reference

#include <mesh.hpp>

Inheritance diagram for painlessmesh::Connection:
Inheritance graph
[legend]
Collaboration diagram for painlessmesh::Connection:
Collaboration graph
[legend]

Public Member Functions

 Connection (AsyncClient *client, Mesh< painlessmesh::Connection > *mesh, bool station)
 
void initTasks ()
 
bool addMessage (const TSTRING &msg, bool priority=false)
 
bool addMessageWithPriority (const TSTRING &msg, uint8_t priorityLevel)
 
void onMessageReceived (size_t bytes=0)
 
void onMessageSent (bool success, size_t bytes=0)
 
void recordLatency (uint32_t latencyMs)
 
int getLatency ()
 
int getQuality ()
 
int getRSSI ()
 
- Public Member Functions inherited from painlessmesh::layout::Neighbour
bool validSubs (protocol::NodeTree tree)
 
bool updateSubs (protocol::NodeTree tree)
 
protocol::NodeSyncRequest request (NodeTree &&layout)
 
protocol::NodeSyncReply reply (NodeTree &&layout)
 
- Public Member Functions inherited from painlessmesh::protocol::NodeTree
 NodeTree ()
 
virtual ~NodeTree ()=default
 
 NodeTree (uint32_t nodeID, bool iAmRoot, bool timeAuthority=false)
 
 NodeTree (JsonObject jsonObj)
 
JsonObject addTo (JsonObject &&jsonObj) const
 
bool operator== (const NodeTree &b) const
 
bool operator!= (const NodeTree &b) const
 
TSTRING toString (bool pretty=false)
 
size_t jsonObjectSize () const
 
void clear ()
 
- Public Member Functions inherited from painlessmesh::protocol::PackageInterface
virtual ~PackageInterface ()=default
 
- Public Member Functions inherited from painlessmesh::tcp::BufferedConnection
 BufferedConnection (AsyncClient *client)
 
 ~BufferedConnection ()
 
void initialize (Scheduler *scheduler)
 
void close ()
 
bool write (const TSTRING &data, bool priority=false)
 
bool writeWithPriority (const TSTRING &data, uint8_t priorityLevel)
 
void onDisconnect (std::function< void()> callback)
 
void onReceive (std::function< void(TSTRING)> callback)
 
bool connected ()
 

Public Attributes

Mesh< Connection > * mesh
 
bool station = true
 
bool newConnection = true
 
Task timeSyncTask
 
Task nodeSyncTask
 
Task timeOutTask
 
uint32_t messagesRx = 0
 
uint32_t messagesTx = 0
 
uint32_t messagesDropped = 0
 
uint32_t timeLastReceived = 0
 
uint64_t bytesRx = 0
 
uint64_t bytesTx = 0
 
std::vector< uint32_t > latencySamples
 
- Public Attributes inherited from painlessmesh::layout::Neighbour
uint32_t presented = 0
 
- Public Attributes inherited from painlessmesh::protocol::NodeTree
uint32_t nodeId = 0
 
bool root = false
 
bool hasTimeAuthority = false
 
std::list< NodeTree > subs
 

Static Public Attributes

static const size_t MAX_LATENCY_SAMPLES = 10
 

Protected Member Functions

std::shared_ptr< Connection > shared_from_this ()
 
- Protected Member Functions inherited from painlessmesh::tcp::BufferedConnection
bool writeNext ()
 
template<typename T >
std::shared_ptr< T > shared_from (T *derived)
 

Additional Inherited Members

- Protected Attributes inherited from painlessmesh::tcp::BufferedConnection
bool mConnected = true
 
AsyncClient * client
 
Scheduler * mScheduler = nullptr
 
std::function< void(TSTRING)> receiveCallback
 
std::function< void()> disconnectCallback
 
painlessmesh::buffer::ReceiveBuffer< TSTRING > receiveBuffer
 
painlessmesh::buffer::SentBuffer< TSTRING > sentBuffer
 
Task sentBufferTask
 
Task readBufferTask
 

Constructor & Destructor Documentation

◆ Connection()

painlessmesh::Connection::Connection ( AsyncClient *  client,
Mesh< painlessmesh::Connection > *  mesh,
bool  station 
)
inline

Member Function Documentation

◆ addMessage()

bool painlessmesh::Connection::addMessage ( const TSTRING &  msg,
bool  priority = false 
)
inline

◆ addMessageWithPriority()

bool painlessmesh::Connection::addMessageWithPriority ( const TSTRING &  msg,
uint8_t  priorityLevel 
)
inline

Add message with explicit priority level (0-3)

Parameters
msgThe message to send
priorityLevelPriority level: 0=CRITICAL, 1=HIGH, 2=NORMAL, 3=LOW

◆ getLatency()

int painlessmesh::Connection::getLatency ( )
inline

Get average latency from recent samples Returns -1 if no samples available

◆ getQuality()

int painlessmesh::Connection::getQuality ( )
inline

Calculate connection quality (0-100) Based on: latency, packet loss, RSSI

◆ getRSSI()

int painlessmesh::Connection::getRSSI ( )
inline

Get WiFi RSSI if available Returns RSSI in dBm (typically -30 to -90) or 0 if not available

◆ initTasks()

void painlessmesh::Connection::initTasks ( )
inline

◆ onMessageReceived()

void painlessmesh::Connection::onMessageReceived ( size_t  bytes = 0)
inline

Record message received timestamp and bytes

◆ onMessageSent()

void painlessmesh::Connection::onMessageSent ( bool  success,
size_t  bytes = 0 
)
inline

Record message sent and bytes

◆ recordLatency()

void painlessmesh::Connection::recordLatency ( uint32_t  latencyMs)
inline

Record round-trip time sample

◆ shared_from_this()

std::shared_ptr< Connection > painlessmesh::Connection::shared_from_this ( )
inlineprotected

Member Data Documentation

◆ bytesRx

uint64_t painlessmesh::Connection::bytesRx = 0

◆ bytesTx

uint64_t painlessmesh::Connection::bytesTx = 0

◆ latencySamples

std::vector<uint32_t> painlessmesh::Connection::latencySamples

◆ MAX_LATENCY_SAMPLES

const size_t painlessmesh::Connection::MAX_LATENCY_SAMPLES = 10
static

◆ mesh

Mesh<Connection>* painlessmesh::Connection::mesh

◆ messagesDropped

uint32_t painlessmesh::Connection::messagesDropped = 0

◆ messagesRx

uint32_t painlessmesh::Connection::messagesRx = 0

◆ messagesTx

uint32_t painlessmesh::Connection::messagesTx = 0

◆ newConnection

bool painlessmesh::Connection::newConnection = true

◆ nodeSyncTask

Task painlessmesh::Connection::nodeSyncTask

◆ station

bool painlessmesh::Connection::station = true

◆ timeLastReceived

uint32_t painlessmesh::Connection::timeLastReceived = 0

◆ timeOutTask

Task painlessmesh::Connection::timeOutTask

◆ timeSyncTask

Task painlessmesh::Connection::timeSyncTask

The documentation for this class was generated from the following file: