diff --git a/esphome/components/openthread/__init__.py b/esphome/components/openthread/__init__.py index 14176a1ebc..7e151c87ab 100644 --- a/esphome/components/openthread/__init__.py +++ b/esphome/components/openthread/__init__.py @@ -57,6 +57,8 @@ def set_sdkconfig_options(config): add_idf_sdkconfig_option("CONFIG_OPENTHREAD_DNS64_CLIENT", True) add_idf_sdkconfig_option("CONFIG_OPENTHREAD_SRP_CLIENT", True) add_idf_sdkconfig_option("CONFIG_OPENTHREAD_SRP_CLIENT_MAX_SERVICES", 5) + + # TODO: Add suport for sleepy end devices add_idf_sdkconfig_option("CONFIG_OPENTHREAD_FTD", True) # Full Thread Device @@ -87,9 +89,5 @@ async def to_code(config): mdns_component = await cg.get_variable(config[CONF_MDNS_ID]) cg.add(var.set_mdns(mdns_component)) await cg.register_component(var, config) - cg.add_global(cg.RawStatement('#include "esp_openthread.h"')) - cg.add_global(cg.RawStatement('#include "esp_openthread_lock.h"')) - cg.add_global(cg.RawStatement('#include "esp_task_wdt.h"')) - cg.add_global(cg.RawStatement("#include ")) set_sdkconfig_options(config) diff --git a/esphome/components/openthread/openthread.cpp b/esphome/components/openthread/openthread.cpp index 834eb92a57..27333d6682 100644 --- a/esphome/components/openthread/openthread.cpp +++ b/esphome/components/openthread/openthread.cpp @@ -1,9 +1,7 @@ +#include "esphome/core/defines.h" +#ifdef USE_OPENTHREAD #include "openthread.h" -#ifndef USE_ESP_IDF -#error "OpenThread is not supported on this platform" -#endif - #include #include @@ -204,3 +202,5 @@ void OpenThreadComponent::set_mdns(esphome::mdns::MDNSComponent *mdns) { this->m } // namespace openthread } // namespace esphome + +#endif \ No newline at end of file diff --git a/esphome/components/openthread/openthread.h b/esphome/components/openthread/openthread.h index c529a7dbc8..8569a9823e 100644 --- a/esphome/components/openthread/openthread.h +++ b/esphome/components/openthread/openthread.h @@ -1,4 +1,6 @@ #pragma once +#include "esphome/core/defines.h" +#ifdef USE_OPENTHREAD #include "esphome/core/component.h" #include "esphome/components/mdns/mdns_component.h" @@ -61,3 +63,4 @@ class OpenThreadLockGuard { } // namespace openthread } // namespace esphome +#endif \ No newline at end of file diff --git a/esphome/components/openthread/openthread_esp.cpp b/esphome/components/openthread/openthread_esp.cpp index 9bdb4fcee2..a6d48a0cde 100644 --- a/esphome/components/openthread/openthread_esp.cpp +++ b/esphome/components/openthread/openthread_esp.cpp @@ -1,4 +1,5 @@ -// #ifdef USE_ESP_IDF +#include "esphome/core/defines.h" +#if defined(USE_OPENTHREAD) && defined(USE_ESP_IDF) #include "openthread.h" #include @@ -168,4 +169,4 @@ OpenThreadLockGuard::~OpenThreadLockGuard() { esp_openthread_lock_release(); } } // namespace openthread } // namespace esphome -// #endif +#endif