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
|
||||
|
||||
# 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";
|
16
src/main.cpp
16
src/main.cpp
|
@ -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;
|
||||
|
@ -52,10 +52,22 @@ void setup()
|
|||
}
|
||||
|
||||
// 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);
|
||||
|
|
Loading…
Reference in a new issue