10 esp_ble_gatts_cb_param_t *param) {
15 int dev_num = esp_ble_get_bond_device_num();
16 esp_ble_bond_dev_t *dev_list =
17 (esp_ble_bond_dev_t *)malloc(
sizeof(esp_ble_bond_dev_t) * dev_num);
18 esp_ble_get_bond_device_list(&dev_num, dev_list);
19 ESP_LOGI(
"MIDIBLE",
"Bonded devices list [%d]:", dev_num);
20 for (
int i = 0; i < dev_num; i++) {
21 ESP_LOGI(
"MIDIBLE",
" - %02x:%02x:%02x:%02x:%02x:%02x",
22 dev_list[i].bd_addr[0], dev_list[i].bd_addr[1],
23 dev_list[i].bd_addr[2], dev_list[i].bd_addr[3],
24 dev_list[i].bd_addr[4], dev_list[i].bd_addr[5]);
30 esp_ble_gap_cb_param_t *param) {
34 case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
36 "status: %d, min_int: %d, max_int: %d, conn_int: %d, "
37 "latency: %d, timeout: %d",
38 param->update_conn_params.status,
39 param->update_conn_params.min_int,
40 param->update_conn_params.max_int,
41 param->update_conn_params.conn_int,
42 param->update_conn_params.latency,
43 param->update_conn_params.timeout);
46 case ESP_GAP_BLE_PASSKEY_NOTIF_EVT:
50 ESP_LOGI(
"MIDIBLE",
"The passkey Notify number: %06d",
51 param->ble_security.key_notif.passkey);
54 case ESP_GAP_BLE_KEY_EVT:
55 ESP_LOGI(
"MIDIBLE",
"key type: %s",
57 param->ble_security.ble_key.key_type));
60 case ESP_GAP_BLE_AUTH_CMPL_EVT:
61 ESP_LOGI(
"MIDIBLE",
"%02x:%02x:%02x:%02x:%02x:%02x",
62 param->ble_security.auth_cmpl.bd_addr[0],
63 param->ble_security.auth_cmpl.bd_addr[1],
64 param->ble_security.auth_cmpl.bd_addr[2],
65 param->ble_security.auth_cmpl.bd_addr[3],
66 param->ble_security.auth_cmpl.bd_addr[4],
67 param->ble_security.auth_cmpl.bd_addr[5]);
68 ESP_LOGI(
"MIDIBLE",
"address type: %d",
69 param->ble_security.auth_cmpl.addr_type);
70 ESP_LOGI(
"MIDIBLE",
"pair status: %s",
71 param->ble_security.auth_cmpl.success ?
"success"
73 if (!param->ble_security.auth_cmpl.success) {
74 ESP_LOGI(
"MIDIBLE",
"fail reason: 0x%x",
75 param->ble_security.auth_cmpl.fail_reason);
77 ESP_LOGI(
"MIDIBLE",
"auth mode: %s",
79 param->ble_security.auth_cmpl.auth_mode));
84 case ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT:
85 ESP_LOGI(
"MIDIBLE",
"status: %d",
86 param->remove_bond_dev_cmpl.status);
87 ESP_LOGI(
"MIDIBLE",
"%02x:%02x:%02x:%02x:%02x:%02x",
88 param->remove_bond_dev_cmpl.bd_addr[0],
89 param->remove_bond_dev_cmpl.bd_addr[1],
90 param->remove_bond_dev_cmpl.bd_addr[2],
91 param->remove_bond_dev_cmpl.bd_addr[3],
92 param->remove_bond_dev_cmpl.bd_addr[4],
93 param->remove_bond_dev_cmpl.bd_addr[5]);
Helpers for printing the names of enum values of the ESP32 Bluetooth API.
const char * esp_gatts_cb_event_to_string(esp_gatts_cb_event_t event)
const char * esp_ble_key_type_to_string(esp_ble_key_type_t key_type)
const char * esp_gap_ble_cb_event_to_string(esp_gap_ble_cb_event_t event)
const char * esp_ble_auth_req_to_string(esp_ble_auth_req_t auth_type)
Helpers for printing Bluetooth events and status.
void print_gatts_event(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
void show_bonded_devices(void)
void print_gap_event(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)