net: mqtt: Add keep alive timeout helper

Add function that returns remaining time until next keep alive message
shall be sent. Such function could be used for instance as a source
for `poll` timeout.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2020-01-17 13:03:16 +01:00 committed by Jukka Rissanen
commit 20b1c695ab
2 changed files with 30 additions and 0 deletions

View file

@ -707,6 +707,18 @@ int mqtt_abort(struct mqtt_client *client);
*/
int mqtt_live(struct mqtt_client *client);
/**
* @brief Helper function to determine when next keep alive message should be
* sent. Can be used for instance as a source for `poll` timeout.
*
* @param[in] client Client instance for which the procedure is requested.
*
* @return Time in milliseconds until next keep alive message is expected to
* be sent. Function will return UINT32_MAX if keep alive messages are
* not enabled.
*/
u32_t mqtt_keepalive_time_left(const struct mqtt_client *client);
/**
* @brief Receive an incoming MQTT packet. The registered callback will be
* called with the packet content.