mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 02:28:28 +02:00
947c104eff
Co-authored-by: Ben Buxton <bb@cactii.net> Co-authored-by: Otto Winter <otto@otto-winter.com> Co-authored-by: Stefan Agner <stefan@agner.ch> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: René Klomp <rene@klomp.ws> Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl> Co-authored-by: Geoff Davis <geoff@geoffdavis.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: dentra <dentra@users.noreply.github.com> Co-authored-by: Guillermo Ruffino <glm.net@gmail.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Barry Loong <loongyh@users.noreply.github.com> Co-authored-by: Sergey V. DUDANOV <sergey.dudanov@gmail.com> Co-authored-by: Balazs Scheidler <bazsi77@gmail.com>
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/components/ble_client/ble_client.h"
|
|
#include "esphome/components/esp32_ble_tracker/esp32_ble_tracker.h"
|
|
#include "esphome/components/cover/cover.h"
|
|
#include "esphome/components/am43/am43_base.h"
|
|
|
|
#ifdef ARDUINO_ARCH_ESP32
|
|
|
|
#include <esp_gattc_api.h>
|
|
|
|
namespace esphome {
|
|
namespace am43 {
|
|
|
|
namespace espbt = esphome::esp32_ble_tracker;
|
|
|
|
class Am43Component : public cover::Cover, public esphome::ble_client::BLEClientNode, public Component {
|
|
public:
|
|
void setup() override;
|
|
void loop() override;
|
|
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 dump_config() override;
|
|
float get_setup_priority() const override { return setup_priority::DATA; }
|
|
cover::CoverTraits get_traits() override;
|
|
void set_pin(uint16_t pin) { this->pin_ = pin; }
|
|
void set_invert_position(bool invert_position) { this->invert_position_ = invert_position; }
|
|
|
|
protected:
|
|
void control(const cover::CoverCall &call) override;
|
|
uint16_t char_handle_;
|
|
uint16_t pin_;
|
|
bool invert_position_;
|
|
Am43Encoder *encoder_;
|
|
Am43Decoder *decoder_;
|
|
bool logged_in_;
|
|
|
|
float position_;
|
|
};
|
|
|
|
} // namespace am43
|
|
} // namespace esphome
|
|
|
|
#endif
|