ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
ezsp_proxy_tap.cpp
Go to the documentation of this file.
1#include "ezsp_proxy_tap.h"
2
3#ifdef USE_EZSP_PROXY_TAP
4
5#include "esphome/core/log.h"
6
8
9ESPHOME_LOG_TAG(TAG, "ezsp_proxy_tap");
10
11void EzspProxyTap::setup() { this->parent_->set_tap(this); }
12
13void EzspProxyTap::dump_config() { ESP_LOGCONFIG(TAG, "EZSP Proxy Tap:\n Port: %s", this->parent_->get_name()); }
14
15void EzspProxyTap::on_device_rx(const uint8_t *data, size_t len) {
16 for (size_t i = 0; i < len; i++) {
17 if (this->acknowledger_.feed(data[i])) {
18 uint8_t frame[ASH_ACK_FRAME_SIZE];
20 this->parent_->write_from_tap(frame, sizeof(frame));
21 ESP_LOGV(TAG, "Sent ACK %u", this->acknowledger_.ack_num());
22 }
23 }
24}
25
27 // Numbering from an earlier session is stale
28 this->acknowledger_.reset();
29}
30
32 // The frame numbering ended with the NCP's power; whatever boots next starts over
33 this->acknowledger_.reset();
34}
35
36} // namespace esphome::ezsp_proxy_tap
37
38#endif // USE_EZSP_PROXY_TAP
void on_device_rx(const uint8_t *data, size_t len) override
serial_proxy::SerialProxy * parent_
void set_tap(SerialProxyTap *tap)
Attach a traffic observer. At most one, set once at setup time.
bool write_from_tap(const uint8_t *data, size_t len)
Write bytes originating from the tap rather than from a client.
const char * get_name() const
Get the human-readable port name.
void ash_build_ack_frame(uint8_t *output, uint8_t ack_num)
ESPHOME_LOG_TAG(TAG, "ezsp_proxy_tap")
const void size_t len
Definition hal.h:68