|
@ -88,8 +88,10 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool XD0MQTT::begin(void) { |
|
|
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.uri = MQTT_BROKER_URI; |
|
|
|
|
|
// mqtt_cfg.host = "home.xd0.de";
|
|
|
|
|
|
// mqtt_cfg.port = 8883;
|
|
|
mqtt_cfg.event_handle = mqtt_event_handler; |
|
|
mqtt_cfg.event_handle = mqtt_event_handler; |
|
|
mqtt_cfg.cert_pem = (const char *)rootCACertificate; |
|
|
mqtt_cfg.cert_pem = (const char *)rootCACertificate; |
|
|
mqtt_cfg.username = MQTT_USERNAME; |
|
|
mqtt_cfg.username = MQTT_USERNAME; |
|
@ -97,6 +99,9 @@ bool XD0MQTT::begin(void) { |
|
|
mqtt_cfg.user_context = (void*)this; |
|
|
mqtt_cfg.user_context = (void*)this; |
|
|
|
|
|
|
|
|
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); |
|
|
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_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_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client);
|
|
|
esp_mqtt_client_start(client); |
|
|
esp_mqtt_client_start(client); |
|
|