mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-30 10:48:06 +02:00
Merge branch 'feature/add_get_outbox_size' into 'master'
Add esp_mqtt_client_get_outbox_size API See merge request espressif/esp-mqtt!82
This commit is contained in:
@ -358,6 +358,14 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl
|
|||||||
*/
|
*/
|
||||||
esp_err_t esp_mqtt_client_register_event(esp_mqtt_client_handle_t client, esp_mqtt_event_id_t event, esp_event_handler_t event_handler, void* event_handler_arg);
|
esp_err_t esp_mqtt_client_register_event(esp_mqtt_client_handle_t client, esp_mqtt_event_id_t event, esp_event_handler_t event_handler, void* event_handler_arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get outbox size
|
||||||
|
*
|
||||||
|
* @param client mqtt client handle
|
||||||
|
* @return outbox size
|
||||||
|
*/
|
||||||
|
int esp_mqtt_client_get_outbox_size(esp_mqtt_client_handle_t client);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif //__cplusplus
|
#endif //__cplusplus
|
||||||
|
@ -1761,3 +1761,22 @@ static void esp_mqtt_client_dispatch_transport_error(esp_mqtt_client_handle_t cl
|
|||||||
#endif
|
#endif
|
||||||
esp_mqtt_dispatch_event_with_msgid(client);
|
esp_mqtt_dispatch_event_with_msgid(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int esp_mqtt_client_get_outbox_size(esp_mqtt_client_handle_t client)
|
||||||
|
{
|
||||||
|
int outbox_size = 0;
|
||||||
|
|
||||||
|
if (client == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MQTT_API_LOCK(client);
|
||||||
|
|
||||||
|
if (client->outbox) {
|
||||||
|
outbox_size = outbox_get_size(client->outbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
MQTT_API_UNLOCK(client);
|
||||||
|
|
||||||
|
return outbox_size;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user