forked from ct-Open-Source/Basecamp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWifiControl.hpp
58 lines (48 loc) · 1.43 KB
/
WifiControl.hpp
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
/*
Basecamp - ESP32 library to simplify the basics of IoT projects
Written by Merlin Schumacher (mls@ct.de) for c't magazin für computer technik (https://www.ct.de)
Licensed under GPLv3. See LICENSE for details.
*/
#ifndef WifiControl_h
#define WifiControl_h
#include "debug.hpp"
#include <iomanip>
#include <sstream>
#include <WiFi.h>
#include <WiFiClient.h>
#include <Preferences.h>
class WifiControl {
public:
enum class Mode {
unconfigured,
accessPoint,
client,
};
WifiControl(){};
bool connect();
bool disconnect();
Mode getOperationMode() const;
void begin(String essid, String password = "", String configured = "False",
String hostname = "BasecampDevice", String apSecret="");
IPAddress getIP();
IPAddress getSoftAPIP();
String getAPName();
int status();
static void WiFiEvent(WiFiEvent_t event);
unsigned getMinimumSecretLength() const;
String generateRandomSecret(unsigned length) const;
/*
Returns the MAC Address of the wifi adapter in hexadecimal form, optionally delimited
by a given delimiter which is inserted between every hex-representation.
e.G. getMacAddress(":") would return "aa:bb:cc:..."
*/
String getHardwareMacAddress(const String& delimiter = {});
String getSoftwareMacAddress(const String& delimiter = {});
private:
String _wifiEssid;
String _wifiPassword;
String _ap;
String _wifiAPName;
Mode operationMode_ = Mode::unconfigured;
};
#endif