Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::TopDevice Class Reference

#include <TopDevice.h>

Inheritance diagram for uniot::TopDevice:
[legend]

Public Member Functions

 TopDevice ()
 Construct a new TopDevice instance.
 
virtual void syncSubscriptions () override
 Set up MQTT topic subscriptions for device monitoring.
 
void setScheduler (const TaskScheduler &scheduler)
 Associate a TaskScheduler with this monitoring device.
 
virtual void handle (const String &topic, const Bytes &payload) override
 Handle incoming MQTT messages.
 
void handleTop ()
 Handle request for task and system performance data.
 
void handleMem ()
 Handle request for memory usage information.
 
- Public Member Functions inherited from uniot::MQTTDevice
 MQTTDevice ()
 Constructs a new MQTTDevice instance.
 
virtual ~MQTTDevice ()
 Virtual destructor that handles cleanup and unregistration from MQTTKit.
 
const String & getDeviceId () const
 Gets the device identifier.
 
const String & getOwnerId () const
 Gets the owner identifier.
 
const String & subscribe (const String &topic)
 Subscribes to a specific MQTT topic.
 
const String & subscribeDevice (const String &subTopic)
 Subscribes to a device-specific subtopic.
 
const String & subscribeGroup (const String &groupId, const String &subTopic)
 Subscribes to a group-specific subtopic.
 
bool unsubscribe (const String &topic)
 Unsubscribes from a specific topic.
 
void unsubscribeFromAll ()
 Unsubscribes from all subscribed topics.
 
bool isSubscribed (const String &topic)
 Checks if the device is subscribed to a given topic.
 
bool isTopicMatch (const String &storedTopic, const String &incomingTopic) const
 Determines if a stored topic matches an incoming topic string using MQTT wildcards.
 
void publish (const String &topic, const Bytes &payload, bool retained=false, bool sign=false)
 Publishes a message to a specific topic.
 
void publishDevice (const String &subTopic, const Bytes &payload, bool retained=false, bool sign=false)
 Publishes a message to a device-specific subtopic.
 
void publishGroup (const String &groupId, const String &subTopic, const Bytes &payload, bool retained=false, bool sign=false)
 Publishes a message to a group-specific subtopic.
 
void publishEmptyDevice (const String &subTopic)
 Publishes an empty message to a device-specific subtopic with retained flag set.
 

Constructor & Destructor Documentation

◆ TopDevice()

uniot::TopDevice::TopDevice ( )
inline

Construct a new TopDevice instance.

Initializes the TopDevice with default values and no scheduler attached.

Member Function Documentation

◆ handle()

virtual void uniot::TopDevice::handle ( const String & topic,
const Bytes & payload )
inlineoverridevirtual

Handle incoming MQTT messages.

Routes incoming messages to the appropriate handler based on the topic.

Parameters
topicThe MQTT topic of the received message
payloadThe binary payload of the message @override Implements MQTTDevice::handle

Implements uniot::MQTTDevice.

◆ handleMem()

void uniot::TopDevice::handleMem ( )
inline

Handle request for memory usage information.

Collects and publishes information about available free heap memory. Data is sent via MQTT in CBOR format to the "debug/mem" topic.

◆ handleTop()

void uniot::TopDevice::handleTop ( )
inline

Handle request for task and system performance data.

Collects and publishes information about:

  • All registered tasks (name, status, execution time)
  • Idle time of the system
  • Current timestamp and system uptime

Data is sent via MQTT in CBOR format to the "debug/top" topic.

◆ setScheduler()

void uniot::TopDevice::setScheduler ( const TaskScheduler & scheduler)
inline

Associate a TaskScheduler with this monitoring device.

Links a TaskScheduler to enable task performance monitoring. The scheduler is required for the 'top' functionality to work.

Parameters
schedulerReference to the TaskScheduler to monitor

◆ syncSubscriptions()

virtual void uniot::TopDevice::syncSubscriptions ( )
inlineoverridevirtual

Set up MQTT topic subscriptions for device monitoring.

Subscribes to debug topics that trigger system information requests:

  • debug/top/ask: Request task and performance statistics
  • debug/mem/ask: Request memory usage information

@override Implements MQTTDevice::syncSubscriptions

Implements uniot::MQTTDevice.


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