[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

@@ -110,12 +110,12 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
static void mqtt_app_start(void)
{
esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URL,
.broker.address.uri = CONFIG_BROKER_URL,
};
#if CONFIG_BROKER_URL_FROM_STDIN
char line[128];
if (strcmp(mqtt_cfg.uri, "FROM_STDIN") == 0) {
if (strcmp(mqtt_cfg.broker.address.uri, "FROM_STDIN") == 0) {
int count = 0;
printf("Please enter url of mqtt broker\n");
while (count < 128) {
@@ -129,7 +129,7 @@ static void mqtt_app_start(void)
}
vTaskDelay(10 / portTICK_PERIOD_MS);
}
mqtt_cfg.uri = line;
mqtt_cfg.broker.address.uri = line;
printf("Broker url: %s\n", line);
} else {
ESP_LOGE(TAG, "Configuration mismatch: wrong broker url");