Skip to content

Commit

Permalink
add dhcp_hostname config for esp32
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Hinkov committed Feb 8, 2021
1 parent 2b78d7e commit 008d599
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions mos_esp32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cdefs:
MGOS_ETH_PHY_DP83848: 0

config_schema:
- ["eth.dhcp_hostname", "s", {title: "Host name to include in DHCP requests"}]
- ["eth.clk_mode", "i", 0, {title: "50 MHz clock source: 0 in <- GPIO0, 1 out -> GPIO0, 2 out -> GPIO16, 3 out -> GPIO17 (inverted)"}]
- ["eth.mdc_gpio", "i", 23, {title: "GPIO to use for RMII MDC signal"}]
- ["eth.mdio_gpio", "i", 18, {title: "GPIO to use for RMII MDIO signal"}]
Expand Down
8 changes: 8 additions & 0 deletions src/esp32/esp32_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ bool mgos_ethernet_init(void) {
return false;
}

if (mgos_sys_config_get_eth_dhcp_hostname() != NULL &&
esp_netif_set_hostname(esp_netif_get_handle_from_ifkey("ETH_DEF"),
mgos_sys_config_get_eth_dhcp_hostname()) !=
ESP_OK) {
LOG(LL_ERROR, ("ETH: Failed to set host name"));
goto out;
}

esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID,
esp32_eth_event_handler, eth_if);
esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP,
Expand Down

0 comments on commit 008d599

Please sign in to comment.