6 namespace pvvx_mithermometer {
8 static const char *
const TAG =
"display.pvvx_mithermometer";
11 ESP_LOGCONFIG(TAG,
"PVVX MiThermometer display:");
16 ESP_LOGCONFIG(TAG,
" Set time on connection: %s", YESNO(this->
time_ !=
nullptr));
18 LOG_UPDATE_INTERVAL(
this);
22 esp_ble_gattc_cb_param_t *param) {
24 case ESP_GATTC_OPEN_EVT:
28 case ESP_GATTC_DISCONNECT_EVT:
34 case ESP_GATTC_SEARCH_CMPL_EVT: {
40 this->connection_established_ =
true;
63 ESP_LOGD(TAG,
"[%s] BLE client not enabled. Init connection.", this->
parent_->
address_str().c_str());
68 ESP_LOGW(TAG,
"[%s] Not connected to BLE client. State update can not be written.",
73 ESP_LOGW(TAG,
"[%s] No ble handle to BLE client. State update can not be written.",
77 ESP_LOGD(TAG,
"[%s] Send to display: bignum %d, smallnum: %d, cfg: 0x%02x, validity period: %u.",
82 blk[2] = (this->
bignum_ >> 8) & 0xff;
83 blk[3] = this->smallnum_ & 0xff;
84 blk[4] = (this->smallnum_ >> 8) & 0xff;
92 uint8_t mask = 1 << bit;
96 this->
cfg_ &= (0xFF ^ mask);
102 ESP_LOGW(TAG,
"[%s] Not connected to BLE client.", this->
parent_->
address_str().c_str());
107 blk, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
125 if (this->
time_ ==
nullptr)
128 ESP_LOGW(TAG,
"[%s] Not connected to BLE client. Time can not be synced.", this->
parent_->
address_str().c_str());
132 ESP_LOGW(TAG,
"[%s] No ble handle to BLE client. Time can not be synced.", this->
parent_->
address_str().c_str());
136 if (!time.is_valid()) {
137 ESP_LOGW(TAG,
"[%s] Time is not yet valid. Time can not be synced.", this->
parent_->
address_str().c_str());
142 ESP_LOGD(TAG,
"[%s] Sync time with timestamp %lu.", this->
parent_->
address_str().c_str(), time.timestamp);
144 blk[1] = time.timestamp & 0xff;
145 blk[2] = (time.timestamp >> 8) & 0xff;
146 blk[3] = (time.timestamp >> 16) & 0xff;
147 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_
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_