@@ -24,11 +24,6 @@ static const char *TAG = "mqtt_client";
2424ESP_EVENT_DEFINE_BASE (MQTT_EVENTS );
2525#endif
2626
27- #define MQTT_OVER_TCP_SCHEME "mqtt"
28- #define MQTT_OVER_SSL_SCHEME "mqtts"
29- #define MQTT_OVER_WS_SCHEME "ws"
30- #define MQTT_OVER_WSS_SCHEME "wss"
31-
3227const static int STOPPED_BIT = (1 << 0 );
3328const static int RECONNECT_BIT = (1 << 1 );
3429const static int DISCONNECT_BIT = (1 << 2 );
@@ -1587,9 +1582,6 @@ static void esp_mqtt_task(void *pv)
15871582 break ;
15881583 case MQTT_STATE_INIT :
15891584 xEventGroupClearBits (client -> status_bits , RECONNECT_BIT | DISCONNECT_BIT );
1590- client -> event .event_id = MQTT_EVENT_BEFORE_CONNECT ;
1591- esp_mqtt_dispatch_event_with_msgid (client );
1592-
15931585
15941586 client -> transport = client -> config -> transport ;
15951587 if (!client -> transport ) {
@@ -1617,6 +1609,9 @@ static void esp_mqtt_task(void *pv)
16171609 esp_mqtt_set_ssl_transport_properties (client -> transport_list , client -> config );
16181610#endif
16191611
1612+ client -> event .event_id = MQTT_EVENT_BEFORE_CONNECT ;
1613+ esp_mqtt_dispatch_event_with_msgid (client );
1614+
16201615 if (esp_transport_connect (client -> transport ,
16211616 client -> config -> host ,
16221617 client -> config -> port ,
@@ -2282,3 +2277,13 @@ int esp_mqtt_client_get_outbox_size(esp_mqtt_client_handle_t client)
22822277
22832278 return outbox_size ;
22842279}
2280+
2281+ esp_transport_handle_t esp_mqtt_client_get_transport (esp_mqtt_client_handle_t client , char * transport_scheme ){
2282+ if (client == NULL || (transport_scheme == NULL && client -> config -> transport == NULL )) {
2283+ return NULL ;
2284+ }
2285+ if (transport_scheme == NULL && client -> config -> transport != NULL ) {
2286+ return client -> config -> transport ;
2287+ }
2288+ return esp_transport_list_get_transport (client -> transport_list , transport_scheme );
2289+ }
0 commit comments