#pragma once #include "esphome/components/esp32_ble_client/ble_client_base.h" #include "ap2_protocol.h" #include #include namespace esphome { namespace ap2_hub { class AP2Hub; /* Transient BLE client the hub uses during a scan: connect to one candidate, * look for the Nordic-UART service, send M99, and confirm an AP2 by its reply. * Every probe ends at ClientState::IDLE, which is the single signal back to the * hub that the prober is free for the next candidate. */ class AP2ProbeClient : public esp32_ble_client::BLEClientBase { public: void set_hub(AP2Hub *hub) { this->hub_ = hub; } void start_probe(uint64_t mac, esp_ble_addr_type_t type); void abort_probe(); bool gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override; void set_state(espbt::ClientState st) override; protected: AP2Hub *hub_{nullptr}; uint16_t rx_handle_{0}; uint16_t tx_handle_{0}; uint16_t ccc_handle_{0}; bool active_{false}; bool confirmed_{false}; std::string fw_; }; } // namespace ap2_hub } // namespace esphome