Building the right ESP32 based application
Posted: Sat Dec 26, 2020 11:27 am
Hello everyone!
I would like to get some tips on how to create a complete firmware for ESP32.
It is the general concept and used approaches to programming using ESP-IDF.
There is a lot of documentation and examples too, but they do not show the whole concept of building a correct application.
Just blinking an LED or some other small task is not for such microcontroller resources.
I think this thread will be very relevant for all developers who plan to make good applications based on ESP32.
Tasks:
1. WiFi - full automation and logic for switching between modes, handling all dangerous events that affect the performance of the application.
2. File system - based on LittleFS for storage and settings and other information.
3. WebServer - designed for easy initial configuration of the device.
4. WebClient (HTTPS) - connections to external resources to receive updates (possibly to check for Internet availability)
5. UDPServer + UDPClient - designed to search for similar devices in the local network
6. Socket - to connect to a cloud resource for data exchange and backup settings at the time of firmware update
7. UART - an interface for data exchange with the STM32 microcontroller
8. Updating the STM32 firmware, as well as the WiFi module itself, the firmware is located on a remote server as BIN files.
9. Getting time from the Internet.
It turns out a lot of modules that need to be linked together and ensure good work for all tasks, as well as handle possible options for modules if disconnection from an access point or the Internet is disconnected.
I opened this topic due to the fact that many modules I have already done, but questions arise that force us to reconsider the whole approach of creating a reliable firmware.
For example, I ran into a UDP module (both server and client) problem. When sending a broadcast request, I want to receive responses for some time (because there can be many responses and all of them need to be processed) and exit the loop in order to send the request again. But now, if there is no answer, then I am forever in this cycle and there is no way to send a request. I also found a memory leak in the response loop when using cJSON in this loop. Functionally everything is done correctly, but the memory is not freed. To exit the loop, it was suggested to use select (), but there is very little information on it and there is no recommendation on the cases of its use.
Give a general concept of building an application for such a list of tasks.
I would like to get some tips on how to create a complete firmware for ESP32.
It is the general concept and used approaches to programming using ESP-IDF.
There is a lot of documentation and examples too, but they do not show the whole concept of building a correct application.
Just blinking an LED or some other small task is not for such microcontroller resources.
I think this thread will be very relevant for all developers who plan to make good applications based on ESP32.
Tasks:
1. WiFi - full automation and logic for switching between modes, handling all dangerous events that affect the performance of the application.
2. File system - based on LittleFS for storage and settings and other information.
3. WebServer - designed for easy initial configuration of the device.
4. WebClient (HTTPS) - connections to external resources to receive updates (possibly to check for Internet availability)
5. UDPServer + UDPClient - designed to search for similar devices in the local network
6. Socket - to connect to a cloud resource for data exchange and backup settings at the time of firmware update
7. UART - an interface for data exchange with the STM32 microcontroller
8. Updating the STM32 firmware, as well as the WiFi module itself, the firmware is located on a remote server as BIN files.
9. Getting time from the Internet.
It turns out a lot of modules that need to be linked together and ensure good work for all tasks, as well as handle possible options for modules if disconnection from an access point or the Internet is disconnected.
I opened this topic due to the fact that many modules I have already done, but questions arise that force us to reconsider the whole approach of creating a reliable firmware.
For example, I ran into a UDP module (both server and client) problem. When sending a broadcast request, I want to receive responses for some time (because there can be many responses and all of them need to be processed) and exit the loop in order to send the request again. But now, if there is no answer, then I am forever in this cycle and there is no way to send a request. I also found a memory leak in the response loop when using cJSON in this loop. Functionally everything is done correctly, but the memory is not freed. To exit the loop, it was suggested to use select (), but there is very little information on it and there is no recommendation on the cases of its use.
Give a general concept of building an application for such a list of tasks.