From dcf5ca9e62bb424d704a32a71edee670d9721194 Mon Sep 17 00:00:00 2001 From: Scott Raymond Date: Fri, 12 May 2023 17:32:17 +0000 Subject: [PATCH] Consolidate wifi configuration near top of main.cpp, rename variables to reduce jargon and ambiguity --- src/main.cpp | 27 ++++++++++++++------------- src/network_credentials.h | 2 -- 2 files changed, 14 insertions(+), 15 deletions(-) delete mode 100644 src/network_credentials.h diff --git a/src/main.cpp b/src/main.cpp index c19ecf7..07d478c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,10 +34,15 @@ float linear_turn_fudge = 1.0; float linear_motion_fudge = 1.0; bool wheels_forward = true; -// Set these to your desired credentials. -bool use_wifi = false; -const char *ssid = "silly-bobcat"; -const char *password = (char *)NULL; +// Either connect to your existing wifi network... +bool use_wifi = true; +const char *wifi_name = "YOUR WIFI NETWORK NAME"; +const char *wifi_password = "YOUR WIFI PASSWORD"; + +// ...or create a wifi hotspot +const char *hotspot_name = "silly-bobcat"; +const char *hotspot_password = (char *)NULL; + // primitive motion plan parsing/interpreting #define MAX_PLAN_LEN 1024 @@ -532,10 +537,6 @@ void addAllFiles() } } -// Replace with your network credentials -#include "network_credentials.h" -// const char* network_ssid = "YOUR SSID"; -// const char* network_password = "YOUR PASSWORD"; void setup() { @@ -565,9 +566,9 @@ void setup() // try connecting to the wifi network if (use_wifi) { WiFi.mode(WIFI_STA); - WiFi.begin(network_ssid, network_password); + WiFi.begin(wifi_name, wifi_password); Serial.print("Connecting to "); - Serial.print(network_ssid); + Serial.print(wifi_name); Serial.print(" "); for(int i=0; i<20; i++) { @@ -583,8 +584,8 @@ void setup() Serial.println(" --> connected."); } if (!use_wifi || (WiFi.status() != WL_CONNECTED)){ - Serial.println("Configuring access point..."); - WiFi.softAP(ssid); + Serial.println("Configuring hotspot..."); + WiFi.softAP(hotspot_name); IPAddress myIP = WiFi.softAPIP(); // WiFi.softAPsetHostname(hostname); Serial.print("AP IP address: "); @@ -594,7 +595,7 @@ void setup() Serial.println(WiFi.localIP()); } // mdns_init(); - // mdns_hostname_set(ssid); + // mdns_hostname_set(hotspot_name); Serial.println("Configuring server..."); // dynamic pages diff --git a/src/network_credentials.h b/src/network_credentials.h deleted file mode 100644 index 733713a..0000000 --- a/src/network_credentials.h +++ /dev/null @@ -1,2 +0,0 @@ -const char* network_ssid = "BWX-Faculty"; -const char* network_password = "BWXaccessSTAR*"; \ No newline at end of file