3 #include "ble_service.h" 4 #include "ble_characteristic.h" 20 #include <esp_gap_ble_api.h> 21 #include <esp_gatts_api.h> 24 namespace esp32_ble_server {
26 using namespace esp32_ble;
38 void setup()
override;
40 void dump_config()
override;
41 float get_setup_priority()
const override;
46 void set_manufacturer(
const std::string &manufacturer) { this->manufacturer_ = manufacturer; }
47 void set_model(
const std::string &model) { this->model_ = model; }
49 std::shared_ptr<BLEService> create_service(
const uint8_t *uuid,
bool advertise =
false);
50 std::shared_ptr<BLEService> create_service(uint16_t uuid,
bool advertise =
false);
51 std::shared_ptr<BLEService> create_service(
const std::string &uuid,
bool advertise =
false);
52 std::shared_ptr<BLEService> create_service(
ESPBTUUID uuid,
bool advertise =
false, uint16_t num_handles = 15,
57 const std::map<uint16_t, void *> &
get_clients() {
return this->clients_; }
59 void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if,
60 esp_ble_gatts_cb_param_t *param)
override;
65 bool create_device_characteristics_();
68 this->clients_.insert(std::pair<uint16_t, void *>(conn_id, client));
70 bool remove_client_(uint16_t conn_id) {
return this->clients_.erase(conn_id) > 0; }
72 bool can_proceed_{
false};
76 esp_gatt_if_t gatts_if_{0};
77 bool registered_{
false};
79 uint32_t connected_clients_{0};
const std::map< uint16_t, void * > & get_clients()
bool remove_client_(uint16_t conn_id)
bool can_proceed() override
std::shared_ptr< BLEService > device_information_service_
esp_gatt_if_t get_gatts_if()
optional< std::string > model_
void add_client_(uint16_t conn_id, void *client)
std::vector< BLEServiceComponent * > service_components_
virtual void on_client_connect()
BLEServer * global_ble_server
std::vector< std::shared_ptr< BLEService > > services_
std::string manufacturer_
uint32_t get_connected_client_count()
std::map< uint16_t, void * > clients_
void register_service_component(BLEServiceComponent *component)
void set_model(const std::string &model)
virtual void on_client_disconnect()
void set_manufacturer(const std::string &manufacturer)
Helper class to easily give an object a parent of type T.