Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: tomaszduda23 <tomaszduda23@gmail.com>
36 lines
1020 B
C++
36 lines
1020 B
C++
#pragma once
|
|
#include "esphome/core/defines.h"
|
|
#if defined(USE_NETWORK) && !defined(USE_ZEPHYR)
|
|
#include "esphome/components/button/button.h"
|
|
#include "esphome/core/component.h"
|
|
#if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
|
|
#include "esphome/components/socket/socket.h"
|
|
#else
|
|
#include "WiFiUdp.h"
|
|
#endif
|
|
|
|
namespace esphome::wake_on_lan {
|
|
|
|
class WakeOnLanButton : public button::Button, public Component {
|
|
public:
|
|
void set_macaddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f);
|
|
|
|
void dump_config() override;
|
|
void setup() override;
|
|
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
|
|
|
protected:
|
|
#if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
|
|
std::unique_ptr<socket::Socket> broadcast_socket_{};
|
|
#else
|
|
WiFiUDP udp_client_{};
|
|
#endif
|
|
void press_action() override;
|
|
uint16_t port_{9};
|
|
uint8_t macaddr_[6];
|
|
};
|
|
|
|
} // namespace esphome::wake_on_lan
|
|
|
|
#endif // USE_NETWORK && !USE_ZEPHYR
|