Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
MIDI_Interfaces
BLEMIDI
ESP32
ble2902.c
Go to the documentation of this file.
1
#ifdef ESP32
2
#include <sdkconfig.h>
3
#if CONFIG_BT_BLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED
4
5
#include "
app.h
"
6
#include "
ble2902.h
"
7
#include "
logging.h
"
8
#include "
midi-private.h
"
9
10
#include <string.h>
// memcpy
11
12
void
ble2902_handle_write
(esp_gatt_if_t gatts_if,
13
esp_ble_gatts_cb_param_t *param) {
14
// The actual writing of data and sending a response is already handled
15
// by Bluedroid.
16
uint16_t handle = param->write.handle;
17
uint16_t value =
ble2902_get_value
(handle);
18
if
(value == 0x0001) {
19
ESP_LOGI(
"MIDIBLE"
,
"notify enable"
);
20
}
else
if
(value == 0x0002) {
21
ESP_LOGI(
"MIDIBLE"
,
"indicate enable"
);
22
}
else
if
(value == 0x0003) {
23
ESP_LOGI(
"MIDIBLE"
,
"notify & indicate enable"
);
24
}
else
if
(value == 0x0000) {
25
ESP_LOGI(
"MIDIBLE"
,
"notify/indicate disable "
);
26
}
else
{
27
ESP_LOGE(
"MIDIBLE"
,
"Unknown descriptor value %04x"
, value);
28
}
29
midi_ble_instance_handle_subscribe
(
30
param->write.conn_id,
midi_get_characteristic_handle
(), value & 0x0001);
31
}
32
33
uint16_t
ble2902_get_value
(uint16_t handle) {
34
const
uint8_t *data;
35
uint16_t length;
36
esp_ble_gatts_get_attr_value(handle, &length, &data);
37
if
(length != 2) {
38
ESP_LOGE(
"MIDIBLE"
,
"Unexpected descriptor value length (%d)"
, length);
39
return
0;
40
}
41
uint16_t ret;
42
memcpy(&ret, data, length);
43
return
ret;
44
}
45
46
#endif
47
#endif
app.h
midi_ble_instance_handle_subscribe
void midi_ble_instance_handle_subscribe(uint16_t conn_handle, uint16_t char_handle, bool notify)
ble2902.h
Handling the Client Characteristic Configuration Descriptor (UUID 0x2902) for MIDI over Bluetooth Low...
ble2902_handle_write
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.
ble2902_get_value
uint16_t ble2902_get_value(uint16_t handle)
Get the value of the descriptor.
logging.h
midi-private.h
Declarations of internal functions for the MIDI over BLE system, used in the midi-*....
midi_get_characteristic_handle
uint16_t midi_get_characteristic_handle(void)
Generated by
1.17.0