6 namespace pvvx_mithermometer {
8 static const char *
const TAG =
"display.pvvx_mithermometer";
11 ESP_LOGCONFIG(TAG,
"PVVX MiThermometer display:");
17 ESP_LOGCONFIG(TAG,
" Set time on connection: %s", YESNO(this->
time_ !=
nullptr));
20 LOG_UPDATE_INTERVAL(
this);
24 esp_ble_gattc_cb_param_t *param) {
26 case ESP_GATTC_OPEN_EVT:
27 if (param->open.status == ESP_GATT_OK) {
32 case ESP_GATTC_DISCONNECT_EVT:
38 case ESP_GATTC_SEARCH_CMPL_EVT: {
44 this->connection_established_ =
true;
67 ESP_LOGD(TAG,
"[%s] BLE client not enabled. Init connection.", this->
parent_->
address_str().c_str());
72 ESP_LOGW(TAG,
"[%s] Not connected to BLE client. State update can not be written.",
77 ESP_LOGW(TAG,
"[%s] No ble handle to BLE client. State update can not be written.",
81 ESP_LOGD(TAG,
"[%s] Send to display: bignum %d, smallnum: %d, cfg: 0x%02x, validity period: %u.",
86 blk[2] = (this->
bignum_ >> 8) & 0xff;
87 blk[3] = this->smallnum_ & 0xff;
88 blk[4] = (this->smallnum_ >> 8) & 0xff;
96 uint8_t mask = 1 << bit;
100 this->
cfg_ &= (0xFF ^ mask);
106 ESP_LOGW(TAG,
"[%s] Not connected to BLE client.", this->
parent_->
address_str().c_str());
111 blk, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
129 if (this->
time_ ==
nullptr)
132 ESP_LOGW(TAG,
"[%s] Not connected to BLE client. Time can not be synced.", this->
parent_->
address_str().c_str());
136 ESP_LOGW(TAG,
"[%s] No ble handle to BLE client. Time can not be synced.", this->
parent_->
address_str().c_str());
140 if (!time.is_valid()) {
141 ESP_LOGW(TAG,
"[%s] Time is not yet valid. Time can not be synced.", this->
parent_->
address_str().c_str());
146 #if ESP_IDF_VERSION_MAJOR >= 5 147 ESP_LOGD(TAG,
"[%s] Sync time with timestamp %" PRIu64
".", this->
parent_->
address_str().c_str(), time.timestamp);
149 ESP_LOGD(TAG,
"[%s] Sync time with timestamp %lu.", this->
parent_->
address_str().c_str(), time.timestamp);
152 blk[1] = time.timestamp & 0xff;
153 blk[2] = (time.timestamp >> 8) & 0xff;
154 blk[3] = (time.timestamp >> 16) & 0xff;
155 blk[4] = (time.timestamp >> 24) & 0xff;
ESPTime now()
Get the time in the currently defined timezone.
bool cancel_timeout(const std::string &name)
Cancel a timeout function.
optional< pvvx_writer_t > writer_
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
void setcfgbit_(uint8_t bit, bool value)
void dump_config() override
uint16_t get_conn_id() const
std::string address_str() const
void set_enabled(bool enabled)
void delayed_disconnect_()
bool connection_established_
uint32_t disconnect_delay_ms_
void send_to_setup_char_(uint8_t *blk, size_t size)
esp32_ble_tracker::ESPBTUUID char_uuid_
void clear()
Clear the screen.
std::string to_string() const
BLECharacteristic * get_characteristic(espbt::ESPBTUUID service, espbt::ESPBTUUID chr)
esp32_ble_tracker::ESPBTUUID service_uuid_
Implementation of SPI Controller mode.
void recalc_timestamp_utc(bool use_day_of_year=true)
Recalculate the timestamp field from the other fields of this ESPTime instance (must be UTC)...
uint16_t validity_period_
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_