Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
midi-events.c
Go to the documentation of this file.
1#ifdef ESP32
2#include <sdkconfig.h>
3#if CONFIG_BT_BLE_ENABLED
4
13#include "ble2902.h"
14#include "logging.h"
15#include "midi-private.h"
16
17void midi_handle_gatts_event(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if,
18 esp_ble_gatts_cb_param_t *param) {
19 // If this event is not specific to an interface, we're interested
20 // If this event is for our interface, we're interested as well.
21 bool for_us = gatts_if == ESP_GATT_IF_NONE || //
22 gatts_if == midi_get_gatts_if();
23 if (!for_us)
24 return;
25
26 switch (event) {
27 case ESP_GATTS_REG_EVT:
28 midi_handle_register_app_event(gatts_if, param);
29 break;
30
31 case ESP_GATTS_READ_EVT:
32 if (param->read.handle == midi_get_characteristic_handle())
33 midi_handle_read_event(gatts_if, param);
34 break;
35
36 case ESP_GATTS_WRITE_EVT:
37 // If it's a short write to our 2902 descriptor
38 if (param->write.is_prep == false &&
39 midi_get_descriptor_handle() == param->write.handle) {
40 ble2902_handle_write(gatts_if, param);
41 }
42 // If it's a write (short or long) to our MIDI characteristic
43 if (midi_get_characteristic_handle() == param->write.handle)
44 midi_handle_write_event(gatts_if, param);
45 break;
46 case ESP_GATTS_EXEC_WRITE_EVT:
47 midi_handle_write_exec_event(gatts_if, param);
48 break;
49
50 case ESP_GATTS_MTU_EVT: midi_handle_mtu_event(gatts_if, param); break;
51
52 case ESP_GATTS_CONF_EVT: break;
53 case ESP_GATTS_UNREG_EVT: break;
54 case ESP_GATTS_CREATE_EVT: break;
55 case ESP_GATTS_ADD_INCL_SRVC_EVT: break;
56 case ESP_GATTS_ADD_CHAR_EVT: break;
57 case ESP_GATTS_ADD_CHAR_DESCR_EVT: break;
58 case ESP_GATTS_DELETE_EVT: break;
59 case ESP_GATTS_START_EVT: break;
60 case ESP_GATTS_STOP_EVT: break;
61 case ESP_GATTS_CONNECT_EVT:
62 midi_handle_connect_event(gatts_if, param);
63 break;
64 case ESP_GATTS_DISCONNECT_EVT:
65 midi_handle_disconnect_event(gatts_if, param);
66 break;
67 case ESP_GATTS_OPEN_EVT: break;
68 case ESP_GATTS_CANCEL_OPEN_EVT: break;
69 case ESP_GATTS_CLOSE_EVT: break;
70 case ESP_GATTS_LISTEN_EVT: break;
71 case ESP_GATTS_CONGEST_EVT: break;
72 case ESP_GATTS_RESPONSE_EVT: break;
73 case ESP_GATTS_CREAT_ATTR_TAB_EVT:
74 if (param->add_attr_tab.status != ESP_GATT_OK) {
75 ESP_LOGE("MIDIBLE",
76 "create attribute table failed, error code=0x%x",
77 param->add_attr_tab.status);
78 break;
79 }
81 break;
82
83 case ESP_GATTS_SET_ATTR_VAL_EVT: break;
84 case ESP_GATTS_SEND_SERVICE_CHANGE_EVT: break;
85 default: break;
86 }
87}
88
89#endif
90#endif
Handling the Client Characteristic Configuration Descriptor (UUID 0x2902) for MIDI over Bluetooth Low...
void ble2902_handle_write(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
Callback when the client writes to the descriptor.
Declarations of internal functions for the MIDI over BLE system, used in the midi-*....
void midi_handle_read_event(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
void midi_handle_register_app_event(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
void midi_handle_mtu_event(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
void midi_handle_disconnect_event(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
void midi_handle_write_event(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
uint16_t midi_get_gatts_if(void)
void midi_handle_create_attribute_table_event(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
void midi_handle_gatts_event(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
void midi_handle_connect_event(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
uint16_t midi_get_descriptor_handle(void)
uint16_t midi_get_characteristic_handle(void)
void midi_handle_write_exec_event(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)