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