mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-30 02:38:19 +02:00
Merge branch 'feature/outbox_memory_selection' into 'master'
Adds a configuration for outbox data destination See merge request espressif/esp-mqtt!166
This commit is contained in:
7
Kconfig
7
Kconfig
@ -152,6 +152,13 @@ menu "ESP-MQTT Configurations"
|
|||||||
bool "Core 1"
|
bool "Core 1"
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
|
config MQTT_OUTBOX_DATA_ON_EXTERNAL_MEMORY
|
||||||
|
bool "Use external memory for outbox data"
|
||||||
|
default n
|
||||||
|
depends on MQTT_USE_CUSTOM_CONFIG
|
||||||
|
help
|
||||||
|
Set to true to use external memory for outbox data.
|
||||||
|
|
||||||
config MQTT_CUSTOM_OUTBOX
|
config MQTT_CUSTOM_OUTBOX
|
||||||
bool "Enable custom outbox implementation"
|
bool "Enable custom outbox implementation"
|
||||||
default n
|
default n
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
#define MQTT_RECON_DEFAULT_MS (10*1000)
|
#define MQTT_RECON_DEFAULT_MS (10*1000)
|
||||||
|
|
||||||
#ifdef CONFIG_MQTT_POLL_READ_TIMEOUT_MS
|
#ifdef CONFIG_MQTT_POLL_READ_TIMEOUT_MS
|
||||||
#define MQTT_POLL_READ_TIMEOUT_MS CONFIG_MQTT_POLL_READ_TIMEOUT_MS
|
#define MQTT_POLL_READ_TIMEOUT_MS CONFIG_MQTT_POLL_READ_TIMEOUT_MS
|
||||||
#else
|
#else
|
||||||
#define MQTT_POLL_READ_TIMEOUT_MS (1000)
|
#define MQTT_POLL_READ_TIMEOUT_MS (1000)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MQTT_MSG_ID_INCREMENTAL CONFIG_MQTT_MSG_ID_INCREMENTAL
|
#define MQTT_MSG_ID_INCREMENTAL CONFIG_MQTT_MSG_ID_INCREMENTAL
|
||||||
|
|
||||||
@ -107,5 +107,11 @@
|
|||||||
#define MQTT_EVENT_QUEUE_SIZE 1
|
#define MQTT_EVENT_QUEUE_SIZE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_MQTT_OUTBOX_DATA_ON_EXTERNAL_MEMORY
|
||||||
|
#define MQTT_OUTBOX_MEMORY MALLOC_CAP_SPIRAM
|
||||||
|
#else
|
||||||
|
#define MQTT_OUTBOX_MEMORY MALLOC_CAP_DEFAULT
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OUTBOX_MAX_SIZE (4*1024)
|
#define OUTBOX_MAX_SIZE (4*1024)
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include "mqtt_outbox.h"
|
#include "mqtt_outbox.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "mqtt_config.h"
|
||||||
#include "sys/queue.h"
|
#include "sys/queue.h"
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
#ifndef CONFIG_MQTT_CUSTOM_OUTBOX
|
#ifndef CONFIG_MQTT_CUSTOM_OUTBOX
|
||||||
@ -31,7 +33,7 @@ outbox_handle_t outbox_init(void)
|
|||||||
|
|
||||||
outbox_item_handle_t outbox_enqueue(outbox_handle_t outbox, outbox_message_handle_t message, outbox_tick_t tick)
|
outbox_item_handle_t outbox_enqueue(outbox_handle_t outbox, outbox_message_handle_t message, outbox_tick_t tick)
|
||||||
{
|
{
|
||||||
outbox_item_handle_t item = calloc(1, sizeof(outbox_item_t));
|
outbox_item_handle_t item = heap_caps_calloc(1, sizeof(outbox_item_t), MQTT_OUTBOX_MEMORY);
|
||||||
ESP_MEM_CHECK(TAG, item, return NULL);
|
ESP_MEM_CHECK(TAG, item, return NULL);
|
||||||
item->msg_id = message->msg_id;
|
item->msg_id = message->msg_id;
|
||||||
item->msg_type = message->msg_type;
|
item->msg_type = message->msg_type;
|
||||||
|
Reference in New Issue
Block a user