espressif / esp-homekit-sdk

544 stars 98 forks source link

Illegal Instruction when initializing mqtt client #49

Closed twlawrenceko closed 2 years ago

twlawrenceko commented 3 years ago

Hello,

As I am trying to implement MQTT inside the HomeKit thread, I got illegal instruction panic error when trying to initialize MQTT. #include <mqtt_client.h> has been added at the top of the file.

Lightbulb example is the one that I am getting the error, but using smart_outlet will not.

/**
 *  Initialize MQTT
 */
static void mqtt_app_init(void)
{
    esp_mqtt_client_config_t mqtt_cfg = {
        .uri = MQTT_BROKER_URL,
    };

    ESP_LOGI(TAG, "MQTT_BROKER_URL: %s", MQTT_BROKER_URL);

    esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
//    esp_mqtt_client_start(client);
}

mqtt_app_init() has been put after the below lines

    /* After all the initializations are done, start the HAP core */
    hap_start();
    /* Start Wi-Fi */
    app_wifi_start(portMAX_DELAY);

    mqtt_app_init();

Thanks

shahpiyushv commented 3 years ago

@twlawrenceko , can you also share the error log?

twlawrenceko commented 2 years ago

Solved by a further investigation

emberist commented 2 years ago

@twlawrenceko can you tell us how you fix this?

twlawrenceko commented 2 years ago

@twlawrenceko can you tell us how you fix this?

Are you getting the same error? It turns out the code that I was previously using wasn’t well defined, which results in MQTT illegal instruction error