mirror of
https://github.com/Crocmagnon/buzzer.git
synced 2024-11-21 23:48:07 +01:00
Allow easy switch between AP and station
This commit is contained in:
parent
bebf8b5af3
commit
61c9623f71
3 changed files with 19 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -58,3 +58,4 @@ Temporary Items
|
||||||
.apdisk
|
.apdisk
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/osx
|
# End of https://www.toptal.com/developers/gitignore/api/osx
|
||||||
|
creds.h
|
||||||
|
|
3
src/creds.dist.h
Normal file
3
src/creds.dist.h
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
// Copy to creds.h and edit
|
||||||
|
const char *ssid = "buzzer";
|
||||||
|
const char *password = "123456789";
|
18
src/main.cpp
18
src/main.cpp
|
@ -1,9 +1,9 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
|
#include "creds.h"
|
||||||
|
|
||||||
const char *ssid = "buzzer";
|
// #define B_WIFI_AP
|
||||||
const char *password = "123456789";
|
|
||||||
|
|
||||||
const byte led = 2;
|
const byte led = 2;
|
||||||
bool ledOn = false;
|
bool ledOn = false;
|
||||||
|
@ -51,11 +51,23 @@ void setup()
|
||||||
file = root.openNextFile();
|
file = root.openNextFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wifi
|
// Wifi
|
||||||
|
#ifdef B_WIFI_AP
|
||||||
Serial.println("Setting up AP...");
|
Serial.println("Setting up AP...");
|
||||||
WiFi.softAP(ssid, password);
|
WiFi.softAP(ssid, password);
|
||||||
Serial.print("IP address: ");
|
Serial.print("IP address: ");
|
||||||
Serial.println(WiFi.softAPIP());
|
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
|
||||||
server.on("/play", HTTP_GET, onPlay);
|
server.on("/play", HTTP_GET, onPlay);
|
||||||
|
|
Loading…
Reference in a new issue