ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
apc_proteous_cover.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome::apc_proteous {
9
11 public:
12 void setup() override;
13 void loop() override;
14 void update() override;
15 void dump_config() override;
16
18
19 protected:
20 void control(const cover::CoverCall &call) override;
21 void parse_response_(const char *line);
22 void send_command_(const char *cmd);
23 void write_command_(const char *cmd, uint32_t now);
24 void stop_cmd_(uint32_t now);
26 void clear_pending_();
27
28 // The longest valid frame is "?s=XX"; anything longer is line noise
29 static constexpr size_t MAX_RESPONSE_LEN = 16;
30
31 // A movement command is acknowledged once the controller reports motion in the commanded
32 // direction; resend it this often, up to MAX_COMMAND_RETRIES times, since the serial link
33 // occasionally drops one. The stop toggle is never resent because a spurious toggle could start the gate.
34 static constexpr uint32_t COMMAND_ACK_MS = 2000;
35 static constexpr uint8_t MAX_COMMAND_RETRIES = 3;
36
37 // The controller echoes every command, sometimes without a terminator. A query sent too soon
38 // after a command collides with that echo, so polling pauses for this long after each command.
39 static constexpr uint32_t COMMAND_QUIET_MS = 250;
40
41 // Set only for a partial target; the gate is stopped when the reported position reaches it
42 optional<float> target_position_{};
43 // Last movement command sent and not yet acknowledged; lets a stop cancel it and drives the retries
44 const char *pending_command_{nullptr};
48 uint8_t command_retries_{0};
49 bool query_s_next_{true};
50};
51
52} // namespace esphome::apc_proteous
Collects bytes into NUL terminated lines of up to N - 1 characters; IGNORE_CHAR bytes are skipped and...
Definition line_reader.h:15
This class simplifies creating components that periodically check a state.
Definition component.h:532
LineReader< MAX_RESPONSE_LEN+1, '\r', '\n'> line_reader_
void control(const cover::CoverCall &call) override
void write_command_(const char *cmd, uint32_t now)
Base class for all cover devices.
Definition cover.h:115
static void uint32_t