mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-30 10:48:06 +02:00
adding error event with error code
This commit is contained in:
@ -82,6 +82,7 @@ typedef struct {
|
|||||||
int topic_len; /*!< Length of the topic for this event asociated with this event */
|
int topic_len; /*!< Length of the topic for this event asociated with this event */
|
||||||
int msg_id; /*!< MQTT messaged id of message */
|
int msg_id; /*!< MQTT messaged id of message */
|
||||||
int session_present; /*!< MQTT session_present flag for connection event */
|
int session_present; /*!< MQTT session_present flag for connection event */
|
||||||
|
esp_err_t last_err; /*!< MQTT last error captured in transports */
|
||||||
} esp_mqtt_event_t;
|
} esp_mqtt_event_t;
|
||||||
|
|
||||||
typedef esp_mqtt_event_t *esp_mqtt_event_handle_t;
|
typedef esp_mqtt_event_t *esp_mqtt_event_handle_t;
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
|
||||||
// Features supported in 4.0
|
// Features supported in 4.0
|
||||||
#define MQTT_SUPPORTED_FEATURE_WS_SUBPROTOCOL
|
#define MQTT_SUPPORTED_FEATURE_WS_SUBPROTOCOL
|
||||||
|
#define MQTT_SUPPORTED_FEATURE_TRANSPORT_ERR_REPORTING
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -993,6 +993,13 @@ static void esp_mqtt_task(void *pv)
|
|||||||
client->config->port,
|
client->config->port,
|
||||||
client->config->network_timeout_ms) < 0) {
|
client->config->network_timeout_ms) < 0) {
|
||||||
ESP_LOGE(TAG, "Error transport connect");
|
ESP_LOGE(TAG, "Error transport connect");
|
||||||
|
client->event.event_id = MQTT_EVENT_ERROR;
|
||||||
|
#ifdef MQTT_SUPPORTED_FEATURE_TRANSPORT_ERR_REPORTING
|
||||||
|
client->event.last_err = get_and_clear_last_error(client->transport);
|
||||||
|
#else
|
||||||
|
client->event.last_err = ESP_FAIL; // In case reporting not supported, only report general error
|
||||||
|
#endif
|
||||||
|
esp_mqtt_dispatch_event_with_msgid(client);
|
||||||
esp_mqtt_abort_connection(client);
|
esp_mqtt_abort_connection(client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user