Merged
Merge Request #8
·
created by
added LWT ( last will & testament ) option to mqtt connect.
added support for a last will & testament message. LWT settings are not required for connection, but can be provided as optional parameter when calling the mqttclient connect function. ( see publisher test case ). The parameters to be added are the topic to publish on and the message to be published in case of a connection disruption.
-
agreed, changed it to lwt_topic and lwt_message.
-
agreed, changed it to lwt_topic and lwt_message.
-
yep, minor typo. has been fixed.
-
yep, minor typo. has been fixed.
-
yep, minor typo. has been fixed.
-
Please fix the comments on the code and add the following :
- If a connection was made and the connection is lost ( e.g. the network connection is disabled ) the LWT needs to get published.
- If the connection is restored, make sure data is being send again.
- Again, disable the network connection and check to see if the LWT is again being published. If not, make sure it gets re-issued if a connection is restored. The LWT needs to be stored in a member-variable of clientpaho...
-
fixed the code relevant to the comments. looking into the connection issues now.
-
LWT is correctly published on connection interruption. date is picked up again once connection is restored and LWT is also published again once interrupted again.
-
Tested and looking good. Merging to Development and Master
-
mentioned in commit b4d6ed568a3652ab9a0078f2eb6e976d1497d898
-
Status changed to merged
29 | 29 | |
30 | 30 | } |
31 | 31 | |
32 | -void Publisher::connect( const std::string &hostname, int portnumber, const std::string &username, const std::string &password ) | |
32 | +void Publisher::connect(const std::string &hostname, int portnumber, const std::string &username, const std::string &password, const std::string &lwt_topic, const std::string &lwt_message) | |
1 |
|
36 | 36 | |
37 | 37 | virtual ~Publisher() {} |
38 | 38 | |
39 | - void connect( const std::string &hostname, int portnumber = 1883, const std::string &username = std::string(), const std::string &password = std::string() ); | |
39 | + void connect( const std::string &hostname, int portnumber = 1883, const std::string &username = std::string(), const std::string &password = std::string() | |
40 | + , const std::string &lwt_topic = std::string(), const std::string &lwt_message = std::string() ); | |
1 |
|
59 | 60 | * @param port The port to use. |
60 | 61 | * @param credentials The credentials to use. |
61 | 62 | */ |
62 | - virtual void connect(const std::string& host, int port, const Credentials& credentials) = 0; | |
63 | + virtual void connect(const std::string& host, int port, const Credentials& credentials, const mqtt_LWT &lwt = mqtt_LWT() ) = 0; | |
1 |
|
59 | 60 | * @param port The port to use. |
60 | 61 | * @param credentials The credentials to use. |
61 | 62 | */ |
62 | - virtual void connect(const std::string& host, int port, const Credentials& credentials) = 0; | |
63 | + virtual void connect(const std::string& host, int port, const Credentials& credentials, const mqtt_LWT &lwt = mqtt_LWT() ) = 0; | |
63 | 64 | |
64 | 65 | /** |
65 | 66 | * @brief Connect to the endpoint |
66 | 67 | * @param endpoint an uri endpoint description. |
67 | 68 | */ |
68 | - virtual void connect(const std::string& endpoint) = 0; | |
69 | + virtual void connect(const std::string& endpoint, const mqtt_LWT &lwt = mqtt_LWT() ) = 0; | |
1 |
|
91 | 92 | /** |
92 | 93 | * @see IMqttClient |
93 | 94 | */ |
94 | - virtual void connect(const std::string& host, int port, const Credentials& credentials) override; | |
95 | + virtual void connect( const std::string& host, int port, const Credentials &credentials, const mqtt_LWT &lwt = mqtt_LWT() ) override; | |
1 |
|