ESPHome 2025.6.1
Loading...
Searching...
No Matches
openthread.h
Go to the documentation of this file.
1#pragma once
3#ifdef USE_OPENTHREAD
4
8
9#include <openthread/thread.h>
10
11#include <optional>
12#include <vector>
13
14namespace esphome {
15namespace openthread {
16
17class InstanceLock;
18
20 public:
23 void setup() override;
24 float get_setup_priority() const override { return setup_priority::WIFI; }
25
26 bool is_connected();
28 std::optional<otIp6Address> get_omr_address();
29 void ot_main();
30
31 protected:
32 std::optional<otIp6Address> get_omr_address_(InstanceLock &lock);
33};
34
35extern OpenThreadComponent *global_openthread_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
36
38 public:
40 // This has to run after the mdns component or else no services are available to advertise
41 float get_setup_priority() const override { return this->mdns_->get_setup_priority() - 1.0; }
42 void setup() override;
43
44 protected:
46 std::vector<esphome::mdns::MDNSService> mdns_services_;
47 std::vector<std::unique_ptr<uint8_t[]>> memory_pool_;
48 void *pool_alloc_(size_t size);
49};
50
52 public:
53 static std::optional<InstanceLock> try_acquire(int delay);
54 static InstanceLock acquire();
56
57 // Returns the global openthread instance guarded by this lock
58 otInstance *get_instance();
59
60 private:
61 // Use a private constructor in order to force thehandling
62 // of acquisition failure
63 InstanceLock() {}
64};
65
66} // namespace openthread
67} // namespace esphome
68#endif
float get_setup_priority() const override
static std::optional< InstanceLock > try_acquire(int delay)
std::optional< otIp6Address > get_omr_address_(InstanceLock &lock)
std::optional< otIp6Address > get_omr_address()
float get_setup_priority() const override
Definition openthread.h:24
std::vector< std::unique_ptr< uint8_t[]> > memory_pool_
Definition openthread.h:47
void set_mdns(esphome::mdns::MDNSComponent *mdns)
std::vector< esphome::mdns::MDNSService > mdns_services_
Definition openthread.h:46
float get_setup_priority() const override
Definition openthread.h:41
esphome::mdns::MDNSComponent * mdns_
Definition openthread.h:45
std::array< IPAddress, 5 > IPAddresses
Definition ip_address.h:143
OpenThreadComponent * global_openthread_component
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
void IRAM_ATTR HOT delay(uint32_t ms)
Definition core.cpp:29