ESPHome 2026.11.0b6
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#ifdef USE_BINARY_SENSOR
24 SUB_BINARY_SENSOR(connected)
25#endif
26
27 public:
29 static constexpr size_t HEADER_SIZE = 1;
30
31 explicit BasicSession(PacketInterface *lower);
32
33 void setup() override;
34 void dump_config() override;
35 bool send_to_interface(const PacketBuffer &data, const PacketMetaData &meta_data) override;
36
37 void set_keep_alive(uint32_t keep_alive_ms) { this->keep_alive_ms_ = keep_alive_ms; }
38 void set_session_timeout(uint32_t timeout_ms) { this->timeout_ms_ = timeout_ms; }
39
40 bool is_connected() const { return this->connected_; }
41
42 protected:
43 void receive_(const PacketBuffer &data, const PacketMetaData &meta_data);
44 void on_interval_();
45 void send_keep_alive_();
46 void set_connected_(bool connected);
47
54 bool peer_known_{false};
55 bool connected_{false};
56};
57
58} // namespace esphome::packet_interface
59#endif
A session layer that reports whether the peer can be reached.
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