ESPHome  2024.12.2
wake_on_lan.h
Go to the documentation of this file.
1 #pragma once
2 #include "esphome/core/defines.h"
3 #ifdef USE_NETWORK
6 #if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
8 #else
9 #include "WiFiUdp.h"
10 #endif
11 
12 namespace esphome {
13 namespace wake_on_lan {
14 
15 class WakeOnLanButton : 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_[6];
32 };
33 
34 } // namespace wake_on_lan
35 } // namespace esphome
36 #endif
void set_macaddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f)
Definition: wake_on_lan.cpp:13
const float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition: component.cpp:26
Base class for all buttons.
Definition: button.h:29
float get_setup_priority() const override
Definition: wake_on_lan.h:21
std::unique_ptr< socket::Socket > broadcast_socket_
Definition: wake_on_lan.h:25
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7