Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
events.c
Go to the documentation of this file.
1#ifdef ESP32
2#include <sdkconfig.h>
3#if CONFIG_BT_BLE_ENABLED
4
5#include "advertising.h"
6#include "esp_enums2string.h"
7#include "events-debug.h"
8#include "logging.h"
9#include "midi-private.h"
10
11#include <string.h>
12
13void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if,
14 esp_ble_gatts_cb_param_t *param) {
15 print_gatts_event(event, gatts_if, param);
16
17 // Upon registration, associate the interface id with the registered app
18 if (event == ESP_GATTS_REG_EVT && param->reg.app_id == midi_get_app_id()) {
19 ESP_LOGI("MIDIBLE", "Registering MIDI app");
20 if (param->reg.status != ESP_GATT_OK) {
21 ESP_LOGE("MIDIBLE", "Register app failed, app_id %04x, status: %d",
22 param->reg.app_id, param->reg.status);
23 return;
24 }
26 }
27
28 midi_handle_gatts_event(event, gatts_if, param);
29}
30
31void gap_event_handler(esp_gap_ble_cb_event_t event,
32 esp_ble_gap_cb_param_t *param) {
33 print_gap_event(event, param);
34
35 switch (event) {
36 case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT:
38 break;
39 case ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT:
41 break;
42 case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:
43 if (param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) {
44 ESP_LOGE("MIDIBLE", "Advertising start failed");
45 }
46 break;
47 case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT:
48 if (param->adv_stop_cmpl.status != ESP_BT_STATUS_SUCCESS) {
49 ESP_LOGE("MIDIBLE", "Advertising stop failed");
50 }
51 break;
52
53 case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT: break;
54
55 case ESP_GAP_BLE_PASSKEY_REQ_EVT: break;
56 case ESP_GAP_BLE_OOB_REQ_EVT: break;
57 case ESP_GAP_BLE_LOCAL_IR_EVT: break;
58 case ESP_GAP_BLE_LOCAL_ER_EVT: break;
59 case ESP_GAP_BLE_NC_REQ_EVT: break;
60 case ESP_GAP_BLE_SEC_REQ_EVT:
61 // Send the positive (true) security response to the peer device to
62 // accept the security request. If not accept the security request,
63 // should send the security response with negative (false) accept
64 // value.
65 esp_ble_gap_security_rsp(param->ble_security.ble_req.bd_addr, true);
66 break;
67 case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: break;
68 case ESP_GAP_BLE_KEY_EVT: break;
69 case ESP_GAP_BLE_AUTH_CMPL_EVT: break;
70 case ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT: break;
71
72 case ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT:
73 if (param->local_privacy_cmpl.status != ESP_BT_STATUS_SUCCESS) {
74 ESP_LOGE("MIDIBLE",
75 "config local privacy failed, error status = %d",
76 param->local_privacy_cmpl.status);
77 break;
78 }
80
81 default: break;
82 }
83}
84
85#endif
86#endif
Advertising the MIDI service for Bluetooth Low Energy.
bool advertising_handle_config_complete_event(esp_ble_gap_cb_param_t *param)
Callback that indicates that the configuration of the advertising data was complete.
bool advertising_config(void)
Configure the advertising data, register with the Bluetooth driver.
bool advertising_handle_config_response_complete_event(esp_ble_gap_cb_param_t *param)
Callback that indicates that the configuration of the advertising response data was complete.
Helpers for printing the names of enum values of the ESP32 Bluetooth API.
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 print_gap_event(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
Declarations of internal functions for the MIDI over BLE system, used in the midi-*....
void midi_register_interface(esp_gatt_if_t gatts_if)
uint16_t midi_get_app_id(void)
void midi_handle_gatts_event(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)