ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
basic_session.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_PACKET_INTERFACE_BASIC_SESSION
5#include "packet_interface.h"
6#ifdef USE_BINARY_SENSOR
8#endif
9
11
23 public:
25 static constexpr size_t HEADER_SIZE = 1;
26
27 explicit BasicSession(PacketInterface *lower);
28
29 void setup() override;
30 void dump_config() override;
31 bool send_to_interface(const PacketBuffer &data, const PacketMetaData &meta_data) override;
32
33 void set_keep_alive(uint32_t keep_alive_ms) { this->keep_alive_ms_ = keep_alive_ms; }
34 void set_session_timeout(uint32_t timeout_ms) { this->timeout_ms_ = timeout_ms; }
35#ifdef USE_BINARY_SENSOR
37#endif
38
39 bool is_connected() const { return this->connected_; }
40
41 protected:
42 void receive_(const PacketBuffer &data, const PacketMetaData &meta_data);
43 void on_interval_();
44 void send_keep_alive_();
45 void set_connected_(bool connected);
46
48#ifdef USE_BINARY_SENSOR
50#endif
56 bool peer_known_{false};
57 bool connected_{false};
58};
59
60} // namespace esphome::packet_interface
61#endif
Base class for all binary_sensor-type classes.
A session layer that reports whether the peer can be reached.
binary_sensor::BinarySensor * connected_sensor_
bool send_to_interface(const PacketBuffer &data, const PacketMetaData &meta_data) override
void set_connected_sensor(binary_sensor::BinarySensor *sensor)
void set_session_timeout(uint32_t timeout_ms)
void set_keep_alive(uint32_t keep_alive_ms)
static constexpr size_t HEADER_SIZE
The packet type byte.
void receive_(const PacketBuffer &data, const PacketMetaData &meta_data)
A buffer class that efficiently represents a composite buffer with three sections:
A class that will transport data to and from an abstract channel.
A struct to hold metadata about a packet.
static void uint32_t