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
701ac714
Commit
701ac714
authored
Apr 30, 2021
by
Eric Duminil
Browse files
Adding 'wifi_scan' as command
parent
071f3796
Pipeline
#3295
passed with stage
in 1 minute and 46 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/wifi_util.cpp
View file @
701ac714
...
...
@@ -14,8 +14,29 @@ namespace config {
namespace
wifi
{
char
local_ip
[
16
];
// "255.255.255.255\0"
// Initialize Wi-Fi
void
scanNetworks
()
{
Serial
.
println
();
Serial
.
println
(
F
(
"WiFi - Scanning..."
));
bool
async
=
false
;
bool
showHidden
=
true
;
int
n
=
WiFi
.
scanNetworks
(
async
,
showHidden
);
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
Serial
.
print
(
F
(
" * '"
));
Serial
.
print
(
WiFi
.
SSID
(
i
));
Serial
.
print
(
F
(
"' ("
));
int16_t
quality
=
2
*
(
100
+
WiFi
.
RSSI
(
i
));
Serial
.
print
(
util
::
min
(
util
::
max
(
quality
,
0
),
100
));
Serial
.
println
(
F
(
" %)"
));
}
Serial
.
println
(
F
(
"Done!"
));
Serial
.
println
();
}
// Initialize Wi-Fi
void
connect
(
const
char
*
hostname
)
{
sensor_console
::
defineCommand
(
"wifi_scan"
,
scanNetworks
,
F
(
" (Scans available WiFi networks)"
));
//NOTE: WiFi Multi could allow multiple SSID and passwords.
WiFi
.
persistent
(
false
);
// Don't write user & password to Flash.
WiFi
.
mode
(
WIFI_STA
);
// Set ESP to be a WiFi-client only
...
...
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