110 BLEEvent(esp_gap_ble_cb_event_t e, esp_ble_gap_cb_param_t *p) {
112 this->init_gap_data_(e, p);
120 BLEEvent(esp_gattc_cb_event_t e, esp_gatt_if_t i, esp_ble_gattc_cb_param_t *p) {
122 this->init_gattc_data_(e, i, p);
130 BLEEvent(esp_gatts_cb_event_t e, esp_gatt_if_t i, esp_ble_gatts_cb_param_t *p) {
132 this->init_gatts_data_(e, i, p);
147 delete this->
event_.gattc.gattc_param;
148 delete this->
event_.gattc.data;
149 this->
event_.gattc.gattc_param =
nullptr;
150 this->
event_.gattc.data =
nullptr;
154 delete this->
event_.gatts.gatts_param;
155 delete this->
event_.gatts.data;
156 this->
event_.gatts.gatts_param =
nullptr;
157 this->
event_.gatts.data =
nullptr;
165 this->init_gap_data_(e, p);
168 void load_gattc_event(esp_gattc_cb_event_t e, esp_gatt_if_t i, esp_ble_gattc_cb_param_t *p) {
171 this->init_gattc_data_(e, i, p);
174 void load_gatts_event(esp_gatts_cb_event_t e, esp_gatt_if_t i, esp_ble_gatts_cb_param_t *p) {
177 this->init_gatts_data_(e, i, p);
220 std::vector<uint8_t> *
data;
237 void init_gap_data_(esp_gap_ble_cb_event_t e, esp_ble_gap_cb_param_t *p) {
238 this->
event_.gap.gap_event = e;
246 case ESP_GAP_BLE_SCAN_RESULT_EVT:
247 memcpy(this->
event_.gap.scan_result.bda, p->scan_rst.bda,
sizeof(esp_bd_addr_t));
248 this->
event_.gap.scan_result.ble_addr_type = p->scan_rst.ble_addr_type;
249 this->
event_.gap.scan_result.rssi = p->scan_rst.rssi;
250 this->
event_.gap.scan_result.adv_data_len = p->scan_rst.adv_data_len;
251 this->
event_.gap.scan_result.scan_rsp_len = p->scan_rst.scan_rsp_len;
252 this->
event_.gap.scan_result.search_evt = p->scan_rst.search_evt;
253 memcpy(this->
event_.gap.scan_result.ble_adv, p->scan_rst.ble_adv,
254 ESP_BLE_ADV_DATA_LEN_MAX + ESP_BLE_SCAN_RSP_DATA_LEN_MAX);
257 case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT:
258 this->
event_.gap.scan_complete.status = p->scan_param_cmpl.status;
261 case ESP_GAP_BLE_SCAN_START_COMPLETE_EVT:
262 this->
event_.gap.scan_complete.status = p->scan_start_cmpl.status;
265 case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT:
266 this->
event_.gap.scan_complete.status = p->scan_stop_cmpl.status;
271 case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT:
272 this->
event_.gap.adv_complete.status = p->adv_data_cmpl.status;
274 case ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT:
275 this->
event_.gap.adv_complete.status = p->scan_rsp_data_cmpl.status;
277 case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT:
278 this->
event_.gap.adv_complete.status = p->adv_data_raw_cmpl.status;
280 case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:
281 this->
event_.gap.adv_complete.status = p->adv_start_cmpl.status;
283 case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT:
284 this->
event_.gap.adv_complete.status = p->adv_stop_cmpl.status;
289 case ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT:
290 this->
event_.gap.read_rssi_complete.status = p->read_rssi_cmpl.status;
291 this->
event_.gap.read_rssi_complete.rssi = p->read_rssi_cmpl.rssi;
292 memcpy(this->
event_.gap.read_rssi_complete.remote_addr, p->read_rssi_cmpl.remote_addr,
sizeof(esp_bd_addr_t));
297 case ESP_GAP_BLE_AUTH_CMPL_EVT:
298 case ESP_GAP_BLE_SEC_REQ_EVT:
299 case ESP_GAP_BLE_PASSKEY_NOTIF_EVT:
300 case ESP_GAP_BLE_PASSKEY_REQ_EVT:
301 case ESP_GAP_BLE_NC_REQ_EVT:
302 memcpy(&this->
event_.gap.security, &p->ble_security,
sizeof(esp_ble_sec_t));
315 void init_gattc_data_(esp_gattc_cb_event_t e, esp_gatt_if_t i, esp_ble_gattc_cb_param_t *p) {
316 this->
event_.gattc.gattc_event = e;
317 this->
event_.gattc.gattc_if = i;
320 this->
event_.gattc.gattc_param =
nullptr;
321 this->
event_.gattc.data =
nullptr;
332 this->
event_.gattc.gattc_param =
new esp_ble_gattc_cb_param_t(*p);
338 case ESP_GATTC_NOTIFY_EVT:
339 this->
event_.gattc.data =
new std::vector<uint8_t>(p->notify.value, p->notify.value + p->notify.value_len);
340 this->
event_.gattc.gattc_param->notify.value = this->
event_.gattc.data->data();
342 case ESP_GATTC_READ_CHAR_EVT:
343 case ESP_GATTC_READ_DESCR_EVT:
344 this->
event_.gattc.data =
new std::vector<uint8_t>(p->read.value, p->read.value + p->read.value_len);
345 this->
event_.gattc.gattc_param->read.value = this->
event_.gattc.data->data();
348 this->
event_.gattc.data =
nullptr;
354 void init_gatts_data_(esp_gatts_cb_event_t e, esp_gatt_if_t i, esp_ble_gatts_cb_param_t *p) {
355 this->
event_.gatts.gatts_event = e;
356 this->
event_.gatts.gatts_if = i;
359 this->
event_.gatts.gatts_param =
nullptr;
360 this->
event_.gatts.data =
nullptr;
371 this->
event_.gatts.gatts_param =
new esp_ble_gatts_cb_param_t(*p);
377 case ESP_GATTS_WRITE_EVT:
378 this->
event_.gatts.data =
new std::vector<uint8_t>(p->write.value, p->write.value + p->write.len);
379 this->
event_.gatts.gatts_param->write.value = this->
event_.gatts.data->data();
382 this->
event_.gatts.data =
nullptr;