Merge pull request #3346 from esphome/bump-2022.3.2

2022.3.2
This commit is contained in:
Jesse Hills 2022-03-30 13:28:58 +13:00 committed by GitHub
commit fc7348d46d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -54,9 +54,8 @@ void parse_json(const std::string &data, const json_parse_t &f) {
const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL); const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL);
#endif #endif
bool pass = false; bool pass = false;
size_t request_size = std::min(free_heap - 2048, (size_t)(data.size() * 1.5));
do { do {
const size_t request_size = std::min(free_heap - 2048, (size_t)(data.size() * 1.5));
DynamicJsonDocument json_document(request_size); DynamicJsonDocument json_document(request_size);
if (json_document.memoryPool().buffer() == nullptr) { if (json_document.memoryPool().buffer() == nullptr) {
ESP_LOGE(TAG, "Could not allocate memory for JSON document! Requested %u bytes, free heap: %u", request_size, ESP_LOGE(TAG, "Could not allocate memory for JSON document! Requested %u bytes, free heap: %u", request_size,
@ -76,7 +75,8 @@ void parse_json(const std::string &data, const json_parse_t &f) {
ESP_LOGE(TAG, "Can not allocate more memory for deserialization. Consider making source string smaller"); ESP_LOGE(TAG, "Can not allocate more memory for deserialization. Consider making source string smaller");
return; return;
} }
ESP_LOGW(TAG, "Increasing memory allocation."); ESP_LOGV(TAG, "Increasing memory allocation.");
request_size *= 2;
continue; continue;
} else { } else {
ESP_LOGE(TAG, "JSON parse error: %s", err.c_str()); ESP_LOGE(TAG, "JSON parse error: %s", err.c_str());

View file

@ -1,6 +1,6 @@
"""Constants used by esphome.""" """Constants used by esphome."""
__version__ = "2022.3.1" __version__ = "2022.3.2"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"