fix random resets by initializing all pointers with nullptr

This commit is contained in:
Nicu Hodos 2024-05-03 13:55:19 +02:00
parent 1e69ecd9c9
commit 278d82dec6

View File

@ -10,11 +10,11 @@ namespace Ha {
uint16_t (*publisher)(const char* topic, const char* message); uint16_t (*publisher)(const char* topic, const char* message);
struct DeviceConfig { struct DeviceConfig {
const char* id; const char* id = nullptr;
const char* name; const char* name = nullptr;
const char* model; const char* model = nullptr;
const char* manufacturer; const char* manufacturer = nullptr;
const char* area; const char* area = nullptr;
DeviceConfig* parent = nullptr; DeviceConfig* parent = nullptr;
DeviceConfig(const char* id, const char* name) : id(id), name(name) {} DeviceConfig(const char* id, const char* name) : id(id), name(name) {}
@ -56,14 +56,14 @@ namespace Ha {
}; };
struct Component { struct Component {
const char* name = nullptr;
char* id = nullptr; char* id = nullptr;
const char* name; const char* type = nullptr;
const char* type;
char configTopic[TOPIC_SIZE]; char configTopic[TOPIC_SIZE];
DeviceConfig* mainDevice = nullptr; DeviceConfig* mainDevice = nullptr;
static List<Component> components; static List<Component> components;
Component(const char* name, const char* id, const char* type) : id((char*)id), name(name), type(type) { Component(const char* name, const char* id, const char* type) : name(name), id((char*)id), type(type) {
sprintf(configTopic, "homeassistant/%s/%s/%s/config", type, MAIN_DEVICE_ID, id); sprintf(configTopic, "homeassistant/%s/%s/%s/config", type, MAIN_DEVICE_ID, id);
components.add(this); components.add(this);
} }
@ -136,7 +136,6 @@ namespace Ha {
}; };
struct Switch : Command<Switch>, StateConfig<Switch> { struct Switch : Command<Switch>, StateConfig<Switch> {
const char* area;
virtual void onCommand(const char* msg){} virtual void onCommand(const char* msg){}