This project enables the ESP32 to function as a WiFi access point initially, allowing users to connect to it. Once connected, users can enter their network SSID and password. The ESP32 will then transition to station mode, connecting to the specified network and retrieving time and date information from an NTP (Network Time Protocol) server.
The project is built on the ESP32 platform using the ESP-IDF (Espressif IoT Development Framework). It aims to provide functionalities involving WiFi access point and station modes, as well as support for SPIFFS (SPI Flash File System) and an NTP (Network Time Protocol) server.
- Languages: C, C++, Python
- Build System: CMake
- Containerization: Docker
The project utilizes a combination of C, C++, and Python scripting to implement various features.
- C and C++ are primarily used for firmware development on the ESP32 platform, leveraging the capabilities of the ESP-IDF.
- Python scripts handle code building, flashing, logging, unit testing using gtest/gmock frameworks, coverage analysis using gcov, valgrind support for memory-related issues, documentation generation using doxygen, and static code analysis using cppcheck.
- Build system for this project relies on CMake, which simplifies the process of building the project and managing dependencies.
- Containerization is achieved using Docker for lightweight deployment.
GitHub Actions automate the build, unit tests, and static analysis process. The following jobs are defined:
- Build: Builds the source code.
- Unit Tests: Runs the unit tests for the project.
- Static Analysis with Cppcheck: Identifies potential errors and vulnerabilities in the code.
The GitHub Actions workflow triggers whenever a commit is pushed to any branch of the repository, ensuring the project is continuously built, tested, and analyzed in a pipeline.
This project combines multiple technologies, including ESP-IDF, C, C++, Python, CMake, Docker, gcov, valgrind, cppcheck, Doxygen, gtest, and gmock. It delivers a robust and efficient solution for ESP32-based applications with WiFi capabilities, SPIFFS support, and an NTP server.
Warning: When connecting to the ESP32 server using HTTP (HyperText Transfer Protocol), please be aware that the communication occurs without encryption or security measures. This means that any data transmitted between the client and the ESP32 can potentially be intercepted or modified by malicious actors. TODO: Use HTTPS for secure communication
git clone https://github.com/bkresaj/Esp32_wifi_ap_sta.git
(cd .devcontainer && docker build . -t=esp32_wifi_sta_ap:latest)
docker images
docker run -it --rm --privileged --device=<device_name_of_esp32_when_connected> -v ${PWD}:/workspace --entrypoint bash <image_id>
Note: You will need to approve a security exception in your browser. This is because of a self signed certificate; this will be always the case, unless you preload the CA root into your browser/system as trusted. In Google Chrome -> Settings -> Privacy and security -> Security -> Manage certificates -> Import certificate inside Authorities
openssl req -newkey rsa:2048 -nodes -keyout prvtkey.pem -x509 -days 3650 -out cacert.pem -subj "/CN=ESP32 HTTPS server example" -addext subjectAltName=IP:<IP address after connecting to esp32 AP>
./scripts/build.py
./scripts/flash.py --port <device_name_of_esp32_when_connected>
./scripts/monitor.py --port <device_name_of_esp32_when_connected>
./scripts/clean.py
./scripts/generate_doxygen.py
./scripts/run_cpp_checker.py
NOTE: When rerunning unit tests with different arguments, consider cleaning the tests/build folder and then rerun them again.
./scripts/run_unit_tests.py
./scripts/run_unit_tests.py COVERAGE/HTML_COVERAGE
./scripts/run_unit_tests.py VALGRIND
./scripts/run_unit_tests.py COVERAGE/HTML_COVERAGE VALGRIND