mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-29 18:28:24 +02:00
Config: Fix build issue if WS/WSS transport disabled
Closes https://github.com/espressif/esp-idf/issues/7535
This commit is contained in:
@ -519,19 +519,28 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl
|
||||
|
||||
if (config->transport) {
|
||||
free(client->config->scheme);
|
||||
if (config->transport == MQTT_TRANSPORT_OVER_WS) {
|
||||
client->config->scheme = create_string("ws", 2);
|
||||
ESP_MEM_CHECK(TAG, client->config->scheme, goto _mqtt_set_config_failed);
|
||||
} else if (config->transport == MQTT_TRANSPORT_OVER_TCP) {
|
||||
if (config->transport == MQTT_TRANSPORT_OVER_TCP) {
|
||||
client->config->scheme = create_string("mqtt", 4);
|
||||
ESP_MEM_CHECK(TAG, client->config->scheme, goto _mqtt_set_config_failed);
|
||||
} else if (config->transport == MQTT_TRANSPORT_OVER_SSL) {
|
||||
}
|
||||
#if MQTT_ENABLE_WS
|
||||
else if (config->transport == MQTT_TRANSPORT_OVER_WS) {
|
||||
client->config->scheme = create_string("ws", 2);
|
||||
ESP_MEM_CHECK(TAG, client->config->scheme, goto _mqtt_set_config_failed);
|
||||
}
|
||||
#endif
|
||||
#if MQTT_ENABLE_SSL
|
||||
else if (config->transport == MQTT_TRANSPORT_OVER_SSL) {
|
||||
client->config->scheme = create_string("mqtts", 5);
|
||||
ESP_MEM_CHECK(TAG, client->config->scheme, goto _mqtt_set_config_failed);
|
||||
} else if (config->transport == MQTT_TRANSPORT_OVER_WSS) {
|
||||
}
|
||||
#endif
|
||||
#if MQTT_ENABLE_WSS
|
||||
else if (config->transport == MQTT_TRANSPORT_OVER_WSS) {
|
||||
client->config->scheme = create_string("wss", 3);
|
||||
ESP_MEM_CHECK(TAG, client->config->scheme, goto _mqtt_set_config_failed);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set uri at the end of config to override separately configured uri elements
|
||||
@ -868,14 +877,18 @@ esp_err_t esp_mqtt_client_set_uri(esp_mqtt_client_handle_t client, const char *u
|
||||
}
|
||||
|
||||
if (client->config->path) {
|
||||
esp_transport_handle_t trans = esp_transport_list_get_transport(client->transport_list, "ws");
|
||||
if (trans) {
|
||||
esp_transport_ws_set_path(trans, client->config->path);
|
||||
#if MQTT_ENABLE_WS
|
||||
esp_transport_handle_t ws_trans = esp_transport_list_get_transport(client->transport_list, "ws");
|
||||
if (ws_trans) {
|
||||
esp_transport_ws_set_path(ws_trans, client->config->path);
|
||||
}
|
||||
trans = esp_transport_list_get_transport(client->transport_list, "wss");
|
||||
if (trans) {
|
||||
esp_transport_ws_set_path(trans, client->config->path);
|
||||
#endif
|
||||
#if MQTT_ENABLE_WSS
|
||||
esp_transport_handle_t wss_trans = esp_transport_list_get_transport(client->transport_list, "wss");
|
||||
if (wss_trans) {
|
||||
esp_transport_ws_set_path(wss_trans, client->config->path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (puri.field_data[UF_PORT].len) {
|
||||
|
Reference in New Issue
Block a user