ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
delta_wallbox.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_ESP32
4
5#include <array>
12
13#ifdef USE_TIME
15#endif
16
17namespace esphome::delta_wallbox {
18// Largest FC03 response: unit, function, byte count, 255 data bytes, CRC.
19static constexpr size_t MAX_FRAME_LEN = 260;
36
38 public:
39 DeltaWallbox(const char *user, const char *password) : user_(user), password_(password) {}
40 void update() override;
41 void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
42 esp_ble_gattc_cb_param_t *param) override;
43 void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override;
44 void dump_config() override;
45
46 void set_pin(uint32_t pin) {
47 this->pin_ = pin;
48 this->has_pin_ = true;
49 }
50#ifdef USE_TIME
51 void set_time_id(time::RealTimeClock *time_id) { this->time_id_ = time_id; }
52#endif
53
55 SUB_SENSOR(energy)
56 SUB_SENSOR(charging_time)
57 SUB_SENSOR(charger_state)
58 SUB_SENSOR(max_current)
59 SUB_TEXT_SENSOR(serial_number)
60 SUB_TEXT_SENSOR(fw_version)
61 SUB_TEXT_SENSOR(bt_fw_version)
62 SUB_TEXT_SENSOR(model_name)
63 SUB_TEXT_SENSOR(error_code)
64 void set_charging_state(bool state);
65 void start_charging();
66 void stop_charging();
67
72
73 protected:
74 void write_frame_(const uint8_t *frame, size_t len);
75 void send_frame_(const uint8_t *body, size_t len);
77 void retransmit_();
79 void handle_frame_(const uint8_t *frame, size_t len);
80 void drop_rx_bytes_(size_t count);
81 void reset_state_();
82 // Stops the handshake until the next BLE disconnect; used for failures a retry can't fix.
83 void halt_(const LogString *reason);
84
85 // Members ordered by size so nothing is padded
89#ifdef USE_TIME
91#endif
92 size_t rx_len_{0};
93
94 uint16_t rx_char_handle_{0};
95 uint16_t tx_char_handle_{0};
98 bool has_pin_{false};
100 std::array<uint8_t, MAX_FRAME_LEN> rx_buffer_{};
101};
102} // namespace esphome::delta_wallbox
103#endif
This class simplifies creating components that periodically check a state.
Definition component.h:519
StringRef is a reference to a string owned by something else.
Definition string_ref.h:31
void write_frame_(const uint8_t *frame, size_t len)
void halt_(const LogString *reason)
void set_time_id(time::RealTimeClock *time_id)
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
void handle_frame_(const uint8_t *frame, size_t len)
std::array< uint8_t, MAX_FRAME_LEN > rx_buffer_
void send_frame_(const uint8_t *body, size_t len)
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override
SUB_SENSOR(power) SUB_SENSOR(energy) SUB_SENSOR(charging_time) SUB_SENSOR(charger_state) SUB_SENSOR(max_current) SUB_TEXT_SENSOR(serial_number) SUB_TEXT_SENSOR(fw_version) SUB_TEXT_SENSOR(bt_fw_version) SUB_TEXT_SENSOR(model_name) SUB_TEXT_SENSOR(error_code) void set_charging_state(bool state)
DeltaWallbox(const char *user, const char *password)
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock.
NameCopy * next
bool state
Definition fan.h:2
unsigned count
Definition gif.cpp:51
const void size_t len
Definition hal.h:68
static void uint32_t
char serial_number[10]
Definition sun_gtil2.cpp:15