esp-idf/app_main.c at 45c1d1cba212b2012d53a55fcf9d338a959c2ece · espressif/esp-idf · GitHub

PHOTO EMBED

Mon Apr 25 2022 15:14:18 GMT+0000 (Coordinated Universal Time)

Saved by @danaxe #c

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);
    // 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 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);
}
content_copyCOPY

Save binary

https://github.com/espressif/esp-idf/tree/45c1d1cba2/examples/protocols/mqtt/ssl