mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-30 10:48:06 +02:00
Reduce the includes used in all files.
- To reduce the dependencies to the minimal the number of includes was reduced.
This commit is contained in:
committed by
Euripedes Rocha
parent
fd2d04e687
commit
87fcce72c9
@ -11,7 +11,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#include "esp_event.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -6,6 +6,7 @@
|
||||
#ifndef _MQTT_OUTOBX_H_
|
||||
#define _MQTT_OUTOBX_H_
|
||||
#include "platform.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -7,21 +7,9 @@
|
||||
#define _ESP_PLATFORM_H__
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/event_groups.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/dns.h"
|
||||
|
||||
#include "sys/queue.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include <sys/time.h>
|
||||
|
||||
char *platform_create_id_string(void);
|
||||
int platform_random(int max);
|
||||
|
@ -5,8 +5,6 @@
|
||||
#include "esp_log.h"
|
||||
|
||||
#ifndef CONFIG_MQTT_CUSTOM_OUTBOX
|
||||
|
||||
|
||||
static const char *TAG = "OUTBOX";
|
||||
|
||||
typedef struct outbox_item {
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static const char *TAG = "PLATFORM";
|
||||
|
||||
|
@ -1,13 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include "platform.h"
|
||||
|
||||
#include "esp_event.h"
|
||||
#include "mqtt_client.h"
|
||||
#include "mqtt_msg.h"
|
||||
#include "esp_transport.h"
|
||||
#include "esp_transport_tcp.h"
|
||||
#include "esp_transport_ssl.h"
|
||||
#include "esp_transport_ws.h"
|
||||
#include "esp_log.h"
|
||||
#include "mqtt_outbox.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mqtt_supported_features.h"
|
||||
|
||||
/* using uri parser */
|
||||
@ -112,9 +118,9 @@ struct esp_mqtt_client {
|
||||
TaskHandle_t task_handle;
|
||||
};
|
||||
|
||||
const static int STOPPED_BIT = BIT0;
|
||||
const static int RECONNECT_BIT = BIT1;
|
||||
const static int DISCONNECT_BIT = BIT2;
|
||||
const static int STOPPED_BIT = (1 << 0);
|
||||
const static int RECONNECT_BIT = (1 << 1);
|
||||
const static int DISCONNECT_BIT = (1 << 2);
|
||||
|
||||
static esp_err_t esp_mqtt_dispatch_event(esp_mqtt_client_handle_t client);
|
||||
static esp_err_t esp_mqtt_dispatch_event_with_msgid(esp_mqtt_client_handle_t client);
|
||||
@ -903,7 +909,7 @@ static esp_err_t deliver_publish(esp_mqtt_client_handle_t client)
|
||||
ESP_LOGE(TAG, "%s: mqtt_get_publish_topic() failed", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
ESP_LOGD(TAG, "%s: msg_topic_len=%u", __func__, msg_topic_len);
|
||||
ESP_LOGD(TAG, "%s: msg_topic_len=%zu", __func__, msg_topic_len);
|
||||
|
||||
// get payload
|
||||
msg_data = mqtt_get_publish_data(msg_buf, &msg_data_len);
|
||||
@ -917,7 +923,7 @@ static esp_err_t deliver_publish(esp_mqtt_client_handle_t client)
|
||||
client->event.total_data_len = msg_data_len + msg_total_len - msg_read_len;
|
||||
|
||||
post_data_event:
|
||||
ESP_LOGD(TAG, "Get data len= %d, topic len=%d, total_data: %d offset: %d", msg_data_len, msg_topic_len,
|
||||
ESP_LOGD(TAG, "Get data len= %zu, topic len=%zu, total_data: %d offset: %zu", msg_data_len, msg_topic_len,
|
||||
client->event.total_data_len, msg_data_offset);
|
||||
client->event.event_id = MQTT_EVENT_DATA;
|
||||
client->event.data = msg_data_len > 0 ? msg_data : NULL;
|
||||
@ -938,7 +944,7 @@ post_data_event:
|
||||
msg_total_len - msg_read_len > buf_len ? buf_len : msg_total_len - msg_read_len,
|
||||
client->config->network_timeout_ms);
|
||||
if (msg_data_len <= 0) {
|
||||
ESP_LOGE(TAG, "Read error or timeout: len_read=%d, errno=%d", msg_data_len, errno);
|
||||
ESP_LOGE(TAG, "Read error or timeout: len_read=%zu, errno=%d", msg_data_len, errno);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
msg_read_len += msg_data_len;
|
||||
@ -1065,7 +1071,7 @@ static int mqtt_message_receive(esp_mqtt_client_handle_t client, int read_poll_t
|
||||
} while ((client->mqtt_state.in_buffer_read_len < 6) && (*(buf - 1) & 0x80));
|
||||
}
|
||||
total_len = mqtt_get_total_length(client->mqtt_state.in_buffer, client->mqtt_state.in_buffer_read_len, &fixed_header_len);
|
||||
ESP_LOGD(TAG, "%s: total message length: %d (already read: %u)", __func__, total_len, client->mqtt_state.in_buffer_read_len);
|
||||
ESP_LOGD(TAG, "%s: total message length: %d (already read: %zu)", __func__, total_len, client->mqtt_state.in_buffer_read_len);
|
||||
client->mqtt_state.message_length = total_len;
|
||||
if (client->mqtt_state.in_buffer_length < total_len) {
|
||||
if (mqtt_get_type(client->mqtt_state.in_buffer) == MQTT_MSG_TYPE_PUBLISH) {
|
||||
@ -1087,7 +1093,7 @@ static int mqtt_message_receive(esp_mqtt_client_handle_t client, int read_poll_t
|
||||
client->mqtt_state.in_buffer_read_len += read_len;
|
||||
buf += read_len;
|
||||
if (client->mqtt_state.in_buffer_read_len < fixed_header_len + 2) {
|
||||
ESP_LOGD(TAG, "%s: transport_read(): message reading left in progress :: total message length: %d (already read: %u)",
|
||||
ESP_LOGD(TAG, "%s: transport_read(): message reading left in progress :: total message length: %d (already read: %zu)",
|
||||
__func__, total_len, client->mqtt_state.in_buffer_read_len);
|
||||
return 0;
|
||||
}
|
||||
@ -1122,12 +1128,12 @@ static int mqtt_message_receive(esp_mqtt_client_handle_t client, int read_poll_t
|
||||
}
|
||||
client->mqtt_state.in_buffer_read_len += read_len;
|
||||
if (client->mqtt_state.in_buffer_read_len < total_len) {
|
||||
ESP_LOGD(TAG, "%s: transport_read(): message reading left in progress :: total message length: %d (already read: %u)",
|
||||
ESP_LOGD(TAG, "%s: transport_read(): message reading left in progress :: total message length: %d (already read: %zu)",
|
||||
__func__, total_len, client->mqtt_state.in_buffer_read_len);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ESP_LOGD(TAG, "%s: transport_read():%d %d", __func__, client->mqtt_state.in_buffer_read_len, client->mqtt_state.message_length);
|
||||
ESP_LOGD(TAG, "%s: transport_read():%zu %zu", __func__, client->mqtt_state.in_buffer_read_len, client->mqtt_state.message_length);
|
||||
return 1;
|
||||
err:
|
||||
esp_mqtt_client_dispatch_transport_error(client);
|
||||
@ -1174,7 +1180,7 @@ static esp_err_t mqtt_process_receive(esp_mqtt_client_handle_t client)
|
||||
}
|
||||
break;
|
||||
case MQTT_MSG_TYPE_PUBLISH:
|
||||
ESP_LOGD(TAG, "deliver_publish, message_length_read=%d, message_length=%d", client->mqtt_state.in_buffer_read_len, client->mqtt_state.message_length);
|
||||
ESP_LOGD(TAG, "deliver_publish, message_length_read=%zu, message_length=%zu", client->mqtt_state.in_buffer_read_len, client->mqtt_state.message_length);
|
||||
if (deliver_publish(client) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to deliver publish message id=%d", msg_id);
|
||||
return ESP_FAIL;
|
||||
|
Reference in New Issue
Block a user