Allow easy switch between AP and station

This commit is contained in:
Gabriel Augendre 2023-01-01 01:02:18 +01:00
parent bebf8b5af3
commit 61c9623f71
3 changed files with 19 additions and 3 deletions

1
.gitignore vendored
View file

@ -58,3 +58,4 @@ Temporary Items
.apdisk
# End of https://www.toptal.com/developers/gitignore/api/osx
creds.h

3
src/creds.dist.h Normal file
View file

@ -0,0 +1,3 @@
// Copy to creds.h and edit
const char *ssid = "buzzer";
const char *password = "123456789";

View file

@ -1,9 +1,9 @@
#include <Arduino.h>
#include <ESPAsyncWebServer.h>
#include <SPIFFS.h>
#include "creds.h"
const char *ssid = "buzzer";
const char *password = "123456789";
// #define B_WIFI_AP
const byte led = 2;
bool ledOn = false;
@ -51,11 +51,23 @@ void setup()
file = root.openNextFile();
}
// Wifi
// Wifi
#ifdef B_WIFI_AP
Serial.println("Setting up AP...");
WiFi.softAP(ssid, password);
Serial.print("IP address: ");
Serial.println(WiFi.softAPIP());
#else
Serial.print("Connecting to wifi...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(100);
}
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
#endif
// Server
server.on("/play", HTTP_GET, onPlay);