27 case ESP_GATTC_OPEN_EVT: {
28 if (param->open.status == ESP_GATT_OK) {
33 case ESP_GATTC_DISCONNECT_EVT: {
42 case ESP_GATTC_SEARCH_CMPL_EVT: {
46 ESP_LOGE(TAG,
"[%s] Detected a Tuya AM43 which is not supported, sorry.", this->
parent_->
address_str());
48 ESP_LOGE(TAG,
"[%s] No control service found at device, not an AM43..?", this->
parent_->
address_str());
55 case ESP_GATTC_REG_FOR_NOTIFY_EVT: {
56 this->
node_state = espbt::ClientState::ESTABLISHED;
60 case ESP_GATTC_NOTIFY_EVT: {
61 if (param->notify.handle != this->char_handle_)
63 this->
decoder_->decode(param->notify.value, param->notify.value_len);
77 auto *packet = this->
encoder_->get_light_level_request();
79 this->char_handle_, packet->length, packet->data,
80 ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
95 if (this->
node_state != espbt::ClientState::ESTABLISHED) {
101 auto *packet = this->
encoder_->get_battery_level_request();
103 esp_ble_gattc_write_char(this->
parent_->
get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_,
104 packet->length, packet->data, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);