28 case ESP_GATTC_OPEN_EVT: {
29 if (param->open.status == ESP_GATT_OK) {
34 case ESP_GATTC_DISCONNECT_EVT: {
43 case ESP_GATTC_SEARCH_CMPL_EVT: {
47 ESP_LOGE(TAG,
"[%s] Detected a Tuya AM43 which is not supported, sorry.",
50 ESP_LOGE(TAG,
"[%s] No control service found at device, not an AM43..?",
58 case ESP_GATTC_REG_FOR_NOTIFY_EVT: {
59 this->
node_state = espbt::ClientState::ESTABLISHED;
63 case ESP_GATTC_NOTIFY_EVT: {
64 if (param->notify.handle != this->char_handle_)
66 this->
decoder_->decode(param->notify.value, param->notify.value_len);
80 auto *packet = this->
encoder_->get_light_level_request();
82 this->char_handle_, packet->length, packet->data,
83 ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
85 ESP_LOGW(TAG,
"[%s] esp_ble_gattc_write_char failed, status=%d", this->
parent_->
address_str().c_str(),
99 if (this->
node_state != espbt::ClientState::ESTABLISHED) {
100 ESP_LOGW(TAG,
"[%s] Cannot poll, not connected", this->
parent_->
address_str().c_str());
105 auto *packet = this->
encoder_->get_battery_level_request();
107 esp_ble_gattc_write_char(this->
parent_->
get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_,
108 packet->length, packet->data, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);