[openthread] move esp functions into correct file (#14588)
This commit is contained in:
1 parent
05ae69b766
commit
cbebb81196
3 files changed
+9
-7
No files matched your search
@@ -1,7 +1,6 @@
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_OPENTHREAD
|
||||
#include "openthread.h"
|
||||
#include "esp_openthread.h"
|
||||
|
||||
#include <freertos/portmacro.h>
|
||||
|
||||
@@ -51,7 +50,7 @@ void OpenThreadComponent::on_state_changed_(otChangedFlags flags, void *context)
|
||||
auto *self = static_cast<OpenThreadComponent *>(context);
|
||||
// This runs on the OpenThread task thread with the OT lock held,
|
||||
// so we can safely call otThreadGetDeviceRole directly.
|
||||
otInstance *instance = esp_openthread_get_instance();
|
||||
otInstance *instance = self->get_openthread_instance_();
|
||||
otDeviceRole role = otThreadGetDeviceRole(instance);
|
||||
self->connected_ = role >= OT_DEVICE_ROLE_CHILD;
|
||||
}
|
||||
@@ -233,16 +232,12 @@ bool OpenThreadComponent::teardown() {
|
||||
otSrpClientClearHostAndServices(instance);
|
||||
otSrpClientBuffersFreeAllServices(instance);
|
||||
global_openthread_component = nullptr;
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
|
||||
ESP_LOGD(TAG, "Exit main loop ");
|
||||
int error = esp_openthread_mainloop_exit();
|
||||
int error = this->openthread_stop_();
|
||||
if (error != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Failed attempt to stop main loop %d", error);
|
||||
this->teardown_complete_ = true;
|
||||
}
|
||||
#else
|
||||
this->teardown_complete_ = true;
|
||||
#endif
|
||||
}
|
||||
return this->teardown_complete_;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user