9 static const char *
const TAG =
"ble_binary_output";
12 ESP_LOGCONFIG(TAG,
"BLE Binary Output:");
16 LOG_BINARY_OUTPUT(
this);
20 esp_ble_gattc_cb_param_t *param) {
22 case ESP_GATTC_SEARCH_CMPL_EVT: {
25 ESP_LOGW(TAG,
"Characteristic %s was not found in service %s", this->
char_uuid_.
to_string().c_str(),
33 ESP_LOGD(TAG,
"Write type: ESP_GATT_WRITE_TYPE_RSP");
36 ESP_LOGD(TAG,
"Write type: ESP_GATT_WRITE_TYPE_NO_RSP");
38 ESP_LOGE(TAG,
"Characteristic %s does not allow writing with%s response", this->
char_uuid_.
to_string().c_str(),
42 this->
node_state = espbt::ClientState::ESTABLISHED;
45 this->
node_state = espbt::ClientState::ESTABLISHED;
48 case ESP_GATTC_WRITE_CHAR_EVT: {
49 if (param->write.handle == this->char_handle_) {
50 if (param->write.status != 0)
51 ESP_LOGW(TAG,
"[%s] Write error, status=%d", this->
char_uuid_.
to_string().c_str(), param->write.status);
61 if (this->
node_state != espbt::ClientState::ESTABLISHED) {
62 ESP_LOGW(TAG,
"[%s] Not connected to BLE client. State update can not be written.",
66 uint8_t state_as_uint = (uint8_t) state;
70 sizeof(state_as_uint), &state_as_uint, this->
write_type_, ESP_GATT_AUTH_REQ_NONE);
71 if (err != ESP_GATT_OK)
esp_gatt_char_prop_t char_props_
void write_state(bool state) override
espbt::ESPBTUUID service_uuid_
void dump_config() override
std::string address_str() const
espbt::ESPBTUUID char_uuid_
std::string to_string() const
BLECharacteristic * get_characteristic(espbt::ESPBTUUID service, espbt::ESPBTUUID chr)
Implementation of SPI Controller mode.
esp_gatt_write_type_t write_type_
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
espbt::ClientState node_state