mqtt的长度限制:
mqtt_opt.h(配置文件)
/**
* Output ring-buffer size, must be able to fit largest outgoing publish message topic+payloads
*/
#ifndef MQTT_OUTPUT_RINGBUF_SIZE
#define MQTT_OUTPUT_RINGBUF_SIZE 256*4
#endif
/**
* Number of bytes in receive buffer, must be at least the size of the longest incoming topic + 8
* If one wants to avoid fragmented incoming publish, set length to max incoming topic length + max payload length + 8
*/
#ifndef MQTT_VAR_HEADER_BUFFER_LEN
#define MQTT_VAR_HEADER_BUFFER_LEN 128*4
#endif
lwip长度限制修改:
opt.h文件
/**
* MEM_SIZE: the size of the heap memory. If the application will send
* a lot of data that needs to be copied, this should be set high.
*/
#if !defined MEM_SIZE || defined __DOXYGEN__
#define MEM_SIZE 1024*10
#endif
基于freertos优化lwip的pools
不单独开辟数组内存,直接通过frertos的内存申请释放,统一管理内存。
opt.h
/**
* MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library
* instead of the lwip internal allocator. Can save code size if you
* already use it.
*/
#if !defined MEM_LIBC_MALLOC || defined __DOXYGEN__
#define MEM_LIBC_MALLOC 1
#endif
mem.c
/* in case C library malloc() needs extra protection,
* allow these defines to be overridden.
*/
//#ifndef mem_clib_free
//#define mem_clib_free free
//#endif
//#ifndef mem_clib_malloc
//#define mem_clib_malloc malloc
//#endif
//#ifndef mem_clib_calloc
//#define mem_clib_calloc calloc
//#endif
#ifndef mem_clib_free
#define mem_clib_free vPortFree //(void * pv)
#endif
#ifndef mem_clib_malloc
#define mem_clib_malloc pvPortMalloc //(size_t xWantedSize)
#endif
void* vPortcalloc(unsigned int num , unsigned int size)
{
void *p;
p = pvPortMalloc(num*size);
if(p != NULL){
memset(p,0,num*size);
}
return p;
}
#ifndef mem_clib_calloc
#define mem_clib_calloc vPortcalloc
#endif