A basic class for wifi. More...

#include <mn_wifi.hpp>

+ Inheritance diagram for mn::device::basic_wifi:
+ Collaboration diagram for mn::device::basic_wifi:

Public Types

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 Member Functions

 basic_wifi (const interface_t &type)
 Construct this object. More...
 
virtual ~basic_wifi ()
 
virtual bool stop (bool wifioff)
 
- 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_ifoperator= (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)
 

Protected Member Functions

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_wifi_event (esp_event_base_t event_base, int32_t event_id, void *event_data)
 
virtual void on_ip_event (esp_event_base_t event_base, int32_t event_id, void *event_data)
 

Protected Attributes

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
 

Static Private Member Functions

static void _wifi_event_handler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
 
static void _ip_event_handler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
 

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...
 

Detailed Description

A basic class for wifi.

Member Typedef Documentation

◆ auth_mode_t

◆ interface_t

Member Enumeration Documentation

◆ auth_mode

Authenticate modes.

Enumerator
Open 

authenticate mode : open

WEP 

authenticate mode : WEP

WPA_PSK 

authenticate mode : WPA_PSK

WPA2_PSK 

authenticate mode : WPA2_PSK

WPA_WPA2_PSK 

authenticate mode : WPA_WPA2_PSK

WPA2_ENTERPRISE 

authenticate mode : WPA2_ENTERPRISE

◆ wifi_interface_type

Enumerator
Station 

ESP32 station interface

Acesspoint 

ESP32 soft-AP interface

Constructor & Destructor Documentation

◆ basic_wifi()

mn::device::basic_wifi::basic_wifi ( const interface_t type)

Construct this object.

Parameters
typeWhit type of wifi

◆ ~basic_wifi()

mn::device::basic_wifi::~basic_wifi ( )
virtual

Member Function Documentation

◆ _ip_event_handler()

void mn::device::basic_wifi::_ip_event_handler ( void *  arg,
esp_event_base_t  event_base,
int32_t  event_id,
void *  event_data 
)
staticprivate

◆ _wifi_event_handler()

void mn::device::basic_wifi::_wifi_event_handler ( void *  arg,
esp_event_base_t  event_base,
int32_t  event_id,
void *  event_data 
)
staticprivate

◆ on_ip_event()

virtual void mn::device::basic_wifi::on_ip_event ( esp_event_base_t  event_base,
int32_t  event_id,
void *  event_data 
)
inlineprotectedvirtual

◆ on_wifi_event()

virtual void mn::device::basic_wifi::on_wifi_event ( esp_event_base_t  event_base,
int32_t  event_id,
void *  event_data 
)
inlineprotectedvirtual

Reimplemented in mn::device::basic_wifi_ap.

◆ startup()

int mn::device::basic_wifi::startup ( wifi_init_config_t *  cfg,
wifi_storage_t  storage = WIFI_STORAGE_RAM 
)
protected

start the wifi system and set the config.

Parameters
cfgthe wifi config.
storageWhere to save the wifi configurations.
Returns
  • ERR_MN_WIFI_OK: No error.
  • ERR_MN_WIFI_CREATE_NETIF: Can create the netif.
  • ERR_MNTHREAD_OUTOFMEM: Not enoug memory for the wifi sub system.
  • ERR_MN_WIFI_REGISTER_EVENT: Can not set the event handler for WIFI_EVENT & IP_EVENT.
  • ERR_MNTHREAD_INVALID_ARG: An invalid argument (storage).
  • ERR_MN_WIFI_SET_MODE: set the current mode.
  • ERR_MNTHREAD_NULL The argument cfg is nullptr.

◆ stop()

virtual bool mn::device::basic_wifi::stop ( bool  wifioff)
inlinevirtual

Reimplemented in mn::device::basic_wifi_ap.

◆ unregist()

int mn::device::basic_wifi::unregist ( )
protected

Deregister the wifi_event and ip_event.

Returns
  • ERR_MN_WIFI_OK: No error
  • all other: error.

Member Data Documentation

◆ m_eGroup

mn::event_group_t mn::device::basic_wifi::m_eGroup
protected

The documentation for this class was generated from the following files: