Wifi AP class for the esp32. More...
#include <mn_wifi_ap.hpp>
Inheritance diagram for mn::device::basic_wifi_ap:
Collaboration diagram for mn::device::basic_wifi_ap:Public Types | |
| using | ip4_adress_t = net::basic_ip4_address |
| using | auth_mode_t = typename base_type::auth_mode |
| using | interface_t = typename base_type::wifi_interface_type |
Public Types inherited from mn::device::basic_wifi | |
| enum class | auth_mode : int { Open = WIFI_AUTH_OPEN , WEP = WIFI_AUTH_WEP , WPA_PSK = WIFI_AUTH_WPA_PSK , WPA2_PSK = WIFI_AUTH_WPA2_PSK , WPA_WPA2_PSK = WIFI_AUTH_WPA_WPA2_PSK , WPA2_ENTERPRISE = WIFI_AUTH_WPA2_ENTERPRISE } |
| Authenticate modes. More... | |
| enum class | wifi_interface_type { Station = 0 , Acesspoint = 1 } |
| using | auth_mode_t = basic_wifi::auth_mode |
| using | interface_t = basic_wifi::wifi_interface_type |
Public Types inherited from mn::device::basic_wifi_net_if | |
| enum class | wifi_protocol : uint8_t { none = 0 , b = WIFI_PROTOCOL_11B , g = WIFI_PROTOCOL_11G , n = WIFI_PROTOCOL_11N , bg = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G , bgn = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N , lr = WIFI_PROTOCOL_LR } |
| list of the wifi protocols More... | |
Public Types inherited from mn::device::basic_net_if | |
| using | ip4_address_t = net::basic_ip4_address |
| using | ip_info_t = ip_info |
Public Types inherited from mn::device::basic_network_device | |
| using | ip4_adress_t = net::basic_ip4_address |
Public Member Functions | |
| basic_wifi_ap () | |
| Construct the wifi ap object. More... | |
| ~basic_wifi_ap () | |
| Basic destructor, stopped the Wifi. More... | |
| basic_wifi_ap (const basic_wifi_ap &other)=delete | |
| basic_wifi_ap & | operator= (const basic_wifi_ap &other)=delete |
| int | start (const char *ssid, auth_mode_t mode=auth_mode_t::Open, const char *passphrase="", bool storeCfgToFlash=false, bool ipv6=false, int channel=13, bool ssid_hidden=false, int max_connection=4) |
| int | set_ipinfo (const ip4_adress_t &local_ip, const ip4_adress_t &gateway, const ip4_adress_t &subnet) |
| Set IPv4 infos, local ip, gateway and subnet. More... | |
| int | get_ipinfo (ip4_adress_t &local_ip, ip4_adress_t &gateway, ip4_adress_t &subnet) override |
| Get IPv4 infos, local ip, gateway and subnet. More... | |
| bool | stop (bool wifioff) override |
| virtual ip4_adress_t | get_ip () |
| Get Tte IPv4 address of the WiFi AP device. More... | |
| virtual ip4_adress_t | get_broadcast () |
| Get the broadcast IP address,. More... | |
| virtual ip4_adress_t | get_gateway () |
| Get the gateway IP address,. More... | |
| virtual ip4_adress_t | get_netmask () |
| Get the netmask IP address,. More... | |
| virtual const char * | get_hostname () |
| Get the hostname. More... | |
| virtual bool | set_hostname (const char *hostname) |
| Set the hostname, only work when wifi are started. More... | |
| virtual uint8_t * | get_mac (uint8_t *mac) |
| Get the MAC of the WiFi AP device. More... | |
| virtual const char * | get_mac () |
| Get the MAC of the WiFi AP device as string. More... | |
| virtual uint32_t | get_connected () |
| Get the number of connected stations. More... | |
| operator uint32_t () | |
| operator ip4_adress_t () | |
| operator const char * () | |
| int | stop () override |
| Closes device. More... | |
| int | open () override |
| Opens device. More... | |
| bool | is_enable () override |
| bool | is_stream_support () override |
Public Member Functions inherited from mn::device::basic_wifi | |
| basic_wifi (const interface_t &type) | |
| Construct this object. More... | |
| virtual | ~basic_wifi () |
Public Member Functions inherited from mn::device::basic_wifi_net_if | |
| basic_wifi_net_if (const esp_interface_t &type) noexcept | |
| Construt. More... | |
| virtual bool | create_default (void) |
| Set the hostname. More... | |
| esp_interface_t & | get (void) |
| get the type of the interface More... | |
| const char * | get_hostname (void) |
| Get interface hostname. More... | |
| wifi_mode_t | get_mode (void) |
| Get current operating mode of WiFi. More... | |
| const char * | get_ssid (char ssid[32]) |
| Get the ssid for the wifi. More... | |
| wifi_protocol | get_protocol () |
| Get the current protocol bitmap. More... | |
| wifi_ps_type_t | get_power_save_mode () |
| Get current WiFi power save type. More... | |
| int | set_power_save_mode (const wifi_ps_type_t mode) |
| Set current WiFi power save type. More... | |
| int | set_protocol (const wifi_protocol &prot=wifi_protocol::bgn) |
| Set protocol type of specified interface The default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N) More... | |
Public Member Functions inherited from mn::device::basic_net_if | |
| basic_net_if () | |
| basic_net_if (const basic_net_if &other) | |
| basic_net_if & | operator= (const basic_net_if &other) |
| int | set_mac (uint8_t mac[6]) |
| Set the mac address for the interface instance. More... | |
| esp_err_t | get_mac (uint8_t mac[6]) |
| Get the mac address for the interface instance. More... | |
| const char * | get_hostname () |
| Get the hostname of an interface. More... | |
| bool | set_hostname (const char *hostname) |
| Set the hostname of an interface. More... | |
| bool | is_up () |
| Test if supplied interface is up. More... | |
| int | get_impl_name (char name[6]) |
| Get net interface name from network stack implementation. More... | |
| int | get_impl_index () |
| Get net interface index from network stack implementation. More... | |
| virtual esp_netif_t * | get_netif () |
| Get the Handle to esp-netif instance. More... | |
| virtual esp_netif_config_t * | get_config () |
| Get the config of the esp-netif instance. More... | |
| int | get_ip_infos (ip_info_t &ip_info) |
| Get interface's IP address information. More... | |
| int | set_ip_infos (const ip_info_t &ip_info) |
| Set interface's IP address information. More... | |
| operator bool () | |
| operator esp_netif_t * () | |
| bool | operator== (const basic_net_if &other) |
| bool | operator!= (const basic_net_if &other) |
| bool | operator== (const esp_netif_t *other) |
| bool | operator!= (const esp_netif_t *other) |
Public Member Functions inherited from mn::device::basic_network_device | |
| basic_network_device () | |
| basic_network_device (char prefix[8]) | |
Public Member Functions inherited from mn::device::basic_device | |
| basic_device (char prefix[8]) | |
| const char * | get_prefix () |
Protected Member Functions | |
| tcpip_adapter_ip_info_t | get_ip_infos () |
| Get interface's IP address information. More... | |
| virtual void | on_wifi_event (esp_event_base_t event_base, int32_t event_id, void *event_data) override |
| The basic wife event handler. More... | |
| virtual void | on_start (esp_event_base_t event_base, void *event_data) |
| Call on WIFI_EVENT_AP_START event. More... | |
| virtual void | on_stop (esp_event_base_t event_base, void *event_data) |
| Call on WIFI_EVENT_AP_STOP event. More... | |
| virtual void | on_connected (esp_event_base_t event_base, void *event_data) |
| Call on WIFI_EVENT_AP_STACONNECTED event. More... | |
| virtual void | on_disconnected (esp_event_base_t event_base, void *event_data) |
| Call on WIFI_EVENT_AP_STADISCONNECTED event. More... | |
| virtual void | on_probereqrec (esp_event_base_t event_base, void *event_data) |
| Call on WIFI_EVENT_AP_PROBEREQRECVED event. More... | |
Protected Member Functions inherited from mn::device::basic_wifi | |
| int | startup (wifi_init_config_t *cfg, wifi_storage_t storage=WIFI_STORAGE_RAM) |
| start the wifi system and set the config. More... | |
| int | unregist () |
| Deregister the wifi_event and ip_event. More... | |
| virtual void | on_ip_event (esp_event_base_t event_base, int32_t event_id, void *event_data) |
Private Types | |
| using | base_type = basic_wifi |
Additional Inherited Members | |
Static Public Member Functions inherited from mn::device::basic_net_if | |
| 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... | |
Protected Attributes inherited from mn::device::basic_wifi | |
| mn::event_group_t | m_eGroup |
Protected Attributes inherited from mn::device::basic_wifi_net_if | |
| esp_interface_t | m_ifInterface |
| NET_IF intarface of the device. More... | |
Protected Attributes inherited from mn::device::basic_net_if | |
| esp_netif_config_t * | m_ifConfig |
| esp_netif_t * | m_pNetIf |
Protected Attributes inherited from mn::device::basic_device | |
| const char * | m_prefix |
Detailed Description
Wifi AP class for the esp32.
Member Typedef Documentation
◆ auth_mode_t
| using mn::device::basic_wifi_ap::auth_mode_t = typename base_type::auth_mode |
◆ base_type
|
private |
◆ interface_t
| using mn::device::basic_wifi_ap::interface_t = typename base_type::wifi_interface_type |
◆ ip4_adress_t
Constructor & Destructor Documentation
◆ basic_wifi_ap() [1/2]
|
inline |
Construct the wifi ap object.
◆ ~basic_wifi_ap()
|
inline |
Basic destructor, stopped the Wifi.
◆ basic_wifi_ap() [2/2]
|
delete |
Member Function Documentation
◆ get_broadcast()
|
virtual |
Get the broadcast IP address,.
- Returns
- The broadcast IP address or MNNET_IPV4_ADDRESS_NONE on error.
◆ get_connected()
|
virtual |
Get the number of connected stations.
- Precondition
- start
- Returns
- The number of connected stations.
◆ get_gateway()
|
virtual |
Get the gateway IP address,.
- Returns
- The gateway IP address or MNNET_IPV4_ADDRESS_NONE on error.
◆ get_hostname()
|
virtual |
Get the hostname.
- Precondition
- start
- Returns
- The hostname, on error then return nullptr.
◆ get_ip()
|
virtual |
Get Tte IPv4 address of the WiFi AP device.
- Returns
- The IP address or MNNET_IPV4_ADDRESS_NONE on error.
◆ get_ip_infos()
|
protected |
Get interface's IP address information.
- Returns
- IP information.
- Note
- If the interface is up, IP information is read directly from the TCP/IP stack and if down then read from a copy kept in the TCP/IP adapter library itself.
◆ get_ipinfo()
|
inlineoverridevirtual |
Get IPv4 infos, local ip, gateway and subnet.
- Returns
- If true then get all address and false if not.
Implements mn::device::basic_network_device.
◆ get_mac() [1/2]
|
virtual |
Get the MAC of the WiFi AP device as string.
- Precondition
- start
- Returns
- The MAC of the WiFi AP device as string, on error return nullptr.
Implements mn::device::basic_network_device.
◆ get_mac() [2/2]
|
virtual |
Get the MAC of the WiFi AP device.
- Precondition
- start
- Parameters
-
[out] mac The MAC of the WiFi AP device.
- Returns
- the MAC of the WiFi AP device, on error then return nullptr.
◆ get_netmask()
|
virtual |
Get the netmask IP address,.
- Returns
- The netmask IP address or MNNET_IPV4_ADDRESS_NONE on error.
◆ is_enable()
|
inlineoverridevirtual |
Implements mn::device::basic_device.
◆ is_stream_support()
|
inlineoverridevirtual |
Implements mn::device::basic_device.
◆ on_connected()
|
inlineprotectedvirtual |
Call on WIFI_EVENT_AP_STACONNECTED event.
◆ on_disconnected()
|
inlineprotectedvirtual |
Call on WIFI_EVENT_AP_STADISCONNECTED event.
◆ on_probereqrec()
|
inlineprotectedvirtual |
Call on WIFI_EVENT_AP_PROBEREQRECVED event.
◆ on_start()
|
inlineprotectedvirtual |
Call on WIFI_EVENT_AP_START event.
◆ on_stop()
|
inlineprotectedvirtual |
Call on WIFI_EVENT_AP_STOP event.
◆ on_wifi_event()
|
overrideprotectedvirtual |
The basic wife event handler.
Reimplemented from mn::device::basic_wifi.
◆ open()
|
inlineoverridevirtual |
◆ operator const char *()
|
inline |
- Returns
- The hostname of the WiFi AP device.
◆ operator ip4_adress_t()
|
inline |
- Returns
- The IPv4 address of the WiFi AP device.
◆ operator uint32_t()
|
inline |
- Returns
- The number of connected stations.
◆ operator=()
|
delete |
◆ set_hostname()
|
virtual |
Set the hostname, only work when wifi are started.
- Precondition
- start
- Returns
- If true then set the hostname and false on error.
◆ set_ipinfo()
|
virtual |
Set IPv4 infos, local ip, gateway and subnet.
- Returns
- If true then set all address and false if not.
Implements mn::device::basic_network_device.
◆ start()
| int mn::device::basic_wifi_ap::start | ( | const char * | ssid, |
| auth_mode_t | mode = auth_mode_t::Open, |
||
| const char * | passphrase = "", |
||
| bool | storeCfgToFlash = false, |
||
| bool | ipv6 = false, |
||
| int | channel = 13, |
||
| bool | ssid_hidden = false, |
||
| int | max_connection = 4 |
||
| ) |
- Parameters
-
ssid The ssid for the wifi (min lenght 8) mode authenticate mode. passphrase The password for the wifi, only use when mode not 'auth_mode_t::Open' is. storeCfgToFlash If true then store the config to memory and nvs. ipv6 When true then enable IPv6 after wifi creating. channel channel of target AP. ssid_hidden Broadcast SSID or not, default true, broadcast the SSID. max_connection Max number of stations allowed to connect in, default 4, max 10.
- Returns
- ERR_MN_WIFI_SSID: SSID is invalid
- ERR_MN_WIFI_PASSWORD: Password is to short.
- ERR_MN_WIFI_NOT_INIT: WiFi is not initialized.
- ERR_MNTHREAD_INVALID_ARG: invalid argument.
- ERR_MN_WIFI_IF: invalid interface.
- ERR_MN_WIFI_MODE: invalid mode.
- ERR_MN_WIFI_NVS: WiFi internal NVS error.
- ERR_MNTHREAD_OUTOFMEM: out of memory.
- ERR_MN_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong.
- ERR_MN_WIFI_OK: No error.
◆ stop() [1/2]
|
inlineoverridevirtual |
Closes device.
- Precondition
- Device is opened.
- Returns
- 0 on success, error code otherwise
Implements mn::device::basic_device.
◆ stop() [2/2]
|
overridevirtual |
- Returns
Reimplemented from mn::device::basic_wifi.
The documentation for this class was generated from the following files: