@@ -29,195 +29,35 @@ extern "C" {
2929}
3030
3131#include " IPAddress.h"
32+
33+ #include " ESP8266WiFiType.h"
34+ #include " ESP8266WiFiSTA.h"
35+ #include " ESP8266WiFiAP.h"
36+ #include " ESP8266WiFiScan.h"
37+ #include " ESP8266WiFiGeneric.h"
38+
3239#include " WiFiClient.h"
3340#include " WiFiServer.h"
3441#include " WiFiClientSecure.h"
3542
36- #define WIFI_SCAN_RUNNING (-1 )
37- #define WIFI_SCAN_FAILED (-2 )
38-
39- // Note:
40- // this enums need to be in sync with the SDK!
41-
42- enum WiFiMode {
43- WIFI_OFF = 0 , WIFI_STA = 1 , WIFI_AP = 2 , WIFI_AP_STA = 3
44- };
45-
46- typedef enum WiFiMode WiFiMode_t;
47-
48- typedef enum {
49- WIFI_PHY_MODE_11B = 1 , WIFI_PHY_MODE_11G = 2 , WIFI_PHY_MODE_11N = 3
50- } WiFiPhyMode_t;
51-
52- typedef enum {
53- WIFI_NONE_SLEEP = 0 , WIFI_LIGHT_SLEEP = 2 , WIFI_MODEM_SLEEP = 3
54- } WiFiSleepType_t;
55-
56- class ESP8266WiFiClass {
57-
58- // ----------------------------------------------------------------------------------------------
59- // -------------------------------------- ESP8266WiFiClass --------------------------------------
60- // ----------------------------------------------------------------------------------------------
61-
62- public:
63-
64- ESP8266WiFiClass ();
65-
66- protected:
67-
68- static void _eventCallback (void *event);
69-
70- // ----------------------------------------------------------------------------------------------
71- // ---------------------------------------- STA function ----------------------------------------
72- // ----------------------------------------------------------------------------------------------
73-
74- public:
75-
76- int begin (const char * ssid, const char *passphrase = NULL , int32_t channel = 0 , const uint8_t * bssid = NULL );
77- int begin (char * ssid, char *passphrase = NULL , int32_t channel = 0 , const uint8_t * bssid = NULL );
78- int begin ();
79-
80- void config (IPAddress local_ip, IPAddress gateway, IPAddress subnet);
81- void config (IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns);
82-
83-
84- bool reconnect ();
85- int disconnect (bool wifioff = false );
86-
87- uint8_t waitForConnectResult ();
88-
89- // STA network info
90- IPAddress localIP ();
91-
92- uint8_t * macAddress (uint8_t * mac);
93- String macAddress (void );
94-
95- IPAddress subnetMask ();
96- IPAddress gatewayIP ();
97- IPAddress dnsIP (uint8_t dns_no = 0 );
98-
99- String hostname (void );
100- bool hostname (char * aHostname);
101- bool hostname (const char * aHostname);
102- bool hostname (String aHostname);
103-
104- // STA WiFi info
105- wl_status_t status ();
106- String SSID () const ;
107- String psk () const ;
108-
109- uint8_t *BSSID (void );
110- String BSSIDstr (void );
111-
112- int32_t RSSI ();
113-
114- protected:
115-
116- bool _useStaticIp;
117-
118- // ----------------------------------------------------------------------------------------------
119- // ----------------------------------------- AP function ----------------------------------------
120- // ----------------------------------------------------------------------------------------------
121-
122- public:
123-
124- void softAP (const char * ssid, const char * passphrase = NULL , int channel = 1 , int ssid_hidden = 0 );
125- void softAPConfig (IPAddress local_ip, IPAddress gateway, IPAddress subnet);
126- int softAPdisconnect (bool wifioff = false );
127-
128- IPAddress softAPIP ();
129-
130- uint8_t * softAPmacAddress (uint8_t * mac);
131- String softAPmacAddress (void );
132-
133- protected:
134-
135- // ----------------------------------------------------------------------------------------------
136- // ----------------------------------------- scan function --------------------------------------
137- // ----------------------------------------------------------------------------------------------
138-
139- public:
140-
141- int8_t scanNetworks (bool async = false , bool show_hidden = false );
142-
143- int8_t scanComplete ();
144- void scanDelete ();
145-
146- // scan result
147- bool getNetworkInfo (uint8_t networkItem, String &ssid, uint8_t &encryptionType, int32_t &RSSI , uint8_t * &BSSID , int32_t &channel, bool &isHidden);
148-
149- String SSID (uint8_t networkItem);
150- uint8_t encryptionType (uint8_t networkItem);
151- int32_t RSSI (uint8_t networkItem);
152- uint8_t * BSSID (uint8_t networkItem);
153- String BSSIDstr (uint8_t networkItem);
154- int32_t channel (uint8_t networkItem);
155- bool isHidden (uint8_t networkItem);
156-
157- protected:
158-
159- static bool _scanAsync;
160- static bool _scanStarted;
161- static bool _scanComplete;
162-
163- static size_t _scanCount;
164- static void * _scanResult;
165-
166- static void _scanDone (void * result, int status);
167- void * _getScanInfoByIndex (int i);
168-
169- // ----------------------------------------------------------------------------------------------
170- // -------------------------------------- Generic WiFi function ---------------------------------
171- // ----------------------------------------------------------------------------------------------
172-
173- public:
174-
175- int32_t channel (void );
176-
177- bool setSleepMode (WiFiSleepType_t type);
178- WiFiSleepType_t getSleepMode ();
179-
180- bool setPhyMode (WiFiPhyMode_t mode);
181- WiFiPhyMode_t getPhyMode ();
182-
183- void persistent (bool persistent);
184-
185- bool mode (WiFiMode_t);
186- WiFiMode_t getMode ();
187-
188- bool enableSTA (bool enable);
189- bool enableAP (bool enable);
190-
191- protected:
192- bool _persistent;
193-
194- // ----------------------------------------------------------------------------------------------
195- // ------------------------------------ Generic Network function --------------------------------
196- // ----------------------------------------------------------------------------------------------
197-
43+ class ESP8266WiFiClass : public ESP8266WiFiGenericClass , public ESP8266WiFiSTAClass , public ESP8266WiFiScanClass , public ESP8266WiFiAPClass {
19844 public:
19945
200- int hostByName (const char * aHostname, IPAddress& aResult);
201-
202- protected:
203-
204- // ----------------------------------------------------------------------------------------------
205- // ------------------------------------ STA remote configure -----------------------------------
206- // ----------------------------------------------------------------------------------------------
207-
208- public:
209-
210- bool beginWPSConfig (void );
211-
212- void beginSmartConfig ();
213- bool smartConfigDone ();
214- void stopSmartConfig ();
215-
216- protected:
217-
218- bool _smartConfigStarted;
219- bool _smartConfigDone;
220- static void _smartConfigCallback (uint32_t status, void * result);
46+ // workaround same function name with different signature
47+ using ESP8266WiFiGenericClass::channel;
48+
49+ using ESP8266WiFiSTAClass::SSID ;
50+ using ESP8266WiFiSTAClass::RSSI ;
51+ using ESP8266WiFiSTAClass::BSSID ;
52+ using ESP8266WiFiSTAClass::BSSIDstr;
53+
54+ using ESP8266WiFiScanClass::SSID ;
55+ using ESP8266WiFiScanClass::encryptionType;
56+ using ESP8266WiFiScanClass::RSSI ;
57+ using ESP8266WiFiScanClass::BSSID ;
58+ using ESP8266WiFiScanClass::BSSIDstr;
59+ using ESP8266WiFiScanClass::channel;
60+ using ESP8266WiFiScanClass::isHidden;
22161
22262 // ----------------------------------------------------------------------------------------------
22363 // ------------------------------------------- Debug --------------------------------------------
0 commit comments