Skip to content

Commit

Permalink
Removes leftover calls to event_handler
Browse files Browse the repository at this point in the history
The possibility to add a callback as custom handler was removed from
the client in favor of esp_event. These removes the older alternative
that wasn't possible to use.
  • Loading branch information
euripedesrocha committed Jun 9, 2023
1 parent a89af4b commit a492935
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 14 deletions.
1 change: 0 additions & 1 deletion include/mqtt_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ typedef struct esp_mqtt_event_t {

typedef esp_mqtt_event_t *esp_mqtt_event_handle_t;

typedef esp_err_t (*mqtt_event_callback_t)(esp_mqtt_event_handle_t event);

/**
* *MQTT* client configuration structure
Expand Down
1 change: 0 additions & 1 deletion lib/include/mqtt_client_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ typedef struct mqtt_state {
} mqtt_state_t;

typedef struct {
mqtt_event_callback_t event_handle;
esp_event_loop_handle_t event_loop_handle;
int task_stack;
int task_prio;
Expand Down
12 changes: 0 additions & 12 deletions mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,16 +980,12 @@ static esp_err_t esp_mqtt_dispatch_event(esp_mqtt_client_handle_t client)
client->event.protocol_ver = client->connect_info.protocol_ver;
esp_err_t ret = ESP_FAIL;

if (client->config->event_handle) {
ret = client->config->event_handle(&client->event);
} else {
#ifdef MQTT_SUPPORTED_FEATURE_EVENT_LOOP
esp_event_post_to(client->config->event_loop_handle, MQTT_EVENTS, client->event.event_id, &client->event, sizeof(client->event), portMAX_DELAY);
ret = esp_event_loop_run(client->config->event_loop_handle, 0);
#else
return ESP_FAIL;
#endif
}
if (client->connect_info.protocol_ver == MQTT_PROTOCOL_V_5) {
#ifdef MQTT_PROTOCOL_5
esp_mqtt5_client_delete_user_property(client->event.property->user_property);
Expand Down Expand Up @@ -2132,10 +2128,6 @@ esp_err_t esp_mqtt_client_register_event(esp_mqtt_client_handle_t client, esp_mq
return ESP_ERR_INVALID_ARG;
}
#ifdef MQTT_SUPPORTED_FEATURE_EVENT_LOOP
if (client->config->event_handle) {
ESP_LOGW(TAG, "Registering event loop while event callback is not null, clearing callback");
client->config->event_handle = NULL;
}

return esp_event_handler_register_with(client->config->event_loop_handle, MQTT_EVENTS, event, event_handler, event_handler_arg);
#else
Expand All @@ -2150,10 +2142,6 @@ esp_err_t esp_mqtt_client_unregister_event(esp_mqtt_client_handle_t client, esp_
return ESP_ERR_INVALID_ARG;
}
#ifdef MQTT_SUPPORTED_FEATURE_EVENT_LOOP
if (client->config->event_handle) {
ESP_LOGW(TAG, "Unregistering event loop while event callback is not null, clearing callback");
client->config->event_handle = NULL;
}

return esp_event_handler_unregister_with(client->config->event_loop_handle, MQTT_EVENTS, event, event_handler);
#else
Expand Down

0 comments on commit a492935

Please sign in to comment.