mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-11 17:14:27 +00:00
[2nd Heap] Tweak 2nd heap stability + set as ESP8266 regular
This commit is contained in:
@@ -137,6 +137,12 @@ boolean PubSubClient::connect(const char *id, const char *user, const char *pass
|
||||
}
|
||||
|
||||
boolean PubSubClient::connect(const char *id, const char *user, const char *pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage, boolean cleanSession) {
|
||||
# ifdef USE_SECOND_HEAP
|
||||
if (!initBuffer()) {
|
||||
return false;
|
||||
}
|
||||
# endif // ifdef USE_SECOND_HEAP
|
||||
|
||||
if (!connected()) {
|
||||
int result = 0;
|
||||
|
||||
@@ -285,6 +291,12 @@ boolean PubSubClient::readByte(uint8_t * result, uint16_t * index){
|
||||
}
|
||||
|
||||
uint16_t PubSubClient::readPacket(uint8_t* lengthLength) {
|
||||
# ifdef USE_SECOND_HEAP
|
||||
if (!initBuffer()) {
|
||||
return 0;
|
||||
}
|
||||
# endif // ifdef USE_SECOND_HEAP
|
||||
|
||||
uint16_t len = 0;
|
||||
if(!readByte(buffer, &len)) return 0;
|
||||
bool isPublish = (buffer[0]&0xF0) == MQTTPUBLISH;
|
||||
@@ -672,6 +684,12 @@ uint16_t PubSubClient::writeString(const char* string, uint8_t* buf, uint16_t po
|
||||
}
|
||||
|
||||
size_t PubSubClient::appendBuffer(uint8_t data) {
|
||||
# ifdef USE_SECOND_HEAP
|
||||
if (!initBuffer()) {
|
||||
return 0;
|
||||
}
|
||||
# endif // ifdef USE_SECOND_HEAP
|
||||
|
||||
buffer[_bufferWritePos] = data;
|
||||
++_bufferWritePos;
|
||||
if (_bufferWritePos >= MQTT_MAX_PACKET_SIZE) {
|
||||
|
||||
@@ -64,6 +64,8 @@ lib_ignore = ESP32_ping
|
||||
|
||||
; Keep optimization flag to -O2
|
||||
; See: https://github.com/platformio/platform-espressif8266/issues/288
|
||||
; For "-fno-strict-aliasing"
|
||||
; See: https://github.com/esp8266/Arduino/issues/8261
|
||||
[esp82xx_2_7_x]
|
||||
build_flags = -DNDEBUG
|
||||
-mtarget-align
|
||||
|
||||
@@ -17,10 +17,10 @@ platform_packages = ${core_stage.platform_packages}
|
||||
lib_ignore = ${core_stage.lib_ignore}
|
||||
|
||||
[regular_platform]
|
||||
build_flags = ${core312_platform.build_flags}
|
||||
platform = ${core312_platform.platform}
|
||||
platform_packages = ${core312_platform.platform_packages}
|
||||
lib_ignore = ${core312_platform.lib_ignore}
|
||||
build_flags = ${core_stage_2ndheap.build_flags}
|
||||
platform = ${core_stage_2ndheap.platform}
|
||||
platform_packages = ${core_stage_2ndheap.platform_packages}
|
||||
lib_ignore = ${core_stage_2ndheap.lib_ignore}
|
||||
|
||||
|
||||
[beta_platform_2ndheap]
|
||||
@@ -82,6 +82,7 @@ src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<te
|
||||
platform = ${regular_platform.platform}
|
||||
platform_packages = ${regular_platform.platform_packages}
|
||||
build_flags = ${regular_platform.build_flags}
|
||||
-DBUILD_NO_DEBUG
|
||||
lib_ignore = ${regular_platform.lib_ignore}
|
||||
|
||||
|
||||
@@ -89,6 +90,7 @@ lib_ignore = ${regular_platform.lib_ignore}
|
||||
platform = ${beta_platform.platform}
|
||||
platform_packages = ${beta_platform.platform_packages}
|
||||
build_flags = ${beta_platform.build_flags}
|
||||
-DBUILD_NO_DEBUG
|
||||
lib_ignore = ${beta_platform.lib_ignore}
|
||||
|
||||
|
||||
|
||||
+21
-26
@@ -188,17 +188,11 @@ extra_scripts = ${esp8266_custom_common_274.extra_scripts}
|
||||
; NORMAL: 1024k version --------------------------
|
||||
[env:normal_ESP8266_1M]
|
||||
extends = esp8266_1M
|
||||
platform = ${regular_platform.platform}
|
||||
platform_packages = ${regular_platform.platform_packages}
|
||||
build_flags = ${regular_platform.build_flags}
|
||||
platform = ${normal.platform}
|
||||
platform_packages = ${normal.platform_packages}
|
||||
build_flags = ${normal.build_flags}
|
||||
${esp8266_1M.build_flags}
|
||||
lib_ignore = ${regular_platform.lib_ignore}
|
||||
ESP8266SdFat
|
||||
SD(esp8266)
|
||||
SD
|
||||
SDFS
|
||||
LittleFS(esp8266)
|
||||
|
||||
lib_ignore = ${normal.lib_ignore}
|
||||
|
||||
|
||||
;[env:normal_312_ESP8266_1M]
|
||||
@@ -211,17 +205,12 @@ lib_ignore = ${regular_platform.lib_ignore}
|
||||
|
||||
[env:normal_ESP8266_1M_VCC]
|
||||
extends = esp8266_1M
|
||||
platform = ${regular_platform.platform}
|
||||
platform_packages = ${regular_platform.platform_packages}
|
||||
build_flags = ${regular_platform.build_flags}
|
||||
platform = ${normal.platform}
|
||||
platform_packages = ${normal.platform_packages}
|
||||
build_flags = ${normal.build_flags}
|
||||
${esp8266_1M.build_flags}
|
||||
-D FEATURE_ADC_VCC=1
|
||||
lib_ignore = ${regular_platform.lib_ignore}
|
||||
ESP8266SdFat
|
||||
SD(esp8266)
|
||||
SD
|
||||
SDFS
|
||||
LittleFS(esp8266)
|
||||
lib_ignore = ${normal.lib_ignore}
|
||||
|
||||
|
||||
|
||||
@@ -236,20 +225,20 @@ lib_ignore = ${regular_platform.lib_ignore}
|
||||
|
||||
; NORMAL: 2048k WROOM02 version 256k SPIFFS --------------------------
|
||||
[env:normal_WROOM02_2M256]
|
||||
extends = espWroom2M256, regular_platform
|
||||
build_flags = ${regular_platform.build_flags}
|
||||
extends = espWroom2M256, normal
|
||||
build_flags = ${normal.build_flags}
|
||||
${espWroom2M256.build_flags}
|
||||
|
||||
|
||||
; NORMAL: 4096k version --------------------------
|
||||
[env:normal_ESP8266_4M1M]
|
||||
extends = esp8266_4M1M, regular_platform
|
||||
build_flags = ${regular_platform.build_flags}
|
||||
extends = esp8266_4M1M, normal
|
||||
build_flags = ${normal.build_flags}
|
||||
${esp8266_4M1M.build_flags}
|
||||
|
||||
[env:normal_ESP8266_4M1M_VCC]
|
||||
extends = esp8266_4M1M, regular_platform
|
||||
build_flags = ${regular_platform.build_flags}
|
||||
extends = esp8266_4M1M, normal
|
||||
build_flags = ${normal.build_flags}
|
||||
${esp8266_4M1M.build_flags}
|
||||
-D FEATURE_ADC_VCC=1
|
||||
-D NO_LIMIT_BUILD_SIZE
|
||||
@@ -266,12 +255,17 @@ build_flags = ${normal_beta.build_flags}
|
||||
-DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22y
|
||||
lib_ignore = ESP32_ping
|
||||
ESP32WebServer
|
||||
ServoESP32
|
||||
ESP32HTTPUpdateServer
|
||||
ServoESP32
|
||||
IRremoteESP8266
|
||||
HeatpumpIR
|
||||
TinyWireM
|
||||
ESP8266SdFat
|
||||
SD(esp8266)
|
||||
SD
|
||||
SDFS
|
||||
ArduinoOTA
|
||||
ESP8266mDNS
|
||||
I2C AXP192 Power management
|
||||
|
||||
|
||||
@@ -522,6 +516,7 @@ build_flags = ${regular_platform.build_flags}
|
||||
extends = esp8266_4M1M, regular_platform
|
||||
build_flags = ${regular_platform.build_flags}
|
||||
${esp8266_4M1M.build_flags}
|
||||
-D BUILD_NO_DEBUG
|
||||
-D PLUGIN_DISPLAY_COLLECTION
|
||||
-D WEBSERVER_USE_CDN_JS_CSS
|
||||
lib_ignore = ${regular_platform.lib_ignore}
|
||||
|
||||
@@ -288,8 +288,6 @@ void Web_StreamingBuffer::endStream() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Web_StreamingBuffer::sendContentBlocking(String& data) {
|
||||
#ifdef USE_SECOND_HEAP
|
||||
HeapSelectDram ephemeral;
|
||||
@@ -300,12 +298,10 @@ void Web_StreamingBuffer::sendContentBlocking(String& data) {
|
||||
const uint32_t length = data.length();
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_DEV)) {
|
||||
String log;
|
||||
log += F("sendcontent free: ");
|
||||
log += ESP.getFreeHeap();
|
||||
log += F(" chunk size:");
|
||||
log += length;
|
||||
addLogMove(LOG_LEVEL_DEBUG_DEV, log);
|
||||
addLogMove(LOG_LEVEL_DEBUG_DEV, strformat(
|
||||
F("sendcontent free: %u chunk size: %u"),
|
||||
ESP.getFreeHeap(),
|
||||
length));
|
||||
}
|
||||
#endif // ifndef BUILD_NO_DEBUG
|
||||
const uint32_t freeBeforeSend = ESP.getFreeHeap();
|
||||
@@ -331,7 +327,7 @@ void Web_StreamingBuffer::sendContentBlocking(String& data) {
|
||||
|
||||
web_server.sendContent(data);
|
||||
|
||||
if (data.length() > CHUNKED_BUFFER_SIZE) {
|
||||
if (data.length() > (CHUNKED_BUFFER_SIZE + 1)) {
|
||||
data = String(); // Clear also allocated memory
|
||||
} else {
|
||||
data.clear();
|
||||
@@ -385,6 +381,7 @@ void Web_StreamingBuffer::sendHeaderBlocking(bool allowOriginAll,
|
||||
const uint32_t freeBeforeSend = ESP.getFreeHeap();
|
||||
|
||||
const uint32_t beginWait = millis();
|
||||
|
||||
web_server.setContentLength(CONTENT_LENGTH_UNKNOWN);
|
||||
web_server.sendHeader(F("Cache-Control"), F("no-cache"));
|
||||
|
||||
|
||||
@@ -173,16 +173,21 @@ String WiFi_AP_Candidate::toString(const String& separator) const {
|
||||
|
||||
result += encryption_type();
|
||||
if (phy_known()) {
|
||||
result += ' ';
|
||||
if (phy_11b) result += 'b';
|
||||
if (phy_11g) result += 'g';
|
||||
if (phy_11n) result += 'n';
|
||||
String phy_str;
|
||||
|
||||
if (phy_11b) phy_str += 'b';
|
||||
if (phy_11g) phy_str += 'g';
|
||||
if (phy_11n) phy_str += 'n';
|
||||
#ifdef ESP32
|
||||
if (phy_11ax) result += F("/ax");
|
||||
if (phy_lr) result += F("/lr");
|
||||
if (ftm_initiator) result += F("/FTM_i");
|
||||
if (ftm_responder) result += F("/FTM_r");
|
||||
if (phy_11ax) phy_str += F("/ax");
|
||||
if (phy_lr) phy_str += F("/lr");
|
||||
if (ftm_initiator) phy_str += F("/FTM_i");
|
||||
if (ftm_responder) phy_str += F("/FTM_r");
|
||||
#endif
|
||||
|
||||
if (phy_str.length()) {
|
||||
result += strformat(F(" (%s)"), phy_str.c_str());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,8 @@ bool equals(const String& str, const char& c) {
|
||||
|
||||
void move_special(String& dest, String&& source) {
|
||||
#ifdef USE_SECOND_HEAP
|
||||
if ((source.length() > 0) && !mmu_is_iram(&(source[0]))) {
|
||||
// Only try to store larger strings here as those tend to be kept for a longer period.
|
||||
if ((source.length() >= 32) && mmu_is_dram(&(source[0]))) {
|
||||
// The string was not allocated on the 2nd heap, so copy instead of move
|
||||
HeapSelectIram ephemeral;
|
||||
if (dest.reserve(source.length())) {
|
||||
@@ -92,8 +93,10 @@ bool reserve_special(String& str, size_t size) {
|
||||
}
|
||||
// FIXME TD-er: Should also use this for ESP32 with PSRAM to allocate on PSRAM
|
||||
#ifdef USE_SECOND_HEAP
|
||||
{
|
||||
if (size >= 32) {
|
||||
// Only try to store larger strings here as those tend to be kept for a longer period.
|
||||
HeapSelectIram ephemeral;
|
||||
// String does round up to nearest multiple of 16 bytes, so no need to round up to multiples of 32 bit here
|
||||
if (str.reserve(size)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user