17 Network::Network(String ssid, String password,
int WIFI_CS,
int WIFI_IRQ,
int WIFI_RST,
int WIFI_EN) : pSsid(ssid),
26 DBFUNCCALLln(
"Network::init()");
28 if (WiFi.status() == WL_NO_SHIELD) {
29 DBERROR(
"NO WiFi shield present");
30 DBERROR(
"WiFi Library could not find WiFi shield. " +
decodeWiFistate(WiFi.status()));
31 DBINFO3ln(
"programm is not continuing");
36 DBINFO3ln(String(
"WiFi Firmware Version = ") + String(WiFi.firmwareVersion()));
41 DBFUNCCALLln(
"Network::connectToWiFi()");
42 while (WiFi.status() != WL_CONNECTED) {
44 DBINFO3ln(
"Attempting WLAN connection (WEP)...");
45 DBINFO3ln(
"SSID: " +
pSsid);
48 DBERROR(
"WLAN connection failed");
49 DBINFO3ln(
"trying again in 3 seconds");
53 WiFi.macAddress(
pMac);
55 WiFi.macAddress(
pMac);
65 DBFUNCCALLln(
"Network::printNetworkInfo()");
73 DBFUNCCALLln(
"Network::printWiFiData()");
76 Serial.print(
"IP Address: ");
80 WiFi.macAddress(
pMac);
81 Serial.print(
"MAC address: ");
86 DBFUNCCALLln(
"Network::printCurrentNet()");
88 Serial.print(
"SSID: ");
89 Serial.println(WiFi.SSID());
92 Serial.print(
"BSSID: ");
96 Serial.print(
"signal strength (RSSI):");
97 Serial.println(
pRssi);
100 Serial.print(
"Encryption Type: ");
106 for (
int i = 5; i >= 0; i--) {
110 Serial.print(mac[i], HEX);
119 DBFUNCCALLln(
"Network::decodeWiFistate(int errorcode)");
122 return "WL_NO_SHIELD";
124 return "WL_IDLE_STATUS";
125 case WL_NO_SSID_AVAIL:
126 return "WL_NO_SSID_AVAIL";
127 case WL_SCAN_COMPLETED:
128 return "WL_SCAN_COMPLETED";
130 return "WL_CONNECTED";
131 case WL_CONNECT_FAILED:
132 return "WL_CONNECT_FAILED";
133 case WL_CONNECTION_LOST:
134 return "WL_CONNECTION_LOST";
135 case WL_DISCONNECTED:
136 return "WL_DISCONNECTED";
137 case WL_AP_LISTENING:
138 return "WL_AP_LISTENING";
139 case WL_AP_CONNECTED:
140 return "WL_AP_CONNECTED";
142 return "WL_AP_FAILED";
143 case WL_PROVISIONING:
144 return "WL_PROVISIONING";
145 case WL_PROVISIONING_FAILED:
146 return "WL_PROVISIONING_FAILED";
153 DBFUNCCALLln(
"Network::decodeEncryptionType(int errorcode)");
The Network class establishes a WLAN-Connection.
void printMacAddress(byte mac[])
Pritns Mac-address.
void connectToWiFi()
Connects to a WiFi with the given Credential.
void printNetworkInfo()
Prints all relevant Network-Information of the connected network to serial.
byte pEncryption
value represents the type of encryption
byte pMacRouter[6]
Contains MAC Adress of the Router BSSID.
Network(String ssid, String password, int WIFI_CS, int WIFI_IRQ, int WIFI_RST, int WIFI_EN)
Construct a new Network object.
IPAddress pIPLocal
Contains own IP-Adress.
long pRssi
The current RSSI /Received Signal Strength in dBm.
String decodeWiFistate(int errorcode)
Decodes the Error Values from Wifi status() and returns a description.
void printCurrentNet()
Prints all relevant Information of the current Network.
void init()
Intitialize WLan-Hardware.
void printWiFiData()
Prints all relevant WiFi-Information of the connected network to serial.
String decodeEncryptionType(int errorcode)
Construct a new decode Encryption Type object.
String pPassword
Contains WiFi Password.
String pSsid
Contains the SSID the WiFi shield is currently connected to.
byte pMac[6]
Contains own MAC Adress.