mirror of
https://github.com/esphome/esphome.git
synced 2024-12-21 16:27:44 +01:00
Disable automatic usage of SNTP servers from DHCP (#2273)
This commit is contained in:
parent
ede1de9021
commit
97a18717e6
@ -11,6 +11,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "lwip/err.h"
|
#include "lwip/err.h"
|
||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
|
#include "lwip/apps/sntp.h"
|
||||||
|
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
@ -92,6 +93,11 @@ bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
|
|||||||
tcpip_adapter_dhcp_status_t dhcp_status;
|
tcpip_adapter_dhcp_status_t dhcp_status;
|
||||||
tcpip_adapter_dhcpc_get_status(TCPIP_ADAPTER_IF_STA, &dhcp_status);
|
tcpip_adapter_dhcpc_get_status(TCPIP_ADAPTER_IF_STA, &dhcp_status);
|
||||||
if (!manual_ip.has_value()) {
|
if (!manual_ip.has_value()) {
|
||||||
|
// lwIP starts the SNTP client if it gets an SNTP server from DHCP. We don't need the time, and more importantly,
|
||||||
|
// the built-in SNTP client has a memory leak in certain situations. Disable this feature.
|
||||||
|
// https://github.com/esphome/issues/issues/2299
|
||||||
|
sntp_servermode_dhcp(false);
|
||||||
|
|
||||||
// Use DHCP client
|
// Use DHCP client
|
||||||
if (dhcp_status != TCPIP_ADAPTER_DHCP_STARTED) {
|
if (dhcp_status != TCPIP_ADAPTER_DHCP_STARTED) {
|
||||||
esp_err_t err = tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA);
|
esp_err_t err = tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA);
|
||||||
|
@ -16,6 +16,7 @@ extern "C" {
|
|||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
#include "lwip/dhcp.h"
|
#include "lwip/dhcp.h"
|
||||||
#include "lwip/init.h" // LWIP_VERSION_
|
#include "lwip/init.h" // LWIP_VERSION_
|
||||||
|
#include "lwip/apps/sntp.h"
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6
|
||||||
#include "lwip/netif.h" // struct netif
|
#include "lwip/netif.h" // struct netif
|
||||||
#endif
|
#endif
|
||||||
@ -112,6 +113,11 @@ bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
|
|||||||
|
|
||||||
enum dhcp_status dhcp_status = wifi_station_dhcpc_status();
|
enum dhcp_status dhcp_status = wifi_station_dhcpc_status();
|
||||||
if (!manual_ip.has_value()) {
|
if (!manual_ip.has_value()) {
|
||||||
|
// lwIP starts the SNTP client if it gets an SNTP server from DHCP. We don't need the time, and more importantly,
|
||||||
|
// the built-in SNTP client has a memory leak in certain situations. Disable this feature.
|
||||||
|
// https://github.com/esphome/issues/issues/2299
|
||||||
|
sntp_servermode_dhcp(false);
|
||||||
|
|
||||||
// Use DHCP client
|
// Use DHCP client
|
||||||
if (dhcp_status != DHCP_STARTED) {
|
if (dhcp_status != DHCP_STARTED) {
|
||||||
bool ret = wifi_station_dhcpc_start();
|
bool ret = wifi_station_dhcpc_start();
|
||||||
|
Loading…
Reference in New Issue
Block a user