Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
15feb027
Commit
15feb027
authored
Feb 22, 2022
by
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
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/ampel-firmware.ino
View file @
15feb027
...
...
@@ -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
);
...
...
ampel-firmware/config.public.h
View file @
15feb027
...
...
@@ -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
...
...
ampel-firmware/web_config.cpp
View file @
15feb027
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment