mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-05-19 10:32:56 +00:00
implemented switch between wifi station and wifi access point
This commit is contained in:
parent
421ca36e88
commit
03c6c2ab18
1 changed files with 36 additions and 11 deletions
47
src/main.cpp
47
src/main.cpp
|
@ -28,7 +28,7 @@ void setup()
|
||||||
Direction direction1 = static_cast<Direction>(config.getUInt("direction-1", 0));
|
Direction direction1 = static_cast<Direction>(config.getUInt("direction-1", 0));
|
||||||
Direction direction2 = static_cast<Direction>(config.getUInt("direction-2", 1));
|
Direction direction2 = static_cast<Direction>(config.getUInt("direction-2", 1));
|
||||||
|
|
||||||
Connection connection = static_cast<Connection>(config.getUInt("connection", WiFiSta));
|
Connection connection = static_cast<Connection>(config.getUInt("connection", WiFiAP));
|
||||||
IpMethod ipMethod = static_cast<IpMethod>(config.getUInt("ip-method"), Static);
|
IpMethod ipMethod = static_cast<IpMethod>(config.getUInt("ip-method"), Static);
|
||||||
|
|
||||||
String ssid = config.getString("ssid", "artnet");
|
String ssid = config.getString("ssid", "artnet");
|
||||||
|
@ -42,17 +42,42 @@ void setup()
|
||||||
|
|
||||||
config.end();
|
config.end();
|
||||||
|
|
||||||
// WiFi stuff
|
// wait for serial monitor
|
||||||
// WiFi.begin(ssid, pwd);
|
delay(5000);
|
||||||
WiFi.softAP(ssid, pwd);
|
|
||||||
WiFi.softAPConfig(ip, gateway, subnet);
|
switch (connection)
|
||||||
// WiFi.config(ip, gateway, subnet);
|
{
|
||||||
// while (WiFi.status() != WL_CONNECTED) {
|
case WiFiSta:
|
||||||
// Serial.print(".");
|
Serial.println("Initialize as WiFi-Station");
|
||||||
|
WiFi.begin(ssid, pwd);
|
||||||
|
if (ipMethod == Static)
|
||||||
|
{
|
||||||
|
WiFi.config(ip, gateway, subnet);
|
||||||
|
}
|
||||||
|
while (WiFi.status() != WL_CONNECTED)
|
||||||
|
{
|
||||||
|
Serial.print(".");
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
Serial.println("");
|
||||||
|
Serial.print("WiFi connected, IP = ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WiFiAP:
|
||||||
|
Serial.println("Initialize as WiFi-Access-Point");
|
||||||
|
WiFi.softAP(ssid, pwd);
|
||||||
|
WiFi.softAPConfig(ip, gateway, subnet);
|
||||||
|
Serial.print("WiFi AP enabled, IP = ");
|
||||||
|
Serial.println(WiFi.softAPIP());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Ethernet:
|
||||||
|
Serial.print("Not yet implemented");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
delay(500);
|
delay(500);
|
||||||
//}
|
|
||||||
// Serial.print("WiFi connected, IP = ");
|
|
||||||
// Serial.println(WiFi.localIP());
|
|
||||||
|
|
||||||
// Initialize Art-Net
|
// Initialize Art-Net
|
||||||
artnet.begin();
|
artnet.begin();
|
||||||
|
|
Loading…
Add table
Reference in a new issue