Add option to set up for wifi or AP on compile #53
@@ -34,9 +34,19 @@ const int blinker = LED_BUILTIN;
 | 
			
		||||
RTC_DS3231 rtc; // set up RTC
 | 
			
		||||
const int alarmPin = 4; // pin to monitor for RTC alarms
 | 
			
		||||
 | 
			
		||||
// Network options: "wifi" for existing netowrk, "ap" to be an access point
 | 
			
		||||
const char* network = "ap";
 | 
			
		||||
// Connect to existing network
 | 
			
		||||
// Read from config.h
 | 
			
		||||
const char* ssid = WIFI_SSID;
 | 
			
		||||
const char* password = WIFI_PASSWORD;
 | 
			
		||||
// Create a new access point
 | 
			
		||||
// Replace with your network credentials
 | 
			
		||||
const char* ssid_ap     = "vulpes001";
 | 
			
		||||
const char* password_ap = NULL; //"123456789";
 | 
			
		||||
IPAddress local_ip(192,168,0,1);
 | 
			
		||||
IPAddress gateway(192,168,0,1);
 | 
			
		||||
IPAddress subnet(255,255,255,0);
 | 
			
		||||
 | 
			
		||||
const char* PARAM_SEND = "inputSend";
 | 
			
		||||
const char* PARAM_WPM = "inputWPM";
 | 
			
		||||
@@ -347,15 +357,25 @@ void setup() {
 | 
			
		||||
    sender_key.setMessage(String("mo5 "));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  WiFi.mode(WIFI_STA);
 | 
			
		||||
  WiFi.begin(ssid, password);
 | 
			
		||||
  if (WiFi.waitForConnectResult() != WL_CONNECTED) {
 | 
			
		||||
    Serial.println("WiFi Failed!");
 | 
			
		||||
    return;
 | 
			
		||||
  WiFi.setHostname("vulpes");
 | 
			
		||||
  if (network == "wifi"){
 | 
			
		||||
    // Attach to existing wifi
 | 
			
		||||
    WiFi.mode(WIFI_STA);
 | 
			
		||||
    WiFi.begin(ssid, password);
 | 
			
		||||
    if (WiFi.waitForConnectResult() != WL_CONNECTED) {
 | 
			
		||||
      Serial.println("WiFi Failed!");
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    Serial.println();
 | 
			
		||||
    Serial.print("IP Address: ");
 | 
			
		||||
    Serial.println(WiFi.localIP());
 | 
			
		||||
  } else if (network == "ap"){
 | 
			
		||||
    // Act as new access point
 | 
			
		||||
    WiFi.softAPConfig(local_ip, gateway, subnet);
 | 
			
		||||
    WiFi.softAP(ssid_ap, password_ap);
 | 
			
		||||
  }
 | 
			
		||||
  Serial.println();
 | 
			
		||||
  Serial.print("IP Address: ");
 | 
			
		||||
  Serial.println(WiFi.localIP());
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  // Send web page with input fields to client
 | 
			
		||||
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user