![]() |
|
Uniot Core
|
| 0.8.1 |
#include <MQTTKit.h>
Public Member Functions | |
| MQTTKit (const Credentials &credentials, CBORExtender infoExtender=nullptr) | |
| Constructs an MQTTKit instance. | |
| ~MQTTKit () | |
| Destructor - cleans up event listeners. | |
| void | setServer (const char *domain, uint16_t port) |
| Sets the MQTT broker server address and port. | |
| void | addDevice (MQTTDevice &device) |
| Adds a device to be managed by this MQTT kit. | |
| void | removeDevice (MQTTDevice &device) |
| Removes a device from this MQTT kit. | |
| const MQTTPath & | getPath () |
| Gets the MQTT path helper object. | |
| void | renewSubscriptions () |
| Renews all device subscriptions. | |
| virtual void | pushTo (TaskScheduler &scheduler) override |
| Registers MQTT tasks with the provided scheduler. | |
| virtual void | attach () override |
| Attaches this kit (empty implementation) | |
| virtual void | onEventReceived (unsigned int topic, int msg) override |
| Handles network and time events. | |
Public Member Functions inherited from uniot::ISchedulerConnectionKit | |
| virtual | ~ISchedulerConnectionKit () |
| Virtual destructor for proper cleanup. | |
Public Member Functions inherited from uniot::EventListener< unsigned int, int, Bytes > | |
| virtual | ~EventListener ()=default |
| Virtual destructor. | |
| virtual type_id | getTypeId () const override |
| Get the type ID of this class for RTTI. | |
| EventListener * | listenToEvent (unsigned int topic) |
| Subscribe to events of a specific topic. | |
| EventListener * | stopListeningToEvent (unsigned int topic) |
| Unsubscribe from events of a specific topic. | |
| bool | isListeningToEvent (unsigned int topic) |
| Check if this listener is subscribed to a specific topic. | |
| virtual | ~EventListener ()=default |
| Virtual destructor. | |
| virtual type_id | getTypeId () const override |
| Get the type ID of this class for RTTI. | |
| EventListener * | listenToEvent (unsigned int topic) |
| Subscribe to events of a specific topic. | |
| EventListener * | stopListeningToEvent (unsigned int topic) |
| Unsubscribe from events of a specific topic. | |
| bool | isListeningToEvent (unsigned int topic) |
| Check if this listener is subscribed to a specific topic. | |
Public Member Functions inherited from uniot::EventEmitter< unsigned int, int, Bytes > | |
| virtual | ~EventEmitter ()=default |
| Virtual destructor to ensure proper cleanup of derived classes. | |
| void | emitEvent (unsigned int topic, int msg) |
| Emits an event to all registered event buses. | |
| virtual | ~EventEmitter ()=default |
| Virtual destructor to ensure proper cleanup of derived classes. | |
| void | emitEvent (unsigned int topic, int msg) |
| Emits an event to all registered event buses. | |
Public Member Functions inherited from uniot::EventEntity< T_topic, T_msg, T_data > | |
| virtual | ~EventEntity () |
| Destructor - disconnects from all connected EventBus instances. | |
| bool | sendDataToChannel (T_topic channel, T_data data) |
| Sends data to a specific channel on all connected EventBus instances. | |
| void | receiveDataFromChannel (T_topic channel, DataChannelCallback callback) |
| Receives data from a specific channel on all connected EventBus instances. | |
Protected Member Functions | |
| PubSubClient * | client () |
| Gets access to the underlying PubSubClient. | |
Protected Member Functions inherited from uniot::EventEntity< T_topic, T_msg, T_data > | |
| bool | connectUnique (EventBus< T_topic, T_msg, T_data > *eventBus) |
| Connects to an EventBus instance if not already connected. | |
Friends | |
| class | MQTTDevice |
Additional Inherited Members | |
Public Types inherited from uniot::EventEntity< T_topic, T_msg, T_data > | |
| using | DataChannelCallback = std::function<void(unsigned int, bool, T_data)> |
| Callback type for handling data received from channels. | |
Protected Attributes inherited from uniot::EventEntity< T_topic, T_msg, T_data > | |
| IterableQueue< EventBus< T_topic, T_msg, T_data > * > | mEventBusQueue |
| Queue of EventBus instances this entity is connected to. | |
|
inline |
Constructs an MQTTKit instance.
| credentials | The credentials to use for MQTT authentication |
| infoExtender | Optional callback to extend status messages with additional data |
|
inline |
Destructor - cleans up event listeners.
|
inline |
Adds a device to be managed by this MQTT kit.
The device will be initialized with this kit and its topics will be subscribed
| device | The device to add |
|
inlineoverridevirtual |
Attaches this kit (empty implementation)
Implements uniot::ISchedulerConnectionKit.
|
inlineprotected |
Gets access to the underlying PubSubClient.
| mPubSubClient | The underlying PubSubClient instance |
|
inline |
Gets the MQTT path helper object.
| mPath | The MQTT path helper object |
|
inlineoverridevirtual |
Handles network and time events.
Handles network connection events to enable/disable MQTT connections and time synchronization events to initialize MQTT tasks
| topic | The event topic |
| msg | The event message |
Implements uniot::EventListener< unsigned int, int, Bytes >.
|
inlineoverridevirtual |
Registers MQTT tasks with the provided scheduler.
| scheduler | The scheduler to register tasks with |
Implements uniot::ISchedulerConnectionKit.
|
inline |
Removes a device from this MQTT kit.
The device will be detached from this kit and its topic subscriptions will be removed
| device | The device to remove |
|
inline |
Renews all device subscriptions.
Unsubscribes from all topics and then resubscribes to ensure subscriptions are current
|
inline |
Sets the MQTT broker server address and port.
| domain | The server domain name or IP address |
| port | The server port |
|
friend |