27 auto mode_val =
call.get_mode();
28 if (mode_val.has_value()) {
33 pkt = this->
codec_->get_stop_request();
36 pkt = this->
codec_->get_start_request();
39 ESP_LOGW(TAG,
"Unsupported mode: %d",
mode);
43 esp_ble_gattc_write_char(this->
parent_->
get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_,
44 pkt->
length, pkt->
data, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
49 auto target_temp =
call.get_target_temperature();
50 if (target_temp.has_value()) {
51 auto *pkt = this->
codec_->get_set_target_temp_request(*target_temp);
53 esp_ble_gattc_write_char(this->
parent_->
get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_,
54 pkt->length, pkt->data, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
63 case ESP_GATTC_DISCONNECT_EVT: {
69 case ESP_GATTC_SEARCH_CMPL_EVT: {
72 ESP_LOGW(TAG,
"[%s] No control service found at device, not an Anova..?", this->
get_name().c_str());
73 ESP_LOGW(TAG,
"[%s] Note, this component does not currently support Anova Nano.", this->
get_name().c_str());
81 ESP_LOGW(TAG,
"[%s] esp_ble_gattc_register_for_notify failed, status=%d", this->
get_name().c_str(),
status);
85 case ESP_GATTC_REG_FOR_NOTIFY_EVT: {
86 this->
node_state = espbt::ClientState::ESTABLISHED;
91 case ESP_GATTC_NOTIFY_EVT: {
92 if (param->notify.handle != this->char_handle_)
94 this->
codec_->decode(param->notify.value, param->notify.value_len);
95 if (this->
codec_->has_target_temp()) {
98 if (this->
codec_->has_current_temp()) {
101 if (this->
codec_->has_running()) {
104 if (this->
codec_->has_unit()) {
106 ESP_LOGD(TAG,
"Anova units is %s", this->
fahrenheit_ ?
"fahrenheit" :
"celsius");
115 pkt = this->
codec_->get_read_target_temp_request();
118 pkt = this->
codec_->get_read_current_temp_request();
124 if (pkt !=
nullptr) {
126 esp_ble_gattc_write_char(this->
parent_->
get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_,
127 pkt->
length, pkt->
data, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
143 if (this->
node_state != espbt::ClientState::ESTABLISHED)
151 pkt = this->
codec_->get_read_device_status_request();
154 esp_ble_gattc_write_char(this->
parent_->
get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_,
155 pkt->
length, pkt->
data, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);