mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
esp-idf-update
This commit is contained in:
parent
d026f6d1b6
commit
4393edf1a5
16 changed files with 1282 additions and 393 deletions
|
@ -85,6 +85,7 @@ if (ESP_PLATFORM)
|
||||||
include_directories(
|
include_directories(
|
||||||
$ENV{IDF_PATH}/components/esp_hw_support/include/soc/
|
$ENV{IDF_PATH}/components/esp_hw_support/include/soc/
|
||||||
$ENV{IDF_PATH}/components/freertos/include/
|
$ENV{IDF_PATH}/components/freertos/include/
|
||||||
|
$ENV{IDF_PATH}/components/lwip/include/
|
||||||
$ENV{IDF_PATH}/components/freertos/esp_additions/include/
|
$ENV{IDF_PATH}/components/freertos/esp_additions/include/
|
||||||
$ENV{IDF_PATH}/components/freertos/esp_additions/include/freertos/
|
$ENV{IDF_PATH}/components/freertos/esp_additions/include/freertos/
|
||||||
$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/
|
$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/
|
||||||
|
@ -98,6 +99,22 @@ if (ESP_PLATFORM)
|
||||||
$ENV{IDF_PATH}/components/hal/${CONFIG_IDF_TARGET}/include/
|
$ENV{IDF_PATH}/components/hal/${CONFIG_IDF_TARGET}/include/
|
||||||
$ENV{IDF_PATH}/components/app_update/include/
|
$ENV{IDF_PATH}/components/app_update/include/
|
||||||
$ENV{IDF_PATH}/components/bootloader_support/include
|
$ENV{IDF_PATH}/components/bootloader_support/include
|
||||||
|
$ENV{IDF_PATH}/components/lwip/port/include
|
||||||
|
$ENV{IDF_PATH}/components/lwip/port/freertos/include
|
||||||
|
$ENV{IDF_PATH}/components/lwip/port/esp32xx/include
|
||||||
|
$ENV{IDF_PATH}/components/freertos/config/include/freertos/
|
||||||
|
$ENV{IDF_PATH}/components/freertos/config/${CONFIG_IDF_TARGET_ARCH}/include
|
||||||
|
$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/portable/${CONFIG_IDF_TARGET_ARCH}/include
|
||||||
|
$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/portable/${CONFIG_IDF_TARGET_ARCH}/include/freertos
|
||||||
|
$ENV{IDF_PATH}/components/freertos/config/include
|
||||||
|
$ENV{IDF_PATH}/components/esp_driver_gpio/include
|
||||||
|
$ENV{IDF_PATH}/components/esp_driver_spi/include
|
||||||
|
$ENV{IDF_PATH}/components/esp_driver_ledc/include
|
||||||
|
$ENV{IDF_PATH}/components/esp_partition/include
|
||||||
|
$ENV{IDF_PATH}/components/spi_flash/include
|
||||||
|
$ENV{IDF_PATH}/components/esp_app_format/include
|
||||||
|
$ENV{IDF_PATH}/components/esp_bootloader_format/include
|
||||||
|
$ENV{IDF_PATH}/components/esp_system/include/
|
||||||
)
|
)
|
||||||
|
|
||||||
if (CONFIG_IDF_TARGET_ARCH_RISCV)
|
if (CONFIG_IDF_TARGET_ARCH_RISCV)
|
||||||
|
|
|
@ -68,7 +68,7 @@ struct pollfd {
|
||||||
//#include "esp_event_loop.h"
|
//#include "esp_event_loop.h"
|
||||||
#include "nvs.h"
|
#include "nvs.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "esp_spi_flash.h"
|
#include "spi_flash_mmap.h"
|
||||||
#include "freertos/timers.h"
|
#include "freertos/timers.h"
|
||||||
|
|
||||||
#if defined(LWS_ESP_PLATFORM)
|
#if defined(LWS_ESP_PLATFORM)
|
||||||
|
|
|
@ -37,7 +37,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "romfs.h"
|
#include "romfs.h"
|
||||||
#if defined(LWS_WITH_ESP32)
|
#if defined(LWS_WITH_ESP32)
|
||||||
#include "esp_spi_flash.h"
|
#include <esp_flash.h>
|
||||||
|
#include "spi_flash_mmap.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RFS_STRING_MAX 96
|
#define RFS_STRING_MAX 96
|
||||||
|
@ -50,7 +51,10 @@ static void
|
||||||
set_cache(romfs_inode_t inode, size_t len)
|
set_cache(romfs_inode_t inode, size_t len)
|
||||||
{
|
{
|
||||||
#if defined(LWS_WITH_ESP32)
|
#if defined(LWS_WITH_ESP32)
|
||||||
spi_flash_read((uint32_t)inode, cache, len);
|
// spi_flash_read((uint32_t)inode, cache, len);
|
||||||
|
// esp_err_t esp_flash_read(esp_flash_t *chip, void *buffer, uint32_t address, uint32_t length);
|
||||||
|
|
||||||
|
esp_flash_read(NULL, (void *)inode, (uint32_t)cache, len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "private-lib-core.h"
|
#include "private-lib-core.h"
|
||||||
|
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include "esp_spi_flash.h"
|
#include "spi_flash_mmap.h"
|
||||||
#include "esp_wifi.h"
|
#include "esp_wifi.h"
|
||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
#include <esp_netif.h>
|
#include <esp_netif.h>
|
||||||
|
|
|
@ -60,7 +60,7 @@ const struct http2_settings lws_h2_defaults_esp32 = { {
|
||||||
1,
|
1,
|
||||||
/* H2SET_HEADER_TABLE_SIZE */ 512,
|
/* H2SET_HEADER_TABLE_SIZE */ 512,
|
||||||
/* H2SET_ENABLE_PUSH */ 0,
|
/* H2SET_ENABLE_PUSH */ 0,
|
||||||
/* H2SET_MAX_CONCURRENT_STREAMS */ 8,
|
/* H2SET_MAX_CONCURRENT_STREAMS */ 16,
|
||||||
/* H2SET_INITIAL_WINDOW_SIZE */ 0,
|
/* H2SET_INITIAL_WINDOW_SIZE */ 0,
|
||||||
/* H2SET_MAX_FRAME_SIZE */ 16384,
|
/* H2SET_MAX_FRAME_SIZE */ 16384,
|
||||||
/* H2SET_MAX_HEADER_LIST_SIZE */ 512,
|
/* H2SET_MAX_HEADER_LIST_SIZE */ 512,
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#include "private-lib-core.h"
|
#include "private-lib-core.h"
|
||||||
|
|
||||||
|
#include <lwip/sockets.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
lws_plat_pipe_create(struct lws *wsi)
|
lws_plat_pipe_create(struct lws *wsi)
|
||||||
{
|
{
|
||||||
|
@ -41,11 +43,11 @@ lws_plat_pipe_create(struct lws *wsi)
|
||||||
* ephemeral range for us.
|
* ephemeral range for us.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fd[0] = socket(AF_INET, SOCK_DGRAM, 0);
|
fd[0] = lwip_socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd[0] < 0)
|
if (fd[0] < 0)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
fd[1] = socket(AF_INET, SOCK_DGRAM, 0);
|
fd[1] = lwip_socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd[1] < 0)
|
if (fd[1] < 0)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
|
@ -59,7 +61,7 @@ lws_plat_pipe_create(struct lws *wsi)
|
||||||
si->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
si->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||||
si->sin_port = 0;
|
si->sin_port = 0;
|
||||||
|
|
||||||
if (bind(fd[0], (const struct sockaddr *)si, sizeof(*si)) < 0)
|
if (lwip_bind(fd[0], (const struct sockaddr *)si, sizeof(*si)) < 0)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -71,7 +73,7 @@ lws_plat_pipe_create(struct lws *wsi)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sl = sizeof(*si);
|
sl = sizeof(*si);
|
||||||
if (getsockname(fd[0], (struct sockaddr *)si, &sl))
|
if (lwip_getsockname(fd[0], (struct sockaddr *)si, &sl))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
lwsl_info("%s: cancel UDP skt port %d\n", __func__,
|
lwsl_info("%s: cancel UDP skt port %d\n", __func__,
|
||||||
|
@ -106,7 +108,7 @@ lws_plat_pipe_signal(struct lws_context *ctx, int tsi)
|
||||||
* (on udp/raw netconn, doing a sendto/recv is currently possible).
|
* (on udp/raw netconn, doing a sendto/recv is currently possible).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
n = sendto(fd[1], &u, 1, 0, (struct sockaddr *)si, sizeof(*si));
|
n = lwip_sendto(fd[1], &u, 1, 0, (struct sockaddr *)si, sizeof(*si));
|
||||||
|
|
||||||
return n != 1;
|
return n != 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ lws_plat_service(struct lws_context *context, int timeout_ms)
|
||||||
{
|
{
|
||||||
int n = _lws_plat_service_tsi(context, timeout_ms, 0);
|
int n = _lws_plat_service_tsi(context, timeout_ms, 0);
|
||||||
|
|
||||||
#if !defined(LWS_AMAZON_RTOS)
|
#if !defined(LWS_AMAZON_RTOS) && defined(LWS_ESP_PLATFORM) && defined(CONFIG_ESP_INT_WDT)
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd, int unix_skt)
|
||||||
if (vhost->ka_time) {
|
if (vhost->ka_time) {
|
||||||
/* enable keepalive on this socket */
|
/* enable keepalive on this socket */
|
||||||
optval = 1;
|
optval = 1;
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE,
|
if (lwip_setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE,
|
||||||
(const void *)&optval, optlen) < 0)
|
(const void *)&optval, optlen) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -115,17 +115,17 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd, int unix_skt)
|
||||||
#else
|
#else
|
||||||
/* set the keepalive conditions we want on it too */
|
/* set the keepalive conditions we want on it too */
|
||||||
optval = vhost->ka_time;
|
optval = vhost->ka_time;
|
||||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE,
|
if (lwip_setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE,
|
||||||
(const void *)&optval, optlen) < 0)
|
(const void *)&optval, optlen) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
optval = vhost->ka_interval;
|
optval = vhost->ka_interval;
|
||||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL,
|
if (lwip_setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL,
|
||||||
(const void *)&optval, optlen) < 0)
|
(const void *)&optval, optlen) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
optval = vhost->ka_probes;
|
optval = vhost->ka_probes;
|
||||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT,
|
if (lwip_setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT,
|
||||||
(const void *)&optval, optlen) < 0)
|
(const void *)&optval, optlen) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -133,7 +133,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd, int unix_skt)
|
||||||
|
|
||||||
/* Disable Nagle */
|
/* Disable Nagle */
|
||||||
optval = 1;
|
optval = 1;
|
||||||
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &optval, optlen) < 0)
|
if (lwip_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &optval, optlen) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return lws_plat_set_nonblocking(fd);
|
return lws_plat_set_nonblocking(fd);
|
||||||
|
@ -162,7 +162,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
|
||||||
|
|
||||||
#if defined(SO_PRIORITY)
|
#if defined(SO_PRIORITY)
|
||||||
if (pri) { /* 0 is the default already */
|
if (pri) { /* 0 is the default already */
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY,
|
if (lwip_setsockopt(fd, SOL_SOCKET, SO_PRIORITY,
|
||||||
(const void *)&optval, optlen) < 0) {
|
(const void *)&optval, optlen) < 0) {
|
||||||
#if !defined(LWS_WITH_NO_LOGS)
|
#if !defined(LWS_WITH_NO_LOGS)
|
||||||
en = errno;
|
en = errno;
|
||||||
|
@ -177,7 +177,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
|
||||||
|
|
||||||
if (lws_flags & LCCSCF_ALLOW_REUSE_ADDR) {
|
if (lws_flags & LCCSCF_ALLOW_REUSE_ADDR) {
|
||||||
optval = 1;
|
optval = 1;
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
|
if (lwip_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
|
||||||
(const void *)&optval, optlen) < 0) {
|
(const void *)&optval, optlen) < 0) {
|
||||||
#if !defined(LWS_WITH_NO_LOGS)
|
#if !defined(LWS_WITH_NO_LOGS)
|
||||||
en = errno;
|
en = errno;
|
||||||
|
@ -194,7 +194,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
optval = (int)ip_opt_val[n];
|
optval = (int)ip_opt_val[n];
|
||||||
if (setsockopt(fd, IPPROTO_IP, IP_TOS, (const void *)&optval,
|
if (lwip_setsockopt(fd, IPPROTO_IP, IP_TOS, (const void *)&optval,
|
||||||
optlen) < 0) {
|
optlen) < 0) {
|
||||||
#if !defined(LWS_WITH_NO_LOGS)
|
#if !defined(LWS_WITH_NO_LOGS)
|
||||||
en = errno;
|
en = errno;
|
||||||
|
@ -288,7 +288,7 @@ lws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr,
|
||||||
const char *
|
const char *
|
||||||
lws_plat_inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
|
lws_plat_inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
|
||||||
{
|
{
|
||||||
return inet_ntop(af, src, dst, cnt);
|
return lwip_inet_ntop(af, src, dst, cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -64,6 +64,9 @@
|
||||||
#include "freertos/timers.h"
|
#include "freertos/timers.h"
|
||||||
#if defined(LWS_ESP_PLATFORM)
|
#if defined(LWS_ESP_PLATFORM)
|
||||||
#include <esp_attr.h>
|
#include <esp_attr.h>
|
||||||
|
#if !defined(ETHER_ADDR_LEN)
|
||||||
|
#define ETHER_ADDR_LEN 6
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#include <esp_system.h>
|
#include <esp_system.h>
|
||||||
#include <esp_task_wdt.h>
|
#include <esp_task_wdt.h>
|
||||||
|
|
|
@ -219,8 +219,12 @@ done_list:
|
||||||
GetCurrentProcess(), (HANDLE*)&sockfd, 0,
|
GetCurrentProcess(), (HANDLE*)&sockfd, 0,
|
||||||
FALSE, DUPLICATE_SAME_ACCESS))
|
FALSE, DUPLICATE_SAME_ACCESS))
|
||||||
sockfd = LWS_SOCK_INVALID;
|
sockfd = LWS_SOCK_INVALID;
|
||||||
|
#else
|
||||||
|
#if defined(LWS_PLAT_FREERTOS)
|
||||||
|
sockfd = a->info->vh_listen_sockfd;
|
||||||
#else
|
#else
|
||||||
sockfd = dup(a->info->vh_listen_sockfd);
|
sockfd = dup(a->info->vh_listen_sockfd);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -68,6 +68,7 @@ gai_strerror(int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LWS_WITH_ESP32)
|
#if defined(LWS_WITH_ESP32)
|
||||||
|
#include "lwip/port/include/lwipopts.h"
|
||||||
#include "lwip/apps/sntp.h"
|
#include "lwip/apps/sntp.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,7 +5,7 @@ if (ESP_PLATFORM)
|
||||||
project(lws-minimal-esp32 C)
|
project(lws-minimal-esp32 C)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
target_link_libraries(lws-minimal-esp32.elf websockets)
|
target_link_libraries(lws-minimal-esp32.elf PRIVATE websockets)
|
||||||
|
|
||||||
option(LWS_WITH_DRIVERS "With generic drivers for gpio, i2c, display etc" ON)
|
option(LWS_WITH_DRIVERS "With generic drivers for gpio, i2c, display etc" ON)
|
||||||
set(LWS_WITH_DRIVERS ON)
|
set(LWS_WITH_DRIVERS ON)
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
idf_component_register(SRCS
|
idf_component_register(SRCS
|
||||||
lws-minimal-esp32.c
|
lws-minimal-esp32.c
|
||||||
devices.c
|
devices.c
|
||||||
INCLUDE_DIRS "../libwebsockets/include;${IDF_PATH}/components/spi_flash/include;${IDF_PATH}/components/nvs_flash/include;${IDF_PATH}/components/mdns/include")
|
INCLUDE_DIRS "../libwebsockets/include;${IDF_PATH}/components/spi_flash/include;${IDF_PATH}/components/nvs_flash/include;${IDF_PATH}/components/lwip/port/include")
|
||||||
|
#;${IDF_PATH}/components/mdns/include")
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_LIB} websockets)
|
target_link_libraries(${COMPONENT_LIB} websockets)
|
||||||
include_directories(../build/libwebsockets)
|
include_directories(../build/libwebsockets)
|
||||||
|
|
|
@ -195,8 +195,8 @@ init_plat_devices(struct lws_context *ctx)
|
||||||
|
|
||||||
memset(&creds, 0, sizeof(creds));
|
memset(&creds, 0, sizeof(creds));
|
||||||
|
|
||||||
lws_strncpy(creds.ssid, "xxx", sizeof(creds.ssid));
|
// lws_strncpy(creds.ssid, "Ulxxxx", sizeof(creds.ssid));
|
||||||
lws_strncpy(creds.passphrase, "yyy", sizeof(creds.passphrase));
|
// lws_strncpy(creds.passphrase, "secret", sizeof(creds.passphrase));
|
||||||
lws_dll2_add_tail(&creds.list, &netdevs->owner_creds);
|
lws_dll2_add_tail(&creds.list, &netdevs->owner_creds);
|
||||||
|
|
||||||
if (lws_netdev_credentials_settings_set(netdevs)) {
|
if (lws_netdev_credentials_settings_set(netdevs)) {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,7 +5,7 @@
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
|
#include <esp_task_wdt.h>
|
||||||
#include <driver/gpio.h>
|
#include <driver/gpio.h>
|
||||||
|
|
||||||
#include <libwebsockets.h>
|
#include <libwebsockets.h>
|
||||||
|
|
Loading…
Add table
Reference in a new issue