-
Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Copy pathWiFiAP.h
108 lines (77 loc) · 4.02 KB
/
WiFiAP.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
ESP8266WiFiAP.h - esp8266 Wifi support.
Based on WiFi.h from Arduino WiFi shield library.
Copyright (c) 2011-2014 Arduino. All right reserved.
Modified by Ivan Grokhotkov, December 2014
Reworked by Markus Sattler, December 2015
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#include "soc/soc_caps.h"
#if SOC_WIFI_SUPPORTED
#include "esp_wifi_types.h"
#include "WiFiType.h"
#include "WiFiGeneric.h"
#define WIFI_AP_DEFAULT_AUTH_MODE WIFI_AUTH_WPA2_PSK
#define WIFI_AP_DEFAULT_CIPHER WIFI_CIPHER_TYPE_CCMP // Disable by default enabled insecure TKIP and use just CCMP.
// ----------------------------------------------------------------------------------------------
// ------------------------------------ NEW AP Implementation ----------------------------------
// ----------------------------------------------------------------------------------------------
class APClass: public NetworkInterface {
public:
APClass();
~APClass();
bool begin();
bool end();
bool create(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4, bool ftm_responder = false, wifi_auth_mode_t auth_mode = WIFI_AP_DEFAULT_AUTH_MODE, wifi_cipher_type_t cipher = WIFI_AP_DEFAULT_CIPHER);
bool clear();
bool bandwidth(wifi_bandwidth_t bandwidth);
String SSID(void) const;
uint8_t stationCount();
void _onApEvent(int32_t event_id, void* event_data);
protected:
size_t printDriverInfo(Print & out) const;
friend class WiFiGenericClass;
bool onEnable();
bool onDisable();
};
// ----------------------------------------------------------------------------------------------
// ------------------------------- OLD AP API (compatibility) ----------------------------------
// ----------------------------------------------------------------------------------------------
class WiFiAPClass
{
public:
APClass AP;
bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4, bool ftm_responder = false, wifi_auth_mode_t auth_mode = WIFI_AP_DEFAULT_AUTH_MODE, wifi_cipher_type_t cipher = WIFI_AP_DEFAULT_CIPHER);
bool softAP(const String& ssid, const String& passphrase = emptyString, int channel = 1, int ssid_hidden = 0, int max_connection = 4, bool ftm_responder = false, wifi_auth_mode_t auth_mode = WIFI_AP_DEFAULT_AUTH_MODE, wifi_cipher_type_t cipher = WIFI_AP_DEFAULT_CIPHER) {
return softAP(ssid.c_str(), passphrase.c_str(), channel, ssid_hidden, max_connection, ftm_responder, auth_mode, cipher);
}
bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dhcp_lease_start = (uint32_t) 0);
bool softAPdisconnect(bool wifioff = false);
bool softAPbandwidth(wifi_bandwidth_t bandwidth);
uint8_t softAPgetStationNum();
String softAPSSID(void) const;
IPAddress softAPIP();
IPAddress softAPBroadcastIP();
IPAddress softAPNetworkID();
IPAddress softAPSubnetMask();
uint8_t softAPSubnetCIDR();
bool softAPenableIPv6(bool enable=true);
IPAddress softAPlinkLocalIPv6();
const char * softAPgetHostname();
bool softAPsetHostname(const char * hostname);
uint8_t* softAPmacAddress(uint8_t* mac);
String softAPmacAddress(void);
protected:
};
#endif /* SOC_WIFI_SUPPORTED*/