[MQTT] - Updates esp_mqtt configuration struct

- Layered config struct
- Fix examples.
This commit is contained in:
Euripedes Rocha
2022-06-13 07:59:11 -03:00
parent 309440c687
commit ff1c405ed1
20 changed files with 221 additions and 152 deletions

View File

@@ -44,7 +44,7 @@ static void send_binary(esp_mqtt_client_handle_t client)
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);
// sending only the configured portion of the partition (if it's less than the partition size)
int binary_size = MIN(CONFIG_BROKER_BIN_SIZE_TO_SEND,partition->size);
int binary_size = MIN(CONFIG_BROKER_BIN_SIZE_TO_SEND, partition->size);
int msg_id = esp_mqtt_client_publish(client, "/topic/binary", binary_address, binary_size, 0, 0);
ESP_LOGI(TAG, "binary sent with msg_id=%d", msg_id);
}
@@ -123,8 +123,10 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
static void mqtt_app_start(void)
{
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URI,
.cert_pem = (const char *)mqtt_eclipseprojects_io_pem_start,
.broker = {
.address.uri = CONFIG_BROKER_URI,
.verification.certificate = (const char *)mqtt_eclipseprojects_io_pem_start
},
};
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());