Skip to content

Commit 008d599

Browse files
author
Andrey Hinkov
committed
add dhcp_hostname config for esp32
1 parent 2b78d7e commit 008d599

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

mos_esp32.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ cdefs:
99
MGOS_ETH_PHY_DP83848: 0
1010

1111
config_schema:
12+
- ["eth.dhcp_hostname", "s", {title: "Host name to include in DHCP requests"}]
1213
- ["eth.clk_mode", "i", 0, {title: "50 MHz clock source: 0 in <- GPIO0, 1 out -> GPIO0, 2 out -> GPIO16, 3 out -> GPIO17 (inverted)"}]
1314
- ["eth.mdc_gpio", "i", 23, {title: "GPIO to use for RMII MDC signal"}]
1415
- ["eth.mdio_gpio", "i", 18, {title: "GPIO to use for RMII MDIO signal"}]

src/esp32/esp32_eth.c

+8
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ bool mgos_ethernet_init(void) {
126126
return false;
127127
}
128128

129+
if (mgos_sys_config_get_eth_dhcp_hostname() != NULL &&
130+
esp_netif_set_hostname(esp_netif_get_handle_from_ifkey("ETH_DEF"),
131+
mgos_sys_config_get_eth_dhcp_hostname()) !=
132+
ESP_OK) {
133+
LOG(LL_ERROR, ("ETH: Failed to set host name"));
134+
goto out;
135+
}
136+
129137
esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID,
130138
esp32_eth_event_handler, eth_if);
131139
esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP,

0 commit comments

Comments
 (0)