mn_basic_wifi_net_if.hpp
Go to the documentation of this file.
1 /*
2 *This file is part of the Mini Thread Library (https://github.com/RoseLeBlood/MiniThread ).
3 *Copyright (c) 2018 Amber-Sophia Schroeck
4 *
5 *The Mini Thread Library is free software; you can redistribute it and/or modify
6 *it under the terms of the GNU Lesser General Public License as published by
7 *the Free Software Foundation, version 3, or (at your option) any later version.
8 
9 *The Mini Thread Library is distributed in the hope that it will be useful, but
10 *WITHOUT ANY WARRANTY; without even the implied warranty of
11 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 *General Public License for more details.
13 *
14 *You should have received a copy of the GNU Lesser General Public
15 *License along with the Mini Thread Library; if not, see
16 *<https://www.gnu.org/licenses/>.
17 */
18 #ifndef __MINILIB_BASIC_WIFI_NET_IF_H__
19 #define __MINILIB_BASIC_WIFI_NET_IF_H__
20 
21 #include "../mn_config.hpp"
22 #include "mn_basic_netif.hpp"
23 
24 #include <esp_eth.h>
25 #include <esp_wifi.h>
26 #include <esp_system.h>
27 #include <esp_event.h>
28 #include <esp_log.h>
29 
30 
31 #include <cstring>
32 
33 namespace mn {
34  namespace device {
41  public:
45  enum class wifi_protocol : uint8_t {
46  none = 0,
47 
48  b = WIFI_PROTOCOL_11B,
49  g = WIFI_PROTOCOL_11G,
50  n = WIFI_PROTOCOL_11N,
51  bg = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G,
52  bgn = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N,
53  lr = WIFI_PROTOCOL_LR,
54  };
59  basic_wifi_net_if(const esp_interface_t& type) noexcept;
60 
66  virtual bool create_default(void);
67 
72  esp_interface_t& get(void);
77  const char* get_hostname(void);
82  wifi_mode_t get_mode(void);
88  const char* get_ssid(char ssid[32]);
89 
101  wifi_ps_type_t get_power_save_mode();
102 
103 
110  int set_power_save_mode(const wifi_ps_type_t mode);
123  int set_protocol(const wifi_protocol& prot = wifi_protocol::bgn);
124 
125 
126  protected:
130  esp_interface_t m_ifInterface;
131  };
132  }
133 }
134 
135 #endif // __MINILIB_BASIC_WIFI_NET_IF_H__
Wrapper class around esp-idf implementation of a esp-netif device.
Definition: mn_basic_netif.hpp:33
Wrapper basic WiFi class around esp-idf implementation of a esp-netif device.
Definition: mn_basic_wifi_net_if.hpp:40
virtual bool create_default(void)
Set the hostname.
Definition: mn_basic_wifi_net_if.cpp:35
wifi_protocol
list of the wifi protocols
Definition: mn_basic_wifi_net_if.hpp:45
esp_interface_t m_ifInterface
NET_IF intarface of the device.
Definition: mn_basic_wifi_net_if.hpp:130
wifi_ps_type_t get_power_save_mode()
Get current WiFi power save type.
Definition: mn_basic_wifi_net_if.cpp:84
const char * get_hostname(void)
Get interface hostname.
const char * get_ssid(char ssid[32])
Get the ssid for the wifi.
Definition: mn_basic_wifi_net_if.cpp:47
esp_interface_t & get(void)
get the type of the interface
Definition: mn_basic_wifi_net_if.cpp:70
basic_wifi_net_if(const esp_interface_t &type) noexcept
Construt.
Definition: mn_basic_wifi_net_if.cpp:29
wifi_mode_t get_mode(void)
Get current operating mode of WiFi.
Definition: mn_basic_wifi_net_if.cpp:63
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...
Definition: mn_basic_wifi_net_if.cpp:93
wifi_protocol get_protocol()
Get the current protocol bitmap.
Definition: mn_basic_wifi_net_if.cpp:115
int set_power_save_mode(const wifi_ps_type_t mode)
Set current WiFi power save type.
Definition: mn_basic_wifi_net_if.cpp:77
struct mn::memory::detail::ptr_difference type
Definition: mn_allocator_typetraits.hpp:25