Configuration¶
This is the default configuration of the middleware.
When any of the settings shall be modified, it shall be done in dedicated application config lwesp_opts.h
file.
Note
Check Getting started for guidelines on how to create and use configuration file.
-
group
LWESP_OPT
ESP-AT options.
Defines
-
LWESP_CFG_ESP8266
¶ Enables
1
or disables0
support for ESP8266 AT commands.
-
LWESP_CFG_ESP32
¶ Enables
1
or disables0
support for ESP32 AT commands.
-
LWESP_CFG_OS
¶ Enables
1
or disables0
operating system support for ESP library.- Note
Value must be set to
1
in the current revision- Note
Check OS configuration group for more configuration related to operating system
-
LWESP_CFG_MEM_CUSTOM
¶ Enables
1
or disables0
custom memory management functions.When set to
1
, Memory manager block must be provided manually. This includes implementation of functions lwesp_mem_malloc, lwesp_mem_calloc, lwesp_mem_realloc and lwesp_mem_free- Note
Function declaration follows standard C functions
malloc, calloc, realloc, free
. Declaration is available inlwesp/lwesp_mem.h
file. Include this file to final implementation file- Note
When implementing custom memory allocation, it is necessary to take care of multiple threads accessing same resource for custom allocator
-
LWESP_CFG_MEM_ALIGNMENT
¶ Memory alignment for dynamic memory allocations.
- Note
Some CPUs can work faster if memory is aligned, usually to
4
or8
bytes. To speed up this possibilities, you can set memory alignment and library will try to allocate memory on aligned boundaries.- Note
Some CPUs such ARM Cortex-M0 dont’t support unaligned memory access.
- Note
This value must be power of
2
-
LWESP_CFG_USE_API_FUNC_EVT
¶ Enables
1
or disables0
callback function and custom parameter for API functions.When enabled,
2
additional parameters are available in API functions. When command is executed, callback function with its parameter could be called when not set toNULL
.
-
LWESP_CFG_MAX_CONNS
¶ Maximal number of connections AT software can support on ESP device.
- Note
In case of official AT software, leave this on default value (
5
)
-
LWESP_CFG_CONN_MAX_DATA_LEN
¶ Maximal number of bytes we can send at single command to ESP.
When manual TCP read mode is enabled, this parameter defines number of bytes to be read at a time
- Note
Value can not exceed
2048
bytes or no data will be send at all (ESP8266 AT SW limitation)
- Note
This is limitation of ESP AT commands and on systems where RAM is not an issue, it should be set to maximal value (
2048
) to optimize data transfer speed performance
-
LWESP_CFG_MAX_SEND_RETRIES
¶ Set number of retries for send data command.
Sometimes it may happen that
AT+SEND
command fails due to different problems. Trying to send the same data multiple times can raise chances for success.
-
LWESP_CFG_CONN_MAX_RECV_BUFF_SIZE
¶ Maximum single buffer size for network receive data on active connection.
- Note
When ESP sends buffer bigger than maximal, multiple buffers are created
-
LWESP_CFG_AT_PORT_BAUDRATE
¶ Default baudrate used for AT port.
- Note
User may call API function to change to desired baudrate if necessary
-
LWESP_CFG_MODE_STATION
¶ Enables
1
or disables0
ESP acting as station.- Note
When device is in station mode, it can connect to other access points
-
LWESP_CFG_MODE_ACCESS_POINT
¶ Enables
1
or disables0
ESP acting as access point.- Note
When device is in access point mode, it can accept connections from other stations
-
LWESP_CFG_RCV_BUFF_SIZE
¶ Buffer size for received data waiting to be processed.
- Note
When server mode is active and a lot of connections are in queue this should be set high otherwise your buffer may overflow
- Note
Buffer size also depends on TX user driver if it uses DMA or blocking mode. In case of DMA (CPU can work other tasks), buffer may be smaller as CPU will have more time to process all the incoming bytes
- Note
This parameter has no meaning when LWESP_CFG_INPUT_USE_PROCESS is enabled
-
LWESP_CFG_RESET_ON_INIT
¶ Enables
1
or disables0
reset sequence after lwesp_init call.- Note
When this functionality is disabled, user must manually call lwesp_reset to send reset sequence to ESP device.
-
LWESP_CFG_RESTORE_ON_INIT
¶ Enables
1
or disables0
device restore after lwesp_init call.- Note
When this feature is enabled, it will automatically restore and clear any settings stored as default in ESP device
-
LWESP_CFG_RESET_ON_DEVICE_PRESENT
¶ Enables
1
or disables0
reset sequence after lwesp_device_set_present call.- Note
When this functionality is disabled, user must manually call lwesp_reset to send reset sequence to ESP device.
-
LWESP_CFG_RESET_DELAY_DEFAULT
¶ Default delay (milliseconds unit) before sending first AT command on reset sequence.
-
LWESP_CFG_MAX_SSID_LENGTH
¶ Maximum length of SSID for access point scan.
- Note
This parameter must include trailling zero
-
LWESP_CFG_MAX_PWD_LENGTH
¶ Maximum length of PWD for access point.
- Note
This parameter must include trailling zero
-
LWESP_CFG_CONN_POLL_INTERVAL
¶ Poll interval for connections in units of milliseconds.
Value indicates interval time to call poll event on active connections.
- Note
Single poll interval applies for all connections
-
LWESP_CFG_CONN_MANUAL_TCP_RECEIVE
¶ Enables
1
or disables0
manualTCP
data receive from ESP device.Normally ESP automatically sends received TCP data to host device in async mode. When host device is slow or if there is memory constrain, it may happen that processing cannot handle all received data.
When feature is enabled, ESP will notify host device about new data available for read and then user may start read process
- Note
This feature is only available for
TCP
connections.
-
LWESP_MIN_AT_VERSION_MAJOR_ESP8266
¶ Minimal major version for ESP8266
-
LWESP_MIN_AT_VERSION_MINOR_ESP8266
¶ Minimal minor version for ESP8266
-
LWESP_MIN_AT_VERSION_PATCH_ESP8266
¶ Minimal patch version for ESP8266
-
LWESP_MIN_AT_VERSION_MAJOR_ESP32
¶ Minimal major version for ESP32
-
LWESP_MIN_AT_VERSION_MINOR_ESP32
¶ Minimal minor version for ESP32
-
LWESP_MIN_AT_VERSION_PATCH_ESP32
¶ Minimal patch version for ESP32
-
-
group
LWESP_OPT_DBG
Debugging configurations.
Defines
-
LWESP_CFG_DBG
¶ Set global debug support.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
- Note
Set to LWESP_DBG_OFF to globally disable all debugs
-
LWESP_CFG_DBG_OUT
(fmt, ...)¶ Debugging output function.
Called with format and optional parameters for printf-like debug
-
LWESP_CFG_DBG_LVL_MIN
¶ Minimal debug level.
Check LWESP_DBG_LVL for possible values
-
LWESP_CFG_DBG_TYPES_ON
¶ Enabled debug types.
When debug is globally enabled with LWESP_CFG_DBG parameter, user must enable debug types such as TRACE or STATE messages.
Check LWESP_DBG_TYPE for possible options. Separate values with
bitwise OR
operator
-
LWESP_CFG_DBG_INIT
¶ Set debug level for init function.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_DBG_MEM
¶ Set debug level for memory manager.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_DBG_INPUT
¶ Set debug level for input module.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_DBG_THREAD
¶ Set debug level for ESP threads.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_DBG_ASSERT
¶ Set debug level for asserting of input variables.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_DBG_IPD
¶ Set debug level for incoming data received from device.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_DBG_NETCONN
¶ Set debug level for netconn sequential API.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_DBG_PBUF
¶ Set debug level for packet buffer manager.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_DBG_CONN
¶ Set debug level for connections.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_DBG_VAR
¶ Set debug level for dynamic variable allocations.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_AT_ECHO
¶ Enables
1
or disables0
echo mode on AT commands sent to ESP device.- Note
This mode is useful when debugging ESP communication
-
-
group
LWESP_OPT_OS
Operating system dependant configuration.
Defines
-
LWESP_CFG_THREAD_PRODUCER_MBOX_SIZE
¶ Set number of message queue entries for procuder thread.
Message queue is used for storing memory address to command data
-
LWESP_CFG_THREAD_PROCESS_MBOX_SIZE
¶ Set number of message queue entries for processing thread.
Message queue is used to notify processing thread about new received data on AT port
-
LWESP_CFG_INPUT_USE_PROCESS
¶ Enables
1
or disables0
direct support for processing input data.When this mode is enabled, no overhead is included for copying data to receive buffer because bytes are processed directly by lwesp_input_process function
If this mode is not enabled, then user have to send every received byte via lwesp_input function to the internal buffer for future processing. This may introduce additional overhead with data copy and may decrease library performance
- Note
This mode can only be used when LWESP_CFG_OS is enabled
- Note
When using this mode, separate thread must be dedicated only for reading data on AT port. It is usually implemented in LL driver
- Note
Best case for using this mode is if DMA receive is supported by host device
-
LWESP_THREAD_PRODUCER_HOOK
()¶ Producer thread hook, called each time thread wakes-up and does the processing.
It can be used to check if thread is alive.
-
LWESP_THREAD_PROCESS_HOOK
()¶ Process thread hook, called each time thread wakes-up and does the processing.
It can be used to check if thread is alive.
-
-
group
LWESP_OPT_STD_LIB
Standard C library configuration.
Configuration allows you to overwrite default C language function in case of better implementation with hardware (for example DMA for data copy).
Defines
-
LWESP_MEMCPY
(dst, src, len)¶ Memory copy function declaration.
User is able to change the memory function, in case hardware supports copy operation, it may implement its own
Function prototype must be similar to:
void * my_memcpy(void* dst, const void* src, size_t len);
- Return
Destination memory start address
- Parameters
[in] dst
: Destination memory start address[in] src
: Source memory start address[in] len
: Number of bytes to copy
-
LWESP_MEMSET
(dst, b, len)¶ Memory set function declaration.
Function prototype must be similar to:
void * my_memset(void* dst, int b, size_t len);
- Return
Destination memory start address
- Parameters
[in] dst
: Destination memory start address[in] b
: Value (byte) to set in memory[in] len
: Number of bytes to set
-
-
group
LWESP_OPT_MODULES
Configuration of specific modules.
Defines
-
LWESP_CFG_DNS
¶ Enables
1
or disables0
support for DNS functions.
-
LWESP_CFG_WPS
¶ Enables
1
or disables0
support for WPS functions.
-
LWESP_CFG_SNTP
¶ Enables
1
or disables0
support for SNTP protocol with AT commands.
-
LWESP_CFG_HOSTNAME
¶ Enables
1
or disables0
support for hostname with AT commands.
-
LWESP_CFG_PING
¶ Enables
1
or disables0
support for ping functions.
-
LWESP_CFG_MDNS
¶ Enables
1
or disables0
support for mDNS.
-
LWESP_CFG_SMART
¶ Enables
1
or disables0
support for SMART config.
-
-
group
LWESP_OPT_MODULES_NETCONN
Configuration of netconn API module.
Defines
-
LWESP_CFG_NETCONN
¶ Enables
1
or disables0
NETCONN sequential API support for OS systems.- Note
To use this feature, OS support is mandatory.
- See
-
LWESP_CFG_NETCONN_RECEIVE_TIMEOUT
¶ Enables
1
or disables0
receive timeout feature.When this option is enabled, user will get an option to set timeout value for receive data on netconn, before function returns timeout error.
- Note
Even if this option is enabled, user must still manually set timeout, by default time will be set to 0 which means no timeout.
-
LWESP_CFG_NETCONN_ACCEPT_QUEUE_LEN
¶ Accept queue length for new client when netconn server is used.
Defines number of maximal clients waiting in accept queue of server connection
-
LWESP_CFG_NETCONN_RECEIVE_QUEUE_LEN
¶ Receive queue length for pbuf entries.
Defines maximal number of pbuf data packet references for receive
-
-
group
LWESP_OPT_MODULES_MQTT
Configuration of MQTT and MQTT API client modules.
Defines
-
LWESP_CFG_MQTT_MAX_REQUESTS
¶ Maximal number of open MQTT requests at a time.
-
LWESP_CFG_DBG_MQTT
¶ Set debug level for MQTT client module.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
LWESP_CFG_DBG_MQTT_API
¶ Set debug level for MQTT API client module.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
-
group
LWESP_OPT_MODULES_CAYENNE
Configuration of Cayenne MQTT client.
Defines
-
LWESP_CFG_DBG_CAYENNE
¶ Set debug level for Cayenne MQTT client module.
Possible values are LWESP_DBG_ON or LWESP_DBG_OFF
-
-
group
LWESP_OPT_APP_HTTP
Configuration of HTTP server app.
Defines
-
LWESP_CFG_DBG_SERVER
¶ Server debug default setting.
-
HTTP_SSI_TAG_START
¶ SSI tag start string
-
HTTP_SSI_TAG_START_LEN
¶ SSI tag start length
-
HTTP_SSI_TAG_END
¶ SSI tag end string
-
HTTP_SSI_TAG_END_LEN
¶ SSI tag end length
-
HTTP_SSI_TAG_MAX_LEN
¶ Maximal length of tag name excluding start and end parts of tag.
-
HTTP_SUPPORT_POST
¶ Enables
1
or disables0
support for POST request.
-
HTTP_MAX_URI_LEN
¶ Maximal length of allowed uri length including parameters in format
/uri/sub/path?param=value
-
HTTP_MAX_PARAMS
¶ Maximal number of parameters in URI.
-
HTTP_USE_METHOD_NOTALLOWED_RESP
¶ Enables
1
or disables0
method not allowed response.Response is used in case user makes HTTP request with method which is not on the list of allowed methods. See http_req_method_t
- Note
When disabled, connection will be closed without response
-
HTTP_USE_DEFAULT_STATIC_FILES
¶ Enables
1
or disables1
default static files.To allow fast startup of server development, several static files are included by default:
/index.html
/index.shtml
/js/style.css
/js/js.js
-
HTTP_DYNAMIC_HEADERS
¶ Enables
1
or disables0
dynamic headers support.With dynamic headers enabled, script will try to detect most common file extensions and will try to response with:
HTTP response code as first line
Server name as second line
Content type as third line including end of headers (empty line)
-
HTTP_DYNAMIC_HEADERS_CONTENT_LEN
¶ Enables
1
or disables0
content length header for response.If response has fixed length without SSI tags, dynamic headers will try to include “Content-Length” header as part of response message sent to client
- Note
In order to use this, HTTP_DYNAMIC_HEADERS must be enabled
-
HTTP_SERVER_NAME
¶ Default server name for
Server: x
response dynamic header.
-