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:
30 case ESP_GATTC_DISCONNECT_EVT:
36 case ESP_GATTC_SEARCH_CMPL_EVT: {
42 this->connection_established_ =
true;
65 ESP_LOGD(TAG,
"[%s] BLE client not enabled. Init connection.", this->
parent_->
address_str().c_str());
70 ESP_LOGW(TAG,
"[%s] Not connected to BLE client. State update can not be written.",
75 ESP_LOGW(TAG,
"[%s] No ble handle to BLE client. State update can not be written.",
79 ESP_LOGD(TAG,
"[%s] Send to display: bignum %d, smallnum: %d, cfg: 0x%02x, validity period: %u.",
84 blk[2] = (this->
bignum_ >> 8) & 0xff;
85 blk[3] = this->smallnum_ & 0xff;
86 blk[4] = (this->smallnum_ >> 8) & 0xff;
94 uint8_t mask = 1 << bit;
98 this->
cfg_ &= (0xFF ^ mask);
104 ESP_LOGW(TAG,
"[%s] Not connected to BLE client.", this->
parent_->
address_str().c_str());
109 blk, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
127 if (this->
time_ ==
nullptr)
130 ESP_LOGW(TAG,
"[%s] Not connected to BLE client. Time can not be synced.", this->
parent_->
address_str().c_str());
134 ESP_LOGW(TAG,
"[%s] No ble handle to BLE client. Time can not be synced.", this->
parent_->
address_str().c_str());
138 if (!time.is_valid()) {
139 ESP_LOGW(TAG,
"[%s] Time is not yet valid. Time can not be synced.", this->
parent_->
address_str().c_str());
144 #if ESP_IDF_VERSION_MAJOR >= 5 145 ESP_LOGD(TAG,
"[%s] Sync time with timestamp %" PRIu64
".", this->
parent_->
address_str().c_str(), time.timestamp);
147 ESP_LOGD(TAG,
"[%s] Sync time with timestamp %lu.", this->
parent_->
address_str().c_str(), time.timestamp);
150 blk[1] = time.timestamp & 0xff;
151 blk[2] = (time.timestamp >> 8) & 0xff;
152 blk[3] = (time.timestamp >> 16) & 0xff;
153 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_
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
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_