forked from arduino/ArduinoCore-renesas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWiFi.h
295 lines (227 loc) · 7.25 KB
/
WiFi.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#ifndef ARDUINO_WiFi_S3_H
#define ARDUINO_WiFi_S3_H
#include <vector>
#include "WiFiCommands.h"
#include "WiFiTypes.h"
#include "Modem.h"
#include "WiFiClient.h"
#include "WiFiServer.h"
#include "WiFiUdp.h"
#include "WiFiSSLClient.h"
#define DEFAULT_IP_AP_ADDRESS IPAddress(192,168,4,1)
#define DEFAULT_GW_AP_ADDRESS IPAddress(192,168,1,1)
#define DEFAULT_NM_AP_ADDRESS IPAddress(255,255,255,0)
#define WIFI_FIRMWARE_LATEST_VERSION "0.4.1"
#define WL_MAC_ADDR_LENGTH 6
class CAccessPoint {
public:
std::string ssid;
std::string bssid;
uint8_t uint_bssid[6];
std::string rssi;
std::string channel;
std::string encryption_mode;
};
class CWifi {
private:
void _config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2);
unsigned long _timeout;
std::vector<CAccessPoint> access_points;
std::string ssid;
std::string apssid;
IPAddress ip_ap = DEFAULT_IP_AP_ADDRESS;
IPAddress gw_ap = DEFAULT_GW_AP_ADDRESS;
IPAddress nm_ap = DEFAULT_NM_AP_ADDRESS;
public:
CWifi();
/*
* Get firmware version
*/
static const char* firmwareVersion();
/*
* Start WiFi connection for OPEN networks
* param ssid: Pointer to the SSID string.
*/
int begin(const char* ssid);
/* Start WiFi connection with passphrase
* the most secure supported mode will be automatically selected
*
* param ssid: Pointer to the SSID string.
* param passphrase: Passphrase. Valid characters in a passphrase
* must be between ASCII 32-126 (decimal).
*/
int begin(const char* ssid, const char *passphrase);
/* connect as Access Point with a standard passphrase */
uint8_t beginAP(const char *ssid);
uint8_t beginAP(const char *ssid, uint8_t channel);
uint8_t beginAP(const char *ssid, const char* passphrase);
uint8_t beginAP(const char *ssid, const char* passphrase, uint8_t channel);
/* Change IP configuration settings disabling the DHCP client
*
* param local_ip: Static IP configuration
*/
void config(IPAddress local_ip);
/* Change IP configuration settings disabling the DHCP client
*
* param local_ip: Static IP configuration
* param dns_server: IP configuration for DNS server 1
*/
void config(IPAddress local_ip, IPAddress dns_server);
/* Change IP configuration settings disabling the DHCP client
*
* param local_ip: Static IP configuration
* param dns_server: IP configuration for DNS server 1
* param gateway : Static gateway configuration
*/
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
/* Change IP configuration settings disabling the DHCP client
*
* param local_ip: Static IP configuration
* param dns_server: IP configuration for DNS server 1
* param gateway: Static gateway configuration
* param subnet: Static Subnet mask
*/
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);
/* Change DNS IP configuration
*
* param dns_server1: IP configuration for DNS server 1
*/
void setDNS(IPAddress dns_server1);
/* Change DNS IP configuration
*
* param dns_server1: IP configuration for DNS server 1
* param dns_server2: IP configuration for DNS server 2
*
*/
void setDNS(IPAddress dns_server1, IPAddress dns_server2);
/* Set the hostname used for DHCP requests
*
* param name: hostname to set
*
*/
void setHostname(const char* name);
/*
* Disconnect from the network
*
* return: one value of wl_status_t enum
*/
int disconnect(void);
void end(void);
/*
* Get the interface MAC address.
*
* return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
*
* the value returned by this function is meaningfull only if called
* afert a begin (both begin or beginAP) or a ScanNetwork function
* otherwise an empty mac address is returned
*/
uint8_t* macAddress(uint8_t* mac);
/*
* Get the interface IP address.
*
* return: IP address value
*/
IPAddress localIP();
/*
* Get the interface subnet mask address.
*
* return: subnet mask address value
*/
IPAddress subnetMask();
/*
* Get the gateway IP address.
*
* return: gateway IP address value
*/
IPAddress gatewayIP();
IPAddress dnsIP(int n = 0);
/*
* Get the interface the AP IP address.
*
* return: IP address value
*/
IPAddress softAPIP();
/*
* Return the current SSID associated with the network
*
* return: ssid string
*/
const char* SSID();
/*
* Return the current BSSID associated with the network.
*
* return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
*/
uint8_t* BSSID(uint8_t* bssid);
/*
* Return the current RSSI/Received Signal Strength in dBm)
* associated with the network
*
* return: signed value
*/
int32_t RSSI();
/*
* Return the current SSID associated with to the soft AP
*
* return: ssid string
*/
const char* softAPSSID();
/*
* Start scan WiFi networks available
*
* return: Number of discovered networks
*/
int8_t scanNetworks();
/*
* Return the SSID discovered during the network scan.
*
* param networkItem: specify from which network item want to get the information
*
* return: SSID string of the specified item on the networks scanned list
*/
const char* SSID(uint8_t networkItem);
/*
* Return the encryption type of the networks discovered during the scanNetworks
*
* param networkItem: specify from which network item want to get the information
*
* return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
*/
uint8_t encryptionType(uint8_t networkItem);
uint8_t encryptionType();
uint8_t* BSSID(uint8_t networkItem, uint8_t* bssid);
uint8_t channel(uint8_t networkItem);
/*
* Return the RSSI of the networks discovered during the scanNetworks
*
* param networkItem: specify from which network item want to get the information
*
* return: signed value of RSSI of the specified item on the networks scanned list
*/
int32_t RSSI(uint8_t networkItem);
/*
* Return Connection status.
*
* return: one of the value defined in wl_status_t
*/
uint8_t status();
/*
* Return The deauthentication reason code.
*
* return: the deauthentication reason code
*/
uint8_t reasonCode();
/*
* Resolve the given hostname to an IP address.
* param aHostname: Name to be resolved
* param aResult: IPAddress structure to store the returned IP address
* result: 1 if aIPAddrString was successfully converted to an IP address,
* else error code
*/
int hostByName(const char* aHostname, IPAddress& aResult);
unsigned long getTime();
void setTimeout(unsigned long timeout);
};
extern CWifi WiFi;
#endif