mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 01:34:18 +01:00
Add service and server null checks for notify
This commit is contained in:
parent
e4c1ed979c
commit
efd3dbecfb
3 changed files with 4 additions and 3 deletions
|
@ -45,7 +45,8 @@ void BLECharacteristic::notify(bool require_ack) {
|
|||
ESP_LOGW(TAG, "require_ack=true is not yet supported (i.e. INDICATE is not yet supported)");
|
||||
// TODO: Handle when require_ack=true
|
||||
}
|
||||
if (this->service_->get_server()->get_connected_client_count() == 0)
|
||||
if (this->service_ == nullptr || this->service_->get_server() == nullptr ||
|
||||
this->service_->get_server()->get_connected_client_count() == 0)
|
||||
return;
|
||||
|
||||
for (auto &client : this->service_->get_server()->get_clients()) {
|
||||
|
|
|
@ -74,7 +74,7 @@ class BLECharacteristic : public EventEmitter<BLECharacteristicEvt::VectorEvt, s
|
|||
|
||||
protected:
|
||||
bool write_event_{false};
|
||||
BLEService *service_;
|
||||
BLEService *service_ = nullptr;
|
||||
ESPBTUUID uuid_;
|
||||
esp_gatt_char_prop_t properties_;
|
||||
uint16_t handle_{0xFFFF};
|
||||
|
|
|
@ -59,7 +59,7 @@ class BLEService {
|
|||
std::vector<BLECharacteristic *> characteristics_;
|
||||
BLECharacteristic *last_created_characteristic_{nullptr};
|
||||
uint32_t created_characteristic_count_{0};
|
||||
BLEServer *server_;
|
||||
BLEServer *server_ = nullptr;
|
||||
ESPBTUUID uuid_;
|
||||
uint16_t num_handles_;
|
||||
uint16_t handle_{0xFFFF};
|
||||
|
|
Loading…
Reference in a new issue