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.", this->
parent_->
address_str());
49 ESP_LOGE(TAG,
"[%s] No control service found at device, not an AM43..?", this->
parent_->
address_str());
56 case ESP_GATTC_REG_FOR_NOTIFY_EVT: {
57 this->
node_state = espbt::ClientState::ESTABLISHED;
61 case ESP_GATTC_NOTIFY_EVT: {
62 if (param->notify.handle != this->char_handle_)
64 this->
decoder_->decode(param->notify.value, param->notify.value_len);
78 auto *packet = this->
encoder_->get_light_level_request();
80 this->char_handle_, packet->length, packet->data,
81 ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
96 if (this->
node_state != espbt::ClientState::ESTABLISHED) {
102 auto *packet = this->
encoder_->get_battery_level_request();
104 esp_ble_gattc_write_char(this->
parent_->
get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_,
105 packet->length, packet->data, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);