ESPHome 2026.10.0-dev
Loading...
Searching...
No Matches
wake_on_lan.h
Go to the documentation of this file.
1#pragma once
3#if defined(USE_NETWORK) && !defined(USE_ZEPHYR)
7#if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
9#else
10#include "WiFiUdp.h"
11#endif
12
13namespace esphome::wake_on_lan {
14
15class WakeOnLanButton final : public button::Button, public Component {
16 public:
17 void set_macaddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f);
18
19 void dump_config() override;
20 void setup() override;
21 float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
22
23 protected:
24#if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
25 std::unique_ptr<socket::Socket> broadcast_socket_{};
26#else
27 WiFiUDP udp_client_{};
28#endif
29 void press_action() override;
30 uint16_t port_{9};
31 uint8_t macaddr_[MAC_ADDRESS_SIZE];
32};
33
34} // namespace esphome::wake_on_lan
35
36#endif // USE_NETWORK && !USE_ZEPHYR
Base class for all buttons.
Definition button.h:25
void set_macaddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f)
float get_setup_priority() const override
Definition wake_on_lan.h:21
uint8_t macaddr_[MAC_ADDRESS_SIZE]
Definition wake_on_lan.h:31
std::unique_ptr< socket::Socket > broadcast_socket_
Definition wake_on_lan.h:25
constexpr float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition component.h:55