ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
openthread_esp.cpp
Go to the documentation of this file.
2#if defined(USE_OPENTHREAD) && defined(USE_ESP32)
3#include <openthread/dataset.h>
4#include <openthread/ip6.h>
5#include <openthread/tasklet.h>
6#ifdef USE_OPENTHREAD_BORDER_ROUTER
7#include <openthread/platform/infra_if.h>
8#endif
9#include "openthread.h"
10
11#ifdef USE_OPENTHREAD_BORDER_ROUTER
12#include "esp_openthread_border_router.h"
14#ifndef USE_OPENTHREAD_RCP_UART
15#include "esp_coexist.h"
16#endif
17#endif
18#ifdef USE_OPENTHREAD_RCP_UART
19#include "esp_openthread_spinel.h"
20#endif
21#include "esp_log.h"
22#include "esp_openthread.h"
23#include "esp_openthread_lock.h"
24#include "esp_openthread_types.h"
25#include "esp_task_wdt.h"
27#include "esphome/core/hal.h"
29#include "esphome/core/log.h"
31
32#include "esp_err.h"
33#include "esp_netif.h"
34#include "esp_openthread_netif_glue.h"
35#include "esp_vfs_eventfd.h"
36#include "freertos/FreeRTOS.h"
37#include "freertos/task.h"
38#ifndef USE_OPENTHREAD_BORDER_ROUTER
39#include "lwip/dns.h"
40#include "lwip/ip_addr.h"
41#endif
42
43ESPHOME_LOG_TAG(TAG, "openthread");
44
45namespace esphome::openthread {
46
47void OpenThreadComponent::setup() {
48#ifdef USE_OPENTHREAD_BORDER_ROUTER
50 if (backbone_netif == nullptr) {
51 ESP_LOGE(TAG, "Wi-Fi STA backbone netif is not initialized");
52 this->teardown_stage_ = TeardownStage::TEARDOWN_STAGE_COMPLETED;
53 this->mark_failed();
54 return;
55 }
56 esp_openthread_set_backbone_netif(backbone_netif);
58#endif
59
60 // Used eventfds: netif, ot task queue, radio driver, and one more for a border router on the
61 // native radio (the UART Spinel transport has none)
62#if defined(USE_OPENTHREAD_BORDER_ROUTER) && !defined(USE_OPENTHREAD_RCP_UART)
63 constexpr size_t max_eventfds = 4;
64#else
65 constexpr size_t max_eventfds = 3;
66#endif
67 esp_vfs_eventfd_config_t eventfd_config = {
68 .max_fds = max_eventfds,
69 };
70 // Network interface setup handled by network component.
71 // Preferences opens NVS in app_main(); OpenThread keeps its dataset there, and esp_openthread_init()
72 // aborts without it, so fail this component instead.
73 if (global_preferences->nvs_handle == 0) {
74 ESP_LOGE(TAG, "NVS unavailable");
75 this->teardown_stage_ = TeardownStage::TEARDOWN_STAGE_COMPLETED;
76 this->mark_failed();
77 return;
78 }
79 ESP_ERROR_CHECK(esp_vfs_eventfd_register(&eventfd_config));
80
81 // Own task instead of esp_openthread_start(): the dataset activation has to run on the task
82 // that holds the OpenThread task-switching lock, and a border router must not become the
83 // default netif
84 if (xTaskCreate(
85 [](void *arg) {
86 static_cast<OpenThreadComponent *>(arg)->ot_main_();
87 vTaskDelete(nullptr);
88 },
89 CONFIG_OPENTHREAD_TASK_NAME, CONFIG_OPENTHREAD_TASK_SIZE, this, CONFIG_OPENTHREAD_TASK_PRIORITY,
90 nullptr) != pdPASS) {
91 ESP_LOGE(TAG, "Failed to create OpenThread task");
92 esp_vfs_eventfd_unregister();
93 this->teardown_stage_ = TeardownStage::TEARDOWN_STAGE_COMPLETED;
94 this->mark_failed();
95 }
96}
97
98void OpenThreadComponent::ot_main_() {
99 esp_openthread_platform_config_t config = {
100 .radio_config =
101 {
102#ifdef USE_OPENTHREAD_RCP_UART
103 .radio_mode = RADIO_MODE_UART_RCP,
104 .radio_uart_config =
105 {
106 .port = UART_NUM_1,
107 .uart_config =
108 {
109 .baud_rate = static_cast<int>(this->rcp_baud_rate_),
110 .data_bits = UART_DATA_8_BITS,
111 .parity = UART_PARITY_DISABLE,
112 .stop_bits = UART_STOP_BITS_1,
113 .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
114 .rx_flow_ctrl_thresh = 0,
115 .source_clk = UART_SCLK_DEFAULT,
116 },
117 .rx_pin = static_cast<gpio_num_t>(this->rcp_rx_pin_),
118 .tx_pin = static_cast<gpio_num_t>(this->rcp_tx_pin_),
119 },
120#else
121 .radio_mode = RADIO_MODE_NATIVE,
122 .radio_uart_config = {},
123#endif
124 },
125 .host_config =
126 {
127 // There is a conflict between esphome's logger which also
128 // claims the usb serial jtag device.
129 // .host_connection_mode = HOST_CONNECTION_MODE_CLI_USB,
130 // .host_usb_config = USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT(),
131 },
132 .port_config =
133 {
134 .storage_partition_name = "nvs",
135 .netif_queue_size = 10,
136 .task_queue_size = 10,
137 },
138 };
139
140#ifdef USE_OPENTHREAD_RCP_UART
141 // Without a reset pin there is nothing to do on a failure beyond the Spinel driver's own recovery
142 if (this->rcp_reset_pin_ != nullptr) {
143 this->rcp_reset_pin_->setup();
144 esp_openthread_register_rcp_failure_handler(OpenThreadComponent::rcp_failure_handler);
145 esp_openthread_set_coprocessor_reset_failure_callback(OpenThreadComponent::rcp_failure_handler);
146 this->reset_rcp_(false);
147 }
148#endif
149
150 ESP_ERROR_CHECK(esp_openthread_init(&config));
151
152 // Initialize the esp_netif bindings
153 esp_netif_config_t netif_config = ESP_NETIF_DEFAULT_OPENTHREAD();
154 esp_netif_t *netif = esp_netif_new(&netif_config);
155 assert(netif != nullptr);
156 ESP_ERROR_CHECK(esp_netif_attach(netif, esp_openthread_netif_glue_init(&config)));
157#ifndef USE_OPENTHREAD_BORDER_ROUTER
158 esp_netif_set_default_netif(netif);
159#endif
160
161 ESP_LOGD(TAG, "Thread Version: %" PRIu16, otThreadGetVersion());
162
163 otInstance *instance = esp_openthread_get_instance();
164 bool launch_mainloop = true;
165#if defined(USE_OPENTHREAD_BORDER_ROUTER) && !defined(USE_OPENTHREAD_RCP_UART)
166 // The native 802.15.4 radio shares the RF frontend with Wi-Fi. Coexistence has to be on before
167 // the Thread network starts below, or Wi-Fi scanning and association can fail outright.
168 if (const esp_err_t err = esp_coex_wifi_i154_enable(); err != ESP_OK) {
169 ESP_LOGE(TAG, "Failed to enable Wi-Fi/802.15.4 coexistence: %s", esp_err_to_name(err));
170 this->mark_task_failed_(LOG_STR("Coexistence could not be enabled"));
171 launch_mainloop = false;
172 }
173#endif
174
175 {
176 // One lock for the whole bring-up, so the main loop (actions, teardown, the SRP component)
177 // cannot call into the stack half way through. The lock is recursive: hold it before
178 // telling the other tasks that it exists, then let the guard take over.
179 esp_openthread_lock_acquire(portMAX_DELAY);
180 this->lock_initialized_ = true;
181 InstanceLock lock = InstanceLock::acquire();
182 esp_openthread_lock_release();
183
184#ifndef USE_OPENTHREAD_BORDER_ROUTER
185 this->apply_linkmode_(instance);
186#endif
187
188 if (this->output_power_.has_value()) {
189 if (const auto err = otPlatRadioSetTransmitPower(instance, *this->output_power_); err != OT_ERROR_NONE) {
190 ESP_LOGE(TAG, "Failed to set power: %s", otThreadErrorToString(err));
191 }
192 }
193
194 ESP_LOGI(TAG, "Activating dataset...");
195 otOperationalDatasetTlvs dataset = {};
196 bool stored_dataset = false;
197#ifndef USE_OPENTHREAD_FORCE_DATASET
198 // Check if openthread has a valid dataset from a previous execution
199 if (otDatasetGetActiveTlvs(instance, &dataset) != OT_ERROR_NONE) {
200 // Make sure the length is 0 so we fallback to the configuration
201 dataset.mLength = 0;
202 } else {
203 stored_dataset = true;
204 ESP_LOGI(TAG, "Found existing dataset, ignoring config (force_dataset: true to override)");
205 }
206#endif
207
208#ifdef USE_OPENTHREAD_TLVS
209 if (dataset.mLength == 0) {
210 // If we didn't have an active dataset, and we have tlvs, parse it and pass it to esp_openthread_auto_start
211 constexpr size_t len = (sizeof(USE_OPENTHREAD_TLVS) - 1) / 2;
212 static_assert(len <= sizeof(dataset.mTlvs), "OpenThread dataset TLV is too long");
213 parse_hex(USE_OPENTHREAD_TLVS, sizeof(USE_OPENTHREAD_TLVS) - 1, dataset.mTlvs, len);
214 dataset.mLength = len;
215 }
216#endif
217
218 if (dataset.mLength > 0 && !otDatasetIsValid(&dataset, true)) {
219 if (stored_dataset) {
220 ESP_LOGE(TAG, "Stored OpenThread Active Operational Dataset is invalid; set force_dataset: true to replace it");
221 } else {
222 ESP_LOGE(TAG, "Configured OpenThread Active Operational Dataset TLV is invalid");
223 }
224 this->mark_task_failed_(LOG_STR("Invalid dataset"));
225 launch_mainloop = false;
226 } else if (launch_mainloop) {
227 // esp_openthread_auto_start() enables IPv6, which (for Border Router builds) opens a UDP socket
228 // via otPlatUdpSocket(). That path releases and re-acquires the OpenThread task-switching lock,
229 // which asserts unless this task holds the OpenThread lock, as it does here.
230 if (const esp_err_t err = esp_openthread_auto_start(dataset.mLength > 0 ? &dataset : nullptr); err != ESP_OK) {
231 ESP_LOGE(TAG, "Failed to start OpenThread: %s", esp_err_to_name(err));
232 this->mark_task_failed_(LOG_STR("Start failed"));
233 launch_mainloop = false;
234 }
235 }
236
237 if (launch_mainloop) {
238 // Register state change callback to update connected_ reactively instead of polling
239 otError ot_err = otSetStateChangedCallback(instance, OpenThreadComponent::on_state_changed, this);
240 if (ot_err != OT_ERROR_NONE) {
241 ESP_LOGE(TAG, "Failed to register state change callback: %d", ot_err);
242 // Without this callback connected_ would never update, so the component would look
243 // healthy forever while never actually reporting the device as connected.
244 this->mark_task_failed_(LOG_STR("State callback could not be registered"));
245 launch_mainloop = false;
246 }
247 }
248 }
249
250 if (launch_mainloop) {
251#ifdef USE_OPENTHREAD_BORDER_ROUTER
252 this->mainloop_running_ = true;
253#endif
254 const esp_err_t err = esp_openthread_launch_mainloop();
255#ifdef USE_OPENTHREAD_BORDER_ROUTER
256 this->mainloop_running_ = false;
257#endif
258 if (err != ESP_OK) {
259 ESP_LOGE(TAG, "OpenThread main loop failed: %s", esp_err_to_name(err));
260 this->mark_task_failed_(LOG_STR("Main loop failed"));
261 }
262 }
263
264 // Clean up. Taking the lock once more lets every guard finish; the stack is stopped and the
265 // lock withdrawn while it is held.
266 esp_openthread_lock_acquire(portMAX_DELAY);
267 // Best effort: after a normal teardown all of this is done already
268 otIp6SetAddressCallback(instance, nullptr, nullptr);
269#ifdef USE_OPENTHREAD_BORDER_ROUTER
270 if (this->border_router_started_) {
271 (void) esp_openthread_border_router_deinit();
272 this->border_router_started_ = false;
273 }
274#endif
275 (void) otThreadSetEnabled(instance, false);
276 (void) otIp6SetEnabled(instance, false);
277 // Nothing runs the main loop any more, so the stack's reaction to the disables (the border
278 // agent closing its sockets, for one) is run here, with the lock held
279 for (uint8_t i = 0; i < 16 && otTaskletsArePending(instance); i++) {
280 otTaskletsProcess(instance);
281 }
282 this->lock_initialized_ = false;
283 this->connected_ = false;
284 this->task_exited_ = true;
285 esp_openthread_lock_release();
286 esp_openthread_netif_glue_deinit();
287 esp_netif_destroy(netif);
288 // Finalizing the instance closes the sockets the stack still holds, which hands the task
289 // switching lock back and forth, so it has to be held here; deinit destroys it at the end
290 esp_openthread_lock_acquire(portMAX_DELAY);
291 esp_openthread_deinit();
292 esp_vfs_eventfd_unregister();
293 this->teardown_stage_ = TeardownStage::TEARDOWN_STAGE_COMPLETED;
294}
295
296// Runs on the OpenThread task; the component state belongs to the main loop, and the log goes
297// out from there too, where an abort that follows on the task cannot swallow it
298void OpenThreadComponent::mark_task_failed_(const LogString *reason) {
299 this->defer([this, reason]() {
300 ESP_LOGE(TAG, "OpenThread task failed: %s", LOG_STR_ARG(reason));
301 this->mark_failed();
302 });
303}
304
305#ifdef USE_OPENTHREAD_RCP_UART
306void OpenThreadComponent::rcp_failure_handler() {
307 if (global_openthread_component == nullptr) {
308 ESP_LOGE(TAG, "RCP failure reported after OpenThread component was torn down");
309 return;
310 }
311 global_openthread_component->reset_rcp_(true);
312}
313
314void OpenThreadComponent::reset_rcp_(bool recovery_attempt) {
315 if (recovery_attempt) {
316 static constexpr uint8_t MAX_RESET_ATTEMPTS = 5;
317 uint8_t attempt = this->rcp_reset_attempts_;
318 if (attempt > MAX_RESET_ATTEMPTS) {
319 return; // Gave up earlier; the driver keeps reporting the failure
320 }
321 // An RCP that ran long enough since its last reset gets its attempts back; one that keeps failing does not
322 const uint32_t now = millis();
323 if (attempt != 0 && now - this->last_rcp_reset_ms_ > RCP_RESET_FORGET_MS) {
324 attempt = 0;
325 }
326 this->rcp_reset_attempts_ = ++attempt;
327 if (attempt > MAX_RESET_ATTEMPTS) {
328 ESP_LOGE(TAG, "RCP failed to recover after %u reset attempts", MAX_RESET_ATTEMPTS);
329 this->mark_task_failed_(LOG_STR("RCP does not recover"));
330 return;
331 }
332 ESP_LOGW(TAG, "RCP failure detected, reset attempt %u of %u", attempt, MAX_RESET_ATTEMPTS);
333 this->last_rcp_reset_ms_ = now;
334 }
335 this->rcp_reset_pin_->digital_write(true);
336 vTaskDelay(pdMS_TO_TICKS(10));
337 this->rcp_reset_pin_->digital_write(false);
338 vTaskDelay(pdMS_TO_TICKS(30));
339}
340#endif
341
342int OpenThreadComponent::openthread_stop_() { return esp_openthread_mainloop_exit(); }
343
344network::IPAddresses OpenThreadComponent::get_ip_addresses() {
345 network::IPAddresses addresses;
346#if USE_NETWORK_IPV6
347 // The task's clean-up destroys the netif under the lock, so the netif is only read while it is held;
348 // the OpenThread task releases the lock between events, so the wait is short
349 auto lock = InstanceLock::try_acquire(10);
350 if (!lock) {
351 ESP_LOGV(TAG, "Instance lock busy, no addresses this time");
352 return addresses;
353 }
354 if (esp_netif_t *netif = esp_openthread_get_netif(); netif != nullptr) {
355 network::fill_ip6_addresses(netif, addresses);
356 }
357#endif
358 return addresses;
359}
360
361#ifdef USE_OPENTHREAD_BORDER_ROUTER
362static constexpr uint32_t BORDER_ROUTER_RETRY_MS = 10000;
363
364void OpenThreadComponent::loop() {
365 // Thread starts on its own. Border routing starts once the Wi-Fi backbone has an address. When the
366 // backbone goes away the stack is told so it pauses routing on that interface; when it comes back
367 // the border router is created afresh, since the port's infra interface keeps the socket and the
368 // addresses of the backbone as it was. The Wi-Fi listener enables the loop on every link change
369 if (!this->mainloop_running_) {
370 return;
371 }
372 const bool backbone_up = wifi::global_wifi_component->is_connected();
373 if (backbone_up == this->backbone_up_) {
374 this->disable_loop();
375 return;
376 }
377 // Never wait for the lock on the main loop; the OpenThread task releases it between events
378 auto lock = InstanceLock::try_acquire(0);
379 if (!lock) {
380 return;
381 }
382 auto retry_later = [this](const LogString *reason) {
383 this->status_set_error(reason);
384 this->disable_loop();
385 this->set_timeout(BORDER_ROUTER_RETRY_MS, [this]() { this->enable_loop(); });
386 };
387 if (!backbone_up) {
388 if (this->border_router_started_) {
389 ESP_LOGI(TAG, "Wi-Fi backbone lost, border routing pauses");
390 esp_netif_t *backbone = esp_openthread_get_backbone_netif();
391 // A refused report is not retried: the border router is created afresh when the backbone returns
392 if (otPlatInfraIfStateChanged(lock.get_instance(), esp_netif_get_netif_impl_index(backbone), false) !=
393 OT_ERROR_NONE) {
394 ESP_LOGW(TAG, "Stack did not take the backbone loss, routes stay until Wi-Fi returns");
395 }
396 }
397 this->backbone_up_ = false;
398 this->disable_loop();
399 return;
400 }
401 if (this->border_router_started_) {
402 ESP_LOGI(TAG, "Wi-Fi backbone back, border routing restarts");
403 // The old router stays marked as started until it is gone, so a retry tears it down first
404 if (const esp_err_t err = esp_openthread_border_router_deinit(); err != ESP_OK) {
405 ESP_LOGE(TAG, "Failed to deinitialize OpenThread Border Router: %s", esp_err_to_name(err));
406 retry_later(LOG_STR("Border router deinit failed"));
407 return;
408 }
409 this->border_router_started_ = false;
410 }
411 if (const esp_err_t err = esp_openthread_border_router_init(); err != ESP_OK) {
412 ESP_LOGE(TAG, "Failed to initialize OpenThread Border Router: %s", esp_err_to_name(err));
413 retry_later(LOG_STR("Border router init failed"));
414 return;
415 }
416 this->status_clear_error();
417 this->border_router_started_ = true;
418 this->backbone_up_ = true;
419 ESP_LOGI(TAG, "Border routing started");
420 this->disable_loop();
421}
422#endif
423
424// not thread safe, only use in read-only use cases
425otInstance *OpenThreadComponent::get_openthread_instance_() { return esp_openthread_get_instance(); }
426
427InstanceLock InstanceLock::try_acquire(int delay) {
428 if (global_openthread_component == nullptr || !global_openthread_component->is_lock_initialized()) {
429 return InstanceLock(false);
430 }
431 if (!esp_openthread_lock_acquire(delay)) {
432 return InstanceLock(false);
433 }
434 // The clean-up may have released the lock to a waiter just before deinit destroys it
435 if (global_openthread_component->is_task_exited()) {
436 esp_openthread_lock_release();
437 return InstanceLock(false);
438 }
439 return InstanceLock(true);
440}
441
442// The lock went away with the task, so waiting for it could never end
443static void abort_if_task_exited() {
444 if (global_openthread_component->is_task_exited()) {
445 ESP_LOGE(TAG, "OpenThread task has exited, cannot acquire instance lock");
446 abort();
447 }
448}
449
450InstanceLock InstanceLock::acquire() {
451 // teardown() clears global_openthread_component before the stack fully stops; a caller
452 // racing teardown would otherwise dereference a null pointer below.
453 if (global_openthread_component == nullptr) {
454 ESP_LOGE(TAG, "OpenThread component torn down, cannot acquire instance lock");
455 abort();
456 }
457 // A failed setup() never creates the lock; say so now instead of after the wait below
458 if (global_openthread_component->is_failed() && !global_openthread_component->is_lock_initialized()) {
459 ESP_LOGE(TAG, "Setup failed, cannot acquire instance lock");
460 abort();
461 }
462 // Wait for the lock to be created before attempting to acquire it.
463 // esp_openthread_lock_acquire() will assert-crash if called before esp_openthread_init().
464 constexpr uint32_t lock_init_timeout_ms = 10000;
465 uint32_t start = millis();
466 while (!global_openthread_component->is_lock_initialized()) {
467 abort_if_task_exited();
468 if (millis() - start > lock_init_timeout_ms) {
469 ESP_LOGE(TAG, "OpenThread lock not initialized after %" PRIu32 "ms, aborting", lock_init_timeout_ms);
470 abort();
471 }
472 delay(10);
473 esp_task_wdt_reset();
474 }
475 while (!esp_openthread_lock_acquire(100)) {
476 abort_if_task_exited();
477 esp_task_wdt_reset();
478 }
479 // The clean-up may have released the lock to this waiter just before deinit destroys it
480 if (global_openthread_component->is_task_exited()) {
481 esp_openthread_lock_release();
482 abort_if_task_exited();
483 }
484 return InstanceLock(true);
485}
486
487otInstance *InstanceLock::get_instance() { return esp_openthread_get_instance(); }
488
489InstanceLock::~InstanceLock() {
490 if (this->owns_) {
491 esp_openthread_lock_release();
492 }
493}
494
495} // namespace esphome::openthread
496
497#ifndef USE_OPENTHREAD_BORDER_ROUTER
498// ESP-IDF's DNS64 hook runs before lwIP's literal address check and retries every lookup as IPv4,
499// so an IPv6 literal never resolves. Let lwIP handle those; linked with --wrap from __init__.py.
500// Fixed upstream on ESP-IDF master, remove this once a release includes
501// "fix(openthread): bypass DNS64 synthesis for IPv6 literals",
502// https://github.com/espressif/esp-idf/commit/87b133ee1a7e91c1ee95176b4733b7f72236e5da
503// (merged in https://github.com/espressif/esp-idf/commit/83239509832bf5d427935cd365f4b62a320e8765)
504// NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
505extern "C" {
506int __real_lwip_hook_dns_external_resolve(const char *name, ip_addr_t *addr, dns_found_callback found,
507 void *callback_arg, u8_t addrtype, err_t *err);
508int __wrap_lwip_hook_dns_external_resolve(const char *name, ip_addr_t *addr, dns_found_callback found,
509 void *callback_arg, u8_t addrtype, err_t *err) {
510 ip_addr_t literal;
511 if (ipaddr_aton(name, &literal) && IP_IS_V6_VAL(literal))
512 return 0;
513 return __real_lwip_hook_dns_external_resolve(name, addr, found, callback_arg, addrtype, err);
514}
515} // extern "C"
516// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
517#endif // USE_OPENTHREAD_BORDER_ROUTER
518#endif
void add_connect_state_listener(WiFiConnectStateListener *listener)
Add a listener for WiFi connection state changes.
esp_netif_t * get_esp_netif_sta()
esp_netif handle of the station interface, used by network for default-route arbitration.
const char * esp_err_to_name(esp_err_t err)
std::array< IPAddress, 5 > IPAddresses
Definition ip_address.h:368
void fill_ip6_addresses(esp_netif_t *netif, IPAddresses &addresses)
Copies the IPv6 addresses of an esp_netif into addresses[1..], warning once when some do not fit.
Definition util.cpp:13
OpenThreadComponent * global_openthread_component
WiFiComponent * global_wifi_component
const void size_t len
Definition hal.h:68
size_t parse_hex(const char *str, size_t length, uint8_t *data, size_t count)
Parse bytes from a hex-encoded string into a byte array.
Definition helpers.cpp:370
ESPPreferences * global_preferences
void HOT delay(uint32_t ms)
Definition hal.cpp:85
uint32_t IRAM_ATTR HOT millis()
Definition hal.cpp:25
struct esp_netif_obj esp_netif_t
int __real_lwip_hook_dns_external_resolve(const char *name, ip_addr_t *addr, dns_found_callback found, void *callback_arg, u8_t addrtype, err_t *err)
int __wrap_lwip_hook_dns_external_resolve(const char *name, ip_addr_t *addr, dns_found_callback found, void *callback_arg, u8_t addrtype, err_t *err)
ESPHOME_LOG_TAG(TAG, "openthread")
static void uint32_t
SemaphoreHandle_t lock