mirror of
https://github.com/esphome/esphome.git
synced 2025-09-02 11:22:24 +01:00
wip
This commit is contained in:
@@ -147,14 +147,18 @@ class BLEEvent {
|
|||||||
}
|
}
|
||||||
if (this->type_ == GATTC) {
|
if (this->type_ == GATTC) {
|
||||||
delete this->event_.gattc.gattc_param;
|
delete this->event_.gattc.gattc_param;
|
||||||
|
delete[] this->event_.gattc.data;
|
||||||
this->event_.gattc.gattc_param = nullptr;
|
this->event_.gattc.gattc_param = nullptr;
|
||||||
this->reset_gattc_data_();
|
this->event_.gattc.data = nullptr;
|
||||||
|
this->event_.gattc.data_len = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this->type_ == GATTS) {
|
if (this->type_ == GATTS) {
|
||||||
delete this->event_.gatts.gatts_param;
|
delete this->event_.gatts.gatts_param;
|
||||||
|
delete[] this->event_.gatts.data;
|
||||||
this->event_.gatts.gatts_param = nullptr;
|
this->event_.gatts.gatts_param = nullptr;
|
||||||
this->reset_gatts_data_();
|
this->event_.gatts.data = nullptr;
|
||||||
|
this->event_.gatts.data_len = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,20 +239,6 @@ class BLEEvent {
|
|||||||
const esp_ble_sec_t &security() const { return event_.gap.security; }
|
const esp_ble_sec_t &security() const { return event_.gap.security; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Helper to reset GATTC data
|
|
||||||
void reset_gattc_data_() {
|
|
||||||
delete[] this->event_.gattc.data;
|
|
||||||
this->event_.gattc.data = nullptr;
|
|
||||||
this->event_.gattc.data_len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper to reset GATTS data
|
|
||||||
void reset_gatts_data_() {
|
|
||||||
delete[] this->event_.gatts.data;
|
|
||||||
this->event_.gatts.data = nullptr;
|
|
||||||
this->event_.gatts.data_len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize GAP event data
|
// Initialize GAP event data
|
||||||
void init_gap_data_(esp_gap_ble_cb_event_t e, esp_ble_gap_cb_param_t *p) {
|
void init_gap_data_(esp_gap_ble_cb_event_t e, esp_ble_gap_cb_param_t *p) {
|
||||||
this->event_.gap.gap_event = e;
|
this->event_.gap.gap_event = e;
|
||||||
@@ -334,7 +324,8 @@ class BLEEvent {
|
|||||||
|
|
||||||
if (p == nullptr) {
|
if (p == nullptr) {
|
||||||
this->event_.gattc.gattc_param = nullptr;
|
this->event_.gattc.gattc_param = nullptr;
|
||||||
this->reset_gattc_data_();
|
this->event_.gattc.data = nullptr;
|
||||||
|
this->event_.gattc.data_len = 0;
|
||||||
return; // Invalid event, but we can't log in header file
|
return; // Invalid event, but we can't log in header file
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +356,8 @@ class BLEEvent {
|
|||||||
this->event_.gattc.gattc_param->read.value = this->event_.gattc.data;
|
this->event_.gattc.gattc_param->read.value = this->event_.gattc.data;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this->reset_gattc_data_();
|
this->event_.gattc.data = nullptr;
|
||||||
|
this->event_.gattc.data_len = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -377,7 +369,8 @@ class BLEEvent {
|
|||||||
|
|
||||||
if (p == nullptr) {
|
if (p == nullptr) {
|
||||||
this->event_.gatts.gatts_param = nullptr;
|
this->event_.gatts.gatts_param = nullptr;
|
||||||
this->reset_gatts_data_();
|
this->event_.gatts.data = nullptr;
|
||||||
|
this->event_.gatts.data_len = 0;
|
||||||
return; // Invalid event, but we can't log in header file
|
return; // Invalid event, but we can't log in header file
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +394,8 @@ class BLEEvent {
|
|||||||
this->event_.gatts.gatts_param->write.value = this->event_.gatts.data;
|
this->event_.gatts.gatts_param->write.value = this->event_.gatts.data;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this->reset_gatts_data_();
|
this->event_.gatts.data = nullptr;
|
||||||
|
this->event_.gatts.data_len = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user