Browse Source

don't crash on mqtt

split_files
Hendrik Langer 5 years ago
parent
commit
d799d717fc
  1. 7
      src/XD0MQTT.cpp
  2. 4
      src/main.cpp

7
src/XD0MQTT.cpp

@ -88,8 +88,10 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
}
bool XD0MQTT::begin(void) {
esp_mqtt_client_config_t mqtt_cfg;
static esp_mqtt_client_config_t mqtt_cfg;
mqtt_cfg.uri = MQTT_BROKER_URI;
// mqtt_cfg.host = "home.xd0.de";
// mqtt_cfg.port = 8883;
mqtt_cfg.event_handle = mqtt_event_handler;
mqtt_cfg.cert_pem = (const char *)rootCACertificate;
mqtt_cfg.username = MQTT_USERNAME;
@ -97,6 +99,9 @@ bool XD0MQTT::begin(void) {
mqtt_cfg.user_context = (void*)this;
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());
Serial.printf("BROKER URI: %s\n", MQTT_BROKER_URI);
Serial.printf("MQTT USERNAME: %s\n", MQTT_USERNAME);
Serial.printf("MQTT PASSWORD: %s\n", MQTT_PASSWORD);
esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
//esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client);
esp_mqtt_client_start(client);

4
src/main.cpp

@ -126,9 +126,9 @@ void setup()
XD0OTA ota("esp32-weatherstation");
ota.update();
/*
mqtt.begin();
*/
}
void loop()

Loading…
Cancel
Save