- Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Copy pathWiFiGeneric.h
154 lines (122 loc) · 4.8 KB
/
WiFiGeneric.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
ESP8266WiFiGeneric.h - esp8266 Wifi support.
Based on WiFi.h from Ardiono 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"
#include"sdkconfig.h"
#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED
#include"esp_err.h"
#include"esp_event.h"
#include<functional>
#include"WiFiType.h"
#include"IPAddress.h"
#include"esp_smartconfig.h"
#include"esp_netif_types.h"
#if CONFIG_ETH_ENABLED
#include"esp_eth_driver.h"
#endif
#if CONFIG_NETWORK_PROV_NETWORK_TYPE_WIFI
#include"network_provisioning/manager.h"
#endif
#include"lwip/ip_addr.h"
#include"Network.h"
#defineWiFiEventCb NetworkEventCb
#defineWiFiEventFuncCb NetworkEventFuncCb
#defineWiFiEventSysCb NetworkEventSysCb
#definewifi_event_id_tnetwork_event_handle_t
typedefenum {
WIFI_POWER_21dBm = 84, // 21dBm
WIFI_POWER_20_5dBm = 82, // 20.5dBm
WIFI_POWER_20dBm = 80, // 20dBm
WIFI_POWER_19_5dBm = 78, // 19.5dBm
WIFI_POWER_19dBm = 76, // 19dBm
WIFI_POWER_18_5dBm = 74, // 18.5dBm
WIFI_POWER_17dBm = 68, // 17dBm
WIFI_POWER_15dBm = 60, // 15dBm
WIFI_POWER_13dBm = 52, // 13dBm
WIFI_POWER_11dBm = 44, // 11dBm
WIFI_POWER_8_5dBm = 34, // 8.5dBm
WIFI_POWER_7dBm = 28, // 7dBm
WIFI_POWER_5dBm = 20, // 5dBm
WIFI_POWER_2dBm = 8, // 2dBm
WIFI_POWER_MINUS_1dBm = -4// -1dBm
} wifi_power_t;
typedefenum {
WIFI_RX_ANT0 = 0,
WIFI_RX_ANT1,
WIFI_RX_ANT_AUTO
} wifi_rx_ant_t;
typedefenum {
WIFI_TX_ANT0 = 0,
WIFI_TX_ANT1,
WIFI_TX_ANT_AUTO
} wifi_tx_ant_t;
classWiFiGenericClass {
public:
WiFiGenericClass();
wifi_event_id_tonEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
wifi_event_id_tonEvent(WiFiEventFuncCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
wifi_event_id_tonEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
voidremoveEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
voidremoveEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
voidremoveEvent(wifi_event_id_t id);
staticintgetStatusBits();
staticintwaitStatusBits(int bits, uint32_t timeout_ms);
int32_tchannel(void);
intsetChannel(uint8_t primary, wifi_second_chan_t secondary = WIFI_SECOND_CHAN_NONE);
voidpersistent(bool persistent);
voidenableLongRange(bool enable);
staticboolmode(wifi_mode_t);
staticwifi_mode_tgetMode();
boolenableSTA(bool enable);
boolenableAP(bool enable);
boolsetSleep(bool enabled);
boolsetSleep(wifi_ps_type_t sleepType);
wifi_ps_type_tgetSleep();
boolsetTxPower(wifi_power_t power);
wifi_power_tgetTxPower();
boolinitiateFTM(uint8_t frm_count = 16, uint16_t burst_period = 2, uint8_t channel = 1, constuint8_t *mac = NULL);
staticboolsetDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2, wifi_rx_ant_t rx_mode, wifi_tx_ant_t tx_mode);
staticconstchar *getHostname();
staticboolsetHostname(constchar *hostname);
staticboolhostname(const String &aHostname) {
returnsetHostname(aHostname.c_str());
}
staticvoiduseStaticBuffers(bool bufferMode);
staticbooluseStaticBuffers();
staticinthostByName(constchar *aHostname, IPAddress &aResult);
static IPAddress calculateNetworkID(IPAddress ip, IPAddress subnet);
static IPAddress calculateBroadcast(IPAddress ip, IPAddress subnet);
staticuint8_tcalculateSubnetCIDR(IPAddress subnetMask);
constchar *disconnectReasonName(wifi_err_reason_t reason);
constchar *eventName(arduino_event_id_t id);
staticvoid_eventCallback(arduino_event_t *event);
protected:
staticbool _persistent;
staticbool _long_range;
staticwifi_mode_t _forceSleepLastMode;
staticwifi_ps_type_t _sleepEnabled;
staticbool _wifiUseStaticBuffers;
staticintsetStatusBits(int bits);
staticintclearStatusBits(int bits);
friendclassWiFiSTAClass;
friendclassWiFiScanClass;
friendclassWiFiAPClass;
friendclassETHClass;
};
#endif/* SOC_WIFI_SUPPORTED */