diff --git a/components/mqtt/CMakeLists.txt b/components/mqtt/CMakeLists.txt index 1c30e3a9..8f87ad74 100644 --- a/components/mqtt/CMakeLists.txt +++ b/components/mqtt/CMakeLists.txt @@ -4,4 +4,4 @@ idf_component_register(SRCS "esp-mqtt/mqtt_client.c" "esp-mqtt/lib/platform_esp32_idf.c" INCLUDE_DIRS esp-mqtt/include PRIV_INCLUDE_DIRS "esp-mqtt/lib/include" - REQUIRES lwip nghttp mbedtls tcp_transport) + REQUIRES lwip http_parser mbedtls tcp_transport) diff --git a/examples/protocols/mqtt/ssl/main/app_main.c b/examples/protocols/mqtt/ssl/main/app_main.c index 1afb9c0b..24af8ca8 100644 --- a/examples/protocols/mqtt/ssl/main/app_main.c +++ b/examples/protocols/mqtt/ssl/main/app_main.c @@ -32,20 +32,6 @@ extern const uint8_t mqtt_eclipse_org_pem_start[] asm("_binary_mqtt_eclipse_or #endif extern const uint8_t mqtt_eclipse_org_pem_end[] asm("_binary_mqtt_eclipse_org_pem_end"); -// -// Note: this function is for testing purposes only publishing the entire active partition -// (to be checked against the original binary) -// -static void send_binary(esp_mqtt_client_handle_t client) -{ - spi_flash_mmap_handle_t out_handle; - const void *binary_address; - const esp_partition_t* partition = esp_ota_get_running_partition(); - esp_partition_mmap(partition, 0, partition->size, SPI_FLASH_MMAP_DATA, &binary_address, &out_handle); - int msg_id = esp_mqtt_client_publish(client, "/topic/binary", binary_address, partition->size, 0, 0); - ESP_LOGI(TAG, "binary sent with msg_id=%d", msg_id); -} - static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) { esp_mqtt_client_handle_t client = event->client; @@ -82,10 +68,6 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) ESP_LOGI(TAG, "MQTT_EVENT_DATA"); printf("TOPIC=%.*s\r\n", event->topic_len, event->topic); printf("DATA=%.*s\r\n", event->data_len, event->data); - if (strncmp(event->data, "send binary please", event->data_len) == 0) { - ESP_LOGI(TAG, "Sending the binary"); - send_binary(client); - } break; case MQTT_EVENT_ERROR: ESP_LOGI(TAG, "MQTT_EVENT_ERROR"); diff --git a/examples/protocols/mqtt/ssl_psk/README.md b/examples/protocols/mqtt/ssl_psk/README.md index c46688f0..c71a9219 100644 --- a/examples/protocols/mqtt/ssl_psk/README.md +++ b/examples/protocols/mqtt/ssl_psk/README.md @@ -6,6 +6,20 @@ This example connects to a local broker configured to PSK authentication ## How to use example +### Code prepare + +If want to use psk function, maybe need change IDF version beyond v4.1 in `esp_idf_version.h`. Like this : +``` +/** Major version number (X.x.x) */ +#define ESP_IDF_VERSION_MAJOR 4 +/** Minor version number (x.X.x) */ +#define ESP_IDF_VERSION_MINOR 2 +/** Patch version number (x.x.X) */ +#define ESP_IDF_VERSION_PATCH 0 +``` + +This feature is controled by macro `MQTT_SUPPORTED_FEATURE_PSK_AUTHENTICATION`, defined in `mqtt_supported_features.h`. + ### Hardware Required This example can be executed on any ESP32 board, the only required interface is WiFi (or ethernet) to connect to a MQTT