mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 11:47:30 +01:00
fix: json compilation error on rp2040 (#4273)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
48340d41d6
commit
74556b28a8
@ -7,6 +7,9 @@
|
||||
#ifdef USE_ESP32
|
||||
#include <esp_heap_caps.h>
|
||||
#endif
|
||||
#ifdef USE_RP2040
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
namespace esphome {
|
||||
namespace json {
|
||||
@ -24,6 +27,8 @@ std::string build_json(const json_build_t &f) {
|
||||
const size_t free_heap = ESP.getMaxFreeBlockSize(); // NOLINT(readability-static-accessed-through-instance)
|
||||
#elif defined(USE_ESP32)
|
||||
const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
|
||||
#elif defined(USE_RP2040)
|
||||
const size_t free_heap = rp2040.getFreeHeap();
|
||||
#endif
|
||||
|
||||
size_t request_size = std::min(free_heap, (size_t) 512);
|
||||
@ -64,6 +69,8 @@ void parse_json(const std::string &data, const json_parse_t &f) {
|
||||
const size_t free_heap = ESP.getMaxFreeBlockSize(); // NOLINT(readability-static-accessed-through-instance)
|
||||
#elif defined(USE_ESP32)
|
||||
const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
|
||||
#elif defined(USE_RP2040)
|
||||
const size_t free_heap = rp2040.getFreeHeap();
|
||||
#endif
|
||||
bool pass = false;
|
||||
size_t request_size = std::min(free_heap, (size_t)(data.size() * 1.5));
|
||||
|
Loading…
Reference in New Issue
Block a user