Unverified Commit 6e632649 authored by Johny Mattsson's avatar Johny Mattsson Committed by GitHub
Browse files

Support interface-specific hostname on ethernet interface. (#3487)

parent 4b4ce47e
......@@ -230,6 +230,18 @@ static int leth_set_ip( lua_State *L )
return 0;
}
static int leth_set_hostname(lua_State *L)
{
const char *hostname = luaL_checkstring(L, 1);
esp_err_t err = esp_netif_set_hostname(eth, hostname);
if (err != ESP_OK)
return luaL_error (L, "failed to set hostname, code %d", err);
return 0;
}
static int leth_on( lua_State *L )
{
const char *event_name = luaL_checkstring( L, 1 );
......@@ -338,6 +350,7 @@ LROT_BEGIN(eth, NULL, 0)
LROT_FUNCENTRY( get_mac, leth_get_mac )
LROT_FUNCENTRY( set_mac, leth_set_mac )
LROT_FUNCENTRY( set_ip, leth_set_ip )
LROT_FUNCENTRY( set_hostname, leth_set_hostname )
LROT_NUMENTRY( PHY_DP83848, ETH_PHY_DP83848 )
LROT_NUMENTRY( PHY_IP101, ETH_PHY_IP101 )
......
......@@ -200,3 +200,21 @@ eth.set_ip({
dns = "8.8.8.8"
})
```
## eth.set_hostname()
Configures the interface specific hostname for the ethernet interface. The ethernet interface must be initialized before the hostname can be configured.
By default the system hostname is used, as configured in the menu config.
#### Syntax
```lua
eth.set_hostname(hostname)
```
#### Parameters
- `hostname` the hostname to use on the ethernet interface
#### Returns
`nil`
An error is thrown in case the hostname cannot be set.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment