Wrapper class around esp-idf implementation of a esp-netif device.
More...
#include <mn_basic_netif.hpp>
|
static bool | start () |
| Initialize the underlying TCP/IP stack. More...
|
|
static bool | stop () |
| Deinitialize the esp-netif component (and the underlying TCP/IP stack) More...
|
|
Wrapper class around esp-idf implementation of a esp-netif device.
- Note
- To use this, you need to subclass it. All of your task should be derived from the basic_net_if class. Then implement the virtual create_default function.
◆ mn::device::basic_net_if::ip_info
struct mn::device::basic_net_if::ip_info |
◆ ip4_address_t
◆ ip_info_t
◆ basic_net_if() [1/2]
mn::device::basic_net_if::basic_net_if |
( |
| ) |
|
◆ basic_net_if() [2/2]
mn::device::basic_net_if::basic_net_if |
( |
const basic_net_if & |
other | ) |
|
|
inline |
◆ create_default()
virtual bool mn::device::basic_net_if::create_default |
( |
| ) |
|
|
pure virtual |
Creates an instance of new esp-netif object.
- Note
- Must be overwrite, with the driver spcezific version and set m_pNetIf
- Returns
- true: on success
- false: if initializing failed
Implemented in mn::device::basic_wifi_net_if.
◆ get_config()
virtual esp_netif_config_t* mn::device::basic_net_if::get_config |
( |
| ) |
|
|
inlinevirtual |
Get the config of the esp-netif instance.
- Returns
- The config of the esp-netif instance.
◆ get_hostname()
const char * mn::device::basic_net_if::get_hostname |
( |
void |
| ) |
|
Get the hostname of an interface.
- Returns
- Returns the hostname of an interface
◆ get_impl_index()
int mn::device::basic_net_if::get_impl_index |
( |
| ) |
|
Get net interface index from network stack implementation.
- Note
- This index could be used in
setsockopt()
to bind socket with multicast interface
- Returns
- implementation specific index of interface represented with supplied esp_netif
◆ get_impl_name()
int mn::device::basic_net_if::get_impl_name |
( |
char |
name[6] | ) |
|
Get net interface name from network stack implementation.
- Note
- This name could be used in
setsockopt()
to bind socket with appropriate interface
- Parameters
-
[out] | name | Interface name as specified in underlying TCP/IP stack. Note that the actual name will be copied to the specified buffer, which must be allocated to hold maximum interface name size (6 characters for lwIP) |
- Returns
- NO_ERROR: succeed
- ERR_MNTHREAD_INVALID_ARG: The given arcuments are wrong
◆ get_ip_infos()
int mn::device::basic_net_if::get_ip_infos |
( |
ip_info_t & |
ip_info | ) |
|
Get interface's IP address information.
If the interface is up, IP information is read directly from the TCP/IP stack. If the interface is down, IP information is read from a copy kept in the ESP-NETIF instance
- Parameters
-
ip_info | If successful, IP information will be returned in this argument. |
- Returns
- NO_ERROR: succeed
- ERR_MNTHREAD_INVALID_ARG: The given arcuments are wrong
- ERR_MNTHREAD_UNKN: Unbekannter fehler
◆ get_mac()
int mn::device::basic_net_if::get_mac |
( |
uint8_t |
mac[6] | ) |
|
Get the mac address for the interface instance.
- Parameters
-
[out] | mac | Resultant mac address for the related network interface |
- Returns
- NO_ERROR: succeed
- ERR_MNTHREAD_NETIF_NOT_INIT - interface status error
- ERR_MNTHREAD_NOT_SUPPORTED - mac not supported on this interface
◆ get_netif()
virtual esp_netif_t* mn::device::basic_net_if::get_netif |
( |
| ) |
|
|
inlinevirtual |
Get the Handle to esp-netif instance.
- Returns
- The Handle to esp-netif instance.
◆ is_up()
bool mn::device::basic_net_if::is_up |
( |
| ) |
|
Test if supplied interface is up.
- Returns
- - true - Interface is up
- false - Interface is down
◆ operator bool()
mn::device::basic_net_if::operator bool |
( |
| ) |
|
|
inline |
◆ operator esp_netif_t *()
mn::device::basic_net_if::operator esp_netif_t * |
( |
| ) |
|
|
inline |
◆ operator!=() [1/2]
bool mn::device::basic_net_if::operator!= |
( |
const basic_net_if & |
other | ) |
|
◆ operator!=() [2/2]
bool mn::device::basic_net_if::operator!= |
( |
const esp_netif_t * |
other | ) |
|
◆ operator=()
◆ operator==() [1/2]
bool mn::device::basic_net_if::operator== |
( |
const basic_net_if & |
other | ) |
|
◆ operator==() [2/2]
bool mn::device::basic_net_if::operator== |
( |
const esp_netif_t * |
other | ) |
|
◆ set_hostname()
bool mn::device::basic_net_if::set_hostname |
( |
const char * |
hostname | ) |
|
Set the hostname of an interface.
The configured hostname overrides the default configuration value CONFIG_LWIP_LOCAL_HOSTNAME. Please note that when the hostname is altered after interface started/connected the changes would only be reflected once the interface restarts/reconnects
- Parameters
-
hostname | New hostname for the interface. Maximum length 32 bytes. |
- Returns
- true The hostname was changed
- false The hostname was not changed
◆ set_ip_infos()
int mn::device::basic_net_if::set_ip_infos |
( |
const ip_info_t & |
ip_info | ) |
|
Set interface's IP address information.
This function is mainly used to set a static IP on an interface.
If the interface is up, the new IP information is set directly in the TCP/IP stack.
The copy of IP information kept in the ESP-NETIF instance is also updated (this copy is returned if the IP is queried while the interface is still down.)
- Note
- DHCP client/server must be stopped (if enabled for this interface) before setting new IP information.
-
Calling this interface for may generate a SYSTEM_EVENT_STA_GOT_IP or SYSTEM_EVENT_ETH_GOT_IP event.
- Parameters
-
[in] | esp_netif | Handle to esp-netif instance |
[in] | ip_info | IP information to set on the specified interface |
- Returns
-
- ERR_MNTHREAD_INVALID_ARG: The given arcuments are wrong
- ERR_MNTHREAD_UNKN: If DHCP server or client is still running
◆ set_mac()
int mn::device::basic_net_if::set_mac |
( |
uint8_t |
mac[6] | ) |
|
Set the mac address for the interface instance.
- Parameters
-
[in] | mac | Desired mac address for the related network interface |
- Returns
- NO_ERROR: succeed
- ERR_MNTHREAD_NETIF_NOT_INIT - interface status error
- ERR_MNTHREAD_NOT_SUPPORTED - mac not supported on this interface
◆ start()
bool mn::device::basic_net_if::start |
( |
| ) |
|
|
static |
Initialize the underlying TCP/IP stack.
- Returns
- true: on success
- false: if initializing failed
- Note
- This function should be called exactly once from application code, when the application starts up.
◆ stop()
bool mn::device::basic_net_if::stop |
( |
| ) |
|
|
static |
Deinitialize the esp-netif component (and the underlying TCP/IP stack)
- Note
- Deinitialization is not supported yet
- Returns
- true: on success
- false: if initializing failed
◆ m_ifConfig
esp_netif_config_t* mn::device::basic_net_if::m_ifConfig |
|
protected |
A saved / cached copy of esp-netif config
◆ m_pNetIf
esp_netif_t* mn::device::basic_net_if::m_pNetIf |
|
protected |
Reference to the underlying esp-netif handle.
The documentation for this class was generated from the following files: