ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
bedjet_hub.cpp
Go to the documentation of this file.
1#ifdef USE_ESP32
2
3#include "bedjet_hub.h"
4#include "bedjet_child.h"
5#include "bedjet_const.h"
7#include <cinttypes>
8
9namespace esphome::bedjet {
10
11static const LogString *bedjet_button_to_string(BedjetButton button) {
12 switch (button) {
13 case BTN_OFF:
14 return LOG_STR("OFF");
15 case BTN_COOL:
16 return LOG_STR("COOL");
17 case BTN_HEAT:
18 return LOG_STR("HEAT");
19 case BTN_EXTHT:
20 return LOG_STR("EXT HT");
21 case BTN_TURBO:
22 return LOG_STR("TURBO");
23 case BTN_DRY:
24 return LOG_STR("DRY");
25 case BTN_M1:
26 return LOG_STR("M1");
27 case BTN_M2:
28 return LOG_STR("M2");
29 case BTN_M3:
30 return LOG_STR("M3");
31 default:
32 return LOG_STR("unknown");
33 }
34}
35
36/* Public */
37
39 auto *pkt = this->codec_->get_button_request(MAGIC_UPDATE);
40 auto status = this->write_bedjet_packet_(pkt);
41
42 if (status) {
43 ESP_LOGW(TAG, "[%s] MAGIC_UPDATE button failed, status=%d", this->get_name().c_str(), status);
44 }
45}
46
51bool BedJetHub::button_dry() { return this->send_button(BTN_DRY); }
52bool BedJetHub::button_off() { return this->send_button(BTN_OFF); }
56
57bool BedJetHub::set_fan_index(uint8_t fan_speed_index) {
58 if (fan_speed_index > 19) {
59 ESP_LOGW(TAG, "Invalid fan speed index %d, expecting 0-19.", fan_speed_index);
60 return false;
61 }
62
63 auto *pkt = this->codec_->get_set_fan_speed_request(fan_speed_index);
64 auto status = this->write_bedjet_packet_(pkt);
65
66 if (status) {
67 ESP_LOGW(TAG, "[%s] writing fan speed failed, status=%d", this->get_name().c_str(), status);
68 }
69 return status == 0;
70}
71
73 auto *status = this->codec_->get_status_packet();
74 if (status != nullptr) {
75 return status->fan_step;
76 }
77 return 0;
78}
79
80bool BedJetHub::set_target_temp(float temp_c) {
81 auto *pkt = this->codec_->get_set_target_temp_request(temp_c);
82 auto status = this->write_bedjet_packet_(pkt);
83
84 if (status) {
85 ESP_LOGW(TAG, "[%s] writing target temp failed, status=%d", this->get_name().c_str(), status);
86 }
87 return status == 0;
88}
89
90bool BedJetHub::set_time_remaining(uint8_t hours, uint8_t mins) {
91 // FIXME: this may fail depending on current mode or other restrictions enforced by the unit.
92 auto *pkt = this->codec_->get_set_runtime_remaining_request(hours, mins);
93 auto status = this->write_bedjet_packet_(pkt);
94
95 if (status) {
96 ESP_LOGW(TAG, "[%s] writing remaining runtime failed, status=%d", this->get_name().c_str(), status);
97 }
98 return status == 0;
99}
100
102 auto *pkt = this->codec_->get_button_request(button);
103 auto status = this->write_bedjet_packet_(pkt);
104
105 if (status) {
106 ESP_LOGW(TAG, "[%s] writing button %s failed, status=%d", this->get_name().c_str(),
107 LOG_STR_ARG(bedjet_button_to_string(button)), status);
108 } else {
109 ESP_LOGD(TAG, "[%s] writing button %s success", this->get_name().c_str(),
110 LOG_STR_ARG(bedjet_button_to_string(button)));
111 }
112 return status == 0;
113}
114
116 auto *status = this->codec_->get_status_packet();
117 if (status != nullptr) {
118 return status->time_remaining_secs + status->time_remaining_mins * 60 + status->time_remaining_hrs * 3600;
119 }
120 return 0;
121}
122
123/* Bluetooth/GATT */
124
126 if (!this->is_connected()) {
127 if (!this->parent_->enabled) {
128 ESP_LOGI(TAG, "[%s] Cannot write packet: Not connected, enabled=false", this->get_name().c_str());
129 } else {
130 ESP_LOGW(TAG, "[%s] Cannot write packet: Not connected", this->get_name().c_str());
131 }
132 return -1;
133 }
134 auto status = esp_ble_gattc_write_char(this->parent_->get_gattc_if(), this->parent_->get_conn_id(),
135 this->char_handle_cmd_, pkt->data_length + 1, (uint8_t *) &pkt->command,
136 ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
137 return status;
138}
139
141uint8_t BedJetHub::set_notify_(const bool enable) {
142 uint8_t status;
143 if (enable) {
144 status = esp_ble_gattc_register_for_notify(this->parent_->get_gattc_if(), this->parent_->get_remote_bda(),
145 this->char_handle_status_);
146 if (status) {
147 ESP_LOGW(TAG, "[%s] esp_ble_gattc_register_for_notify failed, status=%d", this->get_name().c_str(), status);
148 }
149 } else {
150 status = esp_ble_gattc_unregister_for_notify(this->parent_->get_gattc_if(), this->parent_->get_remote_bda(),
151 this->char_handle_status_);
152 if (status) {
153 ESP_LOGW(TAG, "[%s] esp_ble_gattc_unregister_for_notify failed, status=%d", this->get_name().c_str(), status);
154 }
155 }
156 ESP_LOGV(TAG, "[%s] set_notify: enable=%d; result=%d", this->get_name().c_str(), enable, status);
157 return status;
158}
159
161 bool result = true;
163
164 if (!this->char_handle_cmd_) {
165 chr = this->parent_->get_characteristic(BEDJET_SERVICE_UUID, BEDJET_COMMAND_UUID);
166 if (chr == nullptr) {
167 ESP_LOGW(TAG, "[%s] No control service found at device, not a BedJet..?", this->get_name().c_str());
168 result = false;
169 } else {
170 this->char_handle_cmd_ = chr->handle;
171 }
172 }
173
174 if (!this->char_handle_status_) {
175 chr = this->parent_->get_characteristic(BEDJET_SERVICE_UUID, BEDJET_STATUS_UUID);
176 if (chr == nullptr) {
177 ESP_LOGW(TAG, "[%s] No status service found at device, not a BedJet..?", this->get_name().c_str());
178 result = false;
179 } else {
180 this->char_handle_status_ = chr->handle;
181 }
182 }
183
184 if (!this->config_descr_status_) {
185 // We also need to obtain the config descriptor for this handle.
186 // Otherwise once we set node_state=Established, the parent will flush all handles/descriptors, and we won't be
187 // able to look it up.
188 auto *descr = this->parent_->get_config_descriptor(this->char_handle_status_);
189 if (descr == nullptr) {
190 ESP_LOGW(TAG, "No config descriptor for status handle 0x%x. Will not be able to receive status notifications",
191 this->char_handle_status_);
192 result = false;
193 } else if (descr->uuid.get_uuid().len != ESP_UUID_LEN_16 ||
194 descr->uuid.get_uuid().uuid.uuid16 != ESP_GATT_UUID_CHAR_CLIENT_CONFIG) {
195 char uuid_buf[espbt::UUID_STR_LEN];
196 ESP_LOGW(TAG, "Config descriptor 0x%x (uuid %s) is not a client config char uuid", this->char_handle_status_,
197 descr->uuid.to_str(uuid_buf));
198 result = false;
199 } else {
200 this->config_descr_status_ = descr->handle;
201 }
202 }
203
204 if (!this->char_handle_name_) {
205 chr = this->parent_->get_characteristic(BEDJET_SERVICE_UUID, BEDJET_NAME_UUID);
206 if (chr == nullptr) {
207 ESP_LOGW(TAG, "[%s] No name service found at device, not a BedJet..?", this->get_name().c_str());
208 result = false;
209 } else {
210 this->char_handle_name_ = chr->handle;
211 auto status = esp_ble_gattc_read_char(this->parent_->get_gattc_if(), this->parent_->get_conn_id(),
212 this->char_handle_name_, ESP_GATT_AUTH_REQ_NONE);
213 if (status) {
214 ESP_LOGI(TAG, "[%s] Unable to read name characteristic: %d", this->get_name().c_str(), status);
215 }
216 }
217 }
218
219 ESP_LOGI(TAG,
220 "[%s] Discovered service characteristics:\n"
221 " - Command char: 0x%x\n"
222 " - Status char: 0x%x\n"
223 " - config descriptor: 0x%x\n"
224 " - Name char: 0x%x",
225 this->get_name().c_str(), this->char_handle_cmd_, this->char_handle_status_, this->config_descr_status_,
226 this->char_handle_name_);
227
228 return result;
229}
230
231void BedJetHub::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
232 esp_ble_gattc_cb_param_t *param) {
233 switch (event) {
234 case ESP_GATTC_DISCONNECT_EVT: {
235 ESP_LOGV(TAG, "Disconnected: reason=%d", param->disconnect.reason);
236 this->status_set_warning();
237 this->dispatch_state_(false);
238 break;
239 }
240 case ESP_GATTC_SEARCH_CMPL_EVT: {
241 auto result = this->discover_characteristics_();
242
243 if (result) {
244 ESP_LOGD(TAG, "[%s] Services complete: obtained char handles.", this->get_name().c_str());
245 this->node_state = espbt::ClientState::ESTABLISHED;
246 this->set_notify_(true);
247
248#ifdef USE_TIME
249 if (this->time_id_ != nullptr) {
250 this->send_local_time();
251 }
252#endif
253
254 this->dispatch_state_(true);
255 } else {
256 ESP_LOGW(TAG, "[%s] Failed discovering service characteristics.", this->get_name().c_str());
257 this->parent()->set_enabled(false);
258 this->status_set_warning();
259 this->dispatch_state_(false);
260 }
261 break;
262 }
263 case ESP_GATTC_WRITE_DESCR_EVT: {
264 if (param->write.status != ESP_GATT_OK) {
265 if (param->write.status == ESP_GATT_INVALID_ATTR_LEN) {
266 // This probably means that our hack for notify_en (8 bit vs 16 bit) didn't work right.
267 // Should we try to fall back to BLEClient's way?
268 ESP_LOGW(TAG, "[%s] Invalid attr length writing descr at handle 0x%04d, status=%d", this->get_name().c_str(),
269 param->write.handle, param->write.status);
270 } else {
271 ESP_LOGW(TAG, "[%s] Error writing descr at handle 0x%04d, status=%d", this->get_name().c_str(),
272 param->write.handle, param->write.status);
273 }
274 break;
275 }
276 ESP_LOGD(TAG, "[%s] Write to handle 0x%04x status=%d", this->get_name().c_str(), param->write.handle,
277 param->write.status);
278 break;
279 }
280 case ESP_GATTC_WRITE_CHAR_EVT: {
281 if (param->write.status != ESP_GATT_OK) {
282 ESP_LOGW(TAG, "Error writing char at handle 0x%04d, status=%d", param->write.handle, param->write.status);
283 break;
284 }
285 if (param->write.handle == this->char_handle_cmd_) {
286 if (this->force_refresh_) {
287 // Command write was successful. Publish the pending state, hoping that notify will kick in.
288 // FIXME: better to wait until we know the status has changed
289 this->dispatch_status_();
290 }
291 }
292 break;
293 }
294 case ESP_GATTC_READ_CHAR_EVT: {
295 if (param->read.conn_id != this->parent_->get_conn_id())
296 break;
297 if (param->read.status != ESP_GATT_OK) {
298 ESP_LOGW(TAG, "Error reading char at handle %d, status=%d", param->read.handle, param->read.status);
299 break;
300 }
301
302 if (param->read.handle == this->char_handle_status_) {
303 // This is the additional packet that doesn't fit in the notify packet.
304 this->codec_->decode_extra(param->read.value, param->read.value_len);
305 this->status_packet_ready_();
306 } else if (param->read.handle == this->char_handle_name_) {
307 // The data should represent the name.
308 if (param->read.status == ESP_GATT_OK && param->read.value_len > 0) {
309 std::string bedjet_name(reinterpret_cast<char const *>(param->read.value), param->read.value_len);
310 ESP_LOGV(TAG, "[%s] Got BedJet name: '%s'", this->get_name().c_str(), bedjet_name.c_str());
311 this->set_name_(bedjet_name);
312 }
313 }
314 break;
315 }
316 case ESP_GATTC_REG_FOR_NOTIFY_EVT: {
317 // This event means that ESP received the request to enable notifications on the client side. But we also have to
318 // tell the server that we want it to send notifications. Normally BLEClient parent would handle this
319 // automatically, but as soon as we set our status to Established, the parent is going to purge all the
320 // service/char/descriptor handles, and then get_config_descriptor() won't work anymore. There's no way to disable
321 // the BLEClient parent behavior, so our only option is to write the handle anyway, and hope a double-write
322 // doesn't break anything.
323
324 if (param->reg_for_notify.handle != this->char_handle_status_) {
325 ESP_LOGW(TAG, "[%s] Register for notify on unexpected handle 0x%04x, expecting 0x%04x",
326 this->get_name().c_str(), param->reg_for_notify.handle, this->char_handle_status_);
327 break;
328 }
329
331 this->last_notify_ = 0;
332 this->force_refresh_ = true;
333 break;
334 }
335 case ESP_GATTC_UNREG_FOR_NOTIFY_EVT: {
336 // This event is not handled by the parent BLEClient, so we need to do this either way.
337 if (param->unreg_for_notify.handle != this->char_handle_status_) {
338 ESP_LOGW(TAG, "[%s] Unregister for notify on unexpected handle 0x%04x, expecting 0x%04x",
339 this->get_name().c_str(), param->unreg_for_notify.handle, this->char_handle_status_);
340 break;
341 }
342
344 this->last_notify_ = 0;
345 // Now we wait until the next update() poll to re-register notify...
346 break;
347 }
348 case ESP_GATTC_NOTIFY_EVT: {
349 if (this->processing_)
350 break;
351
352 if (param->notify.conn_id != this->parent_->get_conn_id()) {
353 ESP_LOGW(TAG, "[%s] Received notify event for unexpected parent conn: expect %x, got %x",
354 this->get_name().c_str(), this->parent_->get_conn_id(), param->notify.conn_id);
355 // FIXME: bug in BLEClient holding wrong conn_id.
356 }
357
358 if (param->notify.handle != this->char_handle_status_) {
359 ESP_LOGW(TAG, "[%s] Unexpected notify handle, wanted %04X, got %04X", this->get_name().c_str(),
360 this->char_handle_status_, param->notify.handle);
361 break;
362 }
363
364 // FIXME: notify events come in every ~200-300 ms, which is too fast to be helpful. So we
365 // throttle the updates to once every MIN_NOTIFY_THROTTLE (5 seconds).
366 // Another idea would be to keep notify off by default, and use update() as an opportunity to turn on
367 // notify to get enough data to update status, then turn off notify again.
368
369 uint32_t now = millis();
370 auto delta = now - this->last_notify_;
371
372 if (!this->force_refresh_ && this->codec_->compare(param->notify.value, param->notify.value_len)) {
373 // If the packet is meaningfully different, trigger children as well
374 this->force_refresh_ = true;
375 ESP_LOGV(TAG, "[%s] Incoming packet indicates a significant change.", this->get_name().c_str());
376 }
377
378 if (this->last_notify_ == 0 || delta > MIN_NOTIFY_THROTTLE || this->force_refresh_) {
379 // Set reentrant flag to prevent processing multiple packets.
380 this->processing_ = true;
381 ESP_LOGVV(TAG, "[%s] Decoding packet: last=%" PRId32 ", delta=%" PRId32 ", force=%s", this->get_name().c_str(),
382 this->last_notify_, delta, this->force_refresh_ ? "y" : "n");
383 bool needs_extra = this->codec_->decode_notify(param->notify.value, param->notify.value_len);
384
385 if (needs_extra) {
386 // This means the packet was partial, so read the status characteristic to get the second part.
387 // Ideally this will complete quickly. We won't process additional notification events until it does.
388 auto status = esp_ble_gattc_read_char(this->parent_->get_gattc_if(), this->parent_->get_conn_id(),
389 this->char_handle_status_, ESP_GATT_AUTH_REQ_NONE);
390 if (status) {
391 ESP_LOGI(TAG, "[%s] Unable to read extended status packet", this->get_name().c_str());
392 }
393 } else {
394 this->status_packet_ready_();
395 }
396 }
397 break;
398 }
399 default:
400 ESP_LOGVV(TAG, "[%s] gattc unhandled event: enum=%d", this->get_name().c_str(), event);
401 break;
402 }
403}
404
406 this->last_notify_ = millis();
407 this->processing_ = false;
408
409 if (this->force_refresh_) {
410 // If we requested an immediate update, do that now.
411 this->update();
412 this->force_refresh_ = false;
413 }
414}
415
424 auto handle = this->config_descr_status_;
425 if (handle == 0) {
426 ESP_LOGW(TAG, "No descriptor found for notify of handle 0x%x", this->char_handle_status_);
427 return -1;
428 }
429
430 // NOTE: BLEClient uses `uint8_t*` of length 1, but BLE spec requires 16 bits.
431 uint16_t notify_en = enable ? 1 : 0;
432 auto status = esp_ble_gattc_write_char_descr(this->parent_->get_gattc_if(), this->parent_->get_conn_id(), handle,
433 sizeof(notify_en), (uint8_t *) &notify_en, ESP_GATT_WRITE_TYPE_RSP,
434 ESP_GATT_AUTH_REQ_NONE);
435 if (status) {
436 ESP_LOGW(TAG, "esp_ble_gattc_write_char_descr error, status=%d", status);
437 return status;
438 }
439 ESP_LOGD(TAG, "[%s] wrote notify=%s to status config 0x%04x, for conn %d", this->get_name().c_str(),
440 enable ? "true" : "false", handle, this->parent_->get_conn_id());
441 return ESP_GATT_OK;
442}
443
444/* Time Component */
445
446#ifdef USE_TIME
448 if (this->time_id_ != nullptr) {
449 ESPTime now = this->time_id_->now();
450 if (now.is_valid()) {
451 this->set_clock(now.hour, now.minute);
452 ESP_LOGD(TAG, "Using time component to set BedJet clock: %d:%02d", now.hour, now.minute);
453 }
454 } else {
455 ESP_LOGI(TAG, "`time_id` is not configured: will not sync BedJet clock.");
456 }
457}
458
460 if (this->time_id_ != nullptr) {
461 this->send_local_time();
462 this->time_id_->add_on_time_sync_callback([this] { this->send_local_time(); });
463 } else {
464 ESP_LOGI(TAG, "`time_id` is not configured: will not sync BedJet clock.");
465 }
466}
467#endif
468
469void BedJetHub::set_clock(uint8_t hour, uint8_t minute) {
470 if (!this->is_connected()) {
471 ESP_LOGV(TAG, "[%s] Not connected, cannot send time.", this->get_name().c_str());
472 return;
473 }
474
475 BedjetPacket *pkt = this->codec_->get_set_time_request(hour, minute);
476 auto status = this->write_bedjet_packet_(pkt);
477 if (status) {
478 ESP_LOGW(TAG, "Failed setting BedJet clock: %d", status);
479 } else {
480 ESP_LOGD(TAG, "[%s] BedJet clock set to: %d:%02d", this->get_name().c_str(), hour, minute);
481 }
482}
483
484/* Internal */
485
487 // Parent BLEClientNode has a loop() method, but this component uses
488 // polling via update() and BLE callbacks so loop isn't needed
489 this->disable_loop();
490}
492
494 ESP_LOGCONFIG(TAG,
495 "BedJet Hub '%s'\n"
496 " ble_client.app_id: %d\n"
497 " ble_client.conn_id: %d",
498 this->get_name().c_str(), this->parent()->app_id, this->parent()->get_conn_id());
499 LOG_UPDATE_INTERVAL(this);
500 ESP_LOGCONFIG(TAG, " Child components (%d):", this->children_.size());
501 for (auto *child : this->children_) {
502 ESP_LOGCONFIG(TAG, " - %s", child->describe().c_str());
503 }
504}
505
506void BedJetHub::dispatch_state_(bool is_ready) {
507 for (auto *child : this->children_) {
508 child->on_bedjet_state(is_ready);
509 }
510}
511
513 auto *status = this->codec_->get_status_packet();
514
515 if (!this->is_connected()) {
516 ESP_LOGD(TAG, "[%s] Not connected, will not send status.", this->get_name().c_str());
517 } else if (status != nullptr) {
518 ESP_LOGD(TAG, "[%s] Notifying %d children of latest status @%p.", this->get_name().c_str(), this->children_.size(),
519 status);
520 for (auto *child : this->children_) {
521 child->on_status(status);
522 }
523 } else {
524 uint32_t now = millis();
525 uint32_t diff = now - this->last_notify_;
526
527 if (this->last_notify_ == 0) {
528 // This means we're connected and haven't received a notification, so it likely means that the BedJet is off.
529 // However, it could also mean that it's running, but failing to send notifications.
530 // We can try to unregister for notifications now, and then re-register, hoping to clear it up...
531 // But how do we know for sure which state we're in, and how do we actually clear out the buggy state?
532
533 ESP_LOGI(TAG, "[%s] Still waiting for first GATT notify event.", this->get_name().c_str());
534 } else if (diff > NOTIFY_WARN_THRESHOLD) {
535 ESP_LOGW(TAG, "[%s] Last GATT notify was %" PRId32 " seconds ago.", this->get_name().c_str(), diff / 1000);
536 }
537
538 if (this->timeout_ > 0 && diff > this->timeout_ && this->parent()->enabled) {
539 ESP_LOGW(TAG, "[%s] Timed out after %" PRId32 " sec. Retrying", this->get_name().c_str(), this->timeout_);
540 // set_enabled(false) will only close the connection if state != IDLE.
541 this->parent()->set_state(espbt::ClientState::CONNECTING);
542 this->parent()->set_enabled(false);
543 this->parent()->set_enabled(true);
544 }
545 }
546}
547
549 this->children_.push_back(obj);
550 obj->set_parent(this);
551}
552
553} // namespace esphome::bedjet
554
555#endif
uint8_t status
Definition bl0942.h:8
bool is_ready() const
void disable_loop()
Disable this component's loop.
void set_parent(T *parent)
Set the parent of this object.
Definition helpers.h:1869
bool set_target_temp(float temp_c)
Set the target temperature to temp_c in °C.
void set_name_(const std::string &name)
Definition bedjet_hub.h:154
void dump_config() override
bool button_cool()
Press the COOL button.
void setup_time_()
Initializes time sync callbacks to support syncing current time to the BedJet.
bool button_dry()
Press the DRY button.
uint8_t write_bedjet_packet_(BedjetPacket *pkt)
Send the BedjetPacket to the device.
bool button_ext_heat()
Press the EXT HT button.
uint8_t get_fan_index()
Return the fan speed index, in the range 0-19.
std::unique_ptr< BedjetCodec > codec_
Definition bedjet_hub.h:163
void set_clock(uint8_t hour, uint8_t minute)
Attempt to set the BedJet device's clock to the specified time.
static const uint32_t MIN_NOTIFY_THROTTLE
Definition bedjet_hub.h:147
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
time::RealTimeClock * time_id_
Definition bedjet_hub.h:143
bool set_fan_index(uint8_t fan_speed_index)
Set the fan speed to a stepped index in the range 0-19.
uint16_t get_time_remaining()
Return the remaining runtime, in seconds.
bool set_time_remaining(uint8_t hours, uint8_t mins)
Set the operational runtime remaining.
void upgrade_firmware()
Attempts to check for and apply firmware updates.
void dispatch_state_(bool is_ready)
bool button_memory1()
Press the M1 (memory recall) button.
uint8_t set_notify_(bool enable)
Configures the local ESP BLE client to register (true) or unregister (false) for status notifications...
std::vector< BedJetClient * > children_
Definition bedjet_hub.h:136
bool button_turbo()
Press the TURBO button.
bool button_heat()
Press the HEAT button.
void register_child(BedJetClient *obj)
Register a BedJetClient child component.
bool send_button(BedjetButton button)
Send the button.
uint8_t write_notify_config_descriptor_(bool enable)
Reimplementation of BLEClient.gattc_event_handler() for ESP_GATTC_REG_FOR_NOTIFY_EVT.
bool button_memory3()
Press the M3 (memory recall) button.
bool button_off()
Press the OFF button.
static const uint32_t NOTIFY_WARN_THRESHOLD
Definition bedjet_hub.h:148
void send_local_time()
Attempts to sync the local time (via time_id) to the BedJet device.
bool button_memory2()
Press the M2 (memory recall) button.
void set_state(espbt::ClientState state) override
void set_enabled(bool enabled)
BLECharacteristic * get_characteristic(espbt::ESPBTUUID service, espbt::ESPBTUUID chr)
BLEDescriptor * get_config_descriptor(uint16_t handle)
ESPTime now()
Get the time in the currently defined timezone.
void add_on_time_sync_callback(F &&callback)
uint8_t minute
uint8_t hour
@ BTN_TURBO
Enter Turbo mode (high heat, limited to 10 minutes)
@ BTN_M1
Start the M1 biorhythm/preset program.
@ BTN_DRY
Enter Dry mode (high speed, no heat)
@ BTN_EXTHT
Enter Extended Heat mode (limited to 10 hours)
@ BTN_HEAT
Enter Heat mode (limited to 4 hours)
@ BTN_COOL
Enter Cool mode (fan only)
@ BTN_OFF
Turn BedJet off.
@ BTN_M2
Start the M2 biorhythm/preset program.
@ BTN_M3
Start the M3 biorhythm/preset program.
@ MAGIC_UPDATE
Request a firmware update. This will also restart the Bedjet.
uint32_t IRAM_ATTR HOT millis()
Definition hal.cpp:28
static void uint32_t
A more user-friendly version of struct tm from time.h.
Definition time.h:23
uint8_t minute
minutes after the hour [0-59]
Definition time.h:32
uint8_t hour
hours since midnight [0-23]
Definition time.h:34
bool is_valid(bool check_day_of_week=true, bool check_day_of_year=true) const
Check if this ESPTime is valid (year >= 2019 and the requested fields are in range).
Definition time.h:82