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