Skip to content

Commit 7d7b70c

Browse files
committed
feat(mqtt): modify example and cmake file for building
1 parent fc39abf commit 7d7b70c

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

components/mqtt/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ idf_component_register(SRCS "esp-mqtt/mqtt_client.c"
44
"esp-mqtt/lib/platform_esp32_idf.c"
55
INCLUDE_DIRS esp-mqtt/include
66
PRIV_INCLUDE_DIRS "esp-mqtt/lib/include"
7-
REQUIRES lwip nghttp mbedtls tcp_transport)
7+
REQUIRES lwip http_parser mbedtls tcp_transport)

examples/protocols/mqtt/ssl/main/app_main.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,6 @@ extern const uint8_t mqtt_eclipse_org_pem_start[] asm("_binary_mqtt_eclipse_or
3232
#endif
3333
extern const uint8_t mqtt_eclipse_org_pem_end[] asm("_binary_mqtt_eclipse_org_pem_end");
3434

35-
//
36-
// Note: this function is for testing purposes only publishing the entire active partition
37-
// (to be checked against the original binary)
38-
//
39-
static void send_binary(esp_mqtt_client_handle_t client)
40-
{
41-
spi_flash_mmap_handle_t out_handle;
42-
const void *binary_address;
43-
const esp_partition_t* partition = esp_ota_get_running_partition();
44-
esp_partition_mmap(partition, 0, partition->size, SPI_FLASH_MMAP_DATA, &binary_address, &out_handle);
45-
int msg_id = esp_mqtt_client_publish(client, "/topic/binary", binary_address, partition->size, 0, 0);
46-
ESP_LOGI(TAG, "binary sent with msg_id=%d", msg_id);
47-
}
48-
4935
static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
5036
{
5137
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)
8268
ESP_LOGI(TAG, "MQTT_EVENT_DATA");
8369
printf("TOPIC=%.*s\r\n", event->topic_len, event->topic);
8470
printf("DATA=%.*s\r\n", event->data_len, event->data);
85-
if (strncmp(event->data, "send binary please", event->data_len) == 0) {
86-
ESP_LOGI(TAG, "Sending the binary");
87-
send_binary(client);
88-
}
8971
break;
9072
case MQTT_EVENT_ERROR:
9173
ESP_LOGI(TAG, "MQTT_EVENT_ERROR");

examples/protocols/mqtt/ssl_psk/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ This example connects to a local broker configured to PSK authentication
66

77
## How to use example
88

9+
### Code prepare
10+
11+
If want to use psk function, maybe need change IDF version beyond v4.1 in `esp_idf_version.h`. Like this :
12+
```
13+
/** Major version number (X.x.x) */
14+
#define ESP_IDF_VERSION_MAJOR 4
15+
/** Minor version number (x.X.x) */
16+
#define ESP_IDF_VERSION_MINOR 2
17+
/** Patch version number (x.x.X) */
18+
#define ESP_IDF_VERSION_PATCH 0
19+
```
20+
21+
This feature is controled by macro `MQTT_SUPPORTED_FEATURE_PSK_AUTHENTICATION`, defined in `mqtt_supported_features.h`.
22+
923
### Hardware Required
1024

1125
This example can be executed on any ESP32 board, the only required interface is WiFi (or ethernet) to connect to a MQTT

0 commit comments

Comments
 (0)