LwESP
- Access point
- Ring buffer
- Connections
- Debug support
- Dynamic Host Configuration Protocol
- Domain Name System
- Event management
- Hostname
- Input module
- Multicast DNS
- Memory manager
- Packet buffer
- Ping support
- Server
- Smart config
- Simple Network Time Protocol
- Station API
- Timeout manager
- Structures and enumerations
- Unicode
- Utilities
- Web Server
- Wi-Fi Protected Setup
- group LWESP
Lightweight ESP-AT parser.
Defines
-
lwesp_set_fw_version(v, major_, minor_, patch_)
Set and format major, minor and patch values to firmware version.
- Parameters
v – [in] Version output, pointer to lwesp_sw_version_t structure
major_ – [in] Major version
minor_ – [in] Minor version
patch_ – [in] Patch version
Functions
-
lwespr_t lwesp_init(lwesp_evt_fn cb_func, const uint32_t blocking)
Init and prepare ESP stack for device operation.
Note
Function must be called from operating system thread context. It creates necessary threads and waits them to start, thus running operating system is important.
When LWESP_CFG_RESET_ON_INIT is enabled, reset sequence will be sent to device otherwise manual call to lwesp_reset is required to setup device
When LWESP_CFG_RESTORE_ON_INIT is enabled, restore sequence will be sent to device.
- Parameters
evt_func – [in] Global event callback function for all major events
blocking – [in] Status whether command should be blocking or not. Used when LWESP_CFG_RESET_ON_INIT or LWESP_CFG_RESTORE_ON_INIT are enabled.
- Returns
lwespOK on success, member of lwespr_t enumeration otherwise
-
lwespr_t lwesp_reset(const lwesp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)
Execute reset and send default commands.
-
lwespr_t lwesp_reset_with_delay(uint32_t delay, const lwesp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)
Execute reset and send default commands with delay before first command.
- Parameters
delay – [in] Number of milliseconds to wait before initiating first command to device
evt_fn – [in] Callback function called when command has finished. Set to
NULL
when not usedevt_arg – [in] Custom argument for event callback function
blocking – [in] Status whether command should be blocking or not
- Returns
lwespOK on success, member of lwespr_t enumeration otherwise
-
lwespr_t lwesp_restore(const lwesp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)
Execute restore command and set module to default values.
-
lwespr_t lwesp_set_at_baudrate(uint32_t baud, const lwesp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)
Sets baudrate of AT port (usually UART)
- Parameters
baud – [in] Baudrate in units of bits per second
evt_fn – [in] Callback function called when command has finished. Set to
NULL
when not usedevt_arg – [in] Custom argument for event callback function
blocking – [in] Status whether command should be blocking or not
- Returns
lwespOK on success, member of lwespr_t enumeration otherwise
-
lwespr_t lwesp_set_wifi_mode(lwesp_mode_t mode, const lwesp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)
Sets WiFi mode to either station only, access point only or both.
Configuration changes will be saved in the NVS area of ESP device.
- Parameters
mode – [in] Mode of operation. This parameter can be a value of lwesp_mode_t enumeration
evt_fn – [in] Callback function called when command has finished. Set to
NULL
when not usedevt_arg – [in] Custom argument for event callback function
blocking – [in] Status whether command should be blocking or not
- Returns
lwespOK on success, member of lwespr_t enumeration otherwise
-
lwespr_t lwesp_get_wifi_mode(lwesp_mode_t *mode, const lwesp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)
Gets WiFi mode of either station only, access point only or both.
- Parameters
mode – [in] point to space of Mode to get. This parameter can be a pointer of lwesp_mode_t enumeration
evt_fn – [in] Callback function called when command has finished. Set to
NULL
when not usedevt_arg – [in] Custom argument for event callback function
blocking – [in] Status whether command should be blocking or not
- Returns
lwespOK on success, member of lwespr_t enumeration otherwise
-
lwespr_t lwesp_update_sw(const lwesp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)
Update ESP software remotely.
Note
ESP must be connected to access point to use this feature
-
lwespr_t lwesp_core_lock(void)
Lock stack from multi-thread access, enable atomic access to core.
If lock was
0
prior function call, lock is enabled and increasedNote
Function may be called multiple times to increase locks. Application must take care to call lwesp_core_unlock the same amount of time to make sure lock gets back to
0
-
lwespr_t lwesp_core_unlock(void)
Unlock stack for multi-thread access.
Used in conjunction with lwesp_core_lock function
If lock was non-zero before function call, lock is decreased. When
lock == 0
, protection is disabled and other threads may access to core
-
lwespr_t lwesp_device_set_present(uint8_t present, const lwesp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)
Notify stack if device is present or not.
Use this function to notify stack that device is not physically connected and not ready to communicate with host device
- Parameters
present – [in] Flag indicating device is present
evt_fn – [in] Callback function called when command has finished. Set to
NULL
when not usedevt_arg – [in] Custom argument for event callback function
blocking – [in] Status whether command should be blocking or not
- Returns
lwespOK on success, member of lwespr_t enumeration otherwise
-
uint8_t lwesp_device_is_present(void)
Check if device is present.
- Returns
1
on success,0
otherwise
-
uint8_t lwesp_delay(const uint32_t ms)
Delay for amount of milliseconds.
Delay is based on operating system semaphores. It locks semaphore and waits for timeout in
ms
time. Based on operating system, thread may be put to blocked list during delay and may improve execution speed- Parameters
ms – [in] Milliseconds to delay
- Returns
1
on success,0
otherwise
-
lwespr_t lwesp_get_current_at_fw_version(lwesp_sw_version_t *const version)
Get current AT firmware version of connected Espressif device. It copies version from internal buffer to user variable, and is valid only if reset/restore operation is successful.
- Parameters
version – [out] Output version variable
- Returns
1
on success,0
otherwise
-
lwespr_t lwesp_get_min_at_fw_version(lwesp_sw_version_t *const version)
Get minimal AT version required to run on Espressif device, to be well supported by LwESP library and to ensure proper compatibility and correct operation.
- Parameters
version – [out] Version output, pointer to lwesp_sw_version_t structure
- Returns
-
uint8_t lwesp_device_is_esp8266(void)
Check if modem device is ESP8266.
Note
Function is only available if LWESP_CFG_ESP8266 is enabled, otherwise it is defined as macro and evaluated to
0
- Returns
1
on success,0
otherwise
-
uint8_t lwesp_device_is_esp32(void)
Check if modem device is ESP32.
Note
Function is only available if LWESP_CFG_ESP32 is enabled, otherwise it is defined as macro and evaluated to
0
- Returns
1
on success,0
otherwise
-
uint8_t lwesp_device_is_esp32_c3(void)
Check if modem device is ESP32-C3.
Note
Function is only available if LWESP_CFG_ESP32_C3 is enabled, otherwise it is defined as macro and evaluated to
0
- Returns
1
on success,0
otherwise
-
lwesp_device_t lwesp_device_get_device(void)
Get currently connected Espressif device to AT port.
- Returns
Member of lwesp_device_t enumeration
-
lwesp_set_fw_version(v, major_, minor_, patch_)