mirror of
https://github.com/tbnobody/OpenDTU.git
synced 2026-03-26 19:09:03 +01:00
Prevent empty HASS auto discovery topics if memory allocation fails
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "Utils.h"
|
||||
#include "Display_Graphic.h"
|
||||
#include "Led_Single.h"
|
||||
#include "MessageOutput.h"
|
||||
#include <Esp.h>
|
||||
|
||||
uint32_t Utils::getChipId()
|
||||
@@ -65,3 +66,13 @@ void Utils::restartDtu()
|
||||
yield();
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
bool Utils::checkJsonAlloc(const DynamicJsonDocument& doc, const char* function, const uint16_t line)
|
||||
{
|
||||
if (doc.capacity() == 0) {
|
||||
MessageOutput.printf("Alloc failed: %s, %d\r\n", function, line);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user