Skip to Content
Hands-On Embedded Programming with C++17
book

Hands-On Embedded Programming with C++17

by Maya Posch
January 2019
Intermediate to advanced
458 pages
10h 35m
English
Packt Publishing
Content preview from Hands-On Embedded Programming with C++17

Listener

The class declaration for the Listener class looks like this:

class Listener : public mosqpp::mosquittopp {          // public:          Listener(string clientId, string host, int port, string user, string pass);          ~Listener();          void on_connect(int rc);          void on_message(const struct mosquitto_message* message);          void on_subscribe(int mid, int qos_count, const int* granted_qos);          void sendMessage(string topic, string& message);          void sendMessage(string& topic, char* message, int msgLength); };

This class provides a simple API to connect to an MQTT broker and send messages to said broker. We inherit from the mosquittopp class, re-implementing a number of callback methods to handle the events of connecting newly received messages and completed subscriptions ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On RTOS with Microcontrollers

Hands-On RTOS with Microcontrollers

Brian Amos

Publisher Resources

ISBN: 9781788629300Supplemental Content