A Threaded Secure MQTT Client example. Uses MBED TLS for SSL/TLS connection. QoS0 only for now. Example has been tested with K64F connected via Ethernet.
Fork of HelloMQTT by
Diff: MQTTThreadedClient.h
- Revision:
- 27:c90092f35d79
- Parent:
- 26:4b21de8043a5
- Child:
- 30:b2aed80037db
- Child:
- 31:d34f6adb7a53
diff -r 4b21de8043a5 -r c90092f35d79 MQTTThreadedClient.h --- a/MQTTThreadedClient.h Mon Mar 27 13:45:26 2017 +0000 +++ b/MQTTThreadedClient.h Mon Mar 27 14:08:46 2017 +0000 @@ -100,7 +100,14 @@ disconnect(); } - + /** + * Sets the connection parameters. Must be called before running the startListener as a thread. + * + * @param host - pointer to the host where the MQTT server is running + * @param port - the port number to connect, 1883 for non secure connections, 8883 for + * secure connections + * @param options - the connect data used for logging into the MQTT server. + */ void setConnectionParameters(const char * host, uint16_t port, MQTTPacket_connectData & options); int publish(PubMessage& message); @@ -114,6 +121,8 @@ topicCBMap.insert(std::pair<std::string, FP<void,MessageData &> >(std::string(topic),fp)); } + // TODO: Add unsubscribe functionality. + // Start the listener thread and start polling // MQTT server. void startListener();