/*
Copyright (c):
Philipp Matthias Schäfer (philipp.matthias.schaefer@posteo.de), 2020
This file is part of the KrautStatus' Arduino code.
The Clean CommonMark library is free software: you can redistribute it and/or
modify it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Clean CommonMark 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 Affero General Public License
for more details.
You should have received a copy of the GNU Affero General Public License along
with the Clean CommonMark library. If not, see .
*/
#include
#include
#include
#include "config.h"
WiFiUDP Udp;
void print_mac_address() {
uint8_t mac[6];
WiFi.macAddress(mac);
Serial.print("MAC: ");
for(unsigned int i = 5; i > 0; --i) {
Serial.print(mac[i], HEX);
Serial.print(":");
}
Serial.println(mac[0], HEX);
}
boolean wifi_setup() {
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("No WiFI shield present");
return false;
}
print_mac_address();
while (true) {
Serial.print("Connecting to SSID: ");
Serial.println(SSID);
if (WiFi.begin(SSID, PASSWORD) == WL_CONNECTED) {
break;
}
delay(10000);
}
Serial.println("Connect to WiFi");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
Udp.begin(SERVER_PORT);
return true;
}