Skip to content

Commit 76aadf4

Browse files
committed
add wifi test
1 parent 7772dcb commit 76aadf4

File tree

18 files changed

+471
-0
lines changed

18 files changed

+471
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.cache/
55
build/
66
compile_commands.json
7+
secrets.h

ESP32WiFi/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.pio

ESP32WiFi/compiledb_flags.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Import("env")
2+
3+
env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)

ESP32WiFi/include/README

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
This directory is intended for project header files.
3+
4+
A header file is a file containing C declarations and macro definitions
5+
to be shared between several project source files. You request the use of a
6+
header file in your project source file (C, C++, etc) located in `src` folder
7+
by including it, with the C preprocessing directive `#include'.
8+
9+
```src/main.c
10+
11+
#include "header.h"
12+
13+
int main (void)
14+
{
15+
...
16+
}
17+
```
18+
19+
Including a header file produces the same results as copying the header file
20+
into each source file that needs it. Such copying would be time-consuming
21+
and error-prone. With a header file, the related declarations appear
22+
in only one place. If they need to be changed, they can be changed in one
23+
place, and programs that include the header file will automatically use the
24+
new version when next recompiled. The header file eliminates the labor of
25+
finding and changing all the copies as well as the risk that a failure to
26+
find one copy will result in inconsistencies within a program.
27+
28+
In C, the convention is to give header files names that end with `.h'.
29+
30+
Read more about using header files in official GCC documentation:
31+
32+
* Include Syntax
33+
* Include Operation
34+
* Once-Only Headers
35+
* Computed Includes
36+
37+
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

ESP32WiFi/lib/README

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
This directory is intended for project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link into the executable file.
4+
5+
The source code of each library should be placed in a separate directory
6+
("lib/your_library_name/[Code]").
7+
8+
For example, see the structure of the following example libraries `Foo` and `Bar`:
9+
10+
|--lib
11+
| |
12+
| |--Bar
13+
| | |--docs
14+
| | |--examples
15+
| | |--src
16+
| | |- Bar.c
17+
| | |- Bar.h
18+
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19+
| |
20+
| |--Foo
21+
| | |- Foo.c
22+
| | |- Foo.h
23+
| |
24+
| |- README --> THIS FILE
25+
|
26+
|- platformio.ini
27+
|--src
28+
|- main.c
29+
30+
Example contents of `src/main.c` using Foo and Bar:
31+
```
32+
#include <Foo.h>
33+
#include <Bar.h>
34+
35+
int main (void)
36+
{
37+
...
38+
}
39+
40+
```
41+
42+
The PlatformIO Library Dependency Finder will find automatically dependent
43+
libraries by scanning project source files.
44+
45+
More information about PlatformIO Library Dependency Finder
46+
- https://docs.platformio.org/page/librarymanager/ldf.html

ESP32WiFi/platformio.ini

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env:nologo_esp32c3_super_mini]
12+
platform = espressif32
13+
board = nologo_esp32c3_super_mini
14+
framework = arduino
15+
extra_scripts = pre:compiledb_flags.py
16+
build_unflags =
17+
-std=gnu++11
18+
build_flags =
19+
-std=c++17
20+
monitor_speed = 115200
21+
lib_deps =

ESP32WiFi/src/main.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <Arduino.h>
2+
3+
void setup() {
4+
Serial.begin(115200);
5+
}
6+
7+
void loop() {
8+
}

ESP32WiFi/test/README

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
This directory is intended for PlatformIO Test Runner and project tests.
3+
4+
Unit Testing is a software testing method by which individual units of
5+
source code, sets of one or more MCU program modules together with associated
6+
control data, usage procedures, and operating procedures, are tested to
7+
determine whether they are fit for use. Unit testing finds problems early
8+
in the development cycle.
9+
10+
More information about PlatformIO Unit Testing:
11+
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html

WiFiScan/WiFiScan.ino

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <Arduino.h>
2+
#include <WiFi.h>
3+
4+
void setup()
5+
{
6+
Serial.begin(115200);
7+
8+
// Set WiFi to station mode and disconnect from an AP if it was previously connected
9+
WiFi.mode(WIFI_STA);
10+
WiFi.disconnect();
11+
delay(100);
12+
13+
Serial.println("Setup done");
14+
}
15+
16+
void loop()
17+
{
18+
Serial.println("scan start");
19+
20+
// WiFi.scanNetworks will return the number of networks found
21+
int n = WiFi.scanNetworks();
22+
Serial.println("scan done");
23+
if (n == 0) {
24+
Serial.println("no networks found");
25+
} else {
26+
Serial.print(n);
27+
Serial.println(" networks found");
28+
for (int i = 0; i < n; ++i) {
29+
// Print SSID and RSSI for each network found
30+
Serial.print(i + 1);
31+
Serial.print(": ");
32+
Serial.print(WiFi.SSID(i));
33+
Serial.print(" (");
34+
Serial.print(WiFi.RSSI(i));
35+
Serial.print(")");
36+
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " " : "*");
37+
delay(10);
38+
}
39+
}
40+
Serial.println("");
41+
42+
// Wait a bit before scanning again
43+
delay(5000);
44+
}

WiFiTest/.clangd

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
CompileFlags:
2+
Remove:
3+
- -mlongcalls
4+
- -fno-shrink-wrap
5+
- -fno-tree-switch-conversion
6+
- -fstrict-volatile-bitfields
7+
Add:
8+
- -fgnuc-version=12.3.1
9+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src
10+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src
11+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src
12+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src
13+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src
14+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src
15+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src
16+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src
17+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/Ethernet/src
18+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src
19+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/FS/src
20+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src
21+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src
22+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdateServer/src
23+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/I2S/src
24+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/Insights/src
25+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/LittleFS/src
26+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/NetBIOS/src
27+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/Preferences/src
28+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/RainMaker/src
29+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/SD/src
30+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src
31+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src
32+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/SPIFFS/src
33+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src
34+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src
35+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/USB/src
36+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/Update/src
37+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src
38+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src
39+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src
40+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src
41+
- -I/home/bate/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src

WiFiTest/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.pio

WiFiTest/compiledb_flags.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Import("env")
2+
3+
env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)

WiFiTest/include/README

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
This directory is intended for project header files.
3+
4+
A header file is a file containing C declarations and macro definitions
5+
to be shared between several project source files. You request the use of a
6+
header file in your project source file (C, C++, etc) located in `src` folder
7+
by including it, with the C preprocessing directive `#include'.
8+
9+
```src/main.c
10+
11+
#include "header.h"
12+
13+
int main (void)
14+
{
15+
...
16+
}
17+
```
18+
19+
Including a header file produces the same results as copying the header file
20+
into each source file that needs it. Such copying would be time-consuming
21+
and error-prone. With a header file, the related declarations appear
22+
in only one place. If they need to be changed, they can be changed in one
23+
place, and programs that include the header file will automatically use the
24+
new version when next recompiled. The header file eliminates the labor of
25+
finding and changing all the copies as well as the risk that a failure to
26+
find one copy will result in inconsistencies within a program.
27+
28+
In C, the convention is to give header files names that end with `.h'.
29+
30+
Read more about using header files in official GCC documentation:
31+
32+
* Include Syntax
33+
* Include Operation
34+
* Once-Only Headers
35+
* Computed Includes
36+
37+
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

WiFiTest/lib/README

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
This directory is intended for project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link into the executable file.
4+
5+
The source code of each library should be placed in a separate directory
6+
("lib/your_library_name/[Code]").
7+
8+
For example, see the structure of the following example libraries `Foo` and `Bar`:
9+
10+
|--lib
11+
| |
12+
| |--Bar
13+
| | |--docs
14+
| | |--examples
15+
| | |--src
16+
| | |- Bar.c
17+
| | |- Bar.h
18+
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19+
| |
20+
| |--Foo
21+
| | |- Foo.c
22+
| | |- Foo.h
23+
| |
24+
| |- README --> THIS FILE
25+
|
26+
|- platformio.ini
27+
|--src
28+
|- main.c
29+
30+
Example contents of `src/main.c` using Foo and Bar:
31+
```
32+
#include <Foo.h>
33+
#include <Bar.h>
34+
35+
int main (void)
36+
{
37+
...
38+
}
39+
40+
```
41+
42+
The PlatformIO Library Dependency Finder will find automatically dependent
43+
libraries by scanning project source files.
44+
45+
More information about PlatformIO Library Dependency Finder
46+
- https://docs.platformio.org/page/librarymanager/ldf.html

WiFiTest/platformio.ini

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env:nologo_esp32c3_super_mini]
12+
platform = espressif32
13+
board = nologo_esp32c3_super_mini
14+
framework = arduino
15+
monitor_speed = 115200
16+
extra_scripts = pre:compiledb_flags.py

0 commit comments

Comments
 (0)