esp-netif: Enable easier configuration of custom DHCP server address

This commit is contained in:
David Cermak 2020-02-19 16:56:07 +01:00
parent 741960d5ce
commit bcee69ae06
4 changed files with 13 additions and 11 deletions

View file

@ -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) },
};

View file

@ -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];

View file

@ -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;
/**

View file

@ -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){