From bcee69ae06a17ff55f74120fe6605b6a65475d99 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Wed, 19 Feb 2020 16:56:07 +0100 Subject: [PATCH] esp-netif: Enable easier configuration of custom DHCP server address --- components/esp_netif/esp_netif_defaults.c | 12 +++--------- components/esp_netif/include/esp_netif_ip_addr.h | 6 ++++++ components/esp_wifi/include/esp_mesh.h | 2 ++ components/lwip/port/esp32/netif/wlanif.c | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/components/esp_netif/esp_netif_defaults.c b/components/esp_netif/esp_netif_defaults.c index 4dd497648..af71eaef6 100644 --- a/components/esp_netif/esp_netif_defaults.c +++ b/components/esp_netif/esp_netif_defaults.c @@ -24,12 +24,6 @@ // - default init / create functions for basic default interfaces // -#define IP4TOUINT32(a,b,c,d) (((uint32_t)((a) & 0xffU) << 24) | \ - ((uint32_t)((b) & 0xffU) << 16) | \ - ((uint32_t)((c) & 0xffU) << 8) | \ - (uint32_t)((d) & 0xffU)) - -#define IP4TOADDR(a,b,c,d) esp_netif_htonl(IP4TOUINT32(a, b, c, d)) // @@ -44,7 +38,7 @@ const esp_netif_inherent_config_t _g_esp_netif_inherent_eth_config = ESP_NETIF_I const esp_netif_inherent_config_t _g_esp_netif_inherent_ppp_config = ESP_NETIF_INHERENT_DEFAULT_PPP(); const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip = { - .ip = { .addr = IP4TOADDR( 192, 168, 4, 1) }, - .gw = { .addr = IP4TOADDR( 192, 168, 4, 1) }, - .netmask = { .addr = IP4TOADDR( 255, 255, 255, 0) }, + .ip = { .addr = ESP_IP4TOADDR( 192, 168, 4, 1) }, + .gw = { .addr = ESP_IP4TOADDR( 192, 168, 4, 1) }, + .netmask = { .addr = ESP_IP4TOADDR( 255, 255, 255, 0) }, }; diff --git a/components/esp_netif/include/esp_netif_ip_addr.h b/components/esp_netif/include/esp_netif_ip_addr.h index e673b399b..92f374e1b 100644 --- a/components/esp_netif/include/esp_netif_ip_addr.h +++ b/components/esp_netif/include/esp_netif_ip_addr.h @@ -78,6 +78,12 @@ extern "C" { #define ESP_IPADDR_TYPE_V6 6U #define ESP_IPADDR_TYPE_ANY 46U +#define ESP_IP4TOUINT32(a,b,c,d) (((uint32_t)((a) & 0xffU) << 24) | \ + ((uint32_t)((b) & 0xffU) << 16) | \ + ((uint32_t)((c) & 0xffU) << 8) | \ + (uint32_t)((d) & 0xffU)) + +#define ESP_IP4TOADDR(a,b,c,d) esp_netif_htonl(ESP_IP4TOUINT32(a, b, c, d)) struct esp_ip6_addr { uint32_t addr[4]; diff --git a/components/esp_wifi/include/esp_mesh.h b/components/esp_wifi/include/esp_mesh.h index 6b17a60ce..12632e4fa 100644 --- a/components/esp_wifi/include/esp_mesh.h +++ b/components/esp_wifi/include/esp_mesh.h @@ -224,6 +224,8 @@ typedef enum { MESH_PROTO_HTTP, /**< HTTP protocol */ MESH_PROTO_JSON, /**< JSON format */ MESH_PROTO_MQTT, /**< MQTT protocol */ + MESH_PROTO_AP, + MESH_PROTO_STA, } mesh_proto_t; /** diff --git a/components/lwip/port/esp32/netif/wlanif.c b/components/lwip/port/esp32/netif/wlanif.c index 1e1fe1daa..1555b0ce9 100644 --- a/components/lwip/port/esp32/netif/wlanif.c +++ b/components/lwip/port/esp32/netif/wlanif.c @@ -54,6 +54,7 @@ #include "esp_netif_net_stack.h" #include "esp_compiler.h" +#if !ESP_L2_TO_L3_COPY /** * @brief Free resources allocated in L2 layer * @@ -65,6 +66,7 @@ static void lwip_netif_wifi_free_rx_buffer(struct netif *netif, void *buf) esp_netif_t *esp_netif = esp_netif_get_handle_from_netif_impl(netif); esp_netif_free_rx_buffer(esp_netif, buf); } +#endif /** * In this function, the hardware should be initialized. @@ -177,14 +179,12 @@ wlanif_input(void *h, void *buffer, size_t len, void* eb) #if (ESP_L2_TO_L3_COPY == 1) p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM); if (p == NULL) { -// esp_wifi_internal_free_rx_buffer(eb); esp_netif_free_rx_buffer(esp_netif, eb); return; } p->l2_owner = NULL; memcpy(p->payload, buffer, len); esp_netif_free_rx_buffer(esp_netif, eb); -// esp_wifi_internal_free_rx_buffer(eb); #else p = pbuf_alloc(PBUF_RAW, len, PBUF_REF); if (p == NULL){