mirror of
https://github.com/esphome/esphome.git
synced 2026-08-22 22:26:21 +00:00
[wireguard] Inline the trivial Wireguard setters
This commit is contained in:
@@ -178,25 +178,6 @@ time_t Wireguard::get_latest_handshake() const {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wireguard::set_keepalive(const uint16_t seconds) { this->keepalive_ = seconds; }
|
|
||||||
void Wireguard::set_reboot_timeout(const uint32_t seconds) { this->reboot_timeout_ = seconds; }
|
|
||||||
void Wireguard::set_srctime(time::RealTimeClock *srctime) { this->srctime_ = srctime; }
|
|
||||||
|
|
||||||
#ifdef USE_BINARY_SENSOR
|
|
||||||
void Wireguard::set_status_sensor(binary_sensor::BinarySensor *sensor) { this->status_sensor_ = sensor; }
|
|
||||||
void Wireguard::set_enabled_sensor(binary_sensor::BinarySensor *sensor) { this->enabled_sensor_ = sensor; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_SENSOR
|
|
||||||
void Wireguard::set_handshake_sensor(sensor::Sensor *sensor) { this->handshake_sensor_ = sensor; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_TEXT_SENSOR
|
|
||||||
void Wireguard::set_address_sensor(text_sensor::TextSensor *sensor) { this->address_sensor_ = sensor; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Wireguard::disable_auto_proceed() { this->proceed_allowed_ = false; }
|
|
||||||
|
|
||||||
void Wireguard::enable() {
|
void Wireguard::enable() {
|
||||||
this->enabled_ = true;
|
this->enabled_ = true;
|
||||||
ESP_LOGI(TAG, "Enabled");
|
ESP_LOGI(TAG, "Enabled");
|
||||||
@@ -218,8 +199,6 @@ void Wireguard::publish_enabled_state() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wireguard::is_enabled() { return this->enabled_; }
|
|
||||||
|
|
||||||
void Wireguard::start_connection_() {
|
void Wireguard::start_connection_() {
|
||||||
if (!this->enabled_) {
|
if (!this->enabled_) {
|
||||||
ESP_LOGV(TAG, "Disabled, cannot start connection");
|
ESP_LOGV(TAG, "Disabled, cannot start connection");
|
||||||
|
|||||||
@@ -63,25 +63,25 @@ class Wireguard final : public PollingComponent {
|
|||||||
/// Prevent accidental use of std::string which would dangle
|
/// Prevent accidental use of std::string which would dangle
|
||||||
void set_allowed_ips(std::initializer_list<std::tuple<std::string, std::string>> ips) = delete;
|
void set_allowed_ips(std::initializer_list<std::tuple<std::string, std::string>> ips) = delete;
|
||||||
|
|
||||||
void set_keepalive(uint16_t seconds);
|
void set_keepalive(const uint16_t seconds) { this->keepalive_ = seconds; }
|
||||||
void set_reboot_timeout(uint32_t seconds);
|
void set_reboot_timeout(const uint32_t seconds) { this->reboot_timeout_ = seconds; }
|
||||||
void set_srctime(time::RealTimeClock *srctime);
|
void set_srctime(time::RealTimeClock *srctime) { this->srctime_ = srctime; }
|
||||||
|
|
||||||
#ifdef USE_BINARY_SENSOR
|
#ifdef USE_BINARY_SENSOR
|
||||||
void set_status_sensor(binary_sensor::BinarySensor *sensor);
|
void set_status_sensor(binary_sensor::BinarySensor *sensor) { this->status_sensor_ = sensor; }
|
||||||
void set_enabled_sensor(binary_sensor::BinarySensor *sensor);
|
void set_enabled_sensor(binary_sensor::BinarySensor *sensor) { this->enabled_sensor_ = sensor; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_SENSOR
|
#ifdef USE_SENSOR
|
||||||
void set_handshake_sensor(sensor::Sensor *sensor);
|
void set_handshake_sensor(sensor::Sensor *sensor) { this->handshake_sensor_ = sensor; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_TEXT_SENSOR
|
#ifdef USE_TEXT_SENSOR
|
||||||
void set_address_sensor(text_sensor::TextSensor *sensor);
|
void set_address_sensor(text_sensor::TextSensor *sensor) { this->address_sensor_ = sensor; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Block the setup step until peer is connected.
|
/// Block the setup step until peer is connected.
|
||||||
void disable_auto_proceed();
|
void disable_auto_proceed() { this->proceed_allowed_ = false; }
|
||||||
|
|
||||||
/// Enable the WireGuard component.
|
/// Enable the WireGuard component.
|
||||||
void enable();
|
void enable();
|
||||||
@@ -93,7 +93,7 @@ class Wireguard final : public PollingComponent {
|
|||||||
void publish_enabled_state();
|
void publish_enabled_state();
|
||||||
|
|
||||||
/// Return if the WireGuard component is or is not enabled.
|
/// Return if the WireGuard component is or is not enabled.
|
||||||
bool is_enabled();
|
bool is_enabled() { return this->enabled_; }
|
||||||
|
|
||||||
bool is_peer_up() const;
|
bool is_peer_up() const;
|
||||||
time_t get_latest_handshake() const;
|
time_t get_latest_handshake() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user