Commit 15feb027 authored by Eric Duminil's avatar Eric Duminil
Browse files

Do not stay in Access Point mode indefinitely

parent 8efb0a30
Pipeline #5904 passed with stage
in 2 minutes and 22 seconds
......@@ -181,6 +181,7 @@ void wifiConnected() {
}
void wifiFailed() {
// Ampel will go back to Access Point mode for AP_TIMEOUT seconds, and try connection again after
Serial.print(F("WiFi - Could not connect to "));
Serial.println(config::selected_ssid());
led_effects::showKITTWheel(color::red);
......
......@@ -44,7 +44,12 @@
// SSID and PASSWORD need to be defined, but can be empty.
# define WIFI_SSID ""
# define WIFI_PASSWORD ""
// How long should the Ampel try to connect to WIFI_SSID?
# define WIFI_TIMEOUT 30 // [s]
// If the Ampel cannot connect to WIFI_SSID, it will start an Access Point for ACCESS_POINT_TIMEOUT seconds.
// If someone connects to this Access Point, the Ampel will stay in this mode until everybody logs out.
// If nobody connects to the Access Point before ACCESS_POINT_TIMEOUT seconds, the Ampel will try to connect WIFI_SSID again.
# define ACCESS_POINT_TIMEOUT 30 // [s]
/**
* Sensor
......
......@@ -2,6 +2,9 @@
#define STRING_LEN 33 // Should be enough for ip, addresses, passwords...
#define STRING(x) #x
#define STRINGIFY(x) STRING(x) // Allows to call STRINGIFY(SOME_MACRO) and convert the value of SOME_MACRO to string
#include "config.h"
#ifndef AMPEL_PASSWORD
# error Missing config.h file. Please copy config.public.h to config.h.
......@@ -158,7 +161,6 @@ namespace web_config {
void setWifiFailCallback(void (*fail_function)()) {
std::function<WifiAuthInfo* ()> fail_and_return_null = [fail_function]() {
fail_function();
iotWebConf->forceApMode(true); // Will stay in AP.
return nullptr;
};
iotWebConf->setWifiConnectionFailedHandler(fail_and_return_null);
......@@ -172,10 +174,13 @@ namespace web_config {
iotWebConf->getThingNameParameter()->label = "Ampel name";
iotWebConf->getApPasswordParameter()->label = "Ampel password (user : 'admin')";
iotWebConf->getApTimeoutParameter()->label = "Access Point timeout";
iotWebConf->getApTimeoutParameter()->visible = true;
iotWebConf->getApPasswordParameter()->defaultValue = AMPEL_PASSWORD;
iotWebConf->getWifiSsidParameter()->defaultValue = WIFI_SSID;
iotWebConf->getWifiPasswordParameter()->defaultValue = WIFI_PASSWORD;
iotWebConf->getApTimeoutParameter()->defaultValue = STRINGIFY(ACCESS_POINT_TIMEOUT); // Defined as number in config.h but stored as string in webconf.
co2Params.addItem(&timestepParam);
co2Params.addItem(&temperatureOffsetParam);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment