Lightweight AutoConnect version #411
Replies: 12 comments
-
Lightweight!, Yes, most definitely. I want to reduce too. Here, the following are the statistics when I build the sketch below with ESP32DevKit-C in my environment. #include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>
#include <AutoConnect.h>
WebServer server;
AutoConnect portal(server);
void setup() {
server.on("/", []() {
String content = R"(
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
Place the root page with the sketch application.
</body>
</html>
)";
server.send(200, "text/html", content);
});
portal.begin();
}
void loop() {
portal.handleClient();
}
It doesn't decrease much... Incidentally, for ESP8266, the result as below. ESP-IDF seems to have a larger object size than ESP8266 non-os SDK, or a strange ghost lurks who spits a lot of object code.
|
Beta Was this translation helpful? Give feedback.
-
I was looking forward using AutoConnect, however using BLE_scan example with added AutoConnect from master gave me 118% of flash space used :( It seems AutoConnect adds ~ 500kb on ESP32 |
Beta Was this translation helpful? Give feedback.
-
@atheros
Well, you should have the opportunity to change the partition table. So, 500kb... which one? |
Beta Was this translation helpful? Give feedback.
-
Adding Wifi.h, WebServer.h and AutoConnect to BLE_scan example project results in a binary build ~500kb larger. |
Beta Was this translation helpful? Give feedback.
-
@atheros Many contributors are working on this problem and are mainly discussing it at the arduino-esp32 repository. It relies heavily on the program structure of the esp-idf library and FreeRTOS, and we need to diagnose the source code of the esp-idf library to solve the problem. Even if you identify a bloated text block in a compiled ELF, it is unlikely that you will be able to step into FreeRTOS and change its structure. The same is true for C ++ STDLib. For now, the practical workaround we can adopt is to adjust the partition size. And the contributors of the arduino-esp32 core provide an easy way to adjust the partition size, and the contribution is commendable. |
Beta Was this translation helpful? Give feedback.
-
I did some tests yesterday and it turned out that BLE_scan + Wifi + WebServer serving a static page uses 103% of the flash, so AutoConnect uses additional 15%. Since I cannot fit BLE, WiFi and Webserver in the default partition, I guess making AutoConnect smaller won't help much :) I do not want to play with partition size as I want it to be a plug and play solution, without re-configuring arduino environment and the esp32 itself. |
Beta Was this translation helpful? Give feedback.
-
Just found this repo, looks very nice, looking forward to trying it out! I wanted to comment here for those of you who want to use BLE and WiFi and want to save space. Try using NimBLE, it uses half the flash and ram of the default bluedroid library with nearly 100% backward compatibility. |
Beta Was this translation helpful? Give feedback.
-
@h2zero, Thank you a information. |
Beta Was this translation helpful? Give feedback.
-
Hi @Hieromon, NimBLE (the core) creates it's own mempools for it's operations (size definable in config). The C++ wrapper, due to necessity of a multi-use-case library, does dynamically allocate from the heap. This has been minimized however, heap use and fragmentation is very small, due to some significant optimizations from the original. For instance, with the original library 1 connection as a client used over 10kb of ram, with NimBLE it's less than 1kb, depending on the number of attributes obtained from the peripheral. So to answer the question; almost 😆 ,but it's better for sure. If you decide to check it out I would appreciate any feedback (please note, a significant release is coming soon). |
Beta Was this translation helpful? Give feedback.
-
@h2zero Thank you for your guidance.
It's awesome! It will save many drowning in a small pond. Thank you again. |
Beta Was this translation helpful? Give feedback.
-
Sounds good! Yes it's a significant reduction in resources, shocks many people haha. I've been working on some stability and other improvements that I hope to release soon. Hopefully I'll get some time to test this repo soon as well. |
Beta Was this translation helpful? Give feedback.
-
+1000 for NimBLE. Works great (even better in fact) and use wayyyy less storage/memory. |
Beta Was this translation helpful? Give feedback.
-
@Hieromon first of all congratulation for the beautiful library. I'm using it with PlatformIO and I've noticed that it is using around 40% more flash memory when active compared to the usual WiFi and WebServer libraries alone. Is there a way to increase its efficiency and reduce the memory imprint?
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 12.7% (used 41464 bytes from 327680 bytes)
Flash: [======= ] 70.4% (used 922915 bytes from 1310720 bytes)
esptool.py v2.6
Beta Was this translation helpful? Give feedback.
All reactions