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