mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-30 02:38:19 +02:00
defined macros for supported features in esp-idf based on idf version
This commit is contained in:
38
include/mqtt_supported_features.h
Normal file
38
include/mqtt_supported_features.h
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _MQTT_SUPPORTED_FEATURES_H_
|
||||
#define _MQTT_SUPPORTED_FEATURES_H_
|
||||
|
||||
#if __has_include("esp_idf_version.h")
|
||||
#include "esp_idf_version.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This header defines supported features of IDF which mqtt module
|
||||
* could use depending on specific version of ESP-IDF.
|
||||
* In case "esp_idf_version.h" were not found, all additional
|
||||
* features would be disabled
|
||||
*/
|
||||
|
||||
#ifdef ESP_IDF_VERSION
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
|
||||
|
||||
#define MQTT_SUPPORTED_FEATURE_WS_SUBPROTOCOL
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _MQTT_SUPPORTED_FEATURES_H_
|
@ -9,6 +9,7 @@
|
||||
#include "esp_transport_ws.h"
|
||||
#include "platform.h"
|
||||
#include "mqtt_outbox.h"
|
||||
#include "mqtt_supported_features.h"
|
||||
|
||||
/* using uri parser */
|
||||
#include "http_parser.h"
|
||||
@ -26,6 +27,7 @@
|
||||
# define MQTT_API_UNLOCK_FROM_OTHER_TASK(c) { if (c->task_handle != xTaskGetCurrentTaskHandle()) { xSemaphoreGive(c->api_lock); } }
|
||||
#endif /* MQTT_USE_API_LOCKS */
|
||||
|
||||
|
||||
static const char *TAG = "MQTT_CLIENT";
|
||||
|
||||
/**
|
||||
@ -368,7 +370,9 @@ esp_mqtt_client_handle_t esp_mqtt_client_init(const esp_mqtt_client_config_t *co
|
||||
esp_transport_handle_t ws = esp_transport_ws_init(tcp);
|
||||
ESP_MEM_CHECK(TAG, ws, goto _mqtt_init_failed);
|
||||
esp_transport_set_default_port(ws, MQTT_WS_DEFAULT_PORT);
|
||||
#ifdef MQTT_SUPPORTED_FEATURE_WS_SUBPROTOCOL
|
||||
esp_transport_ws_set_subprotocol(ws, "mqtt");
|
||||
#endif
|
||||
esp_transport_list_add(client->transport_list, ws, "ws");
|
||||
if (config->transport == MQTT_TRANSPORT_OVER_WS) {
|
||||
client->config->scheme = create_string("ws", 2);
|
||||
@ -399,7 +403,9 @@ esp_mqtt_client_handle_t esp_mqtt_client_init(const esp_mqtt_client_config_t *co
|
||||
#if MQTT_ENABLE_WSS
|
||||
esp_transport_handle_t wss = esp_transport_ws_init(ssl);
|
||||
ESP_MEM_CHECK(TAG, wss, goto _mqtt_init_failed);
|
||||
#ifdef MQTT_SUPPORTED_FEATURE_WS_SUBPROTOCOL
|
||||
esp_transport_ws_set_subprotocol(wss, "mqtt");
|
||||
#endif
|
||||
esp_transport_set_default_port(wss, MQTT_WSS_DEFAULT_PORT);
|
||||
esp_transport_list_add(client->transport_list, wss, "wss");
|
||||
if (config->transport == MQTT_TRANSPORT_OVER_WSS) {
|
||||
|
Reference in New Issue
Block a user