mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-07-03 15:38:15 +08:00
Merge branch 'feature/autoip_bind_trigger_callback' into 'master'
lAutoIP trigger callback so that application can know IP changes See merge request sdk/ESP8266_RTOS_SDK!972
This commit is contained in:
@ -67,6 +67,7 @@
|
||||
#include "lwip/autoip.h"
|
||||
#include "lwip/etharp.h"
|
||||
#include "lwip/prot/autoip.h"
|
||||
#include "lwip/dhcp.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -241,6 +242,13 @@ autoip_bind(struct netif *netif)
|
||||
netif_set_addr(netif, &autoip->llipaddr, &sn_mask, &gw_addr);
|
||||
/* interface is used by routing now that an address is set */
|
||||
|
||||
#if ESP_LWIP
|
||||
struct dhcp *dhcp = netif_dhcp_data(netif);
|
||||
if (dhcp->cb != NULL) {
|
||||
dhcp->cb(netif);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -1954,4 +1954,23 @@ dhcp_supplied_address(const struct netif *netif)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if ESP_LWIP
|
||||
/** Set callback for dhcp, reserved parameter for future use.
|
||||
*
|
||||
* @param netif the netif from which to remove the struct dhcp
|
||||
* @param cb callback for dhcp
|
||||
*/
|
||||
void dhcp_set_cb(struct netif *netif, void (*cb)(struct netif*))
|
||||
{
|
||||
struct dhcp *dhcp;
|
||||
dhcp = netif_dhcp_data(netif);
|
||||
|
||||
LWIP_ASSERT("netif != NULL", netif != NULL);
|
||||
|
||||
if (dhcp != NULL) {
|
||||
dhcp->cb = cb;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV4 && LWIP_DHCP */
|
||||
|
@ -103,6 +103,10 @@ struct dhcp
|
||||
ip4_addr_t offered_si_addr;
|
||||
char boot_file_name[DHCP_BOOT_FILE_LEN];
|
||||
#endif /* LWIP_DHCP_BOOTPFILE */
|
||||
|
||||
#if ESP_LWIP
|
||||
void (*cb)(struct netif*); /* callback for dhcp, add a parameter to show dhcp status if needed */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -134,6 +138,10 @@ extern void dhcp_set_ntp_servers(u8_t num_ntp_servers, const ip4_addr_t* ntp_ser
|
||||
|
||||
#define netif_dhcp_data(netif) ((struct dhcp*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP))
|
||||
|
||||
#ifdef ESP_LWIP
|
||||
void dhcp_set_cb(struct netif *netif, void (*cb)(struct netif*));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -98,9 +98,17 @@ static void tcpip_adapter_dhcps_cb(u8_t client_ip[4])
|
||||
|
||||
static err_t _dhcp_start(struct tcpip_api_call_data *p)
|
||||
{
|
||||
err_t ret;
|
||||
struct tcpip_adapter_api_call_data *call = (struct tcpip_adapter_api_call_data *)p;
|
||||
|
||||
return dhcp_start(call->netif);
|
||||
ret = dhcp_start(call->netif);
|
||||
|
||||
#if ESP_LWIP
|
||||
if (ret == ERR_OK)
|
||||
dhcp_set_cb(call->netif, tcpip_adapter_dhcpc_cb);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static err_t _dhcp_stop(struct tcpip_api_call_data *p)
|
||||
|
Reference in New Issue
Block a user