mn_wifi.hpp
Go to the documentation of this file.
1 
21 #ifndef __MINILIB_NET_BASIC_WIFI_H__
22 #define __MINILIB_NET_BASIC_WIFI_H__
23 
24 #include "../mn_config.hpp"
25 
26 
27 #include <esp_err.h>
28 #include <esp_event.h>
29 #include <string>
30 #include <string.h>
31 
32 #include "mn_basic_wifi_net_if.hpp"
33 #include "mn_network_device.hpp"
34 
35 #include "../mn_eventgroup.hpp"
36 
37 
38 namespace mn {
39  namespace device {
43  class basic_wifi : public basic_wifi_net_if {
44  public:
48  enum class auth_mode : int {
49  Open = WIFI_AUTH_OPEN,
50  WEP = WIFI_AUTH_WEP,
51  WPA_PSK = WIFI_AUTH_WPA_PSK,
52  WPA2_PSK = WIFI_AUTH_WPA2_PSK,
53  //WPA3_PSK = WIFI_AUTH_WPA3_PSK, /**< authenticate mode : open */
54  //WPA2_WPA3_PSK = WIFI_AUTH_WPA2_WPA3_PSK,/**< authenticate mode : open */
55  WPA_WPA2_PSK = WIFI_AUTH_WPA_WPA2_PSK,
56  WPA2_ENTERPRISE = WIFI_AUTH_WPA2_ENTERPRISE
57  };
58 
59  enum class wifi_interface_type {
60  Station = 0,
61  Acesspoint = 1,
62  };
65 
70  basic_wifi(const interface_t& type);
71  virtual ~basic_wifi();
72 
73  virtual bool stop(bool wifioff) { return true; }
74  protected:
88  int startup(wifi_init_config_t* cfg, wifi_storage_t storage = WIFI_STORAGE_RAM);
95  int unregist();
96 
97  virtual void on_wifi_event(esp_event_base_t event_base, int32_t event_id, void* event_data) { return; }
98  virtual void on_ip_event(esp_event_base_t event_base, int32_t event_id, void* event_data) { return; }
99  private:
100  static void _wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
101  static void _ip_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
102  protected:
104  };
105  }
106 }
107 
108 #endif // __MINILIB_NET_BASIC_WIFI_H__
Wrapper class around FreeRTOS's implementation of a event_group.
Definition: mn_eventgroup.hpp:35
Wrapper basic WiFi class around esp-idf implementation of a esp-netif device.
Definition: mn_basic_wifi_net_if.hpp:40
A basic class for wifi.
Definition: mn_wifi.hpp:43
virtual bool stop(bool wifioff)
Definition: mn_wifi.hpp:73
int startup(wifi_init_config_t *cfg, wifi_storage_t storage=WIFI_STORAGE_RAM)
start the wifi system and set the config.
Definition: mn_wifi.cpp:53
virtual void on_wifi_event(esp_event_base_t event_base, int32_t event_id, void *event_data)
Definition: mn_wifi.hpp:97
virtual void on_ip_event(esp_event_base_t event_base, int32_t event_id, void *event_data)
Definition: mn_wifi.hpp:98
basic_wifi(const interface_t &type)
Construct this object.
Definition: mn_wifi.cpp:37
static void _wifi_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
Definition: mn_wifi.cpp:98
int unregist()
Deregister the wifi_event and ip_event.
Definition: mn_wifi.cpp:86
auth_mode
Authenticate modes.
Definition: mn_wifi.hpp:48
mn::event_group_t m_eGroup
Definition: mn_wifi.hpp:103
static void _ip_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
Definition: mn_wifi.cpp:108
wifi_interface_type
Definition: mn_wifi.hpp:59
virtual ~basic_wifi()
Definition: mn_wifi.cpp:46
This file is part of the Mini Thread Library (https://github.com/RoseLeBlood/MiniThread ).
struct mn::memory::detail::ptr_difference type
Definition: mn_allocator_typetraits.hpp:25